mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 07:11:52 +08:00
Tests: Fix CMakeTestAllGenerators generator list
Since `cmake --help` output now uses `[arch]` placeholders for the VS generators, this test has been extracting invalid generator names. Switch to using `cmake -E capabilities` to get a more robust listing of the generators that does not depend on parsing human-readable help output.
This commit is contained in:
@@ -9,42 +9,23 @@ endif()
|
|||||||
# Analyze 'cmake --help' output for list of available generators:
|
# Analyze 'cmake --help' output for list of available generators:
|
||||||
#
|
#
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${dir})
|
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${dir})
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} --help
|
execute_process(COMMAND ${CMAKE_COMMAND} -E capabilities
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
OUTPUT_VARIABLE stdout
|
OUTPUT_VARIABLE stdout
|
||||||
ERROR_VARIABLE stderr
|
ERROR_VARIABLE stderr
|
||||||
WORKING_DIRECTORY ${dir})
|
WORKING_DIRECTORY ${dir})
|
||||||
|
|
||||||
string(REPLACE ";" "\\;" stdout "${stdout}")
|
|
||||||
string(REPLACE "\n" "E;" stdout "${stdout}")
|
|
||||||
|
|
||||||
set(collecting 0)
|
|
||||||
set(generators)
|
set(generators)
|
||||||
foreach(eline ${stdout})
|
string(REGEX MATCHALL [["name":"[^"]+","platformSupport"]] generators_json "${stdout}")
|
||||||
string(REGEX REPLACE "^(.*)E$" "\\1" line "${eline}")
|
foreach(gen_json IN LISTS generators_json)
|
||||||
if(collecting AND NOT line STREQUAL "")
|
if("${gen_json}" MATCHES [["name":"([^"]+)"]])
|
||||||
if(line MATCHES "=")
|
set(gen "${CMAKE_MATCH_1}")
|
||||||
string(REGEX REPLACE "^ (.+)= (.*)$" "\\1" gen "${line}")
|
if(NOT gen MATCHES " (Win64|IA64|ARM)$")
|
||||||
if(gen MATCHES "[A-Za-z]")
|
list(APPEND generators "${gen}")
|
||||||
string(REGEX REPLACE "^(.*[^ ]) +$" "\\1" gen "${gen}")
|
|
||||||
if(gen)
|
|
||||||
set(generators ${generators} ${gen})
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
else()
|
|
||||||
if(line MATCHES "^ [A-Za-z0-9]")
|
|
||||||
string(REGEX REPLACE "^ (.+)$" "\\1" gen "${line}")
|
|
||||||
string(REGEX REPLACE "^(.*[^ ]) +$" "\\1" gen "${gen}")
|
|
||||||
if(gen)
|
|
||||||
set(generators ${generators} ${gen})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
if(line STREQUAL "The following generators are available on this platform:")
|
|
||||||
set(collecting 1)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
list(REMOVE_DUPLICATES generators)
|
||||||
|
|
||||||
# Also call with one non-existent generator:
|
# Also call with one non-existent generator:
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user