refactor: modules support redesigned

This commit is contained in:
Mateusz Pusz
2024-01-06 08:51:01 +01:00
parent b582e200a0
commit 0eaf6e2e56
129 changed files with 271 additions and 838 deletions
+31 -37
View File
@@ -27,53 +27,47 @@ if(NOT TARGET gsl::gsl-lite)
find_package(gsl-lite CONFIG REQUIRED)
endif()
if(${projectPrefix}BUILD_CXX_MODULES)
add_library(example_utils INTERFACE)
target_compile_definitions(example_utils INTERFACE ${projectPrefix}MODULES)
target_include_directories(example_utils INTERFACE include)
target_link_libraries(example_utils INTERFACE gsl::gsl-lite)
endif()
add_library(example_utils-headers INTERFACE)
target_include_directories(example_utils-headers INTERFACE include)
target_link_libraries(example_utils-headers INTERFACE gsl::gsl-lite)
#
# add_example(target <mp-units-depependencies>...)
# add_example(target <depependencies>...)
#
function(add_example target)
add_executable(${target} ${target}.cpp)
if(TARGET mp-units::modules)
target_link_libraries(${target} PRIVATE mp-units::modules)
else()
target_link_libraries(${target} PRIVATE ${ARGN})
if(${projectPrefix}BUILD_CXX_MODULES)
add_executable(${target} ${target}.cpp)
target_compile_definitions(${target} PUBLIC ${projectPrefix}MODULES)
target_link_libraries(${target} PRIVATE mp-units::mp-units ${ARGN})
endif()
add_executable(${target}-headers ${target}.cpp)
list(TRANSFORM ARGN APPEND "-headers")
target_link_libraries(${target}-headers PRIVATE mp-units::mp-units ${ARGN})
endfunction()
add_example(avg_speed mp-units::core-io mp-units::si mp-units::cgs mp-units::usc)
add_example(capacitor_time_curve mp-units::core-io mp-units::si mp-units::utility)
add_example(
clcpp_response
mp-units::core-fmt
mp-units::core-io
mp-units::si
mp-units::iau
mp-units::imperial
mp-units::international
mp-units::typographic
mp-units::usc
)
add_example(conversion_factor mp-units::core-fmt mp-units::core-io mp-units::si)
add_example(currency mp-units::core-io)
add_example(foot_pound_second mp-units::core-fmt mp-units::international mp-units::imperial)
add_example(glide_computer mp-units::core-fmt mp-units::international mp-units::utility)
target_link_libraries(glide_computer PRIVATE glide_computer_lib)
add_example(hello_units mp-units::core-fmt mp-units::core-io mp-units::si mp-units::usc)
add_example(measurement mp-units::core-io mp-units::si)
add_example(si_constants mp-units::core-fmt mp-units::si)
add_example(spectroscopy_units mp-units::core-fmt mp-units::si)
add_example(storage_tank mp-units::core-fmt mp-units::si mp-units::utility)
add_example(
strong_angular_quantities mp-units::core-fmt mp-units::core-io mp-units::si mp-units::isq_angle mp-units::utility
)
add_example(total_energy mp-units::core-io mp-units::si mp-units::natural mp-units::utility)
add_example(
unmanned_aerial_vehicle mp-units::core-fmt mp-units::core-io mp-units::si mp-units::international mp-units::utility
)
target_link_libraries(unmanned_aerial_vehicle PRIVATE example_utils)
add_example(avg_speed)
add_example(capacitor_time_curve)
add_example(clcpp_response)
add_example(conversion_factor)
add_example(currency)
add_example(foot_pound_second)
add_example(glide_computer glide_computer_lib)
add_example(hello_units)
add_example(measurement)
add_example(si_constants)
add_example(spectroscopy_units)
add_example(storage_tank)
add_example(strong_angular_quantities)
add_example(total_energy)
add_example(unmanned_aerial_vehicle example_utils)
add_subdirectory(glide_computer_lib)
add_subdirectory(kalman_filter)
+1 -1
View File
@@ -15,7 +15,7 @@
along with this program. If not, see http://www.gnu.org/licenses./
*/
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
+1 -1
View File
@@ -15,7 +15,7 @@
along with this program. If not, see http://www.gnu.org/licenses./
*/
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <iostream>
#include <type_traits>
#ifdef MP_UNITS_MODULES
+1 -1
View File
@@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/quantity_spec_macro.h>
#include <mp-units/compat_macros.h>
#include <iostream>
#include <map>
#ifdef MP_UNITS_MODULES
+1 -1
View File
@@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <iostream>
#include <string_view>
#ifdef MP_UNITS_MODULES
+2 -3
View File
@@ -21,7 +21,7 @@
// SOFTWARE.
#include "glide_computer_lib.h"
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <array>
#include <exception>
#include <iostream>
@@ -32,10 +32,9 @@
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/chrono.h>
#include <mp-units/math.h>
#include <mp-units/systems/international/international.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/si/si.h>
#endif
namespace {
+9 -7
View File
@@ -22,11 +22,13 @@
cmake_minimum_required(VERSION 3.5)
add_library(glide_computer_lib STATIC glide_computer_lib.cpp include/glide_computer_lib.h)
if(TARGET mp-units::modules)
target_link_libraries(glide_computer_lib PUBLIC gsl::gsl-lite mp-units::modules)
else()
target_link_libraries(glide_computer_lib PRIVATE mp-units::core-fmt PUBLIC mp-units::si mp-units::utility)
add_library(glide_computer_lib-headers STATIC glide_computer_lib.cpp include/glide_computer_lib.h)
target_link_libraries(glide_computer_lib-headers PUBLIC mp-units::mp-units example_utils)
target_include_directories(glide_computer_lib-headers PUBLIC include)
if(${projectPrefix}BUILD_CXX_MODULES)
add_library(glide_computer_lib STATIC glide_computer_lib.cpp include/glide_computer_lib.h)
target_compile_definitions(glide_computer_lib PUBLIC ${projectPrefix}MODULES)
target_link_libraries(glide_computer_lib PUBLIC mp-units::mp-units example_utils)
target_include_directories(glide_computer_lib PUBLIC include)
endif()
target_link_libraries(glide_computer_lib PUBLIC example_utils)
target_include_directories(glide_computer_lib PUBLIC include)
@@ -22,7 +22,7 @@
#pragma once
#include <mp-units/quantity_spec_macro.h>
#include <mp-units/compat_macros.h>
//
#include "geographic.h"
#include <algorithm>
@@ -36,10 +36,10 @@
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/chrono.h>
#include <mp-units/math.h> // IWYU pragma: keep
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/chrono.h>
#endif
// An example of a really simplified tactical glide computer
+1 -1
View File
@@ -25,7 +25,7 @@
// !!! renders correctly in the documentation "Examples" section. !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
+2 -3
View File
@@ -23,7 +23,7 @@
#pragma once
#include "ranged_representation.h"
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <compare>
#include <limits>
#include <numbers>
@@ -33,11 +33,10 @@ import mp_units;
#else
#include <mp-units/compare.h>
#include <mp-units/format.h>
#include <mp-units/math.h>
#include <mp-units/quantity.h>
#include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/units.h>
#include <mp-units/systems/si/si.h>
#endif
namespace geographic {
+1 -1
View File
@@ -23,7 +23,7 @@
#pragma once
#include <gsl/gsl-lite.hpp>
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <ostream>
#include <utility>
#ifdef MP_UNITS_MODULES
+8 -20
View File
@@ -22,23 +22,11 @@
cmake_minimum_required(VERSION 3.5)
#
# add_example(target <depependencies>...)
#
function(add_example target)
add_executable(${target} ${target}.cpp)
if(TARGET mp-units::modules)
target_link_libraries(${target} PRIVATE mp-units::modules)
else()
target_link_libraries(${target} PRIVATE ${ARGN})
endif()
endfunction()
add_example(kalman_filter-example_1 mp-units::core-fmt mp-units::si mp-units::utility)
add_example(kalman_filter-example_2 mp-units::core-fmt mp-units::si mp-units::utility)
add_example(kalman_filter-example_3 mp-units::core-fmt mp-units::si mp-units::utility)
add_example(kalman_filter-example_4 mp-units::core-fmt mp-units::si mp-units::utility)
add_example(kalman_filter-example_5 mp-units::core-fmt mp-units::si mp-units::utility)
add_example(kalman_filter-example_6 mp-units::core-fmt mp-units::si mp-units::utility)
add_example(kalman_filter-example_7 mp-units::core-fmt mp-units::si mp-units::utility)
add_example(kalman_filter-example_8 mp-units::core-fmt mp-units::si mp-units::utility)
add_example(kalman_filter-example_1)
add_example(kalman_filter-example_2)
add_example(kalman_filter-example_3)
add_example(kalman_filter-example_4)
add_example(kalman_filter-example_5)
add_example(kalman_filter-example_6)
add_example(kalman_filter-example_7)
add_example(kalman_filter-example_8)
+1 -1
View File
@@ -22,7 +22,7 @@
#pragma once
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <tuple>
#ifdef MP_UNITS_MODULES
import mp_units;
+1 -1
View File
@@ -25,7 +25,7 @@
// !!! renders correctly in the documentation "Examples" section. !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <iostream>
#ifdef MP_UNITS_MODULES
import mp_units;
+1 -1
View File
@@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <iostream>
#include <tuple>
#ifdef MP_UNITS_MODULES
+3 -6
View File
@@ -20,8 +20,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/quantity_spec_macro.h>
#include <mp-units/compat_fmt_macros.h>
#include <mp-units/compat_macros.h>
#include <cassert>
#include <chrono>
#include <iostream>
@@ -30,14 +30,11 @@
#ifdef MP_UNITS_MODULES
import mp_units;
#else
#include <mp-units/chrono.h>
#include <mp-units/format.h>
#include <mp-units/math.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/constants.h>
#include <mp-units/systems/si/unit_symbols.h>
#include <mp-units/systems/si/units.h>
#include <mp-units/systems/si/si.h>
#endif
// allows standard gravity (acceleration) and weight (force) to be expressed with scalar representation
+1 -1
View File
@@ -21,7 +21,7 @@
// SOFTWARE.
#include "geographic.h"
#include <mp-units/bits/fmt_hacks.h>
#include <mp-units/compat_fmt_macros.h>
#include <cassert>
#include <iostream>
#ifdef MP_UNITS_MODULES