CTest: Fail early without PROJECT_BINARY_DIR (#14005)
Do not use PROJECT_BINARY_DIR before it is defined. If it is not defined when needed, fail with an error message suggesting that the project() command be invoked first.
This commit is contained in:
parent
2e1c2bd2dd
commit
d90f49b894
@ -16,6 +16,10 @@ if(NOT RUN_FROM_CTEST_OR_DART)
|
|||||||
message(FATAL_ERROR "Do not incldue CTestTargets.cmake directly")
|
message(FATAL_ERROR "Do not incldue CTestTargets.cmake directly")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT PROJECT_BINARY_DIR)
|
||||||
|
message(FATAL_ERROR "Do not include(CTest) before calling project().")
|
||||||
|
endif()
|
||||||
|
|
||||||
# make directories in the binary tree
|
# make directories in the binary tree
|
||||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Testing/Temporary)
|
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Testing/Temporary)
|
||||||
get_filename_component(CMAKE_HOST_PATH ${CMAKE_COMMAND} PATH)
|
get_filename_component(CMAKE_HOST_PATH ${CMAKE_COMMAND} PATH)
|
||||||
|
@ -52,6 +52,7 @@ if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_RunCMake_test(CMP0019)
|
add_RunCMake_test(CMP0019)
|
||||||
|
add_RunCMake_test(CTest)
|
||||||
if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
|
if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
|
||||||
add_RunCMake_test(CompilerChange)
|
add_RunCMake_test(CompilerChange)
|
||||||
endif()
|
endif()
|
||||||
|
1
Tests/RunCMake/CTest/BeforeProject-result.txt
Normal file
1
Tests/RunCMake/CTest/BeforeProject-result.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
6
Tests/RunCMake/CTest/BeforeProject-stderr.txt
Normal file
6
Tests/RunCMake/CTest/BeforeProject-stderr.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
CMake Error at .*/Modules/CTest.cmake:[0-9]+ \(build_command\):
|
||||||
|
build_command\(\) requires CMAKE_MAKE_PROGRAM to be defined. Call project\(\)
|
||||||
|
or enable_language\(\) first.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
BeforeProject.cmake:[0-9]+ \(include\)
|
||||||
|
CMakeLists.txt:[0-9]+ \(include\)
|
2
Tests/RunCMake/CTest/BeforeProject.cmake
Normal file
2
Tests/RunCMake/CTest/BeforeProject.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
include(CTest)
|
||||||
|
project(${RunCMake_TEST} NONE)
|
5
Tests/RunCMake/CTest/CMakeLists.txt
Normal file
5
Tests/RunCMake/CTest/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
if(NOT NoProject)
|
||||||
|
project(${RunCMake_TEST} NONE)
|
||||||
|
endif()
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
5
Tests/RunCMake/CTest/RunCMakeTest.cmake
Normal file
5
Tests/RunCMake/CTest/RunCMakeTest.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
set(RunCMake_TEST_OPTIONS -DNoProject=1)
|
||||||
|
run_cmake(BeforeProject)
|
||||||
|
unset(RunCMake_TEST_OPTIONS)
|
Loading…
x
Reference in New Issue
Block a user