Tests: Configure SubProject-Stage2 test more robustly
Fix the condition that adds the test to check CMAKE_TEST_GENERATOR rather than the tools used to build CMake. Drop the test on Ninja because the generator does not support subproject generation anyway. Stop using the general build_generator_args and pass the --build-generator options explicitly. Also pass --build-makeprogram explicitly when CMAKE_TEST_MAKEPROGRAM is available because there is no CMakeCache.txt in the test project subdirectory from which to pick up the make program.
This commit is contained in:
parent
003d10c248
commit
68031abf15
|
@ -506,8 +506,8 @@ if(BUILD_TESTING)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# test for correct sub-project generation
|
# test for correct sub-project generation
|
||||||
# not implemented in VS6 or Xcode
|
# not implemented in VS 6, VS 7.0, Xcode, or Ninja
|
||||||
if(NOT MSVC60 AND NOT XCODE AND NOT MSVC70)
|
if(NOT CMAKE_TEST_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja")
|
||||||
# run cmake and configure all of SubProject
|
# run cmake and configure all of SubProject
|
||||||
# but only build the independent executable car
|
# but only build the independent executable car
|
||||||
add_test(SubProject ${CMAKE_CTEST_COMMAND}
|
add_test(SubProject ${CMAKE_CTEST_COMMAND}
|
||||||
|
@ -521,24 +521,23 @@ if(BUILD_TESTING)
|
||||||
--test-command car
|
--test-command car
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${CMAKE_TEST_GENERATOR} MATCHES "Ninja")
|
|
||||||
# The Ninja generator does not create a recursive build system. Start
|
|
||||||
# from the root directory.
|
|
||||||
set(SubProject_SUBDIR)
|
|
||||||
else()
|
|
||||||
set(SubProject_SUBDIR "/foo")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# For stage 2, do not run cmake again.
|
# For stage 2, do not run cmake again.
|
||||||
# Then build the foo sub project which should build
|
# Then build the foo sub project which should build
|
||||||
# the bar library which should be referenced because
|
# the bar library which should be referenced because
|
||||||
# foo links to the static library bar, but bar is not
|
# foo links to the static library bar, but bar is not
|
||||||
# directly in the foo sub project
|
# directly in the foo sub project
|
||||||
|
if(CMAKE_TEST_MAKEPROGRAM)
|
||||||
|
set(SubProject-Stage2_BUILD_MAKEPROGRAM
|
||||||
|
--build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND}
|
add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND}
|
||||||
--build-and-test
|
--build-and-test
|
||||||
"${CMake_SOURCE_DIR}/Tests/SubProject${SubProject_SUBDIR}"
|
"${CMake_SOURCE_DIR}/Tests/SubProject/foo"
|
||||||
"${CMake_BINARY_DIR}/Tests/SubProject${SubProject_SUBDIR}"
|
"${CMake_BINARY_DIR}/Tests/SubProject/foo"
|
||||||
${build_generator_args}
|
--build-generator ${CMAKE_TEST_GENERATOR}
|
||||||
|
--build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
|
||||||
|
${SubProject-Stage2_BUILD_MAKEPROGRAM}
|
||||||
--build-nocmake
|
--build-nocmake
|
||||||
--build-project foo
|
--build-project foo
|
||||||
--build-target foo
|
--build-target foo
|
||||||
|
|
Loading…
Reference in New Issue