Re: [CMake] Finding a pkg-config file
On 2018-09-21 15:55+0200 Florian Lindner wrote: Hello, on a really weird configured system (but I can't change it), there is a pkg-config file which I want to find with cmake: set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:$ENV{PETSC_DIR}/lib/pkgconfig") set(CMAKE_PREFIX_PATH "$ENV{PETSC_DIR}/lib/pkgconfig") find_package(PkgConfig REQUIRED) pkg_check_modules(PETSC REQUIRED craypetsc_real) but -- Checking for module 'craypetsc_real' -- No package 'craypetsc_real' found CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:363 (message): A required package was not found cat $PETSC_DIR/lib/pkgconfig/craypetsc_real.pc VERSION=3.8.4.0 PE=GNU pe=gnu GENCOMP=7.1 CPU_TARGET=haswell install_prefix=/opt/cray/pe root=${install_prefix}/petsc/3.8.4.0/real prefix=${root}/${PE}/${GENCOMP}/${CPU_TARGET} libdir=${prefix}/lib includedir=${prefix}/include cray_as_needed= cray_no_as_needed= Name: craypetsc_real Description: Scientific libraries Version: ${VERSION} Libs: -L${libdir} ${cray_as_needed}-lcraypetsc_gnu_71_real${cray_no_as_needed} -fopenmp Libs.private: Requires: Requires.private: mpich >= 7.0 sci_mp >= 13.0 cray-tpsl >= 16.03.1 hdf5_parallel Conflicts: hdf5 Cflags: -I${includedir} pkg-config also finds it: PKG_CONFIG_PATH=$PETSC_DIR/lib/pkgconfig pkg-config --print-variables craypetsc_real cray_as_needed prefix libdir [...] CMakeError.log does not exist, CMakeOutput.log I have attached. Hi Florian: What happens if you set PKG_CONFIG_PATH outside cmake rather than inside? e.g., env PKG_CONFIG_PATH=$PETSC_DIR/lib/pkgconfig cmake with both set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:$ENV{PETSC_DIR}/lib/pkgconfig") set(CMAKE_PREFIX_PATH "$ENV{PETSC_DIR}/lib/pkgconfig") commented out inside your CMakeList.txt file? That method has always worked for me. And if it works for you, then I would think attempting to set the enviroment variable PKG_CONFIG_PATH inside your CMakeLists.txt file with just set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:$ENV{PETSC_DIR}/lib/pkgconfig") (setting CMAKE_PREFIX_PATH should not be required) should just work, but it is always possible (although I haven't checked documentation to see) there is some incorrect syntax in that line so I would also use message to print out the PKG_CONFIG_PATH environment variable to see what you have actually set it to within CMake. Alan __ Alan W. Irwin Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); the Time Ephemerides project (timeephem.sf.net); PLplot scientific plotting software package (plplot.sf.net); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __ Linux-powered Science __ -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake
[CMake] Finding a pkg-config file
Hello, on a really weird configured system (but I can't change it), there is a pkg-config file which I want to find with cmake: set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:$ENV{PETSC_DIR}/lib/pkgconfig") set(CMAKE_PREFIX_PATH "$ENV{PETSC_DIR}/lib/pkgconfig") find_package(PkgConfig REQUIRED) pkg_check_modules(PETSC REQUIRED craypetsc_real) but -- Checking for module 'craypetsc_real' -- No package 'craypetsc_real' found CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:363 (message): A required package was not found > cat $PETSC_DIR/lib/pkgconfig/craypetsc_real.pc VERSION=3.8.4.0 PE=GNU pe=gnu GENCOMP=7.1 CPU_TARGET=haswell install_prefix=/opt/cray/pe root=${install_prefix}/petsc/3.8.4.0/real prefix=${root}/${PE}/${GENCOMP}/${CPU_TARGET} libdir=${prefix}/lib includedir=${prefix}/include cray_as_needed= cray_no_as_needed= Name: craypetsc_real Description: Scientific libraries Version: ${VERSION} Libs: -L${libdir} ${cray_as_needed}-lcraypetsc_gnu_71_real${cray_no_as_needed} -fopenmp Libs.private: Requires: Requires.private: mpich >= 7.0 sci_mp >= 13.0 cray-tpsl >= 16.03.1 hdf5_parallel Conflicts: hdf5 Cflags: -I${includedir} pkg-config also finds it: > PKG_CONFIG_PATH=$PETSC_DIR/lib/pkgconfig pkg-config --print-variables > craypetsc_real cray_as_needed prefix libdir [...] CMakeError.log does not exist, CMakeOutput.log I have attached. Thanks! Florian The target system is: Hazelhen - - The host system is: Linux - 4.4.114-94.11-default - x86_64 Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. Compiler: /opt/cray/pe/craype/2.5.15/bin/CC Build flags: -craympich-dpm Id flags: The output was: 0 Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out" The CXX compiler identification is GNU, found in "/zhome/academic/HLRS/ipv/ipvflind/software/precice/build/cmake-debug/CMakeFiles/3.5.2/CompilerIdCXX/a.out" Determining if the CXX compiler works passed with the following output: Change Dir: /zhome/academic/HLRS/ipv/ipvflind/software/precice/build/cmake-debug/CMakeFiles/CMakeTmp Run Build Command:"/usr/bin/gmake" "cmTC_7654f/fast" /usr/bin/gmake -f CMakeFiles/cmTC_7654f.dir/build.make CMakeFiles/cmTC_7654f.dir/build gmake[1]: Entering directory '/zhome/academic/HLRS/ipv/ipvflind/software/precice/build/cmake-debug/CMakeFiles/CMakeTmp' Building CXX object CMakeFiles/cmTC_7654f.dir/testCXXCompiler.cxx.obj /opt/cray/pe/craype/2.5.15/bin/CC -craympich-dpm-o CMakeFiles/cmTC_7654f.dir/testCXXCompiler.cxx.obj -c /zhome/academic/HLRS/ipv/ipvflind/software/precice/build/cmake-debug/CMakeFiles/CMakeTmp/testCXXCompiler.cxx Linking CXX executable cmTC_7654f /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7654f.dir/link.txt --verbose=1 /opt/cray/pe/craype/2.5.15/bin/CC -craympich-dpm CMakeFiles/cmTC_7654f.dir/testCXXCompiler.cxx.obj -o cmTC_7654f gmake[1]: Leaving directory '/zhome/academic/HLRS/ipv/ipvflind/software/precice/build/cmake-debug/CMakeFiles/CMakeTmp' Detecting CXX compiler ABI info compiled with the following output: Change Dir: /zhome/academic/HLRS/ipv/ipvflind/software/precice/build/cmake-debug/CMakeFiles/CMakeTmp Run Build Command:"/usr/bin/gmake" "cmTC_7b642/fast" /usr/bin/gmake -f CMakeFiles/cmTC_7b642.dir/build.make CMakeFiles/cmTC_7b642.dir/build gmake[1]: Entering directory '/zhome/academic/HLRS/ipv/ipvflind/software/precice/build/cmake-debug/CMakeFiles/CMakeTmp' Building CXX object CMakeFiles/cmTC_7b642.dir/CMakeCXXCompilerABI.cpp.obj /opt/cray/pe/craype/2.5.15/bin/CC -craympich-dpm-o CMakeFiles/cmTC_7b642.dir/CMakeCXXCompilerABI.cpp.obj -c /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp Linking CXX executable cmTC_7b642 /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7b642.dir/link.txt --verbose=1 /opt/cray/pe/craype/2.5.15/bin/CC -craympich-dpm-v CMakeFiles/cmTC_7b642.dir/CMakeCXXCompilerABI.cpp.obj -o cmTC_7b642 Using built-in specs. COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/g++ COLLECT_LTO_WRAPPER=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper Target: x86_64-suse-linux Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib Thread model: posix gcc version 7.3.0 20180125 (Cray Inc.) (GCC) COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/