build: projectPrefix usage added
This commit is contained in:
1 parent
bc7849beb1
commit
f9fb6cc8b3
13 files changed
+52
-47
No files matched your search
+5
-3
@@ -26,15 +26,17 @@ project(mp-units
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
option(UNITS_AS_SYSTEM_HEADERS "Exports library as system headers" OFF)
|
||||
message(STATUS "UNITS_AS_SYSTEM_HEADERS: ${UNITS_AS_SYSTEM_HEADERS}")
|
||||
set(projectPrefix UNITS_)
|
||||
|
||||
option(${projectPrefix}AS_SYSTEM_HEADERS "Exports library as system headers" OFF)
|
||||
message(STATUS "${projectPrefix}AS_SYSTEM_HEADERS: ${${projectPrefix}AS_SYSTEM_HEADERS}")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(AddUnitsModule)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
if(UNITS_AS_SYSTEM_HEADERS)
|
||||
if(${projectPrefix}AS_SYSTEM_HEADERS)
|
||||
set(units_as_system SYSTEM)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ function(check_libcxx_in_use variable)
|
||||
set(${variable} ${${variable}} PARENT_SCOPE)
|
||||
|
||||
list(POP_BACK CMAKE_MESSAGE_INDENT)
|
||||
if(UNITS_LIBCXX)
|
||||
if(${projectPrefix}LIBCXX)
|
||||
message(CHECK_PASS "found")
|
||||
else()
|
||||
message(CHECK_FAIL "not found")
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
option(UNITS_USE_LIBFMT "Enables usage of libfmt instead of the one from 'std'" ON)
|
||||
message(STATUS "UNITS_USE_LIBFMT: ${UNITS_USE_LIBFMT}")
|
||||
option(${projectPrefix}USE_LIBFMT "Enables usage of libfmt instead of the one from 'std'" ON)
|
||||
message(STATUS "${projectPrefix}USE_LIBFMT: ${${projectPrefix}USE_LIBFMT}")
|
||||
|
||||
add_units_module(core-fmt mp-units::core)
|
||||
target_compile_definitions(mp-units-core-fmt INTERFACE UNITS_USE_LIBFMT=$<BOOL:${UNITS_USE_LIBFMT}>)
|
||||
target_compile_definitions(mp-units-core-fmt INTERFACE ${projectPrefix}USE_LIBFMT=$<BOOL:${${projectPrefix}USE_LIBFMT}>)
|
||||
|
||||
if(UNITS_USE_LIBFMT)
|
||||
if(${projectPrefix}USE_LIBFMT)
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
target_link_libraries(mp-units-core-fmt INTERFACE fmt::fmt)
|
||||
endif()
|
||||
@@ -23,15 +23,15 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
# core library options
|
||||
set(UNITS_DOWNCAST_MODE ON CACHE STRING "Select downcasting mode")
|
||||
set_property(CACHE UNITS_DOWNCAST_MODE PROPERTY STRINGS AUTO ON OFF)
|
||||
set(${ProjectPrefix}DOWNCAST_MODE ON CACHE STRING "Select downcasting mode")
|
||||
set_property(CACHE ${ProjectPrefix}DOWNCAST_MODE PROPERTY STRINGS AUTO ON OFF)
|
||||
|
||||
# find dependencies
|
||||
find_package(gsl-lite CONFIG REQUIRED)
|
||||
|
||||
# check if libc++ is being used
|
||||
include(CheckLibcxxInUse)
|
||||
check_libcxx_in_use(UNITS_LIBCXX)
|
||||
check_libcxx_in_use(${ProjectPrefix}LIBCXX)
|
||||
|
||||
# core library definition
|
||||
add_library(mp-units-core INTERFACE)
|
||||
@@ -45,7 +45,7 @@ target_include_directories(mp-units-core ${units_as_system} INTERFACE
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
if(UNITS_LIBCXX)
|
||||
if(${ProjectPrefix}LIBCXX)
|
||||
find_package(range-v3 CONFIG REQUIRED)
|
||||
target_link_libraries(mp-units-core INTERFACE range-v3::range-v3)
|
||||
endif()
|
||||
@@ -55,14 +55,14 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
)
|
||||
endif()
|
||||
|
||||
if(DEFINED UNITS_DOWNCAST_MODE)
|
||||
if(DEFINED ${ProjectPrefix}DOWNCAST_MODE)
|
||||
set(downcast_mode_options OFF ON AUTO)
|
||||
list(FIND downcast_mode_options "${UNITS_DOWNCAST_MODE}" downcast_mode)
|
||||
list(FIND downcast_mode_options "${${ProjectPrefix}DOWNCAST_MODE}" downcast_mode)
|
||||
if(downcast_mode EQUAL -1)
|
||||
message(FATAL_ERROR "'UNITS_DOWNCAST_MODE' should be one of ${downcast_mode_options} ('${UNITS_DOWNCAST_MODE}' received)")
|
||||
message(FATAL_ERROR "'${ProjectPrefix}DOWNCAST_MODE' should be one of ${downcast_mode_options} ('${${ProjectPrefix}DOWNCAST_MODE}' received)")
|
||||
else()
|
||||
message(STATUS "UNITS_DOWNCAST_MODE: ${UNITS_DOWNCAST_MODE}")
|
||||
target_compile_definitions(mp-units-core INTERFACE UNITS_DOWNCAST_MODE=${downcast_mode})
|
||||
message(STATUS "${ProjectPrefix}DOWNCAST_MODE: ${${ProjectPrefix}DOWNCAST_MODE}")
|
||||
target_compile_definitions(mp-units-core INTERFACE ${ProjectPrefix}DOWNCAST_MODE=${downcast_mode})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in new issue
Block a user