Cmake知识整理

Posted jkhere

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cmake知识整理相关的知识,希望对你有一定的参考价值。

CMake官方文档

CMake特点

CMake是支持跨平台的构建系统。

CMake命令

cmake [{-D =}...] -P

参数 作用
-D 用于传入配置项option,更新或创建缓存入口
-E cmake -E [ ...] 命令行工具模式
-Wdev 禁止开发者告警,也会忽略过时信息告警
-P 执行cmake脚本

-E 支持很多内置命令,如make_directory, copy_directory, echo, env, md5sum, rename, touch等。

find_package

加载外部的项目。CMake寻找Find<package>.cmake,在目录CMKAE_MODULE_PATH路径中定义的。

二进制目标

add_executable()
生成可执行文件。
add_library()
默认定义的是static库,可以使用BUILD_SHARED_LIBS变量来改变默认行为。

target_link_libraries() 给二进制添加依赖

构建选项

target_include_directories()
生成INCLUDE_DIRECTORIES, INTERFACE_INCLUDE_DIRECTORIES两个变量。如果只是用于库的实现,那应该用PRIVATE关键字;如果是库的头文件也使用了依赖,应该使用PUBLIC关键字;如果只是头文件使用了的话,那么可以用INTERFACE关键字。默认是什么关键字的?
target_compile_definitions()
生成COMPILE_DEFINITIONS, INTERFACE_COMPILE_DEFINITIONS两个变量。
target_compile_options()
生成COMPILE_OPTIONS, INTERFACE_COMPILE_OPTIONS两个变量。

PRIVATE, PUBLIC, INTERFACE三种模式。

CMake文本内置命令

这些命令是一直存在的。
break
退出循环
cmake_host_system_information
查询系统信息
cmake_minimum_required
cmake版本要求
cmake_parse_arguments
解析传入参数
cmake_policy
设置cmake策略
configure_file
设置配置文件
continue
继续循环
elseif
else
endforeach
endfunction
endif
endmacro
endwhile
以上全是cmake的代码逻辑。
execute_process
执行shell命令或其他脚本命令,并获得结果。可以用于跟外部构建程序交互。
file
文件操作,包括文件读写,移动,上传等。
find_file
查找指定文件的路径,并保存起来。
find_library
查找lib所在的路径,并保存到指定的变量中。NAME字段可以写全称。
find_package
使用第三方的库。
find_path
查找到指定file文件的目录。
find_program

foreach
function
get_cmake_property
get_directory_property
get_filename_component
get_filename_component( [CACHE])
COMP字段可以是DIRECTORY(只保存路径,不包含文件名字),NAME(文件名字不包含路径),EXT(文件名字最长的后缀),PATH,ABSOLUTE(file的全路径),REALPATH(file的真实路径)。
如果CACHE是设置的,那么变量结果会保存进CACHE中。
get_property
得到一个属性。
if
include
加载一个CMake文件,类似于c语言中的include。
include_guard
list
字符串列表处理操作,很有用的工具。
macro
mark_as_advanced
GUI模式下有用,script模式一定用没有。
math
math(EXPR ),数学运算,加减乘除都需要这种语法功能,否则处理不了。
message
打印日志。可以用于停止cmake运行,很方便调试。
option
return
separate_arguments
separate_arguments(),所有的空格被替换成“;”字符,方便用于后续处理。
set_directory_properties
set_property
set
设置变量。
site_name
string
字符串处理功能,包含字符串的查找,替换,正则匹配,大小写转换,长度,比较等。
unset
取消掉环境中某个值的设置。
variable_watch

while

CMake工程内置命令

