VS: in Clang/C2 toolset, setup correct compiler settings
This commit is contained in:
parent
37afe00faa
commit
2c2ec4883b
|
@ -194,8 +194,14 @@ else()
|
|||
if(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
|
||||
set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib")
|
||||
elseif(MSVC_VERSION GREATER 1310)
|
||||
set(_RTC1 "/RTC1")
|
||||
set(_FLAGS_CXX " /GR /EHsc")
|
||||
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
|
||||
# Clang/C2 in MSVC14 Update 1 seems to not support -fsantinize (yet?)
|
||||
# set(_RTC1 "-fsantinize=memory,safe-stack")
|
||||
set(_FLAGS_CXX " -frtti -fexceptions")
|
||||
else()
|
||||
set(_RTC1 "/RTC1")
|
||||
set(_FLAGS_CXX " /GR /EHsc")
|
||||
endif()
|
||||
set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib")
|
||||
else()
|
||||
set(_RTC1 "/GZ")
|
||||
|
@ -296,11 +302,21 @@ macro(__windows_compiler_msvc lang)
|
|||
set(CMAKE_${lang}_LINK_EXECUTABLE
|
||||
"${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
|
||||
|
||||
set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}")
|
||||
set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}")
|
||||
set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
|
||||
set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG")
|
||||
set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
|
||||
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
|
||||
# note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow to compile many projects
|
||||
# that include MS's own headers. CMake itself is affected project too.
|
||||
set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}")
|
||||
set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-D_DEBUG /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}")
|
||||
set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD -O2 -D NDEBUG")
|
||||
set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD -gline-tables-only -O2 -fno-inline -D NDEBUG")
|
||||
set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD -Os -D NDEBUG")
|
||||
else()
|
||||
set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}")
|
||||
set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}")
|
||||
set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
|
||||
set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG")
|
||||
set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
|
||||
endif()
|
||||
set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON)
|
||||
set(CMAKE_NINJA_DEPTYPE_${lang} msvc)
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ static cmVS7FlagTable cmVS14CLFlagTable[] =
|
|||
"Custom", "Custom", 0},
|
||||
{"Optimization", "Od",
|
||||
"Disabled", "Disabled", 0},
|
||||
{"Optimization", "Os",
|
||||
"Minimize Size", "MinSize", 0},
|
||||
{"Optimization", "O1",
|
||||
"Minimize Size", "MinSpace", 0},
|
||||
{"Optimization", "O2",
|
||||
|
|
|
@ -2078,7 +2078,18 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
|||
|
||||
if(this->MSTools)
|
||||
{
|
||||
this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
|
||||
cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*");
|
||||
const char* toolset = this->GlobalGenerator->GetPlatformToolset();
|
||||
if (toolset && clangToolset.find(toolset))
|
||||
{
|
||||
this->WriteString("<ObjectFileName>"
|
||||
"$(IntDir)%(filename).obj"
|
||||
"</ObjectFileName>\n", 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
|
||||
}
|
||||
|
||||
// If not in debug mode, write the DebugInformationFormat field
|
||||
// without value so PDBs don't get generated uselessly.
|
||||
|
|
Loading…
Reference in New Issue