From 9849fa975c20db05bf90bbca395e51e31942ad39 Mon Sep 17 00:00:00 2001 From: Antony Peacock Date: Fri, 1 Nov 2024 08:35:53 +0000 Subject: [PATCH] Ensure object file paths are correctly handled for multi-config builds (#333) * Ensure object file paths are correctly handled for multi-config builds * Make multi-config check dynamic --- cmake/targets.cmake | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/cmake/targets.cmake b/cmake/targets.cmake index 5e8992e6..59e3bfe2 100644 --- a/cmake/targets.cmake +++ b/cmake/targets.cmake @@ -26,6 +26,20 @@ Overview Locates all targets with in a directory and its subdirectories. +.. code-block:: cmake + + targets_get_all( + [DIRECTORY ] + [RESULT ] + ) + + ``DIRECTORY`` + The ``DIRECTORY`` option specifies the directory to recursively search for targets + from. + + ``RESULT`` + The ``RESULT`` option is required to store the results of the function. The list + of all targets from the specified directory and below. #]=======================================================================] function(targets_get_all) @@ -60,6 +74,20 @@ Overview Given a list of targets will return a list of targets containing sources to be compiled. +.. code-block:: cmake + + targets_filter_for_sources( + [TARGETS ] + [RESULT ] + ) + + ``TARGETS`` + The ``TARGETS`` option specifies a list of targets to retrieve source files for. + + ``RESULT`` + The ``RESULT`` option is required to store the results of the function. The list + of source files for all requested targets. + #]=======================================================================] function(targets_filter_for_sources) set(options) @@ -137,10 +165,15 @@ function(targets_get_translation_units) list(APPEND targetTranslationUnits ${filteredTargetSource}) endforeach() + get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) get_target_property(targetBinaryDir ${ARGS_TARGET} BINARY_DIR) foreach(file IN LISTS targetTranslationUnits) targets_relative_path_of_source(TARGET_NAME ${ARGS_TARGET} RESULT file SOURCE_FILE ${file}) - set(translationUnitLocation "${targetBinaryDir}/CMakeFiles/${ARGS_TARGET}.dir/${file}") + if(IS_MULTI_CONFIG) + set(translationUnitLocation "${targetBinaryDir}/CMakeFiles/${ARGS_TARGET}.dir/$/${file}") + else() + set(translationUnitLocation "${targetBinaryDir}/CMakeFiles/${ARGS_TARGET}.dir/${file}") + endif() list(APPEND targetTranslationUnitLocations ${translationUnitLocation}) endforeach()