From a38e542650f7981a25ce1ac4b093b2025a19ea3c Mon Sep 17 00:00:00 2001 From: scott-eddy Date: Fri, 9 Mar 2018 12:17:51 -0500 Subject: [PATCH] Build etl based on different profiles. Works using GNU GCC --- CMakeLists.txt | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8af70d19..444f7e2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,15 @@ cmake_minimum_required(VERSION 3.5.0) project(etl) +####################################################################### +# Define an option to allow consumers of the library to +# specify the profile they would like to compile to. If +# not explicitly set CMake will attempt to choose an appropriate +# profile based on the compiler +####################################################################### +set(ETL_PROFILE "DEFAULT" CACHE STRING "Defines what profile header to include. See https://www.etlcpp.com/setup.html" +) + add_library(etl src/binary.cpp src/crc16_ccitt.cpp @@ -26,8 +35,31 @@ target_include_directories(etl src/private ) +if (${ETL_PROFILE} STREQUAL DEFAULT) + if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") + set(ETL_PROFILE "PROFILE_GCC_GENERIC") + + elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") + set(ETL_PROFILE "PROFILE_MSVC") + + elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "ARMCC") + if (${CXX_STANDARD} EQUAL 11) + set(ETL_PROFILE "PROFILE_ARMV6") + else () + set(ETL_PROFILE "PROFILE_ARMV5") + endif() + elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "TI") + set(ETL_PROFILE "PROFILE_TICC") + + else() + message(FATAL_ERROR "Can't generate default profile for compiler: ${CMAKE_CXX_COMPILER_ID}") + endif() +endif() + +message(STATUS "Compiling with ETL profile set to: ${ETL_PROFILE}") + target_compile_definitions(etl PUBLIC - PROFILE_GCC_GENERIC + ${ETL_PROFILE} )