Tests/RunCMake/property_init: Fix per-config property tests

`per_config` read from undefined variables and always produced an empty
table, so no per-config property was ever checked. Fix it to parse its
arguments, build property names without a doubled `_`, and uppercase
configuration names to match `cmTarget`. Use `-` rather than `/` in
expected values since postfixes become part of artifact file names.

Single-config generators initialize per-config properties only for
`CMAKE_BUILD_TYPE`, so set one and fail if no configurations are found.

This exposes issues with the test expectations which are corrected.
This commit is contained in:
Tyler Yankee committed 2026-10-27 13:36:30 -04:00
1 parent 825a52a64e
commit 29315ad49e
6 files changed
+29 -18

No files matched your search

@@ -1,10 +1,10 @@
per_config(properties
# property expected alias
# Linking properties
"_POSTFIX" "test" "<UNSET>"
"_POSTFIX" "test" "<SAME>"
)
prepare_target_types(library_with_artifact
MODULE SHARED STATIC
IMPORTED_MODULE IMPORTED_SHARED IMPORTED_STATIC)
MODULE OBJECT SHARED STATIC
IMPORTED_MODULE IMPORTED_OBJECT IMPORTED_SHARED IMPORTED_STATIC)
run_property_tests(library_with_artifact properties)
+3 -3
View File
@@ -3,10 +3,10 @@ per_config(properties
# Linking properties
## Platforms
### macOS
"FRAMEWORK_MULTI_CONFIG_POSTFIX_" ".fw" "<UNSET>"
"FRAMEWORK_MULTI_CONFIG_POSTFIX_" ".fw" "<SAME>"
)
prepare_target_types(linkable
EXECUTABLE SHARED STATIC
IMPORTED_EXECUTABLE IMPORTED_SHARED IMPORTED_STATIC)
SHARED STATIC
IMPORTED_SHARED IMPORTED_STATIC)
run_property_tests(linkable properties)
@@ -1,7 +1,7 @@
per_config(properties
# property expected alias
# Usage requirement properties
"MAP_IMPORTED_CONFIG_" "Release" "<UNSET>"
"MAP_IMPORTED_CONFIG_" "Release" "<SAME>"
)
list(APPEND properties
# property expected alias
@@ -1,5 +1,10 @@
include(RunCMake)
# Per-config properties are only initialized for known configurations.
if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif ()
run_cmake(Always)
run_cmake(CompileSources)
run_cmake(Executable)
@@ -3,17 +3,17 @@ set(dir "${CMAKE_CURRENT_BINARY_DIR}")
per_config(properties
# property expected alias
# Compilation properties
"INTERPROCEDURAL_OPTIMIZATION_" "OFF" "<UNSET>"
"INTERPROCEDURAL_OPTIMIZATION_" "OFF" "<SAME>"
# Output location properties
"ARCHIVE_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
"COMPILE_PDB_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
"LIBRARY_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
"PDB_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
"RUNTIME_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
"ARCHIVE_OUTPUT_DIRECTORY_" "${dir}" "<SAME>"
"COMPILE_PDB_OUTPUT_DIRECTORY_" "${dir}" "<SAME>"
"LIBRARY_OUTPUT_DIRECTORY_" "${dir}" "<SAME>"
"PDB_OUTPUT_DIRECTORY_" "${dir}" "<SAME>"
"RUNTIME_OUTPUT_DIRECTORY_" "${dir}" "<SAME>"
)
prepare_target_types(with_artifact
EXECUTABLE MODULE SHARED STATIC
IMPORTED_EXECUTABLE IMPORTED_MODULE IMPORTED_SHARED IMPORTED_STATIC)
EXECUTABLE MODULE OBJECT SHARED STATIC
IMPORTED_EXECUTABLE IMPORTED_MODULE IMPORTED_OBJECT IMPORTED_SHARED IMPORTED_STATIC)
run_property_tests(with_artifact properties)
+9 -3
View File
@@ -24,7 +24,8 @@ function (prepare_target_types name)
endfunction ()
function (per_config variable)
prepare_properties("${property_table}" properties expected_values expected_alias)
set(property_table "${ARGN}")
prepare_properties(property_table expected_properties expected_values expected_alias)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (is_multi_config)
@@ -34,6 +35,11 @@ function (per_config variable)
set(configs "${CMAKE_BUILD_TYPE}")
endif ()
endif ()
if (NOT configs)
message(FATAL_ERROR
"No configurations available to test per-config properties")
endif ()
string(TOUPPER "${configs}" configs)
foreach (property expected alias IN ZIP_LISTS expected_properties expected_values expected_alias)
if (property MATCHES "^_")
@@ -47,10 +53,10 @@ function (per_config variable)
foreach (config IN LISTS configs)
if (prepend)
list(APPEND "${variable}"
"${config}_${property}" "${value}/${config}" "${alias}")
"${config}${property}" "${expected}-${config}" "${alias}")
else ()
list(APPEND "${variable}"
"${property}_${config}" "${value}/${config}" "${alias}")
"${property}${config}" "${expected}-${config}" "${alias}")
endif ()
endforeach ()
endforeach ()