@@ -8,13 +8,120 @@ if(__WINDOWS_CLANG)
8
8
endif ()
9
9
set (__WINDOWS_CLANG 1 )
10
10
11
+ macro (__windows_compiler_clang_gnu lang )
12
+ set (CMAKE_LIBRARY_PATH_FLAG "-L" )
13
+ set (CMAKE_LINK_LIBRARY_FLAG "-l" )
14
+
15
+ set (CMAKE_IMPORT_LIBRARY_PREFIX "" )
16
+ set (CMAKE_SHARED_LIBRARY_PREFIX "" )
17
+ set (CMAKE_SHARED_MODULE_PREFIX "" )
18
+ set (CMAKE_STATIC_LIBRARY_PREFIX "" )
19
+ set (CMAKE_EXECUTABLE_SUFFIX ".exe" )
20
+ set (CMAKE_IMPORT_LIBRARY_SUFFIX ".lib" )
21
+ set (CMAKE_SHARED_LIBRARY_SUFFIX ".dll" )
22
+ set (CMAKE_SHARED_MODULE_SUFFIX ".dll" )
23
+ set (CMAKE_STATIC_LIBRARY_SUFFIX ".lib" )
24
+ set (CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>" )
25
+
26
+ set (CMAKE_FIND_LIBRARY_PREFIXES "lib" "" )
27
+ set (CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib" )
28
+ set (CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1 )
29
+ set (CMAKE_LINK_DEF_FILE_FLAG "-Xlinker /DEF:" )
30
+
31
+ if ("${CMAKE_${lang} _SIMULATE_VERSION}" MATCHES "^([0-9]+)\\ .([0-9]+)" )
32
+ math (EXPR MSVC_VERSION "${CMAKE_MATCH_1} *100 + ${CMAKE_MATCH_2} " )
33
+ endif ()
34
+
35
+ # No -fPIC on Windows
36
+ set (CMAKE_${lang}_COMPILE_OPTIONS_PIC "" )
37
+ set (CMAKE_${lang}_COMPILE_OPTIONS_PIE "" )
38
+ set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO )
39
+ set (CMAKE_${lang}_LINK_OPTIONS_PIE "" )
40
+ set (CMAKE_${lang}_LINK_OPTIONS_NO_PIE "" )
41
+ set (CMAKE_SHARED_LIBRARY_${lang}_FLAGS "" )
42
+
43
+ set (CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1 )
44
+ set (CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1 )
45
+ set (CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1 )
46
+
47
+ # Create archiving rules to support large object file lists for static libraries.
48
+ set (CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>" )
49
+ set (CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>" )
50
+ set (CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>" )
51
+ set (CMAKE_${lang}_CREATE_SHARED_LIBRARY
52
+ "<CMAKE_${lang} _COMPILER> -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang} _FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang} _FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES>" )
53
+ set (CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY} )
54
+ set (CMAKE_${lang}_LINK_EXECUTABLE
55
+ "<CMAKE_${lang} _COMPILER> -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang} _LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>" )
56
+
57
+ set (CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt )
58
+ set (CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt )
59
+ set (CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -D_DEBUG -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmtd )
60
+ set (CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd )
61
+
62
+ if (CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT )
63
+ set (__ADDED_FLAGS "" )
64
+ set (__ADDED_FLAGS_DEBUG "" )
65
+ else ()
66
+ set (__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd" )
67
+ set (__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt" )
68
+ endif ()
69
+
70
+ string (APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG} " )
71
+ string (APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS} " )
72
+ string (APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS} " )
73
+ string (APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS} " )
74
+ set (CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem " )
75
+
76
+ unset (__ADDED_FLAGS )
77
+ unset (__ADDED_FLAGS_DEBUG )
78
+ string (TOLOWER "${CMAKE_BUILD_TYPE} " BUILD_TYPE_LOWER )
79
+ set (CMAKE_${lang}_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames" )
80
+
81
+ enable_language (RC )
82
+ endmacro ()
83
+
11
84
if ("x${CMAKE_C_SIMULATE_ID} " STREQUAL "xMSVC"
12
85
OR "x${CMAKE_CXX_SIMULATE_ID} " STREQUAL "xMSVC" )
13
- include (Platform/Windows-MSVC )
14
- macro (__windows_compiler_clang lang )
15
- set (_COMPILE_${lang} "${_COMPILE_${lang} _MSVC}" )
16
- __windows_compiler_msvc (${lang} )
17
- endmacro ()
86
+
87
+ if ( DEFINED CMAKE_C_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_ID
88
+ AND NOT "x${CMAKE_C_COMPILER_ID} " STREQUAL "x${CMAKE_CXX_COMPILER_ID} " )
89
+ message (FATAL_ERROR "The current configuration mixes Clang and MSVC or "
90
+ "some other CL compatible compiler tool. This is not supported. "
91
+ "Use either clang or MSVC as both C and C++ compilers." )
92
+ endif ()
93
+
94
+ if ( DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT AND DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT
95
+ AND NOT "x${CMAKE_C_COMPILER_FRONTEND_VARIANT} " STREQUAL "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT} " )
96
+ message (FATAL_ERROR "The current configuration uses the Clang compiler "
97
+ "tool with mixed frontend variants, both the GNU and in MSVC CL "
98
+ "like variants. This is not supported. Use either clang/clang++ "
99
+ "or clang-cl as both C and C++ compilers." )
100
+ endif ()
101
+
102
+ if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT} " STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT} " STREQUAL "xMSVC" )
103
+ include (Platform/Windows-MSVC )
104
+
105
+ macro (__windows_compiler_clang lang )
106
+ set (_COMPILE_${lang} "${_COMPILE_${lang} _MSVC}" )
107
+ __windows_compiler_msvc (${lang} )
108
+ endmacro ()
109
+ else ()
110
+ cmake_policy (GET CMP0091 __WINDOWS_CLANG_CMP0091 )
111
+ if (__WINDOWS_CLANG_CMP0091 STREQUAL "NEW" )
112
+ set (CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" )
113
+ else ()
114
+ set (CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "" )
115
+ endif ()
116
+ unset (__WINDOWS_CLANG_CMP0091 )
117
+
118
+ set (CMAKE_BUILD_TYPE_INIT Debug )
119
+
120
+ macro (__windows_compiler_clang lang )
121
+ __windows_compiler_clang_gnu (${lang} )
122
+ endmacro ()
123
+ endif ()
124
+
18
125
else ()
19
126
include (Platform/Windows-GNU )
20
127
macro (__windows_compiler_clang lang )
0 commit comments