什么是cmake安装“ noconfig”?脚本?就是“ XXXTarget-noconfig.cmake”; [英] What are the cmake install "noconfig" scripts for? Ie. "XXXTarget-noconfig.cmake"

查看:249
本文介绍了什么是cmake安装“ noconfig”?脚本?就是“ XXXTarget-noconfig.cmake”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 find_package 编写必要的脚本,以导入一些没有cmake构建或至少没有导出其目标的库的目标,但是否则位于安装路径中: CMAKE_PREFIX_PATH 。例如,对于某些导出目标的库Foo,将生成以下文件:

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

...项目提供的:

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

...这将找到依赖项,然后包括生成的FooTargets.cmake。

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

似乎生成的FooTargets.cmake通常仅通过通配符包含noconfig版本:

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()

但是这些配置是什么在参照?什么是 noconfig?

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

我猜配置是指调试或发布,并且在CMakeLists.txt脚本中未区分这些内容时,它只是在生成

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?

推荐答案

CMAKE_BUILD_TYPE 变量指定构建类型? (配置)在单配置生成器上(例如,在生成make或ninja的构建脚本时)。此变量的值可以是空字符串(例如,在Qt Creator中加载CMake项目并选择 Default 配置时)。

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).

如果将 CMAKE_BUILD_TYPE 设置为发行版,则 install(EXPORT .. )生成

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

如果 CMAKE_BUILD_TYPE 设置为空字符串,然后 install(EXPORT ...)生成

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

这篇关于什么是cmake安装“ noconfig”?脚本?就是“ XXXTarget-noconfig.cmake”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