diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ccd73e0..1e3ac12c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ project(mp-units-dev list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") +set(projectPrefix UNITS_) + # make sure that the file is being used as an entry point include(modern_project_structure) ensure_entry_point() @@ -43,8 +45,8 @@ set_warnings() add_compile_definitions($<$:gsl_CONFIG_CONTRACT_CHECKING_AUDIT>) # enable include-what-you-use -option(UNITS_IWYU "Enables include-what-you-use" OFF) -if(UNITS_IWYU) +option(${projectPrefix}IWYU "Enables include-what-you-use" OFF) +if(${projectPrefix}IWYU) include(include-what-you-use) enable_iwyu( MAPPING_FILE "${PROJECT_SOURCE_DIR}/.mp-units.imp" @@ -54,7 +56,7 @@ if(UNITS_IWYU) NO_COMMENTS ) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(UNITS_AS_SYSTEM_HEADERS ON) + set(${projectPrefix}AS_SYSTEM_HEADERS ON) endif() endif() diff --git a/cmake/warnings.cmake b/cmake/warnings.cmake index ce46d8bb..25ad0d1e 100644 --- a/cmake/warnings.cmake +++ b/cmake/warnings.cmake @@ -24,7 +24,7 @@ cmake_minimum_required(VERSION 3.15) -option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON) +option(${projectPrefix}WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON) macro(_set_flags) set(MSVC_WARNINGS @@ -83,7 +83,7 @@ macro(_set_flags) -Wlogical-op # warn about logical operations being used where bitwise were probably wanted ) - if(WARNINGS_AS_ERRORS) + if(${projectPrefix}WARNINGS_AS_ERRORS) set(GCC_WARNINGS ${GCC_WARNINGS} -Werror) set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) @@ -106,7 +106,7 @@ function(set_warnings) _set_flags() message(STATUS "Setting restrictive compilation warnings") - message(STATUS " Treat warnings as errors: ${WARNINGS_AS_ERRORS}") + message(STATUS " Treat warnings as errors: ${${projectPrefix}WARNINGS_AS_ERRORS}") message(STATUS " Flags: ${flags}") message(STATUS "Setting restrictive compilation warnings - done") @@ -123,7 +123,7 @@ function(set_target_warnings target scope) _set_flags() message(STATUS "Setting ${scope} restrictive compilation warnings for '${target}'") - message(STATUS " Treat warnings as errors: ${WARNINGS_AS_ERRORS}") + message(STATUS " Treat warnings as errors: ${${projectPrefix}WARNINGS_AS_ERRORS}") message(STATUS " Flags: ${flags}") message(STATUS "Setting ${scope} restrictive compilation warnings for '${target}' - done") diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index f939d1a6..78d964bf 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -22,14 +22,15 @@ cmake_minimum_required(VERSION 3.2) -option(UNITS_BUILD_DOCS "Generate project documentation" ON) -message(STATUS "UNITS_BUILD_DOCS: ${UNITS_BUILD_DOCS}") +option(${projectPrefix}BUILD_DOCS "Generate project documentation" ON) +message(STATUS "${projectPrefix}BUILD_DOCS: ${${projectPrefix}BUILD_DOCS}") -if(NOT UNITS_BUILD_DOCS) +if(NOT ${projectPrefix}BUILD_DOCS) return() endif() # set paths to Conan packages (needed for doxygen) +# TODO: remove when Conan will learn how to properly create imported build tools targets include(${CMAKE_BINARY_DIR}/conan_paths.cmake OPTIONAL) # Find all the public headers diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index d5571087..0e7a71b0 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -35,7 +35,7 @@ add_example(custom_systems mp-units::core-io mp-units::si) add_example(hello_units mp-units::core-fmt mp-units::core-io mp-units::si mp-units::si-international) add_example(measurement mp-units::core-io mp-units::si) -if(NOT UNITS_LIBCXX) +if(NOT ${projectPrefix}LIBCXX) add_subdirectory(glide_computer) endif() diff --git a/example/aliases/CMakeLists.txt b/example/aliases/CMakeLists.txt index 286085ab..e61b38a4 100644 --- a/example/aliases/CMakeLists.txt +++ b/example/aliases/CMakeLists.txt @@ -29,8 +29,8 @@ function(add_example target) add_executable(${target}-aliases ${target}.cpp) target_link_libraries(${target}-aliases PRIVATE ${ARGN}) target_compile_definitions(${target}-aliases PRIVATE - UNITS_NO_LITERALS - UNITS_NO_REFERENCES + ${projectPrefix}NO_LITERALS + ${projectPrefix}NO_REFERENCES ) endfunction() @@ -44,11 +44,11 @@ add_example(measurement mp-units::core-io mp-units::si) add_example(total_energy mp-units::core-io mp-units::si mp-units::isq-natural) add_example(unknown_dimension mp-units::core-io mp-units::si) -if(NOT UNITS_LIBCXX) +if(NOT ${projectPrefix}LIBCXX) add_example(glide_computer_example mp-units::core-fmt mp-units::si-international glide_computer) target_compile_definitions(glide_computer_example-aliases PRIVATE - UNITS_NO_LITERALS - UNITS_NO_REFERENCES + ${projectPrefix}NO_LITERALS + ${projectPrefix}NO_REFERENCES ) find_package(wg21-linear_algebra CONFIG REQUIRED) diff --git a/example/kalman_filter/CMakeLists.txt b/example/kalman_filter/CMakeLists.txt index d170256a..25691790 100644 --- a/example/kalman_filter/CMakeLists.txt +++ b/example/kalman_filter/CMakeLists.txt @@ -29,8 +29,8 @@ function(add_example target) add_executable(${target} ${target}.cpp) target_link_libraries(${target} PRIVATE ${ARGN}) target_compile_definitions(${target} PRIVATE - UNITS_NO_LITERALS - UNITS_NO_ALIASES + ${projectPrefix}NO_LITERALS + ${projectPrefix}NO_ALIASES ) endfunction() diff --git a/example/literals/CMakeLists.txt b/example/literals/CMakeLists.txt index b977e711..a968b3fd 100644 --- a/example/literals/CMakeLists.txt +++ b/example/literals/CMakeLists.txt @@ -29,8 +29,8 @@ function(add_example target) add_executable(${target}-literals ${target}.cpp) target_link_libraries(${target}-literals PRIVATE ${ARGN}) target_compile_definitions(${target}-literals PRIVATE - UNITS_NO_REFERENCES - UNITS_NO_ALIASES + ${projectPrefix}NO_REFERENCES + ${projectPrefix}NO_ALIASES ) endfunction() @@ -43,11 +43,11 @@ add_example(foot_pound_second mp-units::core-fmt mp-units::si-fps) add_example(total_energy mp-units::core-io mp-units::si mp-units::isq-natural) add_example(unknown_dimension mp-units::core-io mp-units::si) -if(NOT UNITS_LIBCXX) +if(NOT ${projectPrefix}LIBCXX) add_example(glide_computer_example mp-units::core-fmt mp-units::si-international glide_computer) target_compile_definitions(glide_computer_example-literals PRIVATE - UNITS_NO_REFERENCES - UNITS_NO_ALIASES + ${projectPrefix}NO_REFERENCES + ${projectPrefix}NO_ALIASES ) find_package(wg21-linear_algebra CONFIG REQUIRED) diff --git a/example/references/CMakeLists.txt b/example/references/CMakeLists.txt index 0d8e6e85..3f6a7e0e 100644 --- a/example/references/CMakeLists.txt +++ b/example/references/CMakeLists.txt @@ -29,8 +29,8 @@ function(add_example target) add_executable(${target}-references ${target}.cpp) target_link_libraries(${target}-references PRIVATE ${ARGN}) target_compile_definitions(${target}-references PRIVATE - UNITS_NO_LITERALS - UNITS_NO_ALIASES + ${projectPrefix}NO_LITERALS + ${projectPrefix}NO_ALIASES ) endfunction() @@ -43,11 +43,11 @@ add_example(foot_pound_second mp-units::core-fmt mp-units::si-fps) add_example(total_energy mp-units::core-io mp-units::si mp-units::isq-natural) add_example(unknown_dimension mp-units::core-io mp-units::si) -if(NOT UNITS_LIBCXX) +if(NOT ${projectPrefix}LIBCXX) add_example(glide_computer_example mp-units::core-fmt mp-units::si-international glide_computer) target_compile_definitions(glide_computer_example-references PRIVATE - UNITS_NO_LITERALS - UNITS_NO_ALIASES + ${projectPrefix}NO_LITERALS + ${projectPrefix}NO_ALIASES ) find_package(wg21-linear_algebra CONFIG REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdc84cb4..eacb8a55 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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() diff --git a/src/cmake/CheckLibcxxInUse.cmake b/src/cmake/CheckLibcxxInUse.cmake index a8fe9388..d03c6855 100644 --- a/src/cmake/CheckLibcxxInUse.cmake +++ b/src/cmake/CheckLibcxxInUse.cmake @@ -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") diff --git a/src/core-fmt/CMakeLists.txt b/src/core-fmt/CMakeLists.txt index 157495d1..8ecbae40 100644 --- a/src/core-fmt/CMakeLists.txt +++ b/src/core-fmt/CMakeLists.txt @@ -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=$) +target_compile_definitions(mp-units-core-fmt INTERFACE ${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() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0368ec0e..1858b4eb 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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() diff --git a/test/unit_test/static/CMakeLists.txt b/test/unit_test/static/CMakeLists.txt index 2e8d40fe..14c9604b 100644 --- a/test/unit_test/static/CMakeLists.txt +++ b/test/unit_test/static/CMakeLists.txt @@ -25,7 +25,7 @@ cmake_minimum_required(VERSION 3.2) add_library(unit_tests_static_truncating quantity_test.cpp ) -if(NOT UNITS_LIBCXX) +if(NOT ${projectPrefix}LIBCXX) target_sources(unit_tests_static_truncating PRIVATE quantity_kind_test.cpp quantity_point_kind_test.cpp @@ -64,7 +64,7 @@ add_library(unit_tests_static us_test.cpp ) -if(NOT UNITS_LIBCXX) +if(NOT ${projectPrefix}LIBCXX) target_sources(unit_tests_static PRIVATE custom_rep_test_min_impl.cpp quantity_point_test.cpp