$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/mylib> $<INSTALL_INTERFACE:include/mylib> # <prefix>/include/mylib ) 创建可重定位包INSTALL_INTERFACE请注意, 不建议填充INTERFACE_INCLUDE_DIRECTORIES具有到依赖项的包含目录的绝对路径的目标。这将硬编码到已安装的包中,包括在制作包的机器上找到的...
when testing add_library(JSONUtils::jsonutils ALIAS jsonutils) #Set target properties target_include_directories(jsonutils PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) target_compile_features(jsonutils PRIVATE...
add_library(JSONUtilssrc/json_utils.cpp)target_include_directories(JSONUtilsPUBLIC$<INSTALL_INTERFACE:include>$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>PRIVATE${CMAKE_CURRENT_SOURCE_DIR}/src) 对于目标的依赖项,同样有INTERFACE和PRIVATE的区分。 比如: find_package(Boost 1.55 REQUIRED COMPONE...
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> PRIVATE src) I'm building a library project and since I'm using standard paths (lib/for the static library andinclude/for the public headers), I was hoping to get away by settingCMAKE_INSTA...
project(xxx VERSION 1.0.0) aux_source_directory(. DIR_SRCS) add_library(${PROJECT_NAME} SHARED ${DIR_SRCS}) target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>) # --- install script --- set_target_properties(${...
<INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...]...] 好了,这样我们就将头文件和目标文件分离开了。 但是,你可能注意到了,上面add_executable命令里面把所有的c文件都写进去了,看起来不是很优雅。当c文件变多的时候,这个地方也要跟着改。为了解决这个问题,这里我们引入一个...
INSTALL_INTERFACE 表达式包装的构建需求只被用在使用 install(EXPORT) 指令安装和导出的目标上: 3.9 函数和宏 函数和宏的唯一区别在于作用域,函数有作用域但宏没有。 代码语言:javascript 复制 ## 函数举例 function(SIMPLE REQUIRED_ARG) message(STATUS "Simple arguments: ${REQUIRED_ARG}, followed by ${...
FILE_SET可用于install和target_sources纯头文件库。 <INTERFACE_>HEADER_SETS,<INTERFACE_>HEADER_DIRS为目标头文件。 新增CUDA_ARCHITECTURES对 all 和 all-major.a 的支持 可以为find_*或 find 模块启用 DEBUG 消息。 define_property()新增了INITIALIZE_FROM_VARIABLE选项。
相对路径:会使用 CMAKE_INSTALL_PREFIX 作为前缀路径,即${CMAKE_INSTALL_PREFIX}/<your_path>,指定路径不存在的话可以自动创建。如果在cpack中使用,路径使用CPACK_PACKAGING_INSTALL_PREFIX 绝对路径 COMPONENT:指定一个与安装规则相关联的安装组件名,如"lib", "runtime"等,指定后就会只安装与相关的组件。举例说明...
src/file_utils.h)#Add an alias so that library can be used inside the build tree,e.g.when testingadd_library(JSONUtils::jsonutilsALIASjsonutils)#Set target propertiestarget_include_directories(jsonutilsPUBLIC$<INSTALL_INTERFACE:include>$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>PRIVAT...