From b217d79a2bfb9105a446e81843805605411b633d Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 1 Aug 2026 20:54:10 +0300 Subject: [PATCH] Apply release prefix maps to nested targets --- CMakeLists.txt | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8dfe81..ac0d27a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,11 +74,30 @@ if(ECHOION_REPRODUCIBLE_BUILD) "${ECHOION_COMPONENT_WORKSPACE}=EchoionComponents") endif() foreach(_echoionPrefixMap IN LISTS _echoionPrefixMaps) - add_compile_options( + list(APPEND _echoionReproducibleCompilerOptions "$<$:-ffile-prefix-map=${_echoionPrefixMap}>" "$<$:-fmacro-prefix-map=${_echoionPrefixMap}>" "$<$:-fdebug-prefix-map=${_echoionPrefixMap}>") endforeach() + function(echoion_apply_reproducible_build_options directory) + get_property(_echoionDirectoryTargets + DIRECTORY "${directory}" PROPERTY BUILDSYSTEM_TARGETS) + foreach(_echoionTarget IN LISTS _echoionDirectoryTargets) + get_target_property(_echoionTargetType + "${_echoionTarget}" TYPE) + if(_echoionTargetType MATCHES + "^(EXECUTABLE|STATIC_LIBRARY|SHARED_LIBRARY|MODULE_LIBRARY|OBJECT_LIBRARY)$") + target_compile_options("${_echoionTarget}" PRIVATE + ${_echoionReproducibleCompilerOptions}) + endif() + endforeach() + get_property(_echoionSubdirectories + DIRECTORY "${directory}" PROPERTY SUBDIRECTORIES) + foreach(_echoionSubdirectory IN LISTS _echoionSubdirectories) + echoion_apply_reproducible_build_options( + "${_echoionSubdirectory}") + endforeach() + endfunction() message(STATUS "Reproducible compiler path mapping enabled") else() message(WARNING @@ -580,6 +599,11 @@ if(ECHOION_ENABLE_LEGACY_CPACK) include(CPack) endif() +if(ECHOION_REPRODUCIBLE_BUILD AND + COMMAND echoion_apply_reproducible_build_options) + echoion_apply_reproducible_build_options("${CMAKE_CURRENT_SOURCE_DIR}") +endif() + # Print configuration summary message(STATUS "") message(STATUS "Echoion Configuration:")