- CMake相关
# 根据操作系统类型安装不同的文件
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
install(FILES "linux_specific_file.conf" DESTINATION etc)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
install(FILES "windows_specific_file.conf" DESTINATION etc)
endif()
# 根据构建类型安装不同的库文件
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES "libMyLibrary_d.so" DESTINATION lib)
else()
install(FILES "libMyLibrary.so" DESTINATION lib)
endif()
变量名 | 含义 |
---|---|
CMAKE_SOURCE_DIR | 最顶层CmakeLists.txt所在目录,CHAN |
CMAKE_CURRENT_SOURCE_DIR | 当前CMakeLists.txt 所在路径 |
PROJECT_SOURCE_DIR | 工程的根目录 |
CMAKE_ARCHIVE_OUTPUT_DIRECTORY | 静态库的输出目录 |
CMAKE_LIBRARY_OUTPUT_DIRECTORY | 动态库的输出目录 |
CMAKE_RUNTIME_OUTPUT_DIRECTORY | 可执行文件的输出路径 |