Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the cmake install "noconfig" scripts for? Ie. "XXXTarget-noconfig.cmake"

Tags:

c++

cmake

I'm trying to write the necessary scripts for find_package to import targets for some libraries which do not have cmake builds or at least aren't exporting their targets, but are otherwise in the installation path: CMAKE_PREFIX_PATH. For example, for some library Foo that exports a target, there are the generated files:

lib/cmake/Foo/FooTargets.cmake
lib/cmake/Foo/FooTargets-noconfig.cmake

...and the project-provided:

lib/cmake/Foo/FooConfig.cmake   (and maybe FooConfigVersion.cmake)

...which finds dependencies and then includes the generated FooTargets.cmake.

It seems the generated FooTargets.cmake generally just includes the noconfig version, via wildcard:

# Load information for each installed configuration.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(GLOB CONFIG_FILES "${_DIR}/FooTargets-*.cmake")
foreach(f ${CONFIG_FILES})
  include(${f})
endforeach()

But what are these configurations in reference to? What is "noconfig"?

I'm guessing configuration refers to debug or release, and when these aren't distinguished in the CMakeLists.txt script, it's just generating "noconfig" as a default?

like image 336
johnb003 Avatar asked Jun 21 '18 04:06

johnb003


1 Answers

CMAKE_BUILD_TYPE variable specifies the build type (configuration) on single-configuration generators (for example when generating build scripts for make or ninja). The value of this variable can be the empty string (for example when loading a CMake project in Qt Creator and selecting the Default configuration).

If CMAKE_BUILD_TYPE is set to Release then install(EXPORT ...) generates

lib/cmake/Foo/FooTargets.cmake
lib/cmake/Foo/FooTargets-release.cmake

If CMAKE_BUILD_TYPE is set to the empty string then install(EXPORT ...) generates

lib/cmake/Foo/FooTargets.cmake
lib/cmake/Foo/FooTargets-noconfig.cmake
like image 176
Mihai Pitel Avatar answered Nov 16 '22 20:11

Mihai Pitel