这些命令只在CMake工程中可以使用。
add_compile_definitions
在当前和以后添加编译选项。
add_compile_options
在当前和以后添加编译值。
add_custom_command
功能有两个:1.执行一条命令生成文件。2.给一个target对象添加一条命令,当target本身被创建时会执行该命令,但是,如果target已经创建了,那么command就不会被执行了。
add_custom_target
添加一个构建目标。
add_definitions
添加宏定义。
add_dependencies
添加target的依赖。
add_executable
添加构建二进制执行。
add_library
添加构建lib库。
add_subdirectory
添加构建的二级目录,一般在top的CMakeLists.txt中使用,用于将其他CMakeLists.txt包含进build工程,使用相对目录。
add_test
aux_source_directory
将某个目录下的所有源码文件赋值给一个变量。避免每次增加一个c文件就需要修改CMakeLists.txt,减轻开发编写构建脚本的难度。
build_command
create_test_sourcelist
define_property
enable_language
enable_testing
export
从构建树中导出target,给外部的项目使用。
fltk_wrap_ui
get_source_file_property
get_target_property
get_test_property
include_directories
Add the given directories to those the compiler uses to search for include files. Relative paths are interpreted as relative to the current source directory.给构建树加入用于搜索的头文件目录。
include_external_msproject
include_regular_expression
install
用于安装操作的设置。
link_directories
添加lib库的链接目录。
link_libraries
给后面将要添加的target链接库。
load_cache
加载CACHE缓存。
project
设置项目名称,以及内部自动定义的变量。
qt_wrap_cpp
qt_wrap_ui
remove_definitions
移除宏定义。
set_source_files_properties
给源码文件设置key-value属性。
set_target_properties
设置target目标的属性,很常用。
set_tests_properties
source_group
target_compile_definitions
给某个target添加编译选项定义。
target_compile_features
target_compile_options
给某个target添加选项定义。
target_include_directories
给某个target添加include头文件目录。
target_link_libraries
给某个target增加链接库。
target_sources
给target对象增加源码,target必须时已经通过add_executable()和add_library()命令创建的。
try_compile
try_run

CMake toolchains

主要用于交叉编译,Cross Compiling。
主要通过-DCMAKE_TOOLCHAIN_FILE=path/to/file来传递cmake文件,用于定义一系列交叉编译器的参数。CMAKE_CROSSCOMPILING变量会变置为true。一个典型的toolchain文件:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(CMAKE_SYSROOT /home/devel/rasp-pi-rootfs)
set(CMAKE_STAGING_PREFIX /home/devel/stage)

set(tools /home/devel/gcc-4.7-linaro-rpi-gnueabihf)
set(CMAKE_C_COMPILER ${tools}/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/arm-linux-gnueabihf-g++)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

CMake变量--信息描述部分

CMAKE_AR
CMAKE_ARGC
CMAKE_ARGV0
CMAKE_BINARY_DIR
CMAKE_BUILD_TOOL
CMAKE_CACHEFILE_DIR
CMAKE_CACHE_MAJOR_VERSION
CMAKE_CACHE_MINOR_VERSION
CMAKE_CACHE_PATCH_VERSION
CMAKE_CFG_INTDIR
CMAKE_COMMAND
CMAKE_CROSSCOMPILING
CMAKE_CROSSCOMPILING_EMULATOR
CMAKE_CTEST_COMMAND
CMAKE_CURRENT_BINARY_DIR
CMAKE_CURRENT_LIST_DIR
CMAKE_CURRENT_LIST_FILE
CMAKE_CURRENT_LIST_LINE
CMAKE_CURRENT_SOURCE_DIR
CMAKE_DIRECTORY_LABELS
CMAKE_DL_LIBS
CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION
CMAKE_EDIT_COMMAND
CMAKE_EXECUTABLE_SUFFIX
CMAKE_EXTRA_GENERATOR
CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES
CMAKE_FIND_PACKAGE_NAME
CMAKE_FIND_PACKAGE_SORT_DIRECTION
CMAKE_FIND_PACKAGE_SORT_ORDER
CMAKE_GENERATOR
CMAKE_GENERATOR_INSTANCE
CMAKE_GENERATOR_PLATFORM
CMAKE_GENERATOR_TOOLSET
CMAKE_HOME_DIRECTORY
CMAKE_IMPORT_LIBRARY_PREFIX
CMAKE_IMPORT_LIBRARY_SUFFIX
CMAKE_JOB_POOL_COMPILE
CMAKE_JOB_POOL_LINK
CMAKE_JOB_POOLS
CMAKE_COMPILER_AR
CMAKE
COMPILER_RANLIB
CMAKE_LINK_LIBRARY_SUFFIX
CMAKE_LINK_SEARCH_END_STATIC
CMAKE_LINK_SEARCH_START_STATIC
CMAKE_MAJOR_VERSION
CMAKE_MAKE_PROGRAM
CMAKE_MATCH_COUNT
CMAKE_MATCH

