file文件操作
cmake的file命令_cmake file_物随心转的博客-CSDN博客
set指令
CMake中的set指令详解_cmake set_guanguanboy的博客-CSDN博客
include_directories指令
Cmake命令之include_directories介绍 - 简书
add_subdirectory
Cmake命令之add_subdirectory介绍 - 简书
add_definitions
cmake中add_definitions的用法_学之之博未若知之之要知之之要未若行之之实的博客-CSDN博客
条件编译
if(xxxxx) ... endif()
if(xx) ... elseif(yy) ... else() ... endif()
cmake:if_cmake if_OceanStar的学习笔记的博客-CSDN博客
遍历
foreach(xx xxxs)
endforeach()
options基本格式如下:
option(<variable> "<help_text>" [value])
- variable:定义选项名称
- help_text:说明选项的含义
- value:定义选项默认状态,一般是OFF或者ON,除去ON之外,其他所有值都为认为是OFF。
下面举个例子:
PROJECT(HELLOLIB1)
ADD_SUBDIRECTORY(lib)
SET (LIBHELLO_SRC hello.cpp)
ADD_LIBRARY (hello SHARED ${LIBHELLO_SRC})
ADD_LIBRARY (hello_static STATIC ${LIBHELLO_SRC})
SET_TARGET_PROPERTIES (hello_static PROPERTIES OUTPUT_NAME "hello")
GET_TARGET_PROPERTY (OUTPUT_VALUE hello_static OUTPUT_NAME)
SET_TARGET_PROPERTIES (hello_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES (hello PROPERTIES CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES (hello PROPERTIES VERSION 1.2 SOVERSION 1)
INSTALL (TARGETS hello hello_static LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
INSTALL (FILES hello.h DESTINATION include/hello)
CMAKE 中 add_definitions的用法._add_definitions cmake_Joe_yaoxiao的博客-CSDN博客