2019独角兽企业重金招聘Python工程师标准>>>
Cmake的 debug版本和release版本(转)
debug版本的项目生成的可执行文件需要有调试信息并且不需要进行优化,而release版本的不需要调试信息但是需要优化。这些特性在gcc/g++中通过编译时的参数来决定的,如果将优化程度调到最高需要设置 -O3 ,最低的是 -O0 即不做优化,添加调试信息的参数是 -g -ggdb,如果不添加这个参数,调试信息就不会被包含在生成的二进制中
CMake中有一个变量CMAKE_BUILD_TYPE,可以取值枚举入下:Debug Release RelWithDebInfo 和 MinSizeRel
当这个变量值为Debug的时候,Cmake会使用变量CMAKE_FLAGS_DEBUG 和 CMAKE_C_FLAGS_DEBUG中的字符串作为编译选项生成Makefile,
当这个变量值为Release的时候,工程会使用变量CMAKE_CXX_FLAGS_RELEASE和CMAKE_CFLAGS_RELEASE选项生成Makefile。
现在假设项目中只有一个文件main.cpp,下面是一个可以选择生成debug版和release版的程序的CMakeList.txt:
1 PROJECT(main)
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
3 SET(CMAKE_SOURCE_DIR .)
45 SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
6 SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
78 AUX_SOURCE_DIRECTORY(. DIR_SRCS)
9 ADD_EXECUTABLE(main ${DIR_SRCS})
第 5 和 6 行设置了两个变量 CMAKE_CXX_FLAGS_DEBUG 和 CMAKE_CXX_FLAGS_RELEASE, 这两个变量是分别用于 debug 和 release 的编译选项。 编辑 CMakeList.txt 后需要执行 ccmake 命令生成 Makefile 。在进入项目的根目录,输入 "ccmake ." 进入一个图形化界面,如下图所示:
ccmake的界面
执行了configure后的ccmake的界面
下面我们首先生成debug版的Makefile:将变量CMAKE_BUILD_TYPE设置为Debug,按“c”进行configure,按“g”生成Makefile并推出。这时执行命令 find * | xargs grep “O0”后结果如下:
执行命令 find * | xargs grep “O0”后的结果
CMakeFiles/main.dir/flags.make:CXX_FLAGS = -O0 -Wall -g -ggdb CMakeFiles/main.dir/link.txt:/usr/bin/c++
-O0 -Wall -g -ggdb CMakeFiles/main.dir/main.cpp.o -o main -rdynamic
CMakeLists.txt:SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
这个结果说明生成的 Makefile 中使用了变量 CMAKE_CXX_FLAGS_DEBUG 作为编译时的参数。
下面我们将生成Release版本的Makefile:再次执行“ccmake ." ,将变量CMAKE_BUILD_TYPE设置为Release,生成Makefile并推出。执行命令 find * | xargs grep “O0”后结果如下:
find * | xargs grep "O0"的执行结果
CMakeLists.txt:SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")而执行命令 find * | xargs grep "O3" 后结果如下:
CMakeCache.txt:CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUGCMakeCache.txt:CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUGCMakeFiles/main.dir/flags.make:CXX_FLAGS = -O3 -Wall CMakeFiles/main.dir/link.txt:/usr/bin/c++ -O3 -Wall CMakeFiles/main.dir/main.cpp.o -o main -rdynamic CMakeLists.txt:SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
这两个结果说明生成的Makefile中使用了CMAKE_CXXFLAGS_RELEASE,作为编译时的参数
####################################################################################
在cmake中要编译debug模式的话,在CMakeLists.txt中添加如下两行
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb ")
SET(CMAKE_CXX_FLAGS_RELEASE "${ENV{CXXFLAGS} -O3 -Wall")
然后,在编译的时候,使用如下命令:
cmake -DCMAKE_BUILD_TYPE=Debug/Release path
第三个参数path是指项目的顶层路径
1. cmake支持gdb的实现,
首先在CMakeLists.txt下加入
SET(CMAKE_BUILD_TYPE "Debug")
在下面加入:
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
原因是CMake 中有一个变量 CMAKE_BUILD_TYPE ,可以的取值是 Debug Release RelWithDebInfo >和 MinSizeRel。
当这个变量值为 Debug 的时候,CMake 会使用变量 CMAKE_CXX_FLAGS_DEBUG 和 CMAKE_C_FLAGS_DEBUG 中的字符串作为编译选项生成 Makefile;
2. 在GDB中间加入程序启动参数
比如我们需要调试一个可执行文件./a.out help
这时
$gdb ./a.out
进入到gdb的命令行模式下,然后:
(gdb) set args help
就能加上可执行文件需要的参数,如果要看argc[1]到argc[N]的参数,只需要
(gdb) show args
3. gdb中查看字符串,地址的操作,数据类型
比始有一个int型的变量i,相要知道他的相关信息,可以
(gdb) print i
打印出变量i的当前值
(gdb)x &i
与上面的命令等价。
如果有x命令看时,需要看一片内存区域,(如果某个地方的值为0,用x时会自动截断了)
(gdb) x/16bx address
单字节16进制打印address地址处的长度为16的空间的内存,16表示空间长度,不是16进制,x表示16进制,b表示byte单字节
gdb看变量是哪个数据类型
(gdb) whatis i
即可知道i是什么类型的变量
####################################################################################
官方文档https://cmake.org/cmake/help/v3.7/
CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程),输出各种各样的makefile或者project文件。CMake”这个名字是“cross platform make”的缩写。
-
$> cmake ../sdk -Ddebug=ON
-
$> make
-
$> make install
第一条命令用于根据路径../sdk下的CMakeLists.txt生成Makefile文件;第二条命令执行Makefile文件,编译程序,生成可执行文件;第三条命令安装生成的可执行文件。
#后面为注释的内容。
CMakeLists.txt中的命令可以全部大写,或者全部小写。
# 指定工程名 e.g. 指定本工程的工程名为test_math
project(test_math)
# 定义变量 e.g. 定义SLNDIR变量,变量值为../../。变量的使用方法为${variable name}
set(SLNDIR ../../)
# 从文件加载CMake命令 e.g. 加载../../prj.mak/sp.cmake文件的所有命令
include(${SLNDIR}prj.mak/sp.cmake)
# 添加包含路径,编译器能这些路径中寻找头文件 e.g. 添加两个路径
include_directories (${SLNDIR}src/include ${SLNDIR}src/3rd/include )
# 添加可执行文件。从源文件source1, source2...生成可执行文件name
add_executable(
# 添加库。从源文件source1, source2...生成库name(静态库,动态库)
add_library(
# 显示信息
message([
# 添加build子文件夹。告诉CMake执行source_dir下的 CMakeLists.txt文件,编译source_dir中的源代码
add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])
# 收集所有的源文件。将dir路径下的所有源文件都存储在variable中
aux_source_directory(
# 设置链接库的搜索路径。相当于gcc中的-L(大写L)
Specify directories in which the linker will look for libraries.
link_directories(directory1 directory2 ...)
# 设置链接库。该命令之后的所有target都要链接该命令中设置的库
Link libraries to all targets added later.
link_libraries([item1 [item2 [...]]] [[debug|optimized|general]
# 设置预编译宏。e.g. Debug模式下add_definitions(-g -D_DEBUG); Release模式下add_definitions(-DNDEBUG -O2)
add_definitions(-DFOO -DBAR ...)
# 用户可选择的选项。
option(debug "is debug mode?" OFF).可以通过-D选择不同的选项。
如cmake ../source -Ddebug=ON;cmake ../source -Ddebug=OFF
option(
option_variable可以通过${option_variable}进行访问,其值为ON或者OFF
# 设置变量,取消变量
set (CMAKE_DEBUG_POSTFIX "d")
#设置debug模式时,输出产物名加后缀d
unset (CMAKE_DEBUG_POSTFIX)
# 取消CMAKE_DEBUG_POSTFIX变量的设置
# 逻辑判断
if(
if(NOT
if(
if(
if(DEFINED
if((expression) AND (expression OR (expression)))
if(
cmake操作系统平台的判断
- MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}")
- IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
- MESSAGE(STATUS "current platform: Linux ")
- ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
- MESSAGE(STATUS "current platform: Windows")
- ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- MESSAGE(STATUS "current platform: FreeBSD")
- ELSE ()
- MESSAGE(STATUS "other platform: ${CMAKE_SYSTEM_NAME}")
- ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
- IF (WIN32)
- MESSAGE(STATUS "Now is windows")
- ELSEIF (APPLE)
- MESSAGE(STATUS "Now is Apple systens.")
- ELSEIF (UNIX)
- MESSAGE(STATUS "Now is UNIX-like OS's. Including aPPLE os x and CygWin")
- ENDIF ()
CMake注意事项:
1.使用set设置CMAKE_CXX_FLAGS等变量时不要覆盖,尽量保留系统默认的一些值,在这些值后面添加就行了。例如:
set(LOCAL_CXX_FLAGS "-fPIC -fPE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LOCAL_CXX_FLAGS}")
CMake调用openmp
- FIND_PACKAGE( OpenMP REQUIRED)
- if(OPENMP_FOUND)
- message("OPENMP FOUND")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
- set(CMAKE_SHARE_LINKER_FLAGS "${CMAKE_SHARE_LINKER_FLAGS} ${OpenMP_SHARE_LINKER_FLAGS}")
- endif()
交叉编译
6.1 基本概念
宿主机host是执行编译、链接嵌入式软件的计算机;
目标机target是运行嵌入式软件的硬件平台。
通常我们用的PC机(window系统或者liunx系统)就是宿主机,
而客户使用的车机(QNX系统)、手机(Andorid系统)则是目标机。
在宿主机host上要生成目标机target的程序就是交叉编译。交叉编译时需要修改以下内容:
Ø 修改编译器;
Ø 修改依赖库;
Ø 修改头文件;
使用CMake进行交叉编译就是要告诉CMake目标机target是什么平台、
使用什么编译器、
到哪里寻找依赖库、
到哪里寻到头文件。
CMake使用一些内建变量定义上述内容。
Ø CMAKE_SYSTEM_NAME: 即你目标机target所在的操作系统名称,
比如ARM或者Linux你就需要写"Linux",
如果Windows平台你就写"Windows",
如果你的嵌入式平台没有相关OS你即需要写成"Generic",
只有当CMAKE_SYSTEM_NAME这个变量被设置了,
CMake才认为此时正在交叉编译,它会额外设置一个变量CMAKE_CROSSCOMPILING为TRUE.
Ø CMAKE_C_COMPILER: 顾名思义,即C语言编译器,
这里可以将变量设置成完整路径或者文件名,
设置成完整路径有一个好处就是CMake会去这个路径下去寻找编译相关的其他工具比如linker,binutils等,
如果你写的文件名带有arm-elf等等前缀,
CMake会识别到并且去寻找相关的交叉编译器。
Ø CMAKE_CXX_COMPILER: 同上,此时代表的是C++编译器
Ø CMAKE_FIND_ROOT_PATH: 代表了一系列的相关文件夹路径的根路径的变更
Ø CMAKE_FIND_ROOT_PATH_MODE_PROGRAM:
对FIND_PROGRAM()起作用,有三种取值,NEVER,ONLY,BOTH,
第一个表示不在你CMAKE_FIND_ROOT_PATH下进行查找,
第二个表示只在这个路径下查找,
第三个表示先查找这个路径,再查找全局路径,
对于这个变量来说,一般都是调用宿主机的程序,
所以一般都设置成NEVER
Ø CMAKE_FIND_ROOT_PATH_MODE_LIBRARY:
对FIND_LIBRARY()起作用,表示在链接的时候的库的相关选项,
因此这里需要设置成ONLY来保证我们的库是在交叉环境中找的.
Ø CMAKE_FIND_ROOT_PATH_MODE_INCLUDE:
对FIND_PATH()和FIND_FILE()起作用,一般来说也是ONLY
与交叉编译相关的这些变量如何传递给CMake了?最为方便的一个方法就是将相关的变量设置都放进一个文件(cmake脚本)中去,然后将该文件通过CMAKE_TOOLCHIAIN_FILE传递给CMake, 例如:
cmake-DCMAKE_TOOLCHIAIN_FILE="/path/to/toolchain-file" ..
6.2 附上一个CMake官方文档中的toolchian-file的小例子,这样我们就会对如何写toolchain-file文件有了感性认识:
# this one is important
SET(CMAKE_SYSTEM_NAMELinux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the crosscompiler
SET(CMAKE_C_COMPILER /opt/eldk-2007-01-19/usr/bin/ppc_74xx-gcc)
SET(CMAKE_CXX_COMPILER/opt/eldk-2007-01-19/usr/bin/ppc_74xx-g++)
# where is the targetenvironment
SET(CMAKE_FIND_ROOT_PATH /opt/eldk-2007-01-19/ppc_74xx/home/alex/eldk-ppc74xx-inst)
# search for programs inthe build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAMNEVER)
# for libraries and headersin the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARYONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
6.3 编译生成Android平台上的程序,需要用到GOOGLE为我们提供了的Android NDK用来做Native(C/C++)的build。Android NDK中包含了整套的编译器、系统库、头文件、调试器等。
使用CMake交叉编译Android平台上的程序,就需要:
Ø 指明目标平台为Android
Ø 指明目标硬件是ARM还是X86
Ø 指明ndk level version
Ø 用ndk提供的编译器
Ø 从ndk安装目录搜寻依赖库和头文件
我们可以自己动手编写toolchain-file,设置相应的变量。这也比较麻烦。
幸运的是,我们有Android-cmake项目可以帮忙。该项目生成了一个名为android.toolchain.cmake的toolchain-file文件,该文件帮我们设置了大部分的变量。我们需要做的就是指定cmake的toolchain file为这个项目里面的android.toolchain.cmake文件,然后设置好Android NDK路径即可。
# Usage Linux:
export ANDROID_NDK=/absolute/path/to/the/android-ndk
mkdir build && cdbuild
cmake-DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake ..
make -j8
make install
# Usage Windows:
SETANDROID_NDK=C:\absolute\path\to\the\android-ndk
mkdir build && cdbuild
cmake.exe -G"MinGWMakefiles" ^
-DCMAKE_TOOLCHAIN_FILE=path\to\the\android.toolchain.cmake ^
-DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows\bin\make.exe"^
..
cmake.exe --build . --target install--clean-first
附录:Visual Studio属性与对应cmakelists实现方法:
注意:此附录仅为beta版本,有些条目是推导出来的。
http://blog.csdn.net/xum2008/article/details/7268761
Visual Studio | Cmake | ||
Project Reference | add_dependencies() | ||
General/Output Directory | |||
Debugging/Working Directory | CMAKE can’t set this value, because the info not stored in project file but some intermedia file generated by visual studio | ||
c/c++ | General | Additional Include Directories | include_directories() |
Resolve #using References | Don’t know | ||
Debug Information Format | CMAKE FAQ set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG") set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") Change the default flags for specific config. |
||
Common language runtime support | set_target_properties( target PROPERTIES COMPILE_FLAGS “/clr”) set_target_properties( target PROPERTIES COMPILE_FLAGS “/clr:pure”) set_target_properties( target PROPERTIES COMPILE_FLAGS “/clr:safe”) set_target_properties( target PROPERTIES COMPILE_FLAGS “/clr:oldSynax”) |
||
Suppress Startup Banner | set_target_properties( target PROPERTIES COMPILE_FLAGS “/nologo” ) | ||
Warning Level | set_target_properties( target PROPERTIES COMPILE_FLAGS “/W0” ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/W1” ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/W2” ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/W3” ) set_target_properties( target PROPERTIES COMPILE_FLAGS "/W4" ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/Wall” ) |
||
Treat Warnings As Errors | set_target_properties( target PROPERTIES COMPILE_FLAGS “/WX-" ) #No set_target_properties( target PROPERTIES COMPILE_FLAGS “/WX" ) #Yes |
||
Multi-processor Compilation | set_target_properties( target PROPERTIES COMPILE_FLAGS “/MP" ) #Yes #Don’t set means No |
||
Use Unicode For Assembler Listing | set_target_properties( target PROPERTIES COMPILE_FLAGS “/FAu" ) #yes #Don’t set means no |
||
Optimization | Optimization | set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT/O1 /Ob1 /D NDEBUG") set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2/Ob2 /D NDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") Change the default flags for specific config. |
|
Inline Function Expansion | set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG") set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") Change the default flags for specific config. |
||
Enable Intrinsic Functions | set_target_properties( target PROPERTIES COMPILE_FLAGS “/Oi" ) #yes #Don’t set means no |
||
Favor Size or Speed | set_target_properties( target PROPERTIES COMPILE_FLAGS “/Os" ) #size set_target_properties( target PROPERTIES COMPILE_FLAGS “/Ot" ) #speed #Don’t set means neither |
||
Omit Frame Pointers | set_target_properties( target PROPERTIES COMPILE_FLAGS “/Oy-" ) #no set_target_properties( target PROPERTIES COMPILE_FLAGS “/Oy" ) #yes |
||
Enable Fiber-safe Optimizations | set_target_properties( target PROPERTIES COMPILE_FLAGS “/GT" ) #yes #not setting means no |
||
Whole Program Optimization | set_target_properties( target PROPERTIES COMPILE_FLAGS “/GL" ) #yes #not setting means no |
||
Preprocessor | Preprocessor Definitions | set_target_properties( target PROPERTIES COMPILE_DEFINITIONS DEFNAME=DEFVAL ) set_source_files_properties( filename.cpp PROPERTIES COMPILE_DEFINITIONS DEFNAME=DEFVAL ) |
|
Undefine Preprocessor Definitions | set_target_properties( target PROPERTIES COMPILE_FLAGS “/UDEFNAME" ) | ||
Undefine All Preprocessor Definitions | set_target_properties( target PROPERTIES COMPILE_FLAGS “/u" ) | ||
Ignore Standard Include Path | set_target_properties( target PROPERTIES COMPILE_FLAGS “/X" ) | ||
Preprocess to a File | set_target_properties( target PROPERTIES COMPILE_FLAGS “/P" ) | ||
Preprocess Suppress Line Numbers | set_target_properties( target PROPERTIES COMPILE_FLAGS “/EP" ) | ||
Keep Comments | set_target_properties( target PROPERTIES COMPILE_FLAGS “/C" ) | ||
Code Generation | Enable String Pooling | set_target_properties( target PROPERTIES COMPILE_FLAGS “/GF" ) #yes set_target_properties( target PROPERTIES COMPILE_FLAGS “/GF-" ) #no |
|
Enable Minimum Rebuild | set_target_properties( target PROPERTIES COMPILE_FLAGS “/Gm" ) #yes set_target_properties( target PROPERTIES COMPILE_FLAGS “/Gm-" )#no |
||
Enable C++ Exceptions | set_target_properties( target PROPERTIES COMPILE_FLAGS “/EHsc" ) #yes set_target_properties( target PROPERTIES COMPILE_FLAGS “/EHa" ) #yes, with SEH exceptions set_target_properties( target PROPERTIES COMPILE_FLAGS “/EHs" ) #yes, with extern C functions #not setting means no |
||
Smaller Type Check | set_target_properties( target PROPERTIES COMPILE_FLAGS “/RTCc" ) #yes #not setting means no |
||
Basic Runtime Checks | set_target_properties( target PROPERTIES COMPILE_FLAGS “/RTCs" ) #Stack frame check set_target_properties( target PROPERTIES COMPILE_FLAGS “/RTCu" ) #Uninitialized Variable set_target_properties( target PROPERTIES COMPILE_FLAGS “/TRC1" ) #Both #not setting means no |
||
Runtime Library | CMAKE FAQ set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG/MTd /Zi /Ob0 /Od /RTC1") set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT/O1 /Ob1 /D NDEBUG") set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") Change the default flags for specific config. |
||
Struct Member Alignment | set_target_properties( target PROPERTIES COMPILE_FLAGS “/Zp1" ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/Zp2" ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/Zp4" ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/Zp8" )set_target_properties( target PROPERTIES COMPILE_FLAGS “/Zp16" ) |
||
Buffer Security Check | set_target_properties( target PROPERTIES COMPILE_FLAGS “/GS" ) #yes set_target_properties( target PROPERTIES COMPILE_FLAGS “/GS-" ) #no |
||
Enable Function-Level Linking | set_target_properties( target PROPERTIES COMPILE_FLAGS “/Gy" ) #yes set_target_properties( target PROPERTIES COMPILE_FLAGS “/Gy-" ) #no |
||
Enable Enhaunced Instruction Set | set_target_properties( target PROPERTIES COMPILE_FLAGS “/arch:SSE" ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/arch:SSE2" ) |
||
Floating Point Model | set_target_properties( target PROPERTIES COMPILE_FLAGS “/fp:precise" ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/fp:strict" ) set_target_properties( target PROPERTIES COMPILE_FLAGS “/fp:fast" ) |
||
Enable Floating Point Exceptions | set_target_properties( target PROPERTIES COMPILE_FLAGS “/fp:except" ) | ||
Create Hotpatchable Image | set_target_properties( target PROPERTIES COMPILE_FLAGS “/hotpatch" ) | ||
Language | Disable Language Extensions | set_target_properties( target PROPERTIES COMPILE_FLAGS “/Za" ) | |
Treat Wchar_t As Built in Type | set_target_properties( target PROPERTIES COMPILE_FLAGS “/Zc:wchar_t" )#yes set_target_properties( target PROPERTIES COMPILE_FLAGS “/Zc:wchar_t-" ) #no |
||
Force Conformance in For Loop Scope | |||
Enable Run-Time Type Information | set_target_properties( target PROPERTIES COMPILE_FLAGS “/GR" ) #yes set_target_properties( target PROPERTIES COMPILE_FLAGS “/GR-" ) #no |
||
Open MP Support | set_target_properties( target PROPERTIES COMPILE_FLAGS “/openmp" )#yes set_target_properties( target PROPERTIES COMPILE_FLAGS “/openmp-" )#no |
||
PreCompiled Header | PreCompiled Header | set_target_properties( target PROPERTIES COMPILE_FLAGS "/Yc" ) #create set_target_properties( target PROPERTIES COMPILE_FLAGS "/Yu" ) #use #not setting means no |
|
PreCompiled Header File | set_target_properties( target PROPERTIES COMPILE_FLAGS "/Ycstdafx.h" ) set_target_properties( target PROPERTIES COMPILE_FLAGS "/Yustdafx.h" ) |
||
Precompiled Header output File | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FpPathAndName.pch" ) | ||
Output Files | Expand Attributed Source | set_target_properties( target PROPERTIES COMPILE_FLAGS "/Fx" ) | |
Assembler Output | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FA" ) set_target_properties( target PROPERTIES COMPILE_FLAGS "/FAc" ) set_target_properties( target PROPERTIES COMPILE_FLAGS "/FAs" ) set_target_properties( target PROPERTIES COMPILE_FLAGS "/FAcs" ) #not setting means no list |
||
ASM List Location | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FaDebug" ) | ||
Object File name | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FoName.obj" ) | ||
Program DataBase File Name | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FdC:/Debug/good.pdb" ) | ||
Generate XML Documentation Files | set_target_properties( target PROPERTIES COMPILE_FLAGS "/doc" ) | ||
XML Documentation Filename | set_target_properties( target PROPERTIES COMPILE_FLAGS "/docDocument.xml" ) | ||
Browse Information | Enable Browse Information | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FR" ) | |
Browse Information File | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FRfilename" ) | ||
Advanced | Calling Convention | set_target_properties( target PROPERTIES COMPILE_FLAGS "/Gd" ) #_cdecl set_target_properties( target PROPERTIES COMPILE_FLAGS "/Gr" ) #_fastcall set_target_properties( target PROPERTIES COMPILE_FLAGS "/Gz" ) #_stdcall |
|
Compile As | set_target_properties( target PROPERTIES LINKER_LANGUAGE "CXX" ) #C++ set_target_properties( target PROPERTIES LINKER_LANGUAGE "C" ) #C or set_target_properties( target PROPERTIES COMPILE_FLAGS "/TP" ) #CXX set_target_properties( target PROPERTIES COMPILE_FLAGS "/TC" ) #C |
||
Disable Specific Warnings | set_target_properties( target PROPERTIES COMPILE_FLAGS "/wd4710" ) | ||
Forced Include File | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FIinclude.h" ) | ||
Forced #using File | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FUname" ) | ||
Show Includes | set_target_properties( target PROPERTIES COMPILE_FLAGS "/showIncludes" ) | ||
Use full Paths | set_target_properties( target PROPERTIES COMPILE_FLAGS "/FC" ) | ||
Omit Default Library name | set_target_properties( target PROPERTIES COMPILE_FLAGS "/ZI" ) | ||
Internal Compiler Error Reporting | set_target_properties( target PROPERTIES COMPILE_FLAGS "/errorReport:queue" ) set_target_properties( target PROPERTIES COMPILE_FLAGS "/errorReport:none" ) set_target_properties( target PROPERTIES COMPILE_FLAGS "/errorReport:prompt" ) set_target_properties( target PROPERTIES COMPILE_FLAGS "/errorReport:send" ) |
||
Treat Specific Warnings as Errors | Don't know | ||
Linker | General | Output File | #normal case set_target_properties( target PROPERTIES OUTPUT_NAME "Helloworld" ) set_target_properties( target PROPERTIES PREFIX "lib" ) set_target_properties( target PROPERTIES SUFFIX "lib" ) #for debug version set_target_properties( target PROPERTIES DEBUG_OUTPUT_NAME "Helloworld" ) set_target_properties( target PROPERTIES DEBUG_PREFIX "lib" ) set_target_properties( target PROPERTIES DEBUG_SUFFIX "lib" ) #For dlls set_target_properties( target PROPERTIES OUTPUT_NAME "Helloworld" ) set_target_properties( target PROPERTIES IMPORT_PREFIX "lib" ) set_target_properties( target PROPERTIES IMPORT_SUFFIX "lib" ) set_target_properties( target PROPERTIES PREFIX "bin" ) set_target_properties( target PROPERTIES SUFFIX "dll" ) #output path |
Show Progress | set_target_properties( target PROPERTIES LINK_FLAGS "/VERBOSE" ) set_target_properties( target PROPERTIES LINK_FLAGS "/VERBOSE:Lib" ) set_target_properties( target PROPERTIES LINK_FLAGS "/VERBOSE:ICF" ) set_target_properties( target PROPERTIES LINK_FLAGS "/VERBOSE:REF" ) set_target_properties( target PROPERTIES LINK_FLAGS "/VERBOSE:SAFESEH" ) set_target_properties( target PROPERTIES LINK_FLAGS "/VERBOSE:CLR" ) #not setting means no |
||
Version | set_target_properties( target PROPERTIES VERSION 0.1.2.3) | ||
Enable Incremental Linking | set_target_properties( target PROPERTIES LINK_FLAGS "/INCREMENTAL" ) set_target_properties( target PROPERTIES LINK_FLAGS "/INCREMENTAL:NO" ) set( CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL" ) set( CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO" ) |
||
Suppress Startup Banner | set_target_properties( target PROPERTIES LINK_FLAGS "/NOLOGO" ) | ||
Ignore Import Library | Don't know | ||
Register Output | Don't know | ||
Per-user Redirection | Don't know | ||
Additional Library Directories | link_directories( dir1 dir2 ) set_target_properties( target PROPERTIES LINK_FLAGS "/LIBPATH:dir1 /LIBPATH:dir2" ) |
||
Link Library Dependencies | Don't know | ||
Use Library Dependency Inputs | Don't know | ||
Link Status | set_target_properties( target PROPERTIES LINK_FLAGS "/LTCG:STATUS" ) set_target_properties( target PROPERTIES LINK_FLAGS "/LTCG:NOSTATUS" ) |
||
Prevent DLL Binding | set_target_properties( target PROPERTIES LINK_FLAGS "/ALLOWBIND:NO" ) set_target_properties( target PROPERTIES LINK_FLAGS "/ALLOWBIND:YES" ) |
||
Treat Linker Warnings As Errors | set_target_properties( target PROPERTIES LINK_FLAGS "/WX" ) | ||
Force File Output | set_target_properties( target PROPERTIES LINK_FLAGS "/FORCE" ) | ||
Create Hot Patchable Image | set_target_properties( target PROPERTIES LINK_FLAGS "/FUNCTIONPADMIN" ) set_target_properties( target PROPERTIES LINK_FLAGS "/FUNCTIONPADMIN:16" ) #Itanium only set_target_properties( target PROPERTIES LINK_FLAGS "/FUNCTIONPADMIN:6" ) #x64 only set_target_properties( target PROPERTIES LINK_FLAGS "/FUNCTIONPADMIN:5" ) #x86 only |
||
Specify Section Attributes | Don't know | ||
Input | Additional Dependancies | target_link_libraries( target item1 item2 ) | |
Ignore All Default Libraries | set_target_properties( target PROPERTIES LINK_FLAGS "/NODEFAULTLIB" ) | ||
Put files into folders | source_group( header FILES includeme.h ) | ||