diff options
-rw-r--r-- | Help/command/project.rst | 5 | ||||
-rw-r--r-- | Source/cmProjectCommand.cxx | 24 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/project/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesEmpty-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesEmpty.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesImplicit-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesImplicit.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesNONE-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesNONE.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesTwice-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesTwice-stderr.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/project/LanguagesTwice.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/project/RunCMakeTest.cmake | 6 |
14 files changed, 53 insertions, 5 deletions
diff --git a/Help/command/project.rst b/Help/command/project.rst index cb7d3fc..aabab65 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -5,7 +5,7 @@ Set a name and enable languages for the entire project. .. code-block:: cmake - project(<PROJECT-NAME> [<language-name>...]) + project(<PROJECT-NAME> [LANGUAGES] [<language-name>...]) Sets the name of the project and stores the name in the :variable:`PROJECT_NAME` variable. Additionally this sets variables @@ -18,7 +18,8 @@ Sets the name of the project and stores the name in the Optionally you can specify which languages your project supports. Example languages are ``C``, ``CXX`` (i.e. C++), ``Fortran``, etc. By default ``C`` and ``CXX`` are enabled if no language options are -given. Specify language ``NONE`` to skip enabling any languages. +given. Specify language ``NONE``, or use the ``LANGUAGES`` keyword +and list no languages, to skip enabling any languages. If a variable exists called :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`, the file pointed to by that variable will be included as the last step of the diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 11f9a76..1dcb72b 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -62,15 +62,33 @@ bool cmProjectCommand "Value Computed by CMake", cmCacheManager::STATIC); } + bool haveLanguages = false; std::vector<std::string> languages; - if(args.size() > 1) + for(size_t i = 1; i < args.size(); ++i) { - for(size_t i =1; i < args.size(); ++i) + if(args[i] == "LANGUAGES") + { + if(haveLanguages) + { + this->Makefile->IssueMessage + (cmake::FATAL_ERROR, "LANGUAGES may be specified at most once."); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + haveLanguages = true; + } + else { languages.push_back(args[i]); } } - else + + if (haveLanguages && languages.empty()) + { + languages.push_back("NONE"); + } + + if (languages.empty()) { // if no language is specified do c and c++ languages.push_back("C"); diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9646e67..c29b736 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -82,6 +82,7 @@ add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(list) add_RunCMake_test(message) +add_RunCMake_test(project) add_RunCMake_test(string) add_RunCMake_test(try_compile) add_RunCMake_test(set) diff --git a/Tests/RunCMake/project/CMakeLists.txt b/Tests/RunCMake/project/CMakeLists.txt new file mode 100644 index 0000000..12cd3c7 --- /dev/null +++ b/Tests/RunCMake/project/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/project/LanguagesEmpty-stdout.txt b/Tests/RunCMake/project/LanguagesEmpty-stdout.txt new file mode 100644 index 0000000..fb9c7e8 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesEmpty-stdout.txt @@ -0,0 +1 @@ +ENABLED_LANGUAGES='NONE' diff --git a/Tests/RunCMake/project/LanguagesEmpty.cmake b/Tests/RunCMake/project/LanguagesEmpty.cmake new file mode 100644 index 0000000..4de2cca --- /dev/null +++ b/Tests/RunCMake/project/LanguagesEmpty.cmake @@ -0,0 +1,3 @@ +project(ProjectA LANGUAGES) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") diff --git a/Tests/RunCMake/project/LanguagesImplicit-stdout.txt b/Tests/RunCMake/project/LanguagesImplicit-stdout.txt new file mode 100644 index 0000000..fb9c7e8 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesImplicit-stdout.txt @@ -0,0 +1 @@ +ENABLED_LANGUAGES='NONE' diff --git a/Tests/RunCMake/project/LanguagesImplicit.cmake b/Tests/RunCMake/project/LanguagesImplicit.cmake new file mode 100644 index 0000000..e408454 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesImplicit.cmake @@ -0,0 +1,3 @@ +project(ProjectA NONE) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") diff --git a/Tests/RunCMake/project/LanguagesNONE-stdout.txt b/Tests/RunCMake/project/LanguagesNONE-stdout.txt new file mode 100644 index 0000000..fb9c7e8 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesNONE-stdout.txt @@ -0,0 +1 @@ +ENABLED_LANGUAGES='NONE' diff --git a/Tests/RunCMake/project/LanguagesNONE.cmake b/Tests/RunCMake/project/LanguagesNONE.cmake new file mode 100644 index 0000000..2c0125f --- /dev/null +++ b/Tests/RunCMake/project/LanguagesNONE.cmake @@ -0,0 +1,3 @@ +project(ProjectA LANGUAGES NONE) +get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) +message(STATUS "ENABLED_LANGUAGES='${langs}'") diff --git a/Tests/RunCMake/project/LanguagesTwice-result.txt b/Tests/RunCMake/project/LanguagesTwice-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/project/LanguagesTwice-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/project/LanguagesTwice-stderr.txt b/Tests/RunCMake/project/LanguagesTwice-stderr.txt new file mode 100644 index 0000000..9c69dd0 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesTwice-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LanguagesTwice.cmake:1 \(project\): + LANGUAGES may be specified at most once. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/project/LanguagesTwice.cmake b/Tests/RunCMake/project/LanguagesTwice.cmake new file mode 100644 index 0000000..6c4a3dc --- /dev/null +++ b/Tests/RunCMake/project/LanguagesTwice.cmake @@ -0,0 +1,2 @@ +project(ProjectA LANGUAGES NONE LANGUAGES) +message("This line not reached.") diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake new file mode 100644 index 0000000..cac0f46 --- /dev/null +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(LanguagesImplicit) +run_cmake(LanguagesEmpty) +run_cmake(LanguagesNONE) +run_cmake(LanguagesTwice) |