CMAKE_MINIMUM_REQUIRED_VERSION
CMAKE_MINOR_VERSION
CMAKE_NETRC
CMAKE_NETRC_FILE
CMAKE_PARENT_LIST_FILE
CMAKE_PATCH_VERSION
CMAKE_PROJECT_DESCRIPTION
CMAKE_PROJECT_HOMEPAGE_URL
CMAKE_PROJECT_NAME
CMAKE_PROJECT_VERSION
CMAKE_PROJECT_VERSION_MAJOR
CMAKE_PROJECT_VERSION_MINOR
CMAKE_PROJECT_VERSION_PATCH
CMAKE_PROJECT_VERSION_TWEAK
CMAKE_RANLIB
CMAKE_ROOT
CMAKE_SCRIPT_MODE_FILE
CMAKE_SHARED_LIBRARY_PREFIX
CMAKE_SHARED_LIBRARY_SUFFIX
CMAKE_SHARED_MODULE_PREFIX
CMAKE_SHARED_MODULE_SUFFIX
CMAKE_SIZEOF_VOID_P
CMAKE_SKIP_INSTALL_RULES
CMAKE_SKIP_RPATH
CMAKE_SOURCE_DIR
CMAKE_STATIC_LIBRARY_PREFIX
CMAKE_STATIC_LIBRARY_SUFFIX
CMAKE_TOOLCHAIN_FILE
CMAKE_TWEAK_VERSION
CMAKE_VERBOSE_MAKEFILE
CMAKE_VERSION
CMAKE_VS_DEVENV_COMMAND
CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
CMAKE_VS_MSBUILD_COMMAND
CMAKE_VS_NsightTegra_VERSION
CMAKE_VS_PLATFORM_NAME
CMAKE_VS_PLATFORM_TOOLSET
CMAKE_VS_PLATFORM_TOOLSET_CUDA
CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE
CMAKE_VS_PLATFORM_TOOLSET_VERSION
CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION
CMAKE_XCODE_GENERATE_SCHEME
CMAKE_XCODE_PLATFORM_TOOLSET
_BINARY_DIR
_DESCRIPTION
_HOMEPAGE_URL
_SOURCE_DIR
_VERSION
_VERSION_MAJOR
_VERSION_MINOR
_VERSION_PATCH
_VERSION_TWEAK
PROJECT_BINARY_DIR
PROJECT_DESCRIPTION
PROJECT_HOMEPAGE_URL
PROJECT_NAME
PROJECT_SOURCE_DIR
PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH
PROJECT_VERSION_TWEAK

CMake变量--动作行为部分

BUILD_SHARED_LIBS
CMAKE_ABSOLUTE_DESTINATION_FILES
CMAKE_APPBUNDLE_PATH
CMAKE_AUTOMOC_RELAXED_MODE
CMAKE_BACKWARDS_COMPATIBILITY
CMAKE_BUILD_TYPE
CMAKE_CODEBLOCKS_COMPILER_ID
CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES
CMAKE_CODELITE_USE_TARGETS
CMAKE_COLOR_MAKEFILE
CMAKE_CONFIGURATION_TYPES
CMAKE_DEBUG_TARGET_PROPERTIES
CMAKE_DEPENDS_IN_PROJECT_ONLY
CMAKE_DISABLE_FIND_PACKAGE_
CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
CMAKE_ECLIPSE_MAKE_ARGUMENTS
CMAKE_ECLIPSE_VERSION
CMAKE_ERROR_DEPRECATED
CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
CMAKE_EXPORT_COMPILE_COMMANDS
CMAKE_EXPORT_NO_PACKAGE_REGISTRY
CMAKE_FIND_APPBUNDLE
CMAKE_FIND_FRAMEWORK
CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX
CMAKE_FIND_LIBRARY_PREFIXES
CMAKE_FIND_LIBRARY_SUFFIXES
CMAKE_FIND_NO_INSTALL_PREFIX
CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
CMAKE_FIND_PACKAGE_WARN_NO_MODULE
CMAKE_FIND_ROOT_PATH
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
CMAKE_FRAMEWORK_PATH
CMAKE_IGNORE_PATH
CMAKE_INCLUDE_DIRECTORIES_BEFORE
CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE
CMAKE_INCLUDE_PATH
CMAKE_INSTALL_DEFAULT_COMPONENT_NAME
CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
CMAKE_INSTALL_MESSAGE
CMAKE_INSTALL_PREFIX
CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
CMAKE_LIBRARY_PATH
CMAKE_MFC_FLAG
CMAKE_MODULE_PATH
CMAKE_NOT_USING_CONFIG_FLAGS
CMAKE_POLICY_DEFAULT_CMP
CMAKE_POLICY_WARNING_CMP
CMAKE_PREFIX_PATH
CMAKE_PROGRAM_PATH
CMAKE_PROJECT__INCLUDE
CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
CMAKE_STAGING_PREFIX
CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS
CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE
CMAKE_SUPPRESS_REGENERATION
CMAKE_SYSROOT
CMAKE_SYSROOT_COMPILE
CMAKE_SYSROOT_LINK
CMAKE_SYSTEM_APPBUNDLE_PATH
CMAKE_SYSTEM_FRAMEWORK_PATH
CMAKE_SYSTEM_IGNORE_PATH
CMAKE_SYSTEM_INCLUDE_PATH
CMAKE_SYSTEM_LIBRARY_PATH
CMAKE_SYSTEM_PREFIX_PATH
CMAKE_SYSTEM_PROGRAM_PATH
CMAKE_USER_MAKE_RULES_OVERRIDE
CMAKE_WARN_DEPRECATED
CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY
_ROOT

