mirror of
https://github.com/reactos/CMake.git
synced 2024-12-12 13:56:00 +00:00
Merge topic 'standard-include-directories'
c1340827
Add a variable to specify language-wide system include directories44199097
cmMakefile: Optimize AddSystemIncludeDirectories for empty seta896043b
GHS: Compute include directories consistently with other generators
This commit is contained in:
commit
916d52533e
@ -365,6 +365,7 @@ Variables for Languages
|
||||
/variable/CMAKE_LANG_SIMULATE_VERSION
|
||||
/variable/CMAKE_LANG_SIZEOF_DATA_PTR
|
||||
/variable/CMAKE_LANG_SOURCE_FILE_EXTENSIONS
|
||||
/variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES
|
||||
/variable/CMAKE_LANG_STANDARD_LIBRARIES
|
||||
/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG
|
||||
|
||||
|
6
Help/release/dev/standard-include-directories.rst
Normal file
6
Help/release/dev/standard-include-directories.rst
Normal file
@ -0,0 +1,6 @@
|
||||
standard-include-directories
|
||||
----------------------------
|
||||
|
||||
* A :variable:`CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES` variable was
|
||||
added for use by toolchain files to specify system include directories
|
||||
to be appended to all compiler command lines.
|
14
Help/variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES.rst
Normal file
14
Help/variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES.rst
Normal file
@ -0,0 +1,14 @@
|
||||
CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES
|
||||
-----------------------------------------
|
||||
|
||||
Include directories to be used for every source file compiled with
|
||||
the ``<LANG>`` compiler. This is meant for specification of system
|
||||
include directories needed by the language for the current platform.
|
||||
The directories always appear at the end of the include path passed
|
||||
to the compiler.
|
||||
|
||||
This variable should not be set by project code. It is meant to be set by
|
||||
CMake's platform information modules for the current toolchain, or by a
|
||||
toolchain file when used with :variable:`CMAKE_TOOLCHAIN_FILE`.
|
||||
|
||||
See also :variable:`CMAKE_<LANG>_STANDARD_LIBRARIES`.
|
@ -8,3 +8,5 @@ libraries needed by the language for the current platform.
|
||||
This variable should not be set by project code. It is meant to be set by
|
||||
CMake's platform information modules for the current toolchain, or by a
|
||||
toolchain file when used with :variable:`CMAKE_TOOLCHAIN_FILE`.
|
||||
|
||||
See also :variable:`CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES`.
|
||||
|
@ -2415,6 +2415,18 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
|
||||
|
||||
cmDeleteAll(linkInterfaceIncludeDirectoriesEntries);
|
||||
|
||||
// Add standard include directories for this language.
|
||||
std::string const standardIncludesVar =
|
||||
"CMAKE_" + lang + "_STANDARD_INCLUDE_DIRECTORIES";
|
||||
std::string const standardIncludes =
|
||||
this->Makefile->GetSafeDefinition(standardIncludesVar);
|
||||
std::vector<std::string>::size_type const before = includes.size();
|
||||
cmSystemTools::ExpandListArgument(standardIncludes, includes);
|
||||
for (std::vector<std::string>::iterator i = includes.begin() + before;
|
||||
i != includes.end(); ++i) {
|
||||
cmSystemTools::ConvertToUnixSlashes(*i);
|
||||
}
|
||||
|
||||
return includes;
|
||||
}
|
||||
|
||||
|
@ -322,8 +322,10 @@ void cmGhsMultiTargetGenerator::WriteCompilerDefinitions(
|
||||
void cmGhsMultiTargetGenerator::WriteIncludes(const std::string& config,
|
||||
const std::string& language)
|
||||
{
|
||||
std::vector<std::string> includes =
|
||||
this->GeneratorTarget->GetIncludeDirectories(config, language);
|
||||
std::vector<std::string> includes;
|
||||
this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
|
||||
language, config);
|
||||
|
||||
for (std::vector<std::string>::const_iterator includes_i = includes.begin();
|
||||
includes_i != includes.end(); ++includes_i) {
|
||||
*this->GetFolderBuildStreams() << " -I\"" << *includes_i << "\""
|
||||
|
@ -1385,6 +1385,9 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
|
||||
|
||||
void cmGlobalGenerator::FinalizeTargetCompileInfo()
|
||||
{
|
||||
std::vector<std::string> const langs =
|
||||
this->CMakeInstance->GetState()->GetEnabledLanguages();
|
||||
|
||||
// Construct per-target generator information.
|
||||
for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
|
||||
cmMakefile* mf = this->Makefiles[i];
|
||||
@ -1429,6 +1432,23 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The standard include directories for each language
|
||||
// should be treated as system include directories.
|
||||
std::set<std::string> standardIncludesSet;
|
||||
for (std::vector<std::string>::const_iterator li = langs.begin();
|
||||
li != langs.end(); ++li) {
|
||||
std::string const standardIncludesVar =
|
||||
"CMAKE_" + *li + "_STANDARD_INCLUDE_DIRECTORIES";
|
||||
std::string const standardIncludesStr =
|
||||
mf->GetSafeDefinition(standardIncludesVar);
|
||||
std::vector<std::string> standardIncludesVec;
|
||||
cmSystemTools::ExpandListArgument(standardIncludesStr,
|
||||
standardIncludesVec);
|
||||
standardIncludesSet.insert(standardIncludesVec.begin(),
|
||||
standardIncludesVec.end());
|
||||
}
|
||||
mf->AddSystemIncludeDirectories(standardIncludesSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1574,6 +1574,10 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string>& incs,
|
||||
|
||||
void cmMakefile::AddSystemIncludeDirectories(const std::set<std::string>& incs)
|
||||
{
|
||||
if (incs.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
|
||||
|
||||
for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
|
||||
|
@ -63,6 +63,7 @@ else()
|
||||
PROPERTIES COMPILE_FLAGS "-ITarProp")
|
||||
endif()
|
||||
|
||||
add_subdirectory(StandardIncludeDirectories)
|
||||
add_subdirectory(TargetIncludeDirectories)
|
||||
|
||||
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}")
|
||||
|
@ -0,0 +1,5 @@
|
||||
# Normally this variable should be set by a platform information module or
|
||||
# a toolchain file, but for purposes of this test we simply set it here.
|
||||
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/StdDir)
|
||||
|
||||
add_executable(StandardIncludeDirectories main.c)
|
@ -0,0 +1,5 @@
|
||||
#include "StdIncDir.h"
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user