diff options
27 files changed, 218 insertions, 55 deletions
diff --git a/Help/command/COMPILE_OPTIONS_SHELL.txt b/Help/command/COMPILE_OPTIONS_SHELL.txt new file mode 100644 index 0000000..a1316c8 --- /dev/null +++ b/Help/command/COMPILE_OPTIONS_SHELL.txt @@ -0,0 +1,9 @@ +The final set of compile options used for a target is constructed by +accumulating options from the current target and the usage requirements of +it dependencies. The set of options is de-duplicated to avoid repetition. +While beneficial for individual options, the de-duplication step can break +up option groups. For example, ``-D A -D B`` becomes ``-D A B``. One may +specify a group of options using shell-like quoting along with a ``SHELL:`` +prefix. The ``SHELL:`` prefix is dropped and the rest of the option string +is parsed using the :command:`separate_arguments` ``UNIX_COMMAND`` mode. +For example, ``"SHELL:-D A" "SHELL:-D B"`` becomes ``-D A -D B``. diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst index 3fe2a33..44924e6 100644 --- a/Help/command/add_compile_options.rst +++ b/Help/command/add_compile_options.rst @@ -21,3 +21,5 @@ Arguments to ``add_compile_options`` may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. + +.. include:: COMPILE_OPTIONS_SHELL.txt diff --git a/Help/command/project.rst b/Help/command/project.rst index eb185e4..ac71d7a 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -1,7 +1,7 @@ project ------- -Set a name, version, and enable languages for the entire project. +Sets project details such as name, version, etc. and enables languages. .. code-block:: cmake @@ -63,7 +63,10 @@ The top-level ``CMakeLists.txt`` file for a project must contain a literal, direct call to the :command:`project` command; loading one through the :command:`include` command is not sufficient. If no such call exists CMake will implicitly add one to the top that enables the -default languages (``C`` and ``CXX``). +default languages (``C`` and ``CXX``). The name of the project set in +the top level CMakeLists.txt file is available from the +:variable:`CMAKE_PROJECT_NAME` variable and its description from +:variable:`CMAKE_PROJECT_DESCRIPTION`. .. note:: Call the :command:`cmake_minimum_required` command at the beginning diff --git a/Help/command/target_compile_options.rst b/Help/command/target_compile_options.rst index 3e7dc47..b7b4dc1 100644 --- a/Help/command/target_compile_options.rst +++ b/Help/command/target_compile_options.rst @@ -38,3 +38,5 @@ Arguments to ``target_compile_options`` may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. + +.. include:: COMPILE_OPTIONS_SHELL.txt diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index a04c403..75af22e 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -368,15 +368,17 @@ for "SubprojectB"). Build and Test Mode =================== -CTest provides a command-line signature to to configure (i.e. run cmake on), -build, and or execute a test:: +CTest provides a command-line signature to configure (i.e. run cmake on), +build, and/or execute a test:: ctest --build-and-test <path-to-source> <path-to-build> - --build-generator <generator> [<options>...] [-- <build-options>...] - [--test-command <test>] + --build-generator <generator> + [<options>...] + [--build-options <opts>...] + [--test-command <command> [<args>...]] The configure and test steps are optional. The arguments to this command line -are the source and binary directories. The ``--build-generator`` option *must* +are the source and binary directories. The ``--build-generator`` option *must* be provided to use ``--build-and-test``. If ``--test-command`` is specified then that will be run after the build is complete. Other options that affect this mode include: @@ -425,13 +427,15 @@ this mode include: should be used. e.g. Debug/Release/etc. ``--build-options`` - Add extra options to the build step. - - This option must be the last option with the exception of - ``--test-command`` + Additional options for configuring the build (i.e. for CMake, not for + the build tool). Note that if this is specified, the ``--build-options`` + keyword and its arguments must be the last option given on the command + line, with the possible exception of ``--test-command``. ``--test-command`` - The test to run with the ``--build-and-test`` option. + The command to run as the test step with the ``--build-and-test`` option. + All arguments following this keyword will be assumed to be part of the + test command line, so it must be the last option given. ``--test-timeout`` The time limit in seconds diff --git a/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst index 0af85cb..fb0389e 100644 --- a/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst +++ b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst @@ -4,3 +4,6 @@ VS_DEBUGGER_WORKING_DIRECTORY Sets the local debugger working directory for Visual Studio C++ targets. This is defined in ``<LocalDebuggerWorkingDirectory>`` in the Visual Studio project file. + +This property only works for Visual Studio 2010 and above; +it is ignored on other generators. diff --git a/Help/release/dev/compile-options-shell.rst b/Help/release/dev/compile-options-shell.rst new file mode 100644 index 0000000..3f83e0c --- /dev/null +++ b/Help/release/dev/compile-options-shell.rst @@ -0,0 +1,6 @@ +compile-options-shell +--------------------- + +* :command:`target_compile_options` and :command:`add_compile_options` + commands gained a ``SHELL:`` prefix to specify a group of related + options using shell-like quoting. diff --git a/Help/variable/CMAKE_PROJECT_DESCRIPTION.rst b/Help/variable/CMAKE_PROJECT_DESCRIPTION.rst index f1911ec..6db5b9e 100644 --- a/Help/variable/CMAKE_PROJECT_DESCRIPTION.rst +++ b/Help/variable/CMAKE_PROJECT_DESCRIPTION.rst @@ -1,7 +1,35 @@ CMAKE_PROJECT_DESCRIPTION ------------------------- -The description of the current project. +The description of the top level project. -This specifies description of the current project from the closest inherited -:command:`project` command. +This variable holds the description of the project as specified in the top +level CMakeLists.txt file by a :command:`project` command. In the event that +the top level CMakeLists.txt contains multiple :command:`project` calls, +the most recently called one from that top level CMakeLists.txt will determine +the name that ``CMAKE_PROJECT_DESCRIPTION`` contains. For example, consider +the following top level CMakeLists.txt: + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.0) + project(First DESCRIPTION "I am First") + project(Second DESCRIPTION "I am Second") + add_subdirectory(sub) + project(Third DESCRIPTION "I am Third") + +And ``sub/CMakeLists.txt`` with the following contents: + +.. code-block:: cmake + + project(SubProj DESCRIPTION "I am SubProj") + message("CMAKE_PROJECT_DESCRIPTION = ${CMAKE_PROJECT_DESCRIPTION}") + +The most recently seen :command:`project` command from the top level +CMakeLists.txt would be ``project(Second ...)``, so this will print:: + + CMAKE_PROJECT_DESCRIPTION = I am Second + +To obtain the description from the most recent call to :command:`project` in +the current directory scope or above, see the :variable:`PROJECT_DESCRIPTION` +variable. diff --git a/Help/variable/CMAKE_PROJECT_NAME.rst b/Help/variable/CMAKE_PROJECT_NAME.rst index 431e9f3..94b8dba 100644 --- a/Help/variable/CMAKE_PROJECT_NAME.rst +++ b/Help/variable/CMAKE_PROJECT_NAME.rst @@ -1,7 +1,35 @@ CMAKE_PROJECT_NAME ------------------ -The name of the current project. +The name of the top level project. -This specifies name of the current project from the closest inherited -:command:`project` command. +This variable holds the name of the project as specified in the top +level CMakeLists.txt file by a :command:`project` command. In the event that +the top level CMakeLists.txt contains multiple :command:`project` calls, +the most recently called one from that top level CMakeLists.txt will determine +the name that ``CMAKE_PROJECT_NAME`` contains. For example, consider +the following top level CMakeLists.txt: + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.0) + project(First) + project(Second) + add_subdirectory(sub) + project(Third) + +And ``sub/CMakeLists.txt`` with the following contents: + +.. code-block:: cmake + + project(SubProj) + message("CMAKE_PROJECT_NAME = ${CMAKE_PROJECT_NAME}") + +The most recently seen :command:`project` command from the top level +CMakeLists.txt would be ``project(Second)``, so this will print:: + + CMAKE_PROJECT_NAME = Second + +To obtain the name from the most recent call to :command:`project` in +the current directory scope or above, see the :variable:`PROJECT_NAME` +variable. diff --git a/Help/variable/PROJECT_DESCRIPTION.rst b/Help/variable/PROJECT_DESCRIPTION.rst index 05ede8f..2833e11 100644 --- a/Help/variable/PROJECT_DESCRIPTION.rst +++ b/Help/variable/PROJECT_DESCRIPTION.rst @@ -3,4 +3,7 @@ PROJECT_DESCRIPTION Short project description given to the project command. -This is the description given to the most recent :command:`project` command. +This is the description given to the most recently called :command:`project` +command in the current directory scope or above. To obtain the description +of the top level project, see the :variable:`CMAKE_PROJECT_DESCRIPTION` +variable. diff --git a/Help/variable/PROJECT_NAME.rst b/Help/variable/PROJECT_NAME.rst index 61aa8bc..672680a 100644 --- a/Help/variable/PROJECT_NAME.rst +++ b/Help/variable/PROJECT_NAME.rst @@ -3,4 +3,6 @@ PROJECT_NAME Name of the project given to the project command. -This is the name given to the most recent :command:`project` command. +This is the name given to the most recently called :command:`project` +command in the current directory scope or above. To obtain the name of +the top level project, see the :variable:`CMAKE_PROJECT_NAME` variable. diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 10f7318..2f6bdb4 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -34,7 +34,8 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; @CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@ #if !defined(__STDC__) -# if defined(_MSC_VER) && !defined(__clang__) +# if (defined(_MSC_VER) && !defined(__clang__)) \ + || (defined(__ibmxl__) || defined(__IBMC__)) # define C_DIALECT "90" # else # define C_DIALECT diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index c4601a1..e31c19e 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -47,7 +47,10 @@ macro(java_append_library_directories _var) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") # mips* machines are bi-endian mostly so processor does not tell # endianness of the underlying system. - set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb" "mips64" "mips64el" "mipsn32" "mipsn32el") + set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" + "mips" "mipsel" "mipseb" "mipsr6" "mipsr6el" + "mips64" "mips64el" "mips64r6" "mips64r6el" + "mipsn32" "mipsn32el" "mipsn32r6" "mipsn32r6el") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le") set(_java_libarch "ppc64" "ppc64le") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a9bf8e6..f95375e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 11) -set(CMake_VERSION_PATCH 20180312) +set(CMake_VERSION_PATCH 20180315) #set(CMake_VERSION_RC 1) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index dbd024d..4a9dc47 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -475,7 +475,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) strncpy(bar + curFieldLen + 2, help, width - curFieldLen - 2); if (curFieldLen + helpLen + 2 < width) { memset(bar + curFieldLen + helpLen + 2, ' ', - width - curFieldLen + helpLen + 2); + width - (curFieldLen + helpLen + 2)); } } } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 34c6175..26e0db9 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -580,7 +580,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, if (!targets.empty()) { std::string fname = "/" + std::string(targetName) + "Targets.cmake"; - cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile); + cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile, + testLangs); tcfg.SetExportFile((this->BinaryDirectory + fname).c_str()); tcfg.SetConfig(tcConfig); diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 798f2e6..87648cb 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -18,7 +18,8 @@ cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator( cmGlobalGenerator* gg, const std::vector<std::string>& targets, - cmMakefile* mf) + cmMakefile* mf, std::set<std::string> const& langs) + : Languages(langs.begin(), langs.end()) { gg->CreateImportedGenerationObjects(mf, targets, this->Exports); } @@ -36,12 +37,14 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; + for (std::string const& lang : this->Languages) { #define FIND_TARGETS(PROPERTY) \ - this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps); + this->FindTargets("INTERFACE_" #PROPERTY, te, lang, emittedDeps); - CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS) + CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS) #undef FIND_TARGETS + } this->PopulateProperties(te, properties, emittedDeps); @@ -53,7 +56,7 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) std::string cmExportTryCompileFileGenerator::FindTargets( const std::string& propName, cmGeneratorTarget const* tgt, - std::set<cmGeneratorTarget const*>& emitted) + std::string const& language, std::set<cmGeneratorTarget const*>& emitted) { const char* prop = tgt->GetProperty(propName); if (!prop) { @@ -72,8 +75,9 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); - std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config, - false, &gDummyHead, tgt, &dagChecker); + std::string result = + cge->Evaluate(tgt->GetLocalGenerator(), this->Config, false, &gDummyHead, + tgt, &dagChecker, language); const std::set<cmGeneratorTarget const*>& allTargets = cge->GetAllTargetsSeen(); @@ -97,7 +101,8 @@ void cmExportTryCompileFileGenerator::PopulateProperties( if (p.find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 || p.find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0 || p.find("INTERFACE_LINK_LIBRARIES") == 0) { - std::string evalResult = this->FindTargets(p, target, emitted); + std::string evalResult = + this->FindTargets(p, target, std::string(), emitted); std::vector<std::string> depends; cmSystemTools::ExpandListArgument(evalResult, depends); diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 70c3857..ca2987c 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -21,7 +21,8 @@ class cmExportTryCompileFileGenerator : public cmExportFileGenerator public: cmExportTryCompileFileGenerator(cmGlobalGenerator* gg, std::vector<std::string> const& targets, - cmMakefile* mf); + cmMakefile* mf, + std::set<std::string> const& langs); /** Set the list of targets to export. */ void SetConfig(const std::string& config) { this->Config = config; } @@ -49,10 +50,12 @@ protected: private: std::string FindTargets(const std::string& prop, const cmGeneratorTarget* tgt, + std::string const& language, std::set<const cmGeneratorTarget*>& emitted); std::vector<cmGeneratorTarget const*> Exports; std::string Config; + std::vector<std::string> Languages; }; #endif diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b9e2978..63bfbc6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -387,14 +387,15 @@ static void handleSystemIncludesDep( cmLocalGenerator* lg, cmGeneratorTarget const* depTgt, const std::string& config, cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, - std::vector<std::string>& result, bool excludeImported) + std::vector<std::string>& result, bool excludeImported, + std::string const& language) { if (const char* dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { cmGeneratorExpression ge; cmSystemTools::ExpandListArgument( ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt, - dagChecker), + dagChecker, language), result); } if (!depTgt->IsImported() || excludeImported) { @@ -406,7 +407,7 @@ static void handleSystemIncludesDep( cmGeneratorExpression ge; cmSystemTools::ExpandListArgument( ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt, - dagChecker), + dagChecker, language), result); } } @@ -738,7 +739,8 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } bool cmGeneratorTarget::IsSystemIncludeDirectory( - const std::string& dir, const std::string& config) const + const std::string& dir, const std::string& config, + const std::string& language) const { assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); std::string config_upper; @@ -761,7 +763,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( cmGeneratorExpression ge; cmSystemTools::ExpandListArgument( ge.Parse(it)->Evaluate(this->LocalGenerator, config, false, this, - &dagChecker), + &dagChecker, language), result); } @@ -769,7 +771,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( this->GetLinkImplementationClosure(config); for (cmGeneratorTarget const* dep : deps) { handleSystemIncludesDep(this->LocalGenerator, dep, config, this, - &dagChecker, result, excludeImported); + &dagChecker, result, excludeImported, language); } std::for_each(result.begin(), result.end(), @@ -2622,13 +2624,20 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( return includes; } +enum class OptionsParse +{ + None, + Shell +}; + static void processCompileOptionsInternal( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, std::vector<std::string>& options, std::unordered_set<std::string>& uniqueOptions, cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, - bool debugOptions, const char* logName, std::string const& language) + bool debugOptions, const char* logName, std::string const& language, + OptionsParse parse) { for (cmGeneratorTarget::TargetPropertyEntry* entry : entries) { std::vector<std::string> entryOptions; @@ -2639,7 +2648,12 @@ static void processCompileOptionsInternal( std::string usedOptions; for (std::string const& opt : entryOptions) { if (uniqueOptions.insert(opt).second) { - options.push_back(opt); + if (parse == OptionsParse::Shell && + cmHasLiteralPrefix(opt, "SHELL:")) { + cmSystemTools::ParseUnixCommandLine(opt.c_str() + 6, options); + } else { + options.push_back(opt); + } if (debugOptions) { usedOptions += " * " + opt + "\n"; } @@ -2664,7 +2678,7 @@ static void processCompileOptions( { processCompileOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, config, debugOptions, "options", - language); + language, OptionsParse::Shell); } void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result, @@ -2718,7 +2732,7 @@ static void processCompileFeatures( { processCompileOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, config, debugOptions, "features", - std::string()); + std::string(), OptionsParse::None); } void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result, @@ -2768,7 +2782,7 @@ static void processCompileDefinitions( { processCompileOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, config, debugOptions, - "definitions", language); + "definitions", language, OptionsParse::None); } void cmGeneratorTarget::GetCompileDefinitions( diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1ee8a16..2f6ce33 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -413,7 +413,8 @@ public: const std::string& language) const; bool IsSystemIncludeDirectory(const std::string& dir, - const std::string& config) const; + const std::string& config, + const std::string& language) const; /** Add the target output files to the global generator manifest. */ void ComputeTargetManifest(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7fdf896..f8597af 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2031,7 +2031,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (emitted.insert(frameworkDir).second) { std::string incpath = this->XCodeEscapePath(frameworkDir); if (emitSystemIncludes && - gtgt->IsSystemIncludeDirectory(frameworkDir, configName)) { + gtgt->IsSystemIncludeDirectory(frameworkDir, configName, + langForPreprocessor)) { sysfdirs.Add(incpath); } else { fdirs.Add(incpath); @@ -2040,7 +2041,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, } else { std::string incpath = this->XCodeEscapePath(include); if (emitSystemIncludes && - gtgt->IsSystemIncludeDirectory(include, configName)) { + gtgt->IsSystemIncludeDirectory(include, configName, + langForPreprocessor)) { sysdirs.Add(incpath); } else { dirs.Add(incpath); @@ -2053,7 +2055,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (emitted.insert(fwDir).second) { std::string incpath = this->XCodeEscapePath(fwDir); if (emitSystemIncludes && - gtgt->IsSystemIncludeDirectory(fwDir, configName)) { + gtgt->IsSystemIncludeDirectory(fwDir, configName, + langForPreprocessor)) { sysfdirs.Add(incpath); } else { fdirs.Add(incpath); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 08f3c0f..cee540b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -718,7 +718,7 @@ std::string cmLocalGenerator::GetIncludeFlags( frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); if (emitted.insert(frameworkDir).second) { if (sysFwSearchFlag && target && - target->IsSystemIncludeDirectory(i, config)) { + target->IsSystemIncludeDirectory(i, config, lang)) { includeFlags << sysFwSearchFlag; } else { includeFlags << fwSearchFlag; @@ -731,7 +731,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if (!flagUsed || repeatFlag) { if (sysIncludeFlag && target && - target->IsSystemIncludeDirectory(i, config)) { + target->IsSystemIncludeDirectory(i, config, lang)) { includeFlags << sysIncludeFlag; } else { includeFlags << includeFlag; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index fbfaa40..7c10110 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -725,8 +725,9 @@ static Json::Value DumpSourceFilesList( lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file); for (const auto& include : includes) { - fileData.IncludePathList.push_back(std::make_pair( - include, target->IsSystemIncludeDirectory(include, config))); + fileData.IncludePathList.push_back( + std::make_pair(include, target->IsSystemIncludeDirectory( + include, config, fileData.Language))); } } @@ -1005,7 +1006,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, lg->GetIncludeDirectories(includePathList, target, lang, config, true); for (std::string const& i : includePathList) { ld.IncludePathList.push_back( - std::make_pair(i, target->IsSystemIncludeDirectory(i, config))); + std::make_pair(i, target->IsSystemIncludeDirectory(i, config, lang))); } } diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index 692e0de..c9f1710 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -18,9 +18,21 @@ set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "-DTEST_DEFINE" "-DNEEDS_ESCAPE=\"E$CAPE\"" "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>" + "SHELL:" # produces no options ${c_tests} ${cxx_tests} ) +if(BORLAND OR WATCOM) + # these compilers do not support separate -D flags + target_compile_definitions(CompileOptions PRIVATE NO_DEF_TESTS) +else() + set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS + "SHELL:-D DEF_A" + "$<1:SHELL:-D DEF_B>" + "SHELL:-D 'DEF_C' -D \"DEF_D\"" + [[SHELL:-D "DEF_STR=\"string with spaces\""]] + ) +endif() if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero") set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp index 63a0480..4779b88 100644 --- a/Tests/CompileOptions/main.cpp +++ b/Tests/CompileOptions/main.cpp @@ -12,6 +12,28 @@ #endif #endif +#ifndef NO_DEF_TESTS +#ifndef DEF_A +#error Expected definition DEF_A +#endif + +#ifndef DEF_B +#error Expected definition DEF_B +#endif + +#ifndef DEF_C +#error Expected definition DEF_C +#endif + +#ifndef DEF_D +#error Expected definition DEF_D +#endif + +#ifndef DEF_STR +#error Expected definition DEF_STR +#endif +#endif + #include <string.h> int main() @@ -20,6 +42,9 @@ int main() #ifdef TEST_OCTOTHORPE && strcmp(TEST_OCTOTHORPE, "#") == 0 #endif +#ifndef NO_DEF_TESTS + && strcmp(DEF_STR, "string with spaces") == 0 +#endif && strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0 && strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index 5078f30..20bd601 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -32,7 +32,9 @@ target_link_libraries(consumer upstream config_specific) target_compile_options(consumer PRIVATE -Werror=unused-variable) add_library(iface IMPORTED INTERFACE) -set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only") +set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES + "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only>" + ) add_library(imported_consumer imported_consumer.cpp) target_link_libraries(imported_consumer iface) @@ -1116,8 +1116,10 @@ done rm -f "${TMPFILE}.cxx" if [ -z "${cmake_cxx_compiler}" ]; then -cmake_error 7 "Cannot find a C++ compiler supporting C++11 on this system. +cmake_error 7 "Cannot find a C++ compiler that supports both C++11 and the specified C++ flags. Please specify one using environment variable CXX. +The C++ flags are \"$cmake_cxx_flags\". +They can be changed using the environment variable CXXFLAGS. See cmake_bootstrap.log for compilers attempted." fi echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}" |