Teach the compiler identification preprocessor tests to report when Clang simulates MSVC, and what version. If not MSVC, assume GNU. Teach compiler information modules Clang-(C|CXX) to recognize when Clang simulates MSVC and skip loading the GNU information. Teach the Windows-MSVC platform information to recognize when it is loaded as the simulated compiler and use that version information instead of the real compiler's (different) version scheme. Add platform modules Windows-Clang-(C|CXX) and support module Windows-Clang to load either Windows-MSVC or Windows-GNU and wrap the corresponding information macros.
This commit is contained in:
parent
51ab85c398
commit
3d8356d486
|
@ -33,6 +33,12 @@
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||||
|
# if defined(_MSC_VER)
|
||||||
|
# define SIMULATE_ID "MSVC"
|
||||||
|
/* _MSC_VER = VVRR */
|
||||||
|
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||||
|
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||||
|
# endif
|
||||||
|
|
||||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
||||||
# define COMPILER_ID "Embarcadero"
|
# define COMPILER_ID "Embarcadero"
|
||||||
|
|
|
@ -38,6 +38,12 @@
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||||
|
# if defined(_MSC_VER)
|
||||||
|
# define SIMULATE_ID "MSVC"
|
||||||
|
/* _MSC_VER = VVRR */
|
||||||
|
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||||
|
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||||
|
# endif
|
||||||
|
|
||||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
||||||
# define COMPILER_ID "Embarcadero"
|
# define COMPILER_ID "Embarcadero"
|
||||||
|
|
|
@ -30,8 +30,10 @@
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
# if it's the MS C/CXX compiler, search for link
|
# if it's the MS C/CXX compiler, search for link
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
|
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC"
|
||||||
OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
|
OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC"
|
||||||
|
OR "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC"
|
||||||
|
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"
|
||||||
OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
|
OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
|
||||||
|
|
||||||
find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
|
find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
include(Compiler/Clang)
|
include(Compiler/Clang)
|
||||||
__compiler_clang(CXX)
|
__compiler_clang(CXX)
|
||||||
|
|
||||||
|
if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
|
||||||
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
|
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
|
||||||
|
endif()
|
||||||
|
|
|
@ -18,6 +18,11 @@ if(__COMPILER_CLANG)
|
||||||
endif()
|
endif()
|
||||||
set(__COMPILER_CLANG 1)
|
set(__COMPILER_CLANG 1)
|
||||||
|
|
||||||
|
if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC"
|
||||||
|
OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
|
||||||
|
macro(__compiler_clang lang)
|
||||||
|
endmacro()
|
||||||
|
else()
|
||||||
include(Compiler/GNU)
|
include(Compiler/GNU)
|
||||||
|
|
||||||
macro(__compiler_clang lang)
|
macro(__compiler_clang lang)
|
||||||
|
@ -26,3 +31,4 @@ macro(__compiler_clang lang)
|
||||||
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
|
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
|
||||||
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
|
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
include(Platform/Windows-Clang)
|
||||||
|
__windows_compiler_clang(C)
|
|
@ -0,0 +1,2 @@
|
||||||
|
include(Platform/Windows-Clang)
|
||||||
|
__windows_compiler_clang(CXX)
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2001-2013 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
# This module is shared by multiple languages; use include blocker.
|
||||||
|
if(__WINDOWS_CLANG)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(__WINDOWS_CLANG 1)
|
||||||
|
|
||||||
|
if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC"
|
||||||
|
OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
|
||||||
|
include(Platform/Windows-MSVC)
|
||||||
|
macro(__windows_compiler_clang lang)
|
||||||
|
__windows_compiler_msvc(${lang})
|
||||||
|
endmacro()
|
||||||
|
else()
|
||||||
|
include(Platform/Windows-GNU)
|
||||||
|
macro(__windows_compiler_clang lang)
|
||||||
|
__windows_compiler_gnu(${lang})
|
||||||
|
endmacro()
|
||||||
|
endif()
|
|
@ -65,7 +65,11 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MSVC_VERSION)
|
if(NOT MSVC_VERSION)
|
||||||
if(CMAKE_C_COMPILER_VERSION)
|
if(CMAKE_C_SIMULATE_VERSION)
|
||||||
|
set(_compiler_version ${CMAKE_C_SIMULATE_VERSION})
|
||||||
|
elseif(CMAKE_CXX_SIMULATE_VERSION)
|
||||||
|
set(_compiler_version ${CMAKE_CXX_SIMULATE_VERSION})
|
||||||
|
elseif(CMAKE_C_COMPILER_VERSION)
|
||||||
set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
|
set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
|
||||||
else()
|
else()
|
||||||
set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
|
set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
|
||||||
|
@ -220,7 +224,7 @@ set (CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INI
|
||||||
set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT})
|
set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT})
|
||||||
|
|
||||||
macro(__windows_compiler_msvc lang)
|
macro(__windows_compiler_msvc lang)
|
||||||
if(NOT "${CMAKE_${lang}_COMPILER_VERSION}" VERSION_LESS 14)
|
if(NOT MSVC_VERSION LESS 1400)
|
||||||
# for 2005 make sure the manifest is put in the dll with mt
|
# for 2005 make sure the manifest is put in the dll with mt
|
||||||
set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll ")
|
set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll ")
|
||||||
set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe ")
|
set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe ")
|
||||||
|
|
Loading…
Reference in New Issue