[CMake] 默认编译、链接选项

CMakeLists.txt 文件内容:

cmake_minimum_required(VERSION 3.0)

message(STATUS "CMAKE_C_FLAGS = " ${CMAKE_C_FLAGS})
message(STATUS "CMAKE_C_FLAGS_DEBUG = " ${CMAKE_C_FLAGS_DEBUG})
message(STATUS "CMAKE_C_FLAGS_MINSIZEREL = " ${CMAKE_C_FLAGS_MINSIZEREL})
message(STATUS "CMAKE_C_FLAGS_RELEASE = " ${CMAKE_C_FLAGS_RELEASE})
message(STATUS "CMAKE_C_FLAGS_RELWITHDEBINFO = " ${CMAKE_C_FLAGS_RELWITHDEBINFO})

message(STATUS "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS})
message(STATUS "CMAKE_CXX_FLAGS_DEBUG = " ${CMAKE_CXX_FLAGS_DEBUG})
message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL = " ${CMAKE_CXX_FLAGS_MINSIZEREL})
message(STATUS "CMAKE_CXX_FLAGS_RELEASE = " ${CMAKE_CXX_FLAGS_RELEASE})
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO = " ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})

message(STATUS "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS})
message(STATUS "CMAKE_EXE_LINKER_FLAGS_DEBUG = " ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
message(STATUS "CMAKE_EXE_LINKER_FLAGS_MINSIZEREL = " ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL})
message(STATUS "CMAKE_EXE_LINKER_FLAGS_RELEASE = " ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
message(STATUS "CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO = " ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})

message(STATUS "CMAKE_MODULE_LINKER_FLAGS = " ${CMAKE_MODULE_LINKER_FLAGS})
message(STATUS "CMAKE_MODULE_LINKER_FLAGS_DEBUG = " ${CMAKE_MODULE_LINKER_FLAGS_DEBUG})
message(STATUS "CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL = " ${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL})
message(STATUS "CMAKE_MODULE_LINKER_FLAGS_RELEASE = " ${CMAKE_MODULE_LINKER_FLAGS_RELEASE})
message(STATUS "CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO = " ${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO})

message(STATUS "CMAKE_SHARED_LINKER_FLAGS = " ${CMAKE_SHARED_LINKER_FLAGS})
message(STATUS "CMAKE_SHARED_LINKER_FLAGS_DEBUG = " ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})
message(STATUS "CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL = " ${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL})
message(STATUS "CMAKE_SHARED_LINKER_FLAGS_RELEASE = " ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
message(STATUS "CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO = " ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO})

message(STATUS "CMAKE_STATIC_LINKER_FLAGS = " ${CMAKE_STATIC_LINKER_FLAGS})
message(STATUS "CMAKE_STATIC_LINKER_FLAGS_DEBUG = " ${CMAKE_STATIC_LINKER_FLAGS_DEBUG})
message(STATUS "CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL = " ${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL})
message(STATUS "CMAKE_STATIC_LINKER_FLAGS_RELEASE = " ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
message(STATUS "CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO = " ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})

Windows 平台 64 位编译输出:

-- CMAKE_C_FLAGS =  /DWIN32 /D_WINDOWS /W3
-- CMAKE_C_FLAGS_DEBUG = /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
-- CMAKE_C_FLAGS_MINSIZEREL = /MD /O1 /Ob1 /D NDEBUG
-- CMAKE_C_FLAGS_RELEASE = /MD /O2 /Ob2 /D NDEBUG
-- CMAKE_C_FLAGS_RELWITHDEBINFO = /MD /Zi /O2 /Ob1 /D NDEBUG
-- CMAKE_CXX_FLAGS =  /DWIN32 /D_WINDOWS /W3 /GR /EHsc
-- CMAKE_CXX_FLAGS_DEBUG = /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
-- CMAKE_CXX_FLAGS_MINSIZEREL = /MD /O1 /Ob1 /D NDEBUG
-- CMAKE_CXX_FLAGS_RELEASE = /MD /O2 /Ob2 /D NDEBUG
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO = /MD /Zi /O2 /Ob1 /D NDEBUG
-- CMAKE_EXE_LINKER_FLAGS =  /machine:x64
-- CMAKE_EXE_LINKER_FLAGS_DEBUG = /debug /INCREMENTAL
-- CMAKE_EXE_LINKER_FLAGS_MINSIZEREL = /INCREMENTAL:NO
-- CMAKE_EXE_LINKER_FLAGS_RELEASE = /INCREMENTAL:NO
-- CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO = /debug /INCREMENTAL
-- CMAKE_MODULE_LINKER_FLAGS =  /machine:x64
-- CMAKE_MODULE_LINKER_FLAGS_DEBUG = /debug /INCREMENTAL
-- CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL = /INCREMENTAL:NO
-- CMAKE_MODULE_LINKER_FLAGS_RELEASE = /INCREMENTAL:NO
-- CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO = /debug /INCREMENTAL
-- CMAKE_SHARED_LINKER_FLAGS =  /machine:x64
-- CMAKE_SHARED_LINKER_FLAGS_DEBUG = /debug /INCREMENTAL
-- CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL = /INCREMENTAL:NO
-- CMAKE_SHARED_LINKER_FLAGS_RELEASE = /INCREMENTAL:NO
-- CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO = /debug /INCREMENTAL
-- CMAKE_STATIC_LINKER_FLAGS =  /machine:x64
-- CMAKE_STATIC_LINKER_FLAGS_DEBUG =
-- CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL =
-- CMAKE_STATIC_LINKER_FLAGS_RELEASE =
-- CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO =
-- Configuring done
-- Generating done

Ubuntu Linux 16.04 64 位编译输出:

-- CMAKE_C_FLAGS = 
-- CMAKE_C_FLAGS_DEBUG = -g
-- CMAKE_C_FLAGS_MINSIZEREL = -Os -DNDEBUG
-- CMAKE_C_FLAGS_RELEASE = -O3 -DNDEBUG
-- CMAKE_C_FLAGS_RELWITHDEBINFO = -O2 -g -DNDEBUG
-- CMAKE_CXX_FLAGS = 
-- CMAKE_CXX_FLAGS_DEBUG = -g
-- CMAKE_CXX_FLAGS_MINSIZEREL = -Os -DNDEBUG
-- CMAKE_CXX_FLAGS_RELEASE = -O3 -DNDEBUG
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO = -O2 -g -DNDEBUG
-- CMAKE_EXE_LINKER_FLAGS = 
-- CMAKE_EXE_LINKER_FLAGS_DEBUG = 
-- CMAKE_EXE_LINKER_FLAGS_MINSIZEREL = 
-- CMAKE_EXE_LINKER_FLAGS_RELEASE = 
-- CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO = 
-- CMAKE_MODULE_LINKER_FLAGS = 
-- CMAKE_MODULE_LINKER_FLAGS_DEBUG = 
-- CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL = 
-- CMAKE_MODULE_LINKER_FLAGS_RELEASE = 
-- CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO = 
-- CMAKE_SHARED_LINKER_FLAGS = 
-- CMAKE_SHARED_LINKER_FLAGS_DEBUG = 
-- CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL = 
-- CMAKE_SHARED_LINKER_FLAGS_RELEASE = 
-- CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO = 
-- CMAKE_STATIC_LINKER_FLAGS = 
-- CMAKE_STATIC_LINKER_FLAGS_DEBUG = 
-- CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL = 
-- CMAKE_STATIC_LINKER_FLAGS_RELEASE = 
-- CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO = 
-- Configuring done
-- Generating done

作者:icbm
来源:CSDN
原文:https://blog.csdn.net/icbm/article/details/52336497
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/u014671962/article/details/84949634