refactor: add_units_module renamed to add_mp_units_module and target_name parameter added

This commit is contained in:
Mateusz Pusz
2024-01-06 08:51:01 +01:00
parent a7cb512f87
commit 44c557ff4b
4 changed files with 20 additions and 23 deletions

View File

@@ -33,7 +33,7 @@ message(STATUS "${projectPrefix}BUILD_CXX_MODULES: ${${projectPrefix}BUILD_CXX_M
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(AddUnitsModule) include(AddMPUnitsModule)
include(GNUInstallDirs) include(GNUInstallDirs)
if(${projectPrefix}BUILD_CXX_MODULES) if(${projectPrefix}BUILD_CXX_MODULES)
@@ -50,10 +50,7 @@ add_subdirectory(core)
add_subdirectory(systems) add_subdirectory(systems)
# project-wide wrapper # project-wide wrapper
add_units_module( add_mp_units_module(mp-units mp-units DEPENDENCIES mp-units::core mp-units::systems MODULE_INTERFACE_UNIT mp-units.cpp)
mp-units DEPENDENCIES mp-units::core mp-units::systems
MODULE_INTERFACE_UNIT mp-units.cpp
)
# local build # local build
export(EXPORT mp-unitsTargets NAMESPACE mp-units::) export(EXPORT mp-unitsTargets NAMESPACE mp-units::)

View File

@@ -41,16 +41,16 @@ function(validate_arguments_exists module prefix)
endfunction() endfunction()
# #
# add_units_module(ModuleName # add_mp_units_module(Name TargetName
# DEPENDENCIES <depependency>... # DEPENDENCIES <depependency>...
# [HEADERS <header_file>...] # [HEADERS <header_file>...]
# MODULE_INTERFACE_UNIT <miu_file>) # MODULE_INTERFACE_UNIT <miu_file>)
# #
function(add_units_module name) function(add_mp_units_module name target_name)
# parse arguments # parse arguments
set(oneValue MODULE_INTERFACE_UNIT) set(oneValue MODULE_INTERFACE_UNIT)
set(multiValues DEPENDENCIES HEADERS) set(multiValues DEPENDENCIES HEADERS)
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "${oneValue}" "${multiValues}") cmake_parse_arguments(PARSE_ARGV 2 ARG "" "${oneValue}" "${multiValues}")
# validate and process arguments # validate and process arguments
validate_unparsed(${name} ARG) validate_unparsed(${name} ARG)
@@ -61,26 +61,26 @@ function(add_units_module name)
endif() endif()
# define the target for a module # define the target for a module
add_library(mp-units-${name} ${SCOPE} ${ARG_HEADERS}) add_library(${target_name} ${SCOPE} ${ARG_HEADERS})
target_link_libraries(mp-units-${name} ${${projectPrefix}TARGET_SCOPE} ${ARG_DEPENDENCIES}) target_link_libraries(${target_name} ${${projectPrefix}TARGET_SCOPE} ${ARG_DEPENDENCIES})
if(ARG_HEADERS) if(ARG_HEADERS)
target_include_directories( target_include_directories(
mp-units-${name} ${unitsAsSystem} ${${projectPrefix}TARGET_SCOPE} ${target_name} ${unitsAsSystem} ${${projectPrefix}TARGET_SCOPE}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
) )
endif() endif()
set_target_properties(mp-units-${name} PROPERTIES EXPORT_NAME ${name}) set_target_properties(${target_name} PROPERTIES EXPORT_NAME ${name})
add_library(mp-units::${name} ALIAS mp-units-${name}) add_library(mp-units::${name} ALIAS ${target_name})
if(${projectPrefix}BUILD_CXX_MODULES) if(${projectPrefix}BUILD_CXX_MODULES)
target_sources(mp-units-${name} PUBLIC FILE_SET CXX_MODULES FILES ${ARG_MODULE_INTERFACE_UNIT}) target_sources(${target_name} PUBLIC FILE_SET CXX_MODULES FILES ${ARG_MODULE_INTERFACE_UNIT})
install(TARGETS mp-units-${name} install(TARGETS ${target_name}
EXPORT mp-unitsTargets EXPORT mp-unitsTargets
FILE_SET CXX_MODULES FILE_SET CXX_MODULES
DESTINATION ${CMAKE_INSTALL_LIBDIR}/miu DESTINATION ${CMAKE_INSTALL_LIBDIR}/miu
) )
else() else()
install(TARGETS mp-units-${name} EXPORT mp-unitsTargets) install(TARGETS ${target_name} EXPORT mp-unitsTargets)
endif() endif()
if(ARG_HEADERS) if(ARG_HEADERS)
install(DIRECTORY include/mp-units TYPE INCLUDE) install(DIRECTORY include/mp-units TYPE INCLUDE)

View File

@@ -28,8 +28,8 @@ if(NOT TARGET gsl::gsl-lite)
endif() endif()
# core library definition # core library definition
add_units_module( add_mp_units_module(
core core mp-units-core
DEPENDENCIES gsl::gsl-lite DEPENDENCIES gsl::gsl-lite
HEADERS include/mp-units/bits/external/algorithm.h HEADERS include/mp-units/bits/external/algorithm.h
include/mp-units/bits/external/fixed_string.h include/mp-units/bits/external/fixed_string.h

View File

@@ -22,8 +22,8 @@
cmake_minimum_required(VERSION 3.19) cmake_minimum_required(VERSION 3.19)
add_units_module( add_mp_units_module(
systems systems mp-units-systems
DEPENDENCIES mp-units::core DEPENDENCIES mp-units::core
HEADERS include/mp-units/systems/angular/angular.h HEADERS include/mp-units/systems/angular/angular.h
include/mp-units/systems/angular/math.h include/mp-units/systems/angular/math.h