CMake变量--系统描述部分

android
APPLE
BORLAND
CMAKE_CL_64
CMAKE_COMPILER_2005
CMAKE_HOST_APPLE
CMAKE_HOST_SOLARIS
CMAKE_HOST_SYSTEM
CMAKE_HOST_SYSTEM_NAME
CMAKE_HOST_SYSTEM_PROCESSOR
CMAKE_HOST_SYSTEM_VERSION
CMAKE_HOST_UNIX
CMAKE_HOST_WIN32
CMAKE_LIBRARY_ARCHITECTURE
CMAKE_LIBRARY_ARCHITECTURE_REGEX
CMAKE_OBJECT_PATH_MAX
CMAKE_SYSTEM
CMAKE_SYSTEM_NAME
CMAKE_SYSTEM_PROCESSOR
CMAKE_SYSTEM_VERSION
CYGWIN
ENV
GHS-MULTI
MINGW
MSVC
MSVC10
MSVC11
MSVC12
MSVC14
MSVC60
MSVC70
MSVC71
MSVC80
MSVC90
MSVC_IDE
MSVC_TOOLSET_VERSION
MSVC_VERSION
UNIX
WIN32
WINCE
WINDOWS_PHONE
WINDOWS_STORE
XCODE
XCODE_VERSION

CMake变量--构建控制部分

CMAKE_ANDROID_ANT_ADDITIONAL_OPTIONS
CMAKE_ANDROID_API
CMAKE_ANDROID_API_MIN
CMAKE_ANDROID_ARCH
CMAKE_ANDROID_ARCH_ABI
CMAKE_ANDROID_ARM_MODE
CMAKE_ANDROID_ARM_NEON
CMAKE_ANDROID_ASSETS_DIRECTORIES
CMAKE_ANDROID_GUI
CMAKE_ANDROID_JAR_DEPENDENCIES
CMAKE_ANDROID_JAR_DIRECTORIES
CMAKE_ANDROID_JAVA_SOURCE_DIR
CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES
CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES
CMAKE_ANDROID_NDK
CMAKE_ANDROID_NDK_DEPRECATED_HEADERS
CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG
CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
CMAKE_ANDROID_PROCESS_MAX
CMAKE_ANDROID_PROGUARD
CMAKE_ANDROID_PROGUARD_CONFIG_PATH
CMAKE_ANDROID_SECURE_PROPS_PATH
CMAKE_ANDROID_SKIP_ANT_STEP
CMAKE_ANDROID_STANDALONE_TOOLCHAIN
CMAKE_ANDROID_STL_TYPE
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
CMAKE_ARCHIVE_OUTPUT_DIRECTORY_
CMAKE_AUTOGEN_PARALLEL
CMAKE_AUTOMOC
CMAKE_AUTOMOC_COMPILER_PREDEFINES
CMAKE_AUTOMOC_DEPEND_FILTERS
CMAKE_AUTOMOC_MACRO_NAMES
CMAKE_AUTOMOC_MOC_OPTIONS
CMAKE_AUTORCC
CMAKE_AUTORCC_OPTIONS
CMAKE_AUTOUIC
CMAKE_AUTOUIC_OPTIONS
CMAKE_AUTOUIC_SEARCH_PATHS
CMAKE_BUILD_RPATH
CMAKE_BUILD_WITH_INSTALL_NAME_DIR
CMAKE_BUILD_WITH_INSTALL_RPATH
CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_
CMAKE_POSTFIX
CMAKE_CUDA_SEPARABLE_COMPILATION
CMAKE_DEBUG_POSTFIX
CMAKE_ENABLE_EXPORTS
CMAKE_EXE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS

