diff options
author | Brad King <brad.king@kitware.com> | 2013-03-12 22:12:52 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-03-12 22:17:40 (GMT) |
commit | 2e1c2bd2dd97e426944d6ac18e4073ec26ddf64c (patch) | |
tree | ab1b249476f3b36baac84b5a970da85dcbb51c10 | |
parent | 4e5cb375901293e8fedb5d8e44d1481e3f6799d6 (diff) | |
download | CMake-2e1c2bd2dd97e426944d6ac18e4073ec26ddf64c.zip CMake-2e1c2bd2dd97e426944d6ac18e4073ec26ddf64c.tar.gz CMake-2e1c2bd2dd97e426944d6ac18e4073ec26ddf64c.tar.bz2 |
build_command: Fail early without CMAKE_MAKE_PROGRAM (#14005)
If CMAKE_MAKE_PROGRAM is not set fail with an error message instead of
crashing. Suggest calling project() or enable_language() first to
ensure that CMAKE_MAKE_PROGRAM is set.
-rw-r--r-- | Source/cmBuildCommand.cxx | 8 | ||||
-rw-r--r-- | Tests/RunCMake/build_command/BeforeProject-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/build_command/BeforeProject-stderr.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/build_command/BeforeProject.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/build_command/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/build_command/RunCMakeTest.cmake | 4 |
6 files changed, 23 insertions, 1 deletions
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index 3722ab6..91d55a5 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -87,6 +87,14 @@ bool cmBuildCommand const char* makeprogram = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); + if(!makeprogram) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "build_command() requires CMAKE_MAKE_PROGRAM to be defined. " + "Call project() or enable_language() first."); + return true; + } // If null/empty CONFIGURATION argument, GenerateBuildCommand uses 'Debug' // in the currently implemented multi-configuration global generators... diff --git a/Tests/RunCMake/build_command/BeforeProject-result.txt b/Tests/RunCMake/build_command/BeforeProject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/build_command/BeforeProject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/build_command/BeforeProject-stderr.txt b/Tests/RunCMake/build_command/BeforeProject-stderr.txt new file mode 100644 index 0000000..d3d7661 --- /dev/null +++ b/Tests/RunCMake/build_command/BeforeProject-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at BeforeProject.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\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/build_command/BeforeProject.cmake b/Tests/RunCMake/build_command/BeforeProject.cmake new file mode 100644 index 0000000..15788d1 --- /dev/null +++ b/Tests/RunCMake/build_command/BeforeProject.cmake @@ -0,0 +1,2 @@ +build_command(MAKECOMMAND_DEFAULT_VALUE) +project(${RunCMake_TEST} NONE) diff --git a/Tests/RunCMake/build_command/CMakeLists.txt b/Tests/RunCMake/build_command/CMakeLists.txt index e8db6b0..f6e84c0 100644 --- a/Tests/RunCMake/build_command/CMakeLists.txt +++ b/Tests/RunCMake/build_command/CMakeLists.txt @@ -1,3 +1,5 @@ cmake_minimum_required(VERSION 2.8) -project(${RunCMake_TEST} NONE) +if(NOT NoProject) + project(${RunCMake_TEST} NONE) +endif() include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/build_command/RunCMakeTest.cmake b/Tests/RunCMake/build_command/RunCMakeTest.cmake index 4525c57..eaa1d77 100644 --- a/Tests/RunCMake/build_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/build_command/RunCMakeTest.cmake @@ -2,3 +2,7 @@ include(RunCMake) run_cmake(ErrorsOFF) run_cmake(ErrorsON) + +set(RunCMake_TEST_OPTIONS -DNoProject=1) +run_cmake(BeforeProject) +unset(RunCMake_TEST_OPTIONS) |