summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-03-14 15:18:10 +0100
committerUwe Klotz <uklotz@mixxx.org>2020-03-14 15:32:27 +0100
commitc57b9a00f22ee6a0878fe05636cd580a2f93affb (patch)
treef7a47c24b709cc1364babcd4e9527531c9549d83 /CMakeLists.txt
parent6459c392390cd4e21c4b1c8fe94fd997164e0fa4 (diff)
Define and use variables for all supported compilers
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt40
1 files changed, 27 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd0455223e..6df3f12649 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,10 +19,33 @@ if(POLICY CMP0025)
endif()
set(CMAKE_POLICY_WARNING_CMP0025 ON)
+#######################################################################
+# Compilers and toolchains
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ # GNU is GNU GCC
+ set(GNU_GCC true)
+else()
+ set(GNU_GCC false)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ # using regular Clang or AppleClang
+ set(CLANG true)
+else()
+ set(CLANG false)
+endif()
+
+# CMake implicitly sets the variable MSVC to true for Microsoft
+# Visual C++ or another compiler simulating Visual C++.
+# https://cmake.org/cmake/help/latest/variable/MSVC.html
+
+#######################################################################
+
set(CMAKE_CXX_STANDARD 17)
# Speed up builds on HDDs
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # GNU is GNU GCC
+if(GNU_GCC)
add_compile_options(-pipe)
endif()
@@ -112,8 +135,7 @@ else()
endif()
cmake_dependent_option(CCACHE_SUPPORT "Enable ccache support" ON "CCACHE_EXECUTABLE" OFF)
if(CCACHE_SUPPORT)
- if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" # GNU is GNU GCC
- OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # either "AppleClang" or "Clang"
+ if(GNU_GCC OR CLANG)
# without this compiler messages in `make` backend would be uncolored
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto")
endif()
@@ -137,13 +159,6 @@ if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
-if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- # using regular Clang or AppleClang
- set(CLANG ON)
-else()
- set(CLANG OFF)
-endif()
-
# Mixxx itself
add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/analyzer/analyzerbeats.cpp
@@ -712,8 +727,7 @@ if(UNIX AND NOT APPLE)
endif()
# Disable warnings in generated source files
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" # GNU is GNU GCC
- OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # either "AppleClang" or "Clang"
+if(GNU_GCC OR CLANG)
set_property(
SOURCE src/library/rekordbox/rekordbox_anlz.cpp
APPEND_STRING
@@ -2049,7 +2063,7 @@ if(NOT OPTIMIZE STREQUAL "off")
else()
message(FATAL_ERROR "Invalid value passed to OPTIMIZE option: ${OPTIMIZE}")
endif()
- elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ elseif(GNU_GCC)
# Common flags to all optimizations.
# -ffast-math will prevent a performance penalty by denormals
# (floating point values almost Zero are treated as Zero)