| function(run_AliasOutputPathPrefix spelling) | |
| set(top "${RunCMake_BINARY_DIR}/AliasOutputPathPrefix-${spelling}-build") | |
| file(REMOVE_RECURSE "${top}") | |
| set(prefix "sub/dir") | |
| if(spelling STREQUAL "native") | |
| string(REPLACE "/" "\\" prefix "${prefix}") | |
| endif() | |
| set(RunCMake_TEST_SOURCE_DIR "${CMAKE_CURRENT_FUNCTION_LIST_DIR}") | |
| set(RunCMake_TEST_BINARY_DIR "${top}/sub/dir") | |
| set(RunCMake_TEST_VARIANT_DESCRIPTION "-${spelling}") | |
| set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_OUTPUT_PATH_PREFIX=${prefix}") | |
| run_cmake(AliasOutputPathPrefix) | |
| # Inspect all generated graphs, including multi-config implementation files. | |
| file(GLOB graphs "${RunCMake_TEST_BINARY_DIR}/*.ninja" | |
| "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/*.ninja") | |
| foreach(graph IN LISTS graphs) | |
| file(STRINGS "${graph}" lines REGEX "^build .*: phony ") | |
| foreach(line IN LISTS lines) | |
| string(REPLACE "\\" "/" line "${line}") | |
| if(line MATCHES "^build (.+): phony (.+)$" AND | |
| CMAKE_MATCH_1 STREQUAL CMAKE_MATCH_2) | |
| message(FATAL_ERROR "Self-referential alias in ${graph}: ${line}") | |
| endif() | |
| endforeach() | |
| endforeach() | |
| if(RunCMake_GENERATOR_IS_MULTI_CONFIG) | |
| set(configs Debug Release) | |
| else() | |
| set(configs "single") | |
| endif() | |
| set(RunCMake_TEST_BINARY_DIR "${top}") | |
| set(RunCMake_TEST_NO_CLEAN 1) | |
| foreach(config IN LISTS configs) | |
| if(config STREQUAL "single") | |
| set(build_file build.ninja) | |
| set(marker_config "") | |
| else() | |
| set(build_file "build-${config}.ninja") | |
| set(marker_config "${config}") | |
| endif() | |
| file(WRITE "${top}/${build_file}" | |
| "subninja sub/dir/${build_file}\n") | |
| foreach(target IN ITEMS probe distinct) | |
| run_cmake_command(AliasOutputPathPrefix-${spelling}-${config}-${target} | |
| "${RunCMake_MAKE_PROGRAM}" -f "${build_file}" "sub/dir/${target}") | |
| if(NOT EXISTS "${top}/sub/dir/${target}-${marker_config}") | |
| message(FATAL_ERROR "${target} was not built for ${config}") | |
| endif() | |
| endforeach() | |
| endforeach() | |
| endfunction() | |
| run_AliasOutputPathPrefix(slash) | |
| if(CMAKE_HOST_WIN32) | |
| run_AliasOutputPathPrefix(native) | |
| endif() |