Visual Studio属性与对应cmakelists实现方法

Visual Studio属性与对应cmakelists实现方法

Visual StudioCmake
Project Referenceadd_dependencies()
General/Output Directory
Debugging/Working DirectoryCMAKE can’t set this value, because the info not stored in project file but some intermedia file generated by visual studio
c/c++GeneralAdditional Include Directoriesinclude_directories()
Resolve #using ReferencesDon’t know
Debug Information FormatCMAKE 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 supportset_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 Bannerset_target_properties( target PROPERTIES COMPILE_FLAGS “/nologo” )
Warning Levelset_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 Errorsset_target_properties( target PROPERTIES COMPILE_FLAGS “/WX-" ) #No
set_target_properties( target PROPERTIES COMPILE_FLAGS “/WX" )  #Yes
Multi-processor Compilationset_target_properties( target PROPERTIES COMPILE_FLAGS “/MP" )  #Yes
#Don’t set means No
Use Unicode For Assembler Listingset_target_properties( target PROPERTIES COMPILE_FLAGS “/FAu" ) #yes
#Don’t set means no
OptimizationOptimizationset(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 Expansionset(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 Functionsset_target_properties( target PROPERTIES COMPILE_FLAGS “/Oi" ) #yes
#Don’t set means no
Favor Size or Speedset_target_properties( target PROPERTIES COMPILE_FLAGS “/Os" ) #size
set_target_properties( target PROPERTIES COMPILE_FLAGS “/Ot" ) #speed
#Don’t set means neither
Omit Frame Pointersset_target_properties( target PROPERTIES COMPILE_FLAGS “/Oy-" ) #no
set_target_properties( target PROPERTIES COMPILE_FLAGS “/Oy" ) #yes
Enable Fiber-safe Optimizationsset_target_properties( target PROPERTIES COMPILE_FLAGS “/GT" ) #yes
#not setting means no
Whole Program Optimizationset_target_properties( target PROPERTIES COMPILE_FLAGS “/GL" ) #yes
#not setting means no
PreprocessorPreprocessor Definitionsset_target_properties( target PROPERTIES COMPILE_DEFINITIONS DEFNAME=DEFVAL )
set_source_files_properties( filename.cpp PROPERTIES COMPILE_DEFINITIONS DEFNAME=DEFVAL )
Undefine Preprocessor Definitionsset_target_properties( target PROPERTIES COMPILE_FLAGS “/UDEFNAME" )
Undefine All Preprocessor Definitionsset_target_properties( target PROPERTIES COMPILE_FLAGS “/u" )
Ignore Standard Include Pathset_target_properties( target PROPERTIES COMPILE_FLAGS “/X" )
Preprocess to a Fileset_target_properties( target PROPERTIES COMPILE_FLAGS “/P" )
Preprocess Suppress Line Numbersset_target_properties( target PROPERTIES COMPILE_FLAGS “/EP" )
Keep Commentsset_target_properties( target PROPERTIES COMPILE_FLAGS “/C" )
Code GenerationEnable String Poolingset_target_properties( target PROPERTIES COMPILE_FLAGS “/GF" ) #yes
set_target_properties( target PROPERTIES COMPILE_FLAGS “/GF-" ) #no
Enable Minimum Rebuildset_target_properties( target PROPERTIES COMPILE_FLAGS “/Gm" ) #yes
set_target_properties( target PROPERTIES COMPILE_FLAGS “/Gm-" )#no
Enable C++ Exceptionsset_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 Checkset_target_properties( target PROPERTIES COMPILE_FLAGS “/RTCc" ) #yes
#not setting means no
Basic Runtime Checksset_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 LibraryCMAKE 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 Alignmentset_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 Checkset_target_properties( target PROPERTIES COMPILE_FLAGS “/GS" ) #yes
set_target_properties( target PROPERTIES COMPILE_FLAGS “/GS-" ) #no
Enable Function-Level Linkingset_target_properties( target PROPERTIES COMPILE_FLAGS “/Gy" ) #yes
set_target_properties( target PROPERTIES COMPILE_FLAGS “/Gy-" ) #no
Enable Enhaunced Instruction Setset_target_properties( target PROPERTIES COMPILE_FLAGS “/arch:SSE" )
set_target_properties( target PROPERTIES COMPILE_FLAGS “/arch:SSE2" )
Floating Point Modelset_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 Exceptionsset_target_properties( target PROPERTIES COMPILE_FLAGS “/fp:except" )
Create Hotpatchable Imageset_target_properties( target PROPERTIES COMPILE_FLAGS “/hotpatch" )
LanguageDisable Language Extensionsset_target_properties( target PROPERTIES COMPILE_FLAGS “/Za" )
Treat Wchar_t As Built in Typeset_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 Informationset_target_properties( target PROPERTIES COMPILE_FLAGS “/GR" ) #yes
set_target_properties( target PROPERTIES COMPILE_FLAGS “/GR-" ) #no
Open MP Supportset_target_properties( target PROPERTIES COMPILE_FLAGS “/openmp" )#yes
set_target_properties( target PROPERTIES COMPILE_FLAGS “/openmp-" )#no
PreCompiled HeaderPreCompiled Headerset_target_properties( target PROPERTIES COMPILE_FLAGS "/Yc" ) #create
set_target_properties( target PROPERTIES COMPILE_FLAGS "/Yu" ) #use
#not setting means no
PreCompiled Header Fileset_target_properties( target PROPERTIES COMPILE_FLAGS "/Ycstdafx.h" )
set_target_properties( target PROPERTIES COMPILE_FLAGS "/Yustdafx.h" )
Precompiled Header output Fileset_target_properties( target PROPERTIES COMPILE_FLAGS "/FpPathAndName.pch" )
Output FilesExpand Attributed Sourceset_target_properties( target PROPERTIES COMPILE_FLAGS "/Fx" )
Assembler Outputset_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 Locationset_target_properties( target PROPERTIES COMPILE_FLAGS "/FaDebug" )
Object File nameset_target_properties( target PROPERTIES COMPILE_FLAGS "/FoName.obj" )
Program DataBase File Nameset_target_properties( target PROPERTIES COMPILE_FLAGS "/FdC:/Debug/good.pdb" )
Generate XML Documentation Filesset_target_properties( target PROPERTIES COMPILE_FLAGS "/doc" )
XML Documentation Filenameset_target_properties( target PROPERTIES COMPILE_FLAGS "/docDocument.xml" )
Browse InformationEnable Browse Informationset_target_properties( target PROPERTIES COMPILE_FLAGS "/FR" )
Browse Information Fileset_target_properties( target PROPERTIES COMPILE_FLAGS "/FRfilename" )
AdvancedCalling Conventionset_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 Asset_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 Warningsset_target_properties( target PROPERTIES COMPILE_FLAGS "/wd4710" )
Forced Include Fileset_target_properties( target PROPERTIES COMPILE_FLAGS "/FIinclude.h" )
Forced #using Fileset_target_properties( target PROPERTIES COMPILE_FLAGS "/FUname" )
Show Includesset_target_properties( target PROPERTIES COMPILE_FLAGS "/showIncludes" )
Use full Pathsset_target_properties( target PROPERTIES COMPILE_FLAGS "/FC" )
Omit Default Library nameset_target_properties( target PROPERTIES COMPILE_FLAGS "/ZI" )
Internal Compiler Error Reportingset_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 ErrorsDon't know
LinkerGeneralOutput 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 Progressset_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
Versionset_target_properties( target PROPERTIES VERSION 0.1.2.3)
Enable Incremental Linkingset_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 Bannerset_target_properties( target PROPERTIES LINK_FLAGS "/NOLOGO" )
Ignore Import LibraryDon't know
Register OutputDon't know
Per-user RedirectionDon't know
Additional Library Directorieslink_directories( dir1 dir2 )

set_target_properties( target PROPERTIES LINK_FLAGS "/LIBPATH:dir1 /LIBPATH:dir2" )
Link Library DependenciesDon't know
Use Library Dependency InputsDon't know
Link Statusset_target_properties( target PROPERTIES LINK_FLAGS "/LTCG:STATUS" )
set_target_properties( target PROPERTIES LINK_FLAGS "/LTCG:NOSTATUS" )
Prevent DLL Bindingset_target_properties( target PROPERTIES LINK_FLAGS "/ALLOWBIND:NO" )
set_target_properties( target PROPERTIES LINK_FLAGS "/ALLOWBIND:YES" )
Treat Linker Warnings As Errorsset_target_properties( target PROPERTIES LINK_FLAGS "/WX" )
Force File Outputset_target_properties( target PROPERTIES LINK_FLAGS "/FORCE" )
Create Hot Patchable Imageset_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 AttributesDon't know
InputAdditional Dependanciestarget_link_libraries( target item1 item2 )
Ignore All Default Librariesset_target_properties( target PROPERTIES LINK_FLAGS "/NODEFAULTLIB" )
Put files into folderssource_group( header FILES includeme.h )
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值