Files
Tyler Yankee 3c314349d5 presets: Evaluate fileDir macro ahead of schedule
Introduce a mechanism for "immediate" evaluation of preset macros as
they are defined in the current JSON file, rather than deferring until
after the preset graph is merged. This allows `${fileDir}` to always
be expanded with the path to the directory containing the file which
contains the macro, instead of the path being dependent on the preset
in which the macro is used (which could be defined and inherited from
elsewhere).

Bump to presets version 12 to provide backwards compatibility with the
old behavior.

Fixes: #26982
Relates: #27329, #27639
2026-03-17 08:16:50 -04:00

10 lines
428 B
CMake

include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake)
if (PRESET STREQUAL "FileDir")
test_variable(CMAKE_BINARY_DIR "" "${CMAKE_CURRENT_SOURCE_DIR}/subdir/build")
test_variable(TEST_FILE_DIR "" "${CMAKE_CURRENT_SOURCE_DIR}/subdir")
elseif (PRESET STREQUAL "FileDirExt")
test_variable(CMAKE_BINARY_DIR "" "${CMAKE_CURRENT_SOURCE_DIR}/build")
test_variable(TEST_FILE_DIR "" "${CMAKE_CURRENT_SOURCE_DIR}")
endif()