build: UNITS_DOWNCAST_MODE handling in CMake refactored

This commit is contained in:
Mateusz Pusz
2020-12-21 22:15:56 +01:00
parent 79a52ead1c
commit bacb92e5d3

View File

@@ -67,15 +67,15 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
)
endif()
if(UNITS_DOWNCAST_MODE STREQUAL "AUTO")
message(STATUS "Configuring UNITS_DOWNCAST_MODE=AUTOMATIC")
target_compile_definitions(mp-units INTERFACE UNITS_DOWNCAST_MODE=2)
elseif(UNITS_DOWNCAST_MODE)
message(STATUS "Configuring UNITS_DOWNCAST_MODE=ON")
target_compile_definitions(mp-units INTERFACE UNITS_DOWNCAST_MODE=1)
else()
message(STATUS "Configuring UNITS_DOWNCAST_MODE=OFF")
target_compile_definitions(mp-units INTERFACE UNITS_DOWNCAST_MODE=0)
if(DEFINED UNITS_DOWNCAST_MODE)
set(downcast_mode_options OFF ON AUTO)
list(FIND downcast_mode_options "${UNITS_DOWNCAST_MODE}" downcast_mode)
if(downcast_mode EQUAL -1)
message(FATAL_ERROR "'${UNITS_DOWNCAST_MODE}' is an invalid UNITS_DOWNCAST_MODE value")
else()
message(STATUS "Configuring UNITS_DOWNCAST_MODE=${UNITS_DOWNCAST_MODE}")
target_compile_definitions(mp-units INTERFACE UNITS_DOWNCAST_MODE=${downcast_mode})
endif()
endif()
add_library(mp::units ALIAS mp-units)