CMAKE_EXE_LINKER_FLAGS_INIT
CMAKE_EXE_LINKER_FLAGS_INIT
CMAKE_FOLDER
CMAKE_Fortran_FORMAT
CMAKE_Fortran_MODULE_DIRECTORY
CMAKE_GNUtoMS
CMAKE_INCLUDE_CURRENT_DIR
CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE
CMAKE_INSTALL_NAME_DIR
CMAKE_INSTALL_RPATH
CMAKE_INSTALL_RPATH_USE_LINK_PATH
CMAKE_INTERPROCEDURAL_OPTIMIZATION
CMAKE_INTERPROCEDURAL_OPTIMIZATION

CMAKE_ios_INSTALL_COMBINED
CMAKE_CLANG_TIDY
CMAKE
COMPILER_LAUNCHER
CMAKE
CPPCHECK
CMAKE
CPPLINT
CMAKE
INCLUDE_WHAT_YOU_USE
CMAKE
VISIBILITY_PRESET
CMAKE_LIBRARY_OUTPUT_DIRECTORY
CMAKE_LIBRARY_OUTPUT_DIRECTORY

CMAKE_LIBRARY_PATH_FLAG
CMAKE_LINK_DEF_FILE_FLAG
CMAKE_LINK_DEPENDS_NO_SHARED
CMAKE_LINK_INTERFACE_LIBRARIES
CMAKE_LINK_LIBRARY_FILE_FLAG
CMAKE_LINK_LIBRARY_FLAG
CMAKE_LINK_WHAT_YOU_USE
CMAKE_MACOSX_BUNDLE
CMAKE_MACOSX_RPATH
CMAKE_MAP_IMPORTED_CONFIG_
CMAKE_MODULE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS_
CMAKE_MODULE_LINKER_FLAGS_INIT
CMAKE_MODULE_LINKER_FLAGS_INIT
CMAKE_MSVCIDE_RUN_PATH
CMAKE_NINJA_OUTPUT_PATH_PREFIX
CMAKE_NO_BUILTIN_CHRPATH
CMAKE_NO_SYSTEM_FROM_IMPORTED
CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT
CMAKE_PDB_OUTPUT_DIRECTORY
CMAKE_PDB_OUTPUT_DIRECTORY

CMAKE_POSITION_INDEPENDENT_CODE
CMAKE_RUNTIME_OUTPUT_DIRECTORY
CMAKE_RUNTIME_OUTPUT_DIRECTORY_
CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS_
CMAKE_SHARED_LINKER_FLAGS_INIT
CMAKE_SHARED_LINKER_FLAGS_INIT
CMAKE_SKIP_BUILD_RPATH
CMAKE_SKIP_INSTALL_RPATH
CMAKE_STATIC_LINKER_FLAGS
CMAKE_STATIC_LINKER_FLAGS

CMAKE_STATIC_LINKER_FLAGS_INIT
CMAKE_STATIC_LINKER_FLAGS_INIT
CMAKE_TRY_COMPILE_CONFIGURATION
CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
CMAKE_TRY_COMPILE_TARGET_TYPE
CMAKE_USE_RELATIVE_PATHS
CMAKE_VISIBILITY_INLINES_HIDDEN
CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD
CMAKE_VS_SDK_EXCLUDE_DIRECTORIES
CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES
CMAKE_VS_SDK_INCLUDE_DIRECTORIES
CMAKE_VS_SDK_LIBRARY_DIRECTORIES
CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES
CMAKE_VS_SDK_REFERENCE_DIRECTORIES
CMAKE_VS_SDK_SOURCE_DIRECTORIES
CMAKE_WIN32_EXECUTABLE
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
CMAKE_XCODE_ATTRIBUTE

