Skip to content

Commit

Permalink
Ensure object file paths are correctly handled for multi-config builds (
Browse files Browse the repository at this point in the history
#333)

* Ensure object file paths are correctly handled for multi-config builds

* Make multi-config check dynamic
  • Loading branch information
Twon authored Nov 1, 2024
1 parent b3c2ee2 commit 9849fa9
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion cmake/targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ Overview
Locates all targets with in a directory and its subdirectories.
.. code-block:: cmake
targets_get_all(
[DIRECTORY <directory>]
[RESULT <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)
Expand Down Expand Up @@ -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 <targets...>]
[RESULT <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)
Expand Down Expand Up @@ -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/$<CONFIG>/${file}")
else()
set(translationUnitLocation "${targetBinaryDir}/CMakeFiles/${ARGS_TARGET}.dir/${file}")
endif()
list(APPEND targetTranslationUnitLocations ${translationUnitLocation})
endforeach()

Expand Down

0 comments on commit 9849fa9

Please sign in to comment.