mirror of
https://github.com/reactos/CMake.git
synced 2025-03-03 09:27:12 +00:00
project: Add variable CMAKE_PROJECT_INCLUDE_BEFORE
This commit is contained in:
parent
3e129d71bc
commit
0761186949
@ -31,6 +31,10 @@ Further variables are set by the optional arguments described in the following.
|
||||
If any of these arguments is not used, then the corresponding variables are
|
||||
set to the empty string.
|
||||
|
||||
If the variable :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` exists, the file
|
||||
pointed to by that variable will be included as the first step of the project
|
||||
command.
|
||||
|
||||
If the variable :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`
|
||||
or :variable:`CMAKE_PROJECT_INCLUDE` exists, the file pointed to by that
|
||||
variable will be included as the last step of the project command.
|
||||
|
@ -196,6 +196,7 @@ Variables that Change Behavior
|
||||
/variable/CMAKE_PREFIX_PATH
|
||||
/variable/CMAKE_PROGRAM_PATH
|
||||
/variable/CMAKE_PROJECT_INCLUDE
|
||||
/variable/CMAKE_PROJECT_INCLUDE_BEFORE
|
||||
/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE
|
||||
/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
|
||||
/variable/CMAKE_STAGING_PREFIX
|
||||
|
5
Help/release/dev/project-include-before.rst
Normal file
5
Help/release/dev/project-include-before.rst
Normal file
@ -0,0 +1,5 @@
|
||||
cmake_project_include_before
|
||||
----------------------------
|
||||
|
||||
* A variable :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` was added to allow
|
||||
injection of custom code into the project.
|
6
Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst
Normal file
6
Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst
Normal file
@ -0,0 +1,6 @@
|
||||
CMAKE_PROJECT_INCLUDE_BEFORE
|
||||
----------------------------
|
||||
|
||||
A CMake language file or module to be included before processing the
|
||||
:command:`project` command. This is intended for injecting custom code into
|
||||
project builds without modifying their source.
|
@ -25,6 +25,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->IncludeByVariable("CMAKE_PROJECT_INCLUDE_BEFORE")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string const& projectName = args[0];
|
||||
|
||||
this->Makefile->SetProjectName(projectName);
|
||||
|
@ -62,6 +62,12 @@ add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND}
|
||||
-P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
|
||||
)
|
||||
|
||||
add_test(CMakeOnly.ProjectIncludeBefore ${CMAKE_CMAKE_COMMAND}
|
||||
-DTEST=ProjectIncludeBefore
|
||||
-DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE_BEFORE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludeBefore/include.cmake
|
||||
-P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
|
||||
)
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(add_major_test module)
|
||||
|
5
Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt
Normal file
5
Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
set(FOO TRUE)
|
||||
project(ProjectInclude LANGUAGES NONE)
|
||||
if(NOT AUTO_INCLUDE)
|
||||
message(FATAL_ERROR "include file not found")
|
||||
endif()
|
9
Tests/CMakeOnly/ProjectIncludeBefore/include.cmake
Normal file
9
Tests/CMakeOnly/ProjectIncludeBefore/include.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
if(NOT FOO)
|
||||
message(FATAL_ERROR "FOO is not set")
|
||||
endif()
|
||||
|
||||
if(NOT "${PROJECT_NAME}" STREQUAL "")
|
||||
message(FATAL_ERROR "PROJECT_NAME should be empty")
|
||||
endif()
|
||||
|
||||
set(AUTO_INCLUDE TRUE)
|
Loading…
x
Reference in New Issue
Block a user