build: got rid of global options for references and literals

This commit is contained in:
Mateusz Pusz
2021-04-06 16:30:26 +02:00
parent b3b52148c0
commit 512406e900
15 changed files with 10 additions and 76 deletions

View File

@ -41,14 +41,10 @@ class UnitsConan(ConanFile):
"gsl-lite/0.37.0"
)
options = {
"references": [True, False],
"literals": [True, False],
"downcast_mode": ["off", "on", "auto"],
"build_docs": [True, False]
}
default_options = {
"references": True,
"literals": False,
"downcast_mode": "on",
"build_docs": True
}
@ -120,8 +116,6 @@ class UnitsConan(ConanFile):
def generate(self):
tc = CMakeToolchain(self)
tc.variables["UNITS_REFERENCES"] = self.options.references
tc.variables["UNITS_LITERALS"] = self.options.literals
tc.variables["UNITS_DOWNCAST_MODE"] = str(self.options.downcast_mode).upper()
# if self._run_tests: # TODO Enable this when environment is supported in the Conan toolchain
tc.variables["UNITS_BUILD_DOCS"] = self.options.build_docs

View File

@ -123,24 +123,6 @@ It also runs unit tests during Conan build.
Conan Options
^^^^^^^^^^^^^
references
++++++++++
**Values**: ``True``/``False``
**Defaulted to**: ``True``
Determines if library should provide Quantity References for quantities of various units.
literals
++++++++
**Values**: ``True``/``False``
**Defaulted to**: ``False``
Determines if library should provide User Defined Literals (UDLs) for quantities of various units.
downcast_mode
+++++++++++++
@ -167,26 +149,6 @@ Additionally, enables project documentation generation when the project is being
CMake Options
^^^^^^^^^^^^^
UNITS_REFERENCES
++++++++++++++++
**Values**: ``ON``/``OFF``
**Defaulted to**: ``ON``
Equivalent to `references`_.
UNITS_LITERALS
++++++++++++++
**Values**: ``ON``/``OFF``
**Defaulted to**: ``OFF``
Equivalent to `literals`_.
UNITS_DOWNCAST_MODE
+++++++++++++++++++

View File

@ -27,12 +27,7 @@ project(mp-units
)
option(UNITS_AS_SYSTEM_HEADERS "Exports library as system headers" OFF)
option(UNITS_REFERENCES "Enables definitions of Quantity References provided for quantities of various units" ON)
option(UNITS_LITERALS "Enables definitions of User Defined Literals (UDLs) provided for quantities of various units" OFF)
message(STATUS "UNITS_AS_SYSTEM_HEADERS: ${UNITS_AS_SYSTEM_HEADERS}")
message(STATUS "UNITS_REFERENCES: ${UNITS_REFERENCES}")
message(STATUS "UNITS_LITERALS: ${UNITS_LITERALS}")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

View File

@ -38,15 +38,3 @@ function(add_units_module name)
install(TARGETS mp-units-${name} EXPORT mp-unitsTargets)
install(DIRECTORY include/units TYPE INCLUDE)
endfunction()
#
# add_units_systems(ModuleName <depependencies>...)
#
function(add_units_system name)
add_units_module(${name} ${ARGN})
target_compile_definitions(mp-units-${name} INTERFACE
$<$<BOOL:${UNITS_REFERENCES}>:UNITS_REFERENCES>
$<$<BOOL:${UNITS_LITERALS}>:UNITS_LITERALS>
)
endfunction()

View File

@ -55,11 +55,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
)
endif()
target_compile_definitions(mp-units-core INTERFACE
$<$<BOOL:${UNITS_REFERENCES}>:UNITS_REFERENCES>
$<$<BOOL:${UNITS_LITERALS}>:UNITS_LITERALS>
)
if(DEFINED UNITS_DOWNCAST_MODE)
set(downcast_mode_options OFF ON AUTO)
list(FIND downcast_mode_options "${UNITS_DOWNCAST_MODE}" downcast_mode)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(isq-iec80000 mp-units::si)
add_units_module(isq-iec80000 mp-units::si)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(isq-natural mp-units::isq)
add_units_module(isq-natural mp-units::isq)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(si-cgs mp-units::si)
add_units_module(si-cgs mp-units::si)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(si-fps mp-units::si)
add_units_module(si-fps mp-units::si)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(si-iau mp-units::si)
add_units_module(si-iau mp-units::si)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(si-imperial mp-units::si)
add_units_module(si-imperial mp-units::si)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(si-international mp-units::si)
add_units_module(si-international mp-units::si)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(si-typographic mp-units::si)
add_units_module(si-typographic mp-units::si)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(si-us mp-units::si)
add_units_module(si-us mp-units::si)

View File

@ -22,4 +22,4 @@
cmake_minimum_required(VERSION 3.15)
add_units_system(si mp-units::isq)
add_units_module(si mp-units::isq)