Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
07611869
Commit
07611869
authored
Mar 28, 2019
by
Ruslan Baratov
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
project: Add variable CMAKE_PROJECT_INCLUDE_BEFORE
parent
3e129d71
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
0 deletions
+40
-0
Help/command/project.rst
Help/command/project.rst
+4
-0
Help/manual/cmake-variables.7.rst
Help/manual/cmake-variables.7.rst
+1
-0
Help/release/dev/project-include-before.rst
Help/release/dev/project-include-before.rst
+5
-0
Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst
Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst
+6
-0
Source/cmProjectCommand.cxx
Source/cmProjectCommand.cxx
+4
-0
Tests/CMakeOnly/CMakeLists.txt
Tests/CMakeOnly/CMakeLists.txt
+6
-0
Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt
Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt
+5
-0
Tests/CMakeOnly/ProjectIncludeBefore/include.cmake
Tests/CMakeOnly/ProjectIncludeBefore/include.cmake
+9
-0
No files found.
Help/command/project.rst
View file @
07611869
...
@@ -31,6 +31,10 @@ Further variables are set by the optional arguments described in the following.
...
@@ -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
If any of these arguments is not used, then the corresponding variables are
set to the empty string.
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`
If the variable :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`
or :variable:`CMAKE_PROJECT_INCLUDE` exists, the file pointed to by that
or :variable:`CMAKE_PROJECT_INCLUDE` exists, the file pointed to by that
variable will be included as the last step of the project command.
variable will be included as the last step of the project command.
...
...
Help/manual/cmake-variables.7.rst
View file @
07611869
...
@@ -196,6 +196,7 @@ Variables that Change Behavior
...
@@ -196,6 +196,7 @@ Variables that Change Behavior
/variable/CMAKE_PREFIX_PATH
/variable/CMAKE_PREFIX_PATH
/variable/CMAKE_PROGRAM_PATH
/variable/CMAKE_PROGRAM_PATH
/variable/CMAKE_PROJECT_INCLUDE
/variable/CMAKE_PROJECT_INCLUDE
/variable/CMAKE_PROJECT_INCLUDE_BEFORE
/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE
/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE
/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
/variable/CMAKE_STAGING_PREFIX
/variable/CMAKE_STAGING_PREFIX
...
...
Help/release/dev/project-include-before.rst
0 → 100644
View file @
07611869
cmake_project_include_before
----------------------------
* A variable :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` was added to allow
injection of custom code into the project.
Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst
0 → 100644
View file @
07611869
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.
Source/cmProjectCommand.cxx
View file @
07611869
...
@@ -25,6 +25,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
...
@@ -25,6 +25,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
return
false
;
return
false
;
}
}
if
(
!
this
->
IncludeByVariable
(
"CMAKE_PROJECT_INCLUDE_BEFORE"
))
{
return
false
;
}
std
::
string
const
&
projectName
=
args
[
0
];
std
::
string
const
&
projectName
=
args
[
0
];
this
->
Makefile
->
SetProjectName
(
projectName
);
this
->
Makefile
->
SetProjectName
(
projectName
);
...
...
Tests/CMakeOnly/CMakeLists.txt
View file @
07611869
...
@@ -62,6 +62,12 @@ add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND}
...
@@ -62,6 +62,12 @@ add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND}
-P
${
CMAKE_CURRENT_BINARY_DIR
}
/Test.cmake
-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
)
include
(
CMakeParseArguments
)
function
(
add_major_test module
)
function
(
add_major_test module
)
...
...
Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt
0 → 100644
View file @
07611869
set
(
FOO TRUE
)
project
(
ProjectInclude LANGUAGES NONE
)
if
(
NOT AUTO_INCLUDE
)
message
(
FATAL_ERROR
"include file not found"
)
endif
()
Tests/CMakeOnly/ProjectIncludeBefore/include.cmake
0 → 100644
View file @
07611869
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
)
Brad King
@brad.king
mentioned in commit
0dfb056c
·
Apr 04, 2019
mentioned in commit
0dfb056c
mentioned in commit 0dfb056cd3fa655ddf3cabb6b3ce0309b3037ca1
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment