From e762a5c51c3b9f7cb9169242e5b7b57453845176 Mon Sep 17 00:00:00 2001 From: David Brooks Date: Fri, 22 Nov 2019 12:34:29 +1300 Subject: [PATCH 1/2] CMake: specify the compiler we want to use. --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45c2b4beb2..4a49ca184c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,19 @@ cmake_minimum_required(VERSION 3.14) +# Specify the compiler we will use. +# Note: this to be set **before** the project declaration + +if(WIN32) + set(CMAKE_C_COMPILER cl) + set(CMAKE_CXX_COMPILER cl) +elseif(APPLE) + set(CMAKE_C_COMPILER clang) + set(CMAKE_CXX_COMPILER clang++) +else() + set(CMAKE_C_COMPILER cc) + set(CMAKE_CXX_COMPILER c++) +endif() + # Project definition project(OpenCOR) From 8654f205f7190d65c8846e0bb8687bd29a9c4285 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Fri, 22 Nov 2019 14:22:04 +1300 Subject: [PATCH 2/2] CMake: specify the compiler we want to use. --- CMakeLists.txt | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a49ca184c..0281027373 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,5 @@ cmake_minimum_required(VERSION 3.14) -# Specify the compiler we will use. -# Note: this to be set **before** the project declaration - -if(WIN32) - set(CMAKE_C_COMPILER cl) - set(CMAKE_CXX_COMPILER cl) -elseif(APPLE) - set(CMAKE_C_COMPILER clang) - set(CMAKE_CXX_COMPILER clang++) -else() - set(CMAKE_C_COMPILER cc) - set(CMAKE_CXX_COMPILER c++) -endif() - # Project definition project(OpenCOR) @@ -65,6 +51,9 @@ endif() # Make sure that we are using the compiler we support if(WIN32) + set(CMAKE_C_COMPILER cl) + set(CMAKE_CXX_COMPILER cl) + string(REPLACE "." ";" CMAKE_CXX_COMPILER_VERSION_LIST "${CMAKE_CXX_COMPILER_VERSION}") @@ -77,11 +66,17 @@ if(WIN32) message(FATAL_ERROR "${CMAKE_PROJECT_NAME} can only be built using MSVC 2017 on Windows...") endif() elseif(APPLE) + set(CMAKE_C_COMPILER clang) + set(CMAKE_CXX_COMPILER clang++) + if( NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") message(FATAL_ERROR "${CMAKE_PROJECT_NAME} can only be built using (Apple) Clang on macOS...") endif() else() + set(CMAKE_C_COMPILER cc) + set(CMAKE_CXX_COMPILER c++) + if( NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") message(FATAL_ERROR "${CMAKE_PROJECT_NAME} can only be built using GCC/G++ on Linux...")