diff --git a/src/cmake/AddMPUnitsModule.cmake b/src/cmake/AddMPUnitsModule.cmake index e8d12c6f0..da42cd1b6 100644 --- a/src/cmake/AddMPUnitsModule.cmake +++ b/src/cmake/AddMPUnitsModule.cmake @@ -62,25 +62,26 @@ function(add_mp_units_module name target_name) # define the target for a module add_library(${target_name} ${SCOPE}) - target_sources( - ${target_name} - ${${projectPrefix}TARGET_SCOPE} - FILE_SET - HEADERS - BASE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/include - FILES - ${ARG_HEADERS} - ) target_link_libraries(${target_name} ${${projectPrefix}TARGET_SCOPE} ${ARG_DEPENDENCIES}) + set_target_properties(${target_name} PROPERTIES EXPORT_NAME ${name}) + add_library(mp-units::${name} ALIAS ${target_name}) + if(ARG_HEADERS) + target_sources( + ${target_name} + ${${projectPrefix}TARGET_SCOPE} + FILE_SET + HEADERS + BASE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/include + FILES + ${ARG_HEADERS} + ) target_include_directories( ${target_name} ${unitsAsSystem} ${${projectPrefix}TARGET_SCOPE} $ $ ) endif() - set_target_properties(${target_name} PROPERTIES EXPORT_NAME ${name}) - add_library(mp-units::${name} ALIAS ${target_name}) if(${projectPrefix}BUILD_CXX_MODULES) target_sources(${target_name} PUBLIC FILE_SET CXX_MODULES FILES ${ARG_MODULE_INTERFACE_UNIT})