From c57b11cdab10b697137ead42b1eda35012643e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 20 Nov 2020 16:29:11 +0100 Subject: [PATCH] CMake: Remove limited compiler detection and properly support compilers simulating MSVC --- cmake/Modules/CompilerOptions.cmake | 7 +++---- cmake/Modules/DetectArchitecture.cmake | 14 +++++++------- cmake/Modules/DetectCompiler.cmake | 9 --------- swagger/CMakeLists.txt | 2 +- 4 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 cmake/Modules/DetectCompiler.cmake diff --git a/cmake/Modules/CompilerOptions.cmake b/cmake/Modules/CompilerOptions.cmake index 97006f6bf..9dadf3ae7 100644 --- a/cmake/Modules/CompilerOptions.cmake +++ b/cmake/Modules/CompilerOptions.cmake @@ -1,13 +1,12 @@ include_guard(GLOBAL) -include(DetectCompiler) include(DetectArchitecture) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) -if (C_CLANG OR C_GCC) - add_compile_options(-Wall -Wextra -Wvla -Woverloaded-virtual -ffast-math -ftree-vectorize) -elseif (C_MSVC) +if(MSVC) add_compile_options(/MP) +else() + add_compile_options(-Wall -Wextra -Wvla -Woverloaded-virtual -ffast-math -ftree-vectorize) endif() if (SANITIZE_ADDRESS) diff --git a/cmake/Modules/DetectArchitecture.cmake b/cmake/Modules/DetectArchitecture.cmake index fb4ea7cfe..29daa06e4 100644 --- a/cmake/Modules/DetectArchitecture.cmake +++ b/cmake/Modules/DetectArchitecture.cmake @@ -93,7 +93,7 @@ function(detect_msvc_native_opt) endif() endfunction() -if (C_MSVC) +if (MSVC) detect_architecture("_M_AMD64" x86_64) detect_architecture("_M_IX86" x86) detect_architecture("_M_ARM" ARM) @@ -114,7 +114,7 @@ endif() if (FORCE_SSSE3) message(WARNING "FORCE_SSSE3 flag is deprecated, please use ARCH_OPT option.") set(ARCH_OPT "") - if (C_MSVC) + if (MSVC) if (ARCHITECTURE_x86) set(ARCH_OPT "SSE2") endif() @@ -127,7 +127,7 @@ endif() if (FORCE_SSE41) message(WARNING "FORCE_SSE41 flag is deprecated, please use ARCH_OPT option.") set(ARCH_OPT "") - if (C_MSVC) + if (MSVC) if (ARCHITECTURE_x86) set(ARCH_OPT "SSE2") else() @@ -138,7 +138,7 @@ if (FORCE_SSE41) endif() endif() -if (C_MSVC) +if (MSVC) # Glue to make ARCH_OPT more flexible for MSVC if (ARCH_OPT STREQUAL "native") detect_msvc_native_opt() @@ -165,7 +165,7 @@ message(STATUS "Target architecture: ${ARCHITECTURE}-${ARCH_OPT}") cmake_push_check_state(RESET) if (ARCH_OPT) - if(C_MSVC) + if(MSVC) set(CMAKE_REQUIRED_FLAGS "/arch:${ARCH_OPT}") add_compile_options(${CMAKE_REQUIRED_FLAGS}) else() @@ -173,7 +173,7 @@ if (ARCH_OPT) add_compile_options(-march=${ARCH_OPT}) endif() elseif(FORCE_SSSE3 OR FORCE_SSE41) - if (NOT C_MSVC) + if (NOT MSVC) set(CMAKE_REQUIRED_FLAGS ${FORCE_OPT}) add_compile_options(${FORCE_OPT}) endif() @@ -185,7 +185,7 @@ if (NOT FLAG_SUPPORTED) endif() if (ARCHITECTURE_ARM) - if (C_MSVC) + if (MSVC) force_ext_available(ARM_NEON) else() list(APPEND CMAKE_REQUIRED_FLAGS -mfpu=neon) diff --git a/cmake/Modules/DetectCompiler.cmake b/cmake/Modules/DetectCompiler.cmake deleted file mode 100644 index fcec005ce..000000000 --- a/cmake/Modules/DetectCompiler.cmake +++ /dev/null @@ -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() diff --git a/swagger/CMakeLists.txt b/swagger/CMakeLists.txt index c44a42a30..c40c0993a 100644 --- a/swagger/CMakeLists.txt +++ b/swagger/CMakeLists.txt @@ -17,7 +17,7 @@ include_directories( ${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") endif()