Skip to content

Commit

Permalink
fix: target_sources with FILE_SET HEADERS called only when header…
Browse files Browse the repository at this point in the history
…s are present
  • Loading branch information
mpusz committed Jan 6, 2024
1 parent 78dedb1 commit 53e2558
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/cmake/AddMPUnitsModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
)
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})
Expand Down

0 comments on commit 53e2558

Please sign in to comment.