EXECUTABLE_OUTPUT_PATH
LIBRARY_OUTPUT_PATH

CMake变量--编程语言部分

CMAKE_COMPILER_IS_GNUCC
CMAKE_COMPILER_IS_GNUCXX
CMAKE_COMPILER_IS_GNUG77
CMAKE_CUDA_HOST_COMPILER
CMAKE_CUDA_EXTENSIONS
CMAKE_CUDA_STANDARD
CMAKE_CUDA_STANDARD_REQUIRED
CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES
CMAKE_CXX_COMPILE_FEATURES
CMAKE_CXX_EXTENSIONS
CMAKE_CXX_STANDARD
CMAKE_CXX_STANDARD_REQUIRED
CMAKE_C_COMPILE_FEATURES
CMAKE_C_EXTENSIONS
CMAKE_C_STANDARD
CMAKE_C_STANDARD_REQUIRED
CMAKE_Fortran_MODDIR_DEFAULT
CMAKE_Fortran_MODDIR_FLAG
CMAKE_Fortran_MODOUT_FLAG
CMAKE_INTERNAL_PLATFORM_ABI
CMAKE_ANDROID_TOOLCHAIN_MACHINE
CMAKE
ANDROID_TOOLCHAIN_PREFIX
CMAKE
ANDROID_TOOLCHAIN_SUFFIX
CMAKE
ARCHIVE_APPEND
CMAKE
ARCHIVE_CREATE
CMAKE
ARCHIVE_FINISH
CMAKE
COMPILER
CMAKE
COMPILER_ABI
CMAKE
COMPILER_ARCHITECTURE_ID
CMAKE
COMPILER_EXTERNAL_TOOLCHAIN
CMAKE
COMPILER_ID
CMAKE
COMPILER_LOADED
CMAKE
COMPILER_PREDEFINES_COMMAND
CMAKE
COMPILER_TARGET
CMAKE
COMPILER_VERSION
CMAKE
COMPILER_VERSION_INTERNAL
CMAKE
COMPILE_OBJECT
CMAKE
CREATE_SHARED_LIBRARY
CMAKE
CREATE_SHARED_MODULE
CMAKE
CREATE_STATIC_LIBRARY
CMAKE
FLAGS
CMAKE
FLAGS
CMAKE_FLAGSINIT
CMAKE
FLAGS_DEBUG
CMAKE
FLAGS_DEBUG_INIT
CMAKE
FLAGS_INIT
CMAKE
FLAGS_MINSIZEREL
CMAKE
FLAGS_MINSIZEREL_INIT
CMAKE
FLAGS_RELEASE
CMAKE
FLAGS_RELEASE_INIT
CMAKE
FLAGS_RELWITHDEBINFO
CMAKE
FLAGS_RELWITHDEBINFO_INIT
CMAKE
GHS_KERNEL_FLAGS
CMAKE_GHS_KERNEL_FLAGS_DEBUG
CMAKE
GHS_KERNEL_FLAGS_MINSIZEREL
CMAKE
GHS_KERNEL_FLAGS_RELEASE
CMAKE
GHS_KERNEL_FLAGS_RELWITHDEBINFO
CMAKE
IGNORE_EXTENSIONS
CMAKE
IMPLICIT_INCLUDE_DIRECTORIES
CMAKE
IMPLICIT_LINK_DIRECTORIES
CMAKE
IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
CMAKE
IMPLICIT_LINK_LIBRARIES
CMAKE
LIBRARY_ARCHITECTURE
CMAKE
LINKER_PREFERENCE
CMAKE
LINKER_PREFERENCE_PROPAGATES
CMAKE
LINK_EXECUTABLE
CMAKE
OUTPUT_EXTENSION
CMAKE
PLATFORM_ID
CMAKE
SIMULATE_ID
CMAKE
SIMULATE_VERSION
CMAKE
SIZEOF_DATA_PTR
CMAKE
SOURCE_FILE_EXTENSIONS
CMAKE
STANDARD_INCLUDE_DIRECTORIES
CMAKE
STANDARD_LIBRARIES
CMAKE_Swift_LANGUAGE_VERSION
CMAKE_USER_MAKE_RULES_OVERRIDE

CMake变量--CTest部分

CTEST_BINARY_DIRECTORY
CTEST_BUILD_COMMAND
CTEST_BUILD_NAME
CTEST_BZR_COMMAND
CTEST_BZR_UPDATE_OPTIONS
CTEST_CHANGE_ID
CTEST_CHECKOUT_COMMAND
CTEST_CONFIGURATION_TYPE
CTEST_CONFIGURE_COMMAND
CTEST_COVERAGE_COMMAND
CTEST_COVERAGE_EXTRA_FLAGS
CTEST_CURL_OPTIONS
CTEST_CUSTOM_COVERAGE_EXCLUDE
CTEST_CUSTOM_ERROR_EXCEPTION
CTEST_CUSTOM_ERROR_MATCH
CTEST_CUSTOM_ERROR_POST_CONTEXT
CTEST_CUSTOM_ERROR_PRE_CONTEXT
CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE
CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS
CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS
CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
CTEST_CUSTOM_MEMCHECK_IGNORE
CTEST_CUSTOM_POST_MEMCHECK
CTEST_CUSTOM_POST_TEST
CTEST_CUSTOM_PRE_MEMCHECK
CTEST_CUSTOM_PRE_TEST
CTEST_CUSTOM_TEST_IGNORE
CTEST_CUSTOM_WARNING_EXCEPTION
CTEST_CUSTOM_WARNING_MATCH
CTEST_CVS_CHECKOUT
CTEST_CVS_COMMAND
CTEST_CVS_UPDATE_OPTIONS
CTEST_DROP_LOCATION
CTEST_DROP_METHOD
CTEST_DROP_SITE
CTEST_DROP_SITE_CDASH
CTEST_DROP_SITE_PASSWORD
CTEST_DROP_SITE_USER
CTEST_EXTRA_COVERAGE_GLOB
CTEST_GIT_COMMAND
CTEST_GIT_INIT_SUBMODULES
CTEST_GIT_UPDATE_CUSTOM
CTEST_GIT_UPDATE_OPTIONS
CTEST_HG_COMMAND
CTEST_HG_UPDATE_OPTIONS
CTEST_LABELS_FOR_SUBPROJECTS
CTEST_MEMORYCHECK_COMMAND
CTEST_MEMORYCHECK_COMMAND_OPTIONS
CTEST_MEMORYCHECK_SANITIZER_OPTIONS
CTEST_MEMORYCHECK_SUPPRESSIONS_FILE
CTEST_MEMORYCHECK_TYPE
CTEST_NIGHTLY_START_TIME
CTEST_P4_CLIENT
CTEST_P4_COMMAND
CTEST_P4_OPTIONS
CTEST_P4_UPDATE_OPTIONS
CTEST_RUN_CURRENT_SCRIPT
CTEST_SCP_COMMAND
CTEST_SITE
CTEST_SOURCE_DIRECTORY
CTEST_SVN_COMMAND
CTEST_SVN_OPTIONS
CTEST_SVN_UPDATE_OPTIONS
CTEST_TEST_LOAD
CTEST_TEST_TIMEOUT
CTEST_TRIGGER_SITE
CTEST_UPDATE_COMMAND
CTEST_UPDATE_OPTIONS
CTEST_UPDATE_VERSION_ONLY
CTEST_USE_LAUNCHERS

CMake变量--CPack部分

CPACK_ABSOLUTE_DESTINATION_FILES
CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY
CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
CPACK_INCLUDE_TOPLEVEL_DIRECTORY
CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
CPACK_INSTALL_SCRIPT
CPACK_PACKAGING_INSTALL_PREFIX
CPACK_SET_DESTDIR
CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION

以上是关于Cmake知识整理的主要内容,如果未能解决你的问题,请参考以下文章

cmake使用示例与整理总结

cmake使用示例与整理总结

IOS开发-OC学习-常用功能代码片段整理

VS2015 代码片段整理

小程序各种功能代码片段整理---持续更新

常用python日期日志获取内容循环的代码片段