0

I am using CMake to build an executable whose source code is written in C++. I had some code passed down to me that finds and helps link to a certain package. The pertinent commands from that are:

find_package(mypackage REQUIRED)

I have used the documentation for find_package found here and found that I can use the variable mypackage_VERSION to get the version of the package that CMake finds. Here is the relevant code printing that:

if (mypackage_FOUND)
  message(STATUS "Libraries for mypackage found")
  message(STATUS "Package Version: "${mypackage_VERSION})
else()
  message(FATAL_ERROR "Failed to find mypackage.")
endif()

This works to good effect, but I want more information.

I also found out that the CMake variable mypackage_INCLUDE_DIRS carries the directory with the header files.

Is there documentation giving a comprehensive list of variables that CMake sets in response to a find_package execution? So far, I've only been able to find out those two from the documentation and online examples.

villaa
  • 1,043
  • 3
  • 14
  • 32
  • 2
    This is dependent on the finder for the module although many follow the same convention. If this package has a builtin finder `cmake --help-module-list` and `cmake --help-module` should help. – drescherjm Nov 25 '17 at 21:40
  • 1
    Possible duplicate of [How to know library variable names for CMakeLists?](https://stackoverflow.com/questions/42741501/how-to-know-library-variable-names-for-cmakelists) Kindly see [my answer](https://stackoverflow.com/questions/42741501/how-to-know-library-variable-names-for-cmakelists/42752036#42752036) there on printing all variables set by a `find_package()` call. – Florian Nov 27 '17 at 09:05
  • @Florian thanks, I think that post allowed me to understand the problem better and I guess the answer is that the variables `find_package()` sets are not documented because they are arbitrary; they could be anything depending on what the build of the package does. – villaa Nov 28 '17 at 16:41
  • Yes. But there are commonly used variables and you may want to check ["Unifying CMake's FIND_PACKAGE"](https://stackoverflow.com/questions/42346523/unifying-cmakes-find-package). – Florian Nov 28 '17 at 20:13

0 Answers0