# pkg\_check\_modules problem finding libsc as dependency for p4est

**URL:** https://discourse.cmake.org/t/pkg-check-modules-problem-finding-libsc-as-dependency-for-p4est/13580
**Category:** Usage
**Created:** [February 14, 2025, 6:31pm UTC](https://discourse.cmake.org/t/pkg-check-modules-problem-finding-libsc-as-dependency-for-p4est/13580 "2025-02-14T18:31:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@dom](https://discourse.cmake.org/u/dom)
#### Post date: [February 14, 2025, 6:31pm UTC](https://discourse.cmake.org/t/pkg-check-modules-problem-finding-libsc-as-dependency-for-p4est/13580/1 "2025-02-14T18:31:56Z")

</div>

**Hi, I installed p4est, which creates the following pkg-config files:**

> cat /home/dom/prod/spack-stack-20250128/envs/ne-gcc-13.3.1/install/gcc/13.3.1/p4est-2.8-buexbce/lib/pkgconfig/p4est-2.8.pc

prefix=/home/dom/prod/spack-stack-20250128/envs/ne-gcc-13.3.1/install/gcc/13.3.1/p4est-2.8-buexbce  
exec\_prefix=${prefix}  
libdir=${exec\_prefix}/lib  
includedir=${prefix}/include

p4est\_CC=/home/dom/prod/spack-stack-20250128/envs/ne-gcc-13.3.1/install/gcc/13.3.1/openmpi-5.0.5-nvxbduj/bin/mpicc  
p4est\_CFLAGS=-DSC\_LOG\_PRIORITY=SC\_LP\_ESSENTIAL -O2

Name: p4est  
Description: p4est manages a collection—a forest—of octrees in parallel.  
Version: 2.8  
URL: [https://www.p4est.org/](https://www.p4est.org/)

Requires: libsc \>= 2.8.2

Cflags: -I${prefix}/include  
Libs: -L${exec\_prefix}/lib -lp4est  
Libs.private: -lz -lm

**and**

> cat /home/dom/prod/spack-stack-20250128/envs/ne-gcc-13.3.1/install/gcc/13.3.1/p4est-2.8-buexbce/lib/pkgconfig/libsc-2.8.3.pc

prefix=/home/dom/prod/spack-stack-20250128/envs/ne-gcc-13.3.1/install/gcc/13.3.1/p4est-2.8-buexbce  
exec\_prefix=${prefix}  
libdir=${exec\_prefix}/lib  
includedir=${prefix}/include

libsc\_CC=/home/dom/prod/spack-stack-20250128/envs/ne-gcc-13.3.1/install/gcc/13.3.1/openmpi-5.0.5-nvxbduj/bin/mpicc  
libsc\_CFLAGS=-DSC\_LOG\_PRIORITY=SC\_LP\_ESSENTIAL -O2

Name: libsc  
Description: The SC library supports parallel scientific applications.  
Version: 2.8.3  
URL: [https://www.p4est.org/](https://www.p4est.org/)

Cflags: -I${prefix}/include  
Libs: -L${exec\_prefix}/lib -lsc  
Libs.private: -lz -lm

**cmake finds libsc correctly, but the following attempt to find p4est fails:**

pkg\_check\_modules(libsc REQUIRED IMPORTED\_TARGET libsc-2.8.3)  
pkg\_check\_modules(p4est REQUIRED IMPORTED\_TARGET p4est-2.8)

…  
– Found libsc-2.8.3, version 2.8.3  
– Checking for module ‘p4est-2.8’  
– Package ‘libsc’, required by ‘p4est-2.8’, not found  
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:610 (message):  
A required package was not found  
Call Stack (most recent call first):  
/usr/share/cmake/Modules/FindPkgConfig.cmake:832 (\_pkg\_check\_modules\_internal)  
CMakeLists.txt:60 (pkg\_check\_modules)

**I believe this has to do with the name of the .pc file being libsc-2.8.3.pc and therefore some internal name in the cmake cache being wrong (not libsc as it should be)?**
