CMake: Remove limited compiler detection and properly support compilers simulating MSVC

pull/715/head
Kacper Michajłow 2020-11-20 16:29:11 +01:00
rodzic 33ab785085
commit c57b11cdab
4 zmienionych plików z 11 dodań i 21 usunięć

Wyświetl plik

@ -1,13 +1,12 @@
include_guard(GLOBAL) include_guard(GLOBAL)
include(DetectCompiler)
include(DetectArchitecture) include(DetectArchitecture)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
if (C_CLANG OR C_GCC) if(MSVC)
add_compile_options(-Wall -Wextra -Wvla -Woverloaded-virtual -ffast-math -ftree-vectorize)
elseif (C_MSVC)
add_compile_options(/MP) add_compile_options(/MP)
else()
add_compile_options(-Wall -Wextra -Wvla -Woverloaded-virtual -ffast-math -ftree-vectorize)
endif() endif()
if (SANITIZE_ADDRESS) if (SANITIZE_ADDRESS)

Wyświetl plik

@ -93,7 +93,7 @@ function(detect_msvc_native_opt)
endif() endif()
endfunction() endfunction()
if (C_MSVC) if (MSVC)
detect_architecture("_M_AMD64" x86_64) detect_architecture("_M_AMD64" x86_64)
detect_architecture("_M_IX86" x86) detect_architecture("_M_IX86" x86)
detect_architecture("_M_ARM" ARM) detect_architecture("_M_ARM" ARM)
@ -114,7 +114,7 @@ endif()
if (FORCE_SSSE3) if (FORCE_SSSE3)
message(WARNING "FORCE_SSSE3 flag is deprecated, please use ARCH_OPT option.") message(WARNING "FORCE_SSSE3 flag is deprecated, please use ARCH_OPT option.")
set(ARCH_OPT "") set(ARCH_OPT "")
if (C_MSVC) if (MSVC)
if (ARCHITECTURE_x86) if (ARCHITECTURE_x86)
set(ARCH_OPT "SSE2") set(ARCH_OPT "SSE2")
endif() endif()
@ -127,7 +127,7 @@ endif()
if (FORCE_SSE41) if (FORCE_SSE41)
message(WARNING "FORCE_SSE41 flag is deprecated, please use ARCH_OPT option.") message(WARNING "FORCE_SSE41 flag is deprecated, please use ARCH_OPT option.")
set(ARCH_OPT "") set(ARCH_OPT "")
if (C_MSVC) if (MSVC)
if (ARCHITECTURE_x86) if (ARCHITECTURE_x86)
set(ARCH_OPT "SSE2") set(ARCH_OPT "SSE2")
else() else()
@ -138,7 +138,7 @@ if (FORCE_SSE41)
endif() endif()
endif() endif()
if (C_MSVC) if (MSVC)
# Glue to make ARCH_OPT more flexible for MSVC # Glue to make ARCH_OPT more flexible for MSVC
if (ARCH_OPT STREQUAL "native") if (ARCH_OPT STREQUAL "native")
detect_msvc_native_opt() detect_msvc_native_opt()
@ -165,7 +165,7 @@ message(STATUS "Target architecture: ${ARCHITECTURE}-${ARCH_OPT}")
cmake_push_check_state(RESET) cmake_push_check_state(RESET)
if (ARCH_OPT) if (ARCH_OPT)
if(C_MSVC) if(MSVC)
set(CMAKE_REQUIRED_FLAGS "/arch:${ARCH_OPT}") set(CMAKE_REQUIRED_FLAGS "/arch:${ARCH_OPT}")
add_compile_options(${CMAKE_REQUIRED_FLAGS}) add_compile_options(${CMAKE_REQUIRED_FLAGS})
else() else()
@ -173,7 +173,7 @@ if (ARCH_OPT)
add_compile_options(-march=${ARCH_OPT}) add_compile_options(-march=${ARCH_OPT})
endif() endif()
elseif(FORCE_SSSE3 OR FORCE_SSE41) elseif(FORCE_SSSE3 OR FORCE_SSE41)
if (NOT C_MSVC) if (NOT MSVC)
set(CMAKE_REQUIRED_FLAGS ${FORCE_OPT}) set(CMAKE_REQUIRED_FLAGS ${FORCE_OPT})
add_compile_options(${FORCE_OPT}) add_compile_options(${FORCE_OPT})
endif() endif()
@ -185,7 +185,7 @@ if (NOT FLAG_SUPPORTED)
endif() endif()
if (ARCHITECTURE_ARM) if (ARCHITECTURE_ARM)
if (C_MSVC) if (MSVC)
force_ext_available(ARM_NEON) force_ext_available(ARM_NEON)
else() else()
list(APPEND CMAKE_REQUIRED_FLAGS -mfpu=neon) list(APPEND CMAKE_REQUIRED_FLAGS -mfpu=neon)

Wyświetl plik

@ -1,9 +0,0 @@
include_guard(GLOBAL)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(C_CLANG 1)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(C_GCC 1)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(C_MSVC 1)
endif()

Wyświetl plik

@ -17,7 +17,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
) )
if (C_GCC OR C_CLANG) if (NOT MSVC)
set_target_properties(swagger PROPERTIES COMPILE_FLAGS "-Wno-conversion-null -Wno-unused-variable -Wno-unused-parameter") set_target_properties(swagger PROPERTIES COMPILE_FLAGS "-Wno-conversion-null -Wno-unused-variable -Wno-unused-parameter")
endif() endif()