I am using a 3rd party library rbdl, which contains rbdl.pc.cmake, which 'I suppose' is included for using pkg_check_modules
in a cmake file.
I update PKG_CONFIG_PATH
to point at the rbdl folder
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CMAKE_BINARY_DIR}/externals/rbdl")
pkg_check_modules(RBDL rbdl)
but pkg_check_modules
says it cannot find the module.
When I manually duplicate rbdl.pc.cmake, rename the copy into rbdl.pc and run pkg-config --cflags --libs rbdl
in terminal, then my cmake also start working!
Interestingly, now even if I delete rbdl.pc, rbdl module if perfectly found by rbdl.pc.cmake!
So my questions are:
pkg_check_modules
after that tweak with duplicating it, renaming the copy and running pkg-config manually?You understand it wrong! rbdl.pc.cmake
is just a template file. It is not supposed to be used by you! Take a look into CMakeLists.txt
line 160 -- configure_file()
used to render variables ("quoted" by @
in template file) and produce a rbdl.pc
(a real pkg-config
) file. Latter should be installed (some way) and then will be available to pkg-config
hence can be used in your project.
pkg-config
is stupid do not interpret or validate compiler/linker flags any way, so your renamed file "works" (yeah, producing invalid command line for compiler/linker).
I wish you to read CMake documentation before trying to code something using it! It'll save your time and give you a necessary knowledge which stops you from doing stupid things like you described in your question ;-)