From 6348ffb9e55c5e84b9bc65d4d97a2f6b6f016edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 26 Jan 2020 22:00:01 +0200 Subject: ASM: Hook up Windows-specific GNU/Clang compiler information modules This allows building .s/.S assembly code, and makes sure that the `-fPIC` option isn't passed to the compiler (as it errors out on Clang and causes a loud warning on GCC). --- Modules/Platform/Windows-Clang-ASM.cmake | 2 ++ Modules/Platform/Windows-Clang.cmake | 36 +++++++++++++++------------ Modules/Platform/Windows-GNU-ASM.cmake | 2 ++ Modules/Platform/WindowsPhone-Clang-ASM.cmake | 1 + Modules/Platform/WindowsPhone-GNU-ASM.cmake | 1 + Modules/Platform/WindowsStore-Clang-ASM.cmake | 1 + Modules/Platform/WindowsStore-GNU-ASM.cmake | 1 + 7 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 Modules/Platform/Windows-Clang-ASM.cmake create mode 100644 Modules/Platform/Windows-GNU-ASM.cmake create mode 100644 Modules/Platform/WindowsPhone-Clang-ASM.cmake create mode 100644 Modules/Platform/WindowsPhone-GNU-ASM.cmake create mode 100644 Modules/Platform/WindowsStore-Clang-ASM.cmake create mode 100644 Modules/Platform/WindowsStore-GNU-ASM.cmake diff --git a/Modules/Platform/Windows-Clang-ASM.cmake b/Modules/Platform/Windows-Clang-ASM.cmake new file mode 100644 index 0000000..345d77d --- /dev/null +++ b/Modules/Platform/Windows-Clang-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-Clang) +__windows_compiler_clang(ASM) diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index c17cf6d..5eddd04 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -21,7 +21,9 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") set(CMAKE_SHARED_MODULE_SUFFIX ".dll") set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") - set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT -MF ") + if(NOT "${lang}" STREQUAL "ASM") + set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT -MF ") + endif() set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") @@ -61,23 +63,25 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_LINK_EXECUTABLE " -fuse-ld=lld-link -nostartfiles -nostdlib -o -Xlinker /implib: -Xlinker /pdb: -Xlinker /version:. ${CMAKE_GNULD_IMAGE_VERSION} ") - set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt) - set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt) - set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -D_DEBUG -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmtd) - set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd) + if(NOT "${lang}" STREQUAL "ASM") + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -D_DEBUG -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmtd) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd) - if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) - set(__ADDED_FLAGS "") - set(__ADDED_FLAGS_DEBUG "") - else() - set(__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd") - set(__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt") - endif() + if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + set(__ADDED_FLAGS "") + set(__ADDED_FLAGS_DEBUG "") + else() + set(__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd") + set(__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt") + endif() - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}") - string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}") - string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}") + endif() set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") set(CMAKE_PCH_EXTENSION .pch) diff --git a/Modules/Platform/Windows-GNU-ASM.cmake b/Modules/Platform/Windows-GNU-ASM.cmake new file mode 100644 index 0000000..8600892 --- /dev/null +++ b/Modules/Platform/Windows-GNU-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-GNU) +__windows_compiler_gnu(ASM) diff --git a/Modules/Platform/WindowsPhone-Clang-ASM.cmake b/Modules/Platform/WindowsPhone-Clang-ASM.cmake new file mode 100644 index 0000000..94f4ca7 --- /dev/null +++ b/Modules/Platform/WindowsPhone-Clang-ASM.cmake @@ -0,0 +1 @@ +include(Platform/Windows-Clang-ASM) diff --git a/Modules/Platform/WindowsPhone-GNU-ASM.cmake b/Modules/Platform/WindowsPhone-GNU-ASM.cmake new file mode 100644 index 0000000..140eea7 --- /dev/null +++ b/Modules/Platform/WindowsPhone-GNU-ASM.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-ASM) diff --git a/Modules/Platform/WindowsStore-Clang-ASM.cmake b/Modules/Platform/WindowsStore-Clang-ASM.cmake new file mode 100644 index 0000000..94f4ca7 --- /dev/null +++ b/Modules/Platform/WindowsStore-Clang-ASM.cmake @@ -0,0 +1 @@ +include(Platform/Windows-Clang-ASM) diff --git a/Modules/Platform/WindowsStore-GNU-ASM.cmake b/Modules/Platform/WindowsStore-GNU-ASM.cmake new file mode 100644 index 0000000..140eea7 --- /dev/null +++ b/Modules/Platform/WindowsStore-GNU-ASM.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-ASM) -- cgit v0.12