From 407ea7099169bfa88e544b11e17a7a133c7a8691 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Mon, 8 Feb 2021 21:50:36 +0100 Subject: [PATCH] Build: Add support for compiler detection Using this system we can separate settings for different compilers nicely. --- cmake/Modules/CheckPlatform.cmake | 9 +++++++++ cmake/compiler/clang/settings.cmake | 0 cmake/compiler/gcc/settings.cmake | 0 3 files changed, 9 insertions(+) create mode 100644 cmake/compiler/clang/settings.cmake create mode 100644 cmake/compiler/gcc/settings.cmake diff --git a/cmake/Modules/CheckPlatform.cmake b/cmake/Modules/CheckPlatform.cmake index 5b7d83a38..6d88efe32 100644 --- a/cmake/Modules/CheckPlatform.cmake +++ b/cmake/Modules/CheckPlatform.cmake @@ -33,3 +33,12 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") endif() endif() endif() + +message(STATUS "Detected compiler: ${CMAKE_C_COMPILER}") +if(CMAKE_C_COMPILER MATCHES "gcc" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") + include(${CMAKE_SOURCE_DIR}/cmake/compiler/gcc/settings.cmake) +elseif(CMAKE_C_COMPILER MATCHES "clang" OR CMAKE_C_COMPILER_ID MATCHES "Clang") + include(${CMAKE_SOURCE_DIR}/cmake/compiler/clang/settings.cmake) +else() + message(FATAL_ERROR "No supported compiler found") +endif() diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake new file mode 100644 index 000000000..e69de29bb