diff options
103 files changed, 2263 insertions, 2022 deletions
diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst index 4ed10e1..8b3fb57 100644 --- a/Help/command/add_executable.rst +++ b/Help/command/add_executable.rst @@ -14,7 +14,7 @@ files listed in the command invocation. The ``<name>`` corresponds to the logical target name and must be globally unique within a project. The actual file name of the executable built is constructed based on conventions of the native platform (such as ``<name>.exe`` or just -``<name>``. +``<name>``). By default the executable file will be created in the build tree directory corresponding to the source tree directory in which the diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst index 7e7e6bd..d8a96e9 100644 --- a/Help/command/add_test.rst +++ b/Help/command/add_test.rst @@ -28,6 +28,13 @@ quotes, or other characters special in CMake syntax. The options are: directory set to the build directory corresponding to the current source directory. +The given test command is expected to exit with code ``0`` to pass and +non-zero to fail, or vice-versa if the :prop_test:`WILL_FAIL` test +property is set. Any output written to stdout or stderr will be +captured by :manual:`ctest(1)` but does not affect the pass/fail status +unless the :prop_test:`PASS_REGULAR_EXPRESSION` or +:prop_test:`FAIL_REGULAR_EXPRESSION` test property is used. + The ``COMMAND`` and ``WORKING_DIRECTORY`` options may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. diff --git a/Help/command/file.rst b/Help/command/file.rst index bbddd40..96ac6c7 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -103,7 +103,8 @@ Generate a list of files that match the ``<globbing-expressions>`` and store it into the ``<variable>``. Globbing expressions are similar to regular expressions, but much simpler. If ``RELATIVE`` flag is specified, the results will be returned as relative paths to the given -path. +path. No specific order of results is defined. If order is important then +sort the list explicitly (e.g. using the :command:`list(SORT)` command). By default ``GLOB`` lists directories - directories are omited in result if ``LIST_DIRECTORIES`` is set to false. diff --git a/Help/release/dev/FindFLEX-DEFINES_FILE.rst b/Help/release/dev/FindFLEX-DEFINES_FILE.rst new file mode 100644 index 0000000..95133aa --- /dev/null +++ b/Help/release/dev/FindFLEX-DEFINES_FILE.rst @@ -0,0 +1,6 @@ +FindFLEX-DEFINES_FILE +--------------------- + +* The :module:`FindFLEX` module ``FLEX_TARGET`` macro learned a + new ``DEFINES_FILE`` option to specify a custom output header + to be generated. diff --git a/Help/release/dev/deprecate-CMakeForceCompiler.rst b/Help/release/dev/deprecate-CMakeForceCompiler.rst new file mode 100644 index 0000000..dc6e817 --- /dev/null +++ b/Help/release/dev/deprecate-CMakeForceCompiler.rst @@ -0,0 +1,5 @@ +deprecate-CMakeForceCompiler +---------------------------- + +* The :module:`CMakeForceCompiler` module and its macros are now deprecated. + See module documentation for an explanation. diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index 1d8b110..343ab3f 100644 --- a/Modules/CMakeForceCompiler.cmake +++ b/Modules/CMakeForceCompiler.cmake @@ -2,11 +2,17 @@ # CMakeForceCompiler # ------------------ # +# Deprecated. Do not use. # +# The macros provided by this module were once intended for use by +# cross-compiling toolchain files when CMake was not able to automatically +# detect the compiler identification. Since the introduction of this module, +# CMake's compiler identification capabilities have improved and can now be +# taught to recognize any compiler. Furthermore, the suite of information +# CMake detects from a compiler is now too extensive to be provided by +# toolchain files using these macros. # -# This module defines macros intended for use by cross-compiling -# toolchain files when CMake is not able to automatically detect the -# compiler identification. +# ------------------------------------------------------------------------- # # Macro CMAKE_FORCE_C_COMPILER has the following signature: # @@ -64,6 +70,8 @@ # License text for the above reference.) macro(CMAKE_FORCE_C_COMPILER compiler id) + message(DEPRECATION "The CMAKE_FORCE_C_COMPILER macro is deprecated. " + "Instead just set CMAKE_C_COMPILER and allow CMake to identify the compiler.") set(CMAKE_C_COMPILER "${compiler}") set(CMAKE_C_COMPILER_ID_RUN TRUE) set(CMAKE_C_COMPILER_ID ${id}) @@ -76,6 +84,8 @@ macro(CMAKE_FORCE_C_COMPILER compiler id) endmacro() macro(CMAKE_FORCE_CXX_COMPILER compiler id) + message(DEPRECATION "The CMAKE_FORCE_CXX_COMPILER macro is deprecated. " + "Instead just set CMAKE_CXX_COMPILER and allow CMake to identify the compiler.") set(CMAKE_CXX_COMPILER "${compiler}") set(CMAKE_CXX_COMPILER_ID_RUN TRUE) set(CMAKE_CXX_COMPILER_ID ${id}) @@ -88,6 +98,8 @@ macro(CMAKE_FORCE_CXX_COMPILER compiler id) endmacro() macro(CMAKE_FORCE_Fortran_COMPILER compiler id) + message(DEPRECATION "The CMAKE_FORCE_Fortran_COMPILER macro is deprecated. " + "Instead just set CMAKE_Fortran_COMPILER and allow CMake to identify the compiler.") set(CMAKE_Fortran_COMPILER "${compiler}") set(CMAKE_Fortran_COMPILER_ID_RUN TRUE) set(CMAKE_Fortran_COMPILER_ID ${id}) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index c837c52..ca66493 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -27,13 +27,17 @@ # # :: # -# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>]) +# FLEX_TARGET(Name FlexInput FlexOutput +# [COMPILE_FLAGS <string>] +# [DEFINES_FILE <string>] +# ) # # which creates a custom command to generate the <FlexOutput> file from # the <FlexInput> file. If COMPILE_FLAGS option is specified, the next -# parameter is added to the flex command line. Name is an alias used to -# get details of this custom command. Indeed the macro defines the -# following variables: +# parameter is added to the flex command line. If flex is configured to +# output a header file, the DEFINES_FILE option may be used to specify its +# name. Name is an alias used to get details of this custom command. +# Indeed the macro defines the following variables: # # :: # @@ -41,6 +45,7 @@ # FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an # alias for FlexOutput # FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput} +# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any. # # # @@ -113,6 +118,8 @@ find_path(FLEX_INCLUDE_DIR FlexLexer.h mark_as_advanced(FL_LIBRARY FLEX_INCLUDE_DIR) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) + set(FLEX_INCLUDE_DIRS ${FLEX_INCLUDE_DIR}) set(FLEX_LIBRARIES ${FL_LIBRARY}) @@ -145,31 +152,55 @@ if(FLEX_EXECUTABLE) #============================================================ # macro(FLEX_TARGET Name Input Output) - set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]") - if(${ARGC} GREATER 3) - if(${ARGC} EQUAL 5) - if("${ARGV3}" STREQUAL "COMPILE_FLAGS") - set(FLEX_EXECUTABLE_opts "${ARGV4}") - separate_arguments(FLEX_EXECUTABLE_opts) - else() - message(SEND_ERROR ${FLEX_TARGET_usage}) - endif() + set(FLEX_TARGET_outputs "${Output}") + set(FLEX_EXECUTABLE_opts "") + + set(FLEX_TARGET_PARAM_OPTIONS) + set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS + COMPILE_FLAGS + DEFINES_FILE + ) + set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS) + + cmake_parse_arguments( + FLEX_TARGET_ARG + "${FLEX_TARGET_PARAM_OPTIONS}" + "${FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS}" + "${FLEX_TARGET_MULTI_VALUE_KEYWORDS}" + ${ARGN} + ) + + set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>] [DEFINES_FILE <string>]") + + if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "") + message(SEND_ERROR ${FLEX_TARGET_usage}) + else() + if(NOT "${FLEX_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "") + set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}") + separate_arguments(FLEX_EXECUTABLE_opts) + endif() + if(NOT "${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "") + list(APPEND FLEX_TARGET_outputs "${FLEX_TARGET_ARG_DEFINES_FILE}") + list(APPEND FLEX_EXECUTABLE_opts --header-file=${FLEX_TARGET_ARG_DEFINES_FILE}) + endif() + + add_custom_command(OUTPUT ${FLEX_TARGET_outputs} + COMMAND ${FLEX_EXECUTABLE} + ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input} + DEPENDS ${Input} + COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + + set(FLEX_${Name}_DEFINED TRUE) + set(FLEX_${Name}_OUTPUTS ${Output}) + set(FLEX_${Name}_INPUT ${Input}) + set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts}) + if("${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "") + set(FLEX_${Name}_OUTPUT_HEADER "") else() - message(SEND_ERROR ${FLEX_TARGET_usage}) + set(FLEX_${Name}_OUTPUT_HEADER ${FLEX_TARGET_ARG_DEFINES_FILE}) endif() endif() - - add_custom_command(OUTPUT ${Output} - COMMAND ${FLEX_EXECUTABLE} - ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input} - DEPENDS ${Input} - COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - - set(FLEX_${Name}_DEFINED TRUE) - set(FLEX_${Name}_OUTPUTS ${Output}) - set(FLEX_${Name}_INPUT ${Input}) - set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts}) endmacro() #============================================================ @@ -181,11 +212,11 @@ if(FLEX_EXECUTABLE) macro(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget) if(NOT FLEX_${FlexTarget}_OUTPUTS) - message(SEND_ERROR "Flex target `${FlexTarget}' does not exists.") + message(SEND_ERROR "Flex target `${FlexTarget}' does not exist.") endif() if(NOT BISON_${BisonTarget}_OUTPUT_HEADER) - message(SEND_ERROR "Bison target `${BisonTarget}' does not exists.") + message(SEND_ERROR "Bison target `${BisonTarget}' does not exist.") endif() set_source_files_properties(${FLEX_${FlexTarget}_OUTPUTS} diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index b421b0d..a61413a 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -302,6 +302,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) + set(CMAKE_NINJA_DEPTYPE_${lang} msvc) if(NOT CMAKE_RC_COMPILER_INIT) set(CMAKE_RC_COMPILER_INIT rc) @@ -311,4 +312,5 @@ macro(__windows_compiler_msvc lang) endif() enable_language(RC) + set(CMAKE_NINJA_CMCLDEPS_RC 1) endmacro() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ee690e6..fd71b0e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -299,8 +299,6 @@ set(SRCS cmLocalUnixMakefileGenerator3.cxx cmLocale.h ${MACH_SRCS} - cmMakeDepend.cxx - cmMakeDepend.h cmMakefile.cxx cmMakefile.h cmMakefileTargetGenerator.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index bad0f37..a5f01d3 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 4) -set(CMake_VERSION_PATCH 20151017) +set(CMake_VERSION_PATCH 20151026) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 93c94e2..04efb71 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -570,7 +570,7 @@ int cmCPackDebGenerator::createDeb() return 0; } cmArchiveWrite control_tar(fileStream_control_tar, - tar_compression_type, + cmArchiveWrite::CompressGZip, "paxr"); // sets permissions and uid/gid for the files diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 4832186..7c7f5df 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -198,6 +198,10 @@ void cmCTestMultiProcessHandler::UnlockResources(int index) { this->LockedResources.erase(*i); } + if (this->Properties[index]->RunSerial) + { + this->SerialTestRunning = false; + } } //--------------------------------------------------------- @@ -451,11 +455,6 @@ bool cmCTestMultiProcessHandler::CheckOutput() this->WriteCheckpoint(test); this->UnlockResources(test); this->RunningCount -= GetProcessorsUsed(test); - if (this->Properties[test]->RunSerial) - { - this->SerialTestRunning = false; - } - delete p; } return true; diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 96fcc90..6920faf 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -109,7 +109,7 @@ std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const { std::string mod_dir; const char* target_mod_dir = - this->Target->GetProperty("Fortran_MODULE_DIRECTORY"); + this->GeneratorTarget->GetProperty("Fortran_MODULE_DIRECTORY"); const char* moddir_flag = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); if(target_mod_dir && moddir_flag) @@ -214,7 +214,7 @@ cmCommonTargetGenerator this->LocalGenerator->GetFortranFormat(srcfmt); if(format == cmLocalGenerator::FortranFormatNone) { - const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT"); + const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT"); format = this->LocalGenerator->GetFortranFormat(tgtfmt); } const char* var = 0; @@ -265,7 +265,7 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) { - if(this->Target->NameResolvesToFramework(*i)) + if(this->GlobalGenerator->NameResolvesToFramework(*i)) { std::string frameworkDir = *i; frameworkDir += "/../"; @@ -316,10 +316,11 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l) this->AddFortranFlags(flags); } - this->LocalGenerator->AddCMP0018Flags(flags, this->Target, + this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang, this->ConfigName); - this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, + this->LocalGenerator->AddVisibilityPresetFlags(flags, + this->GeneratorTarget, lang); // Append old-style preprocessor definition flags. @@ -331,7 +332,7 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l) AppendFlags(flags,this->GetFrameworkFlags(l)); // Add target-specific flags. - this->LocalGenerator->AddCompileOptions(flags, this->Target, + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang, this->ConfigName); ByLanguageMap::value_type entry(l, flags); @@ -348,13 +349,14 @@ std::string cmCommonTargetGenerator::GetDefines(const std::string &l) std::set<std::string> defines; const char *lang = l.c_str(); // Add the export symbol definition for shared library objects. - if(const char* exportMacro = this->Target->GetExportMacro()) + if(const char* exportMacro = + this->GeneratorTarget->GetExportMacro()) { this->LocalGenerator->AppendDefines(defines, exportMacro); } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AddCompileDefinitions(defines, this->Target, + this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget, this->LocalGenerator->GetConfigName(), l); std::string definesString; @@ -400,8 +402,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const && emitted.insert(linkee).second) { cmLocalGenerator* lg = linkee->GetLocalGenerator(); - cmMakefile* mf = linkee->Target->GetMakefile(); - std::string di = mf->GetCurrentBinaryDirectory(); + std::string di = lg->GetCurrentBinaryDirectory(); di += "/"; di += lg->GetTargetDirectory(linkee); dirs.push_back(di); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 465db92..13098ad 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -185,7 +185,9 @@ cmComputeLinkDepends // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->Target->ComputeLinkType(this->Config); + std::vector<std::string> debugConfigs = + this->Makefile->GetCMakeInstance()->GetDebugConfigs(); + this->LinkType = CMP0003_ComputeLinkType(this->Config, debugConfigs); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 7bdc555..a32bb48 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -407,7 +407,7 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link @@ -571,7 +571,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } return true; @@ -635,7 +635,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, { // Compute the proper name to use to link this library. const std::string& config = this->Config; - bool impexe = (tgt && tgt->Target->IsExecutableWithExports()); + bool impexe = (tgt && tgt->IsExecutableWithExports()); if(impexe && !this->UseImportLibrary && !this->LoaderFlag) { // Skip linking to executables on platforms with no import @@ -643,7 +643,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, return; } - if(tgt && tgt->Target->IsLinkable()) + if(tgt && tgt->IsLinkable()) { // This is a CMake target. Ask the target for its real name. if(impexe && this->LoaderFlag) @@ -1111,7 +1111,7 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item, // For compatibility with CMake 2.4 include the item's directory in // the linker search path. - if(this->OldLinkDirMode && !target->Target->IsFrameworkOnApple() && + if(this->OldLinkDirMode && !target->IsFrameworkOnApple() && this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) == this->OldLinkDirMask.end()) { @@ -1140,7 +1140,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1221,7 +1221,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->Target->GetPolicyStatusCMP0060()) + switch (this->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1531,7 +1531,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->Target->GetPolicyStatusCMP0008()) + switch(this->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1548,7 +1548,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1566,7 +1566,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } break; } @@ -1583,7 +1583,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->Target->GetPolicyStatusCMP0003()) + switch(this->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1594,7 +1594,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1610,7 +1610,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); return false; } } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index f6de2ab..03f4fdd 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -245,7 +245,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) ->IssueMessage(cmake::FATAL_ERROR, "Only executables and non-OBJECT libraries may " "reference target objects.", - depender->Target->GetBacktrace()); + depender->GetBacktrace()); return; } const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib); @@ -325,7 +325,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, // within the project. if(dependee && dependee->GetType() == cmState::EXECUTABLE && - !dependee->Target->IsExecutableWithExports()) + !dependee->IsExecutableWithExports()) { dependee = 0; } @@ -362,7 +362,7 @@ void cmComputeTargetDepends::AddTargetDepend( cmake::MessageType messageType = cmake::AUTHOR_WARNING; bool issueMessage = false; std::ostringstream e; - switch(depender->Target->GetPolicyStatusCMP0046()) + switch(depender->GetPolicyStatusCMP0046()) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0046) << "\n"; @@ -401,7 +401,7 @@ void cmComputeTargetDepends::AddTargetDepend( // within the project. if(linking && dependee && dependee->GetType() == cmState::EXECUTABLE && - !dependee->Target->IsExecutableWithExports()) + !dependee->IsExecutableWithExports()) { dependee = 0; } @@ -417,7 +417,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, const cmGeneratorTarget* dependee, bool linking) { - if(dependee->Target->IsImported() || + if(dependee->IsImported() || dependee->GetType() == cmState::INTERFACE_LIBRARY) { // Skip IMPORTED and INTERFACE targets but follow their utility diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 7874803..5330acd 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -11,9 +11,14 @@ ============================================================================*/ #include "cmConditionEvaluator.h" +#include "cmOutputConverter.h" -cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile): +cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile, + const cmListFileContext &context, + const cmListFileBacktrace& bt): Makefile(makefile), + ExecutionContext(context), + Backtrace(bt), Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)), Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)), Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)), @@ -98,6 +103,25 @@ bool cmConditionEvaluator::IsTrue( errorString, status, true); } +cmListFileContext cmConditionEvaluator::GetConditionContext( + cmMakefile* mf, + const cmCommandContext& command, + const std::string& filePath) +{ + cmListFileContext context = + cmListFileContext::FromCommandContext( + command, + filePath); + + if(!mf->GetCMakeInstance()->GetIsInTryCompile()) + { + cmOutputConverter converter(mf->GetStateSnapshot()); + context.FilePath = converter.Convert(context.FilePath, + cmOutputConverter::HOME); + } + return context; +} + //========================================================================= const char* cmConditionEvaluator::GetDefinitionIfUnquoted( cmExpandedCommandArgument const& argument) const @@ -113,7 +137,8 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted( if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN) { - if(!this->Makefile.HasCMP0054AlreadyBeenReported()) + if(!this->Makefile.HasCMP0054AlreadyBeenReported( + this->ExecutionContext)) { std::ostringstream e; e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n"; @@ -122,7 +147,9 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted( "when the policy is set to NEW. " "Since the policy is not set the OLD behavior will be used."; - this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str()); + this->Makefile.GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, e.str(), + this->Backtrace); } } @@ -159,7 +186,8 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword, if(isKeyword && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN) { - if(!this->Makefile.HasCMP0054AlreadyBeenReported()) + if(!this->Makefile.HasCMP0054AlreadyBeenReported( + this->ExecutionContext)) { std::ostringstream e; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n"; @@ -168,7 +196,9 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword, "when the policy is set to NEW. " "Since the policy is not set the OLD behavior will be used."; - this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str()); + this->Makefile.GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, e.str(), + this->Backtrace); } } diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index c4e2d11..8600825 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -22,7 +22,9 @@ class cmConditionEvaluator public: typedef std::list<cmExpandedCommandArgument> cmArgumentList; - cmConditionEvaluator(cmMakefile& makefile); + cmConditionEvaluator(cmMakefile& makefile, + cmListFileContext const& context, + cmListFileBacktrace const& bt); // this is a shared function for both If and Else to determine if the // arguments were valid, and if so, was the response true. If there is @@ -31,6 +33,9 @@ public: std::string &errorString, cmake::MessageType &status); + static cmListFileContext GetConditionContext(cmMakefile* mf, + const cmCommandContext& command, std::string const& filePath); + private: // Filter the given variable definition based on policy CMP0054. const char* GetDefinitionIfUnquoted( @@ -91,6 +96,8 @@ private: cmake::MessageType &status); cmMakefile& Makefile; + cmListFileContext ExecutionContext; + cmListFileBacktrace Backtrace; cmPolicies::PolicyStatus Policy12Status; cmPolicies::PolicyStatus Policy54Status; cmPolicies::PolicyStatus Policy57Status; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 5bb0f99..4a1f770 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -34,7 +34,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::string outputVariable; std::string copyFile; std::string copyFileError; - std::vector<cmTarget const*> targets; + std::vector<std::string> targets; std::string libsToLink = " "; bool useOldLinkLibs = true; char targetNameBuf[64]; @@ -112,7 +112,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) } if (tgt->IsImported()) { - targets.push_back(tgt); + targets.push_back(argv[i]); } } } @@ -375,9 +375,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (!targets.empty()) { std::string fname = "/" + std::string(targetName) + "Targets.cmake"; - cmExportTryCompileFileGenerator tcfg(gg); + cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile); tcfg.SetExportFile((this->BinaryDirectory + fname).c_str()); - tcfg.SetExports(targets); tcfg.SetConfig(this->Makefile->GetSafeDefinition( "CMAKE_TRY_COMPILE_CONFIGURATION")); diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 8f7b480..dc06678 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -45,7 +45,7 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0); if(target && target->GetType() == cmState::EXECUTABLE && - (target->Target->IsImported() + (target->IsImported() || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) { return target->GetLocation(this->Config); diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 2d74b97..23c11d7 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,10 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg) { this->LG = lg; + if (this->ExportSet) + { + this->ExportSet->Compute(lg); + } } //---------------------------------------------------------------------------- @@ -44,9 +48,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { cmGeneratorTarget *te = this->LG ->FindGeneratorTargetToUse(*tei); - expectedTargets += sep + this->Namespace + te->Target->GetExportName(); + expectedTargets += sep + this->Namespace + te->GetExportName(); sep = " "; - if(this->ExportedTargets.insert(te->Target).second) + if(this->ExportedTargets.insert(te).second) { this->Exports.push_back(te); } @@ -76,45 +80,44 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei != this->Exports.end(); ++tei) { cmGeneratorTarget* gte = *tei; - cmTarget* te = gte->Target; - this->GenerateImportTargetCode(os, te); + this->GenerateImportTargetCode(os, gte); - te->AppendBuildInterfaceIncludes(); + gte->Target->AppendBuildInterfaceIncludes(); ImportPropertyMap properties; - this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", te, + this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_SOURCES", te, + this->PopulateInterfaceProperty("INTERFACE_SOURCES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te, + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); - this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te, + this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", - te, properties); + gte, properties); const bool newCMP0022Behavior = - te->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->GetPolicyStatusCMP0022() != cmPolicies::OLD; + gte->GetPolicyStatusCMP0022() != cmPolicies::WARN + && gte->GetPolicyStatusCMP0022() != cmPolicies::OLD; if (newCMP0022Behavior) { - this->PopulateInterfaceLinkLibrariesProperty(te, + this->PopulateInterfaceLinkLibrariesProperty(gte, cmGeneratorExpression::BuildInterface, properties, missingTargets); } this->PopulateCompatibleInterfaceProperties(gte, properties); - this->GenerateInterfaceProperties(te, os, properties); + this->GenerateInterfaceProperties(gte, os, properties); } // Generate import file content for each configuration. @@ -171,7 +174,7 @@ cmExportBuildFileGenerator // properties); // Generate code in the export file. - this->GenerateImportPropertyCode(os, config, target->Target, + this->GenerateImportPropertyCode(os, config, target, properties); } } @@ -199,7 +202,7 @@ cmExportBuildFileGenerator std::string prop = "IMPORTED_LOCATION"; prop += suffix; std::string value; - if(target->Target->IsAppBundleOnApple()) + if(target->IsAppBundleOnApple()) { value = target->GetFullPath(config, false); } @@ -217,7 +220,7 @@ cmExportBuildFileGenerator // Add the import library for windows DLLs. if(dll_platform && (target->GetType() == cmState::SHARED_LIBRARY || - target->Target->IsExecutableWithExports()) && + target->IsExecutableWithExports()) && mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { std::string prop = "IMPORTED_IMPLIB"; @@ -232,14 +235,18 @@ cmExportBuildFileGenerator //---------------------------------------------------------------------------- void cmExportBuildFileGenerator::HandleMissingTarget( - std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, cmTarget* depender, cmTarget* dependee) + std::string& link_libs, + std::vector<std::string>& missingTargets, + cmGeneratorTarget* depender, + cmGeneratorTarget* dependee) { // The target is not in the export. if(!this->AppendMode) { const std::string name = dependee->GetName(); - std::vector<std::string> namespaces = this->FindNamespaces(mf, name); + cmGlobalGenerator* gg = + dependee->GetLocalGenerator()->GetGlobalGenerator(); + std::vector<std::string> namespaces = this->FindNamespaces(gg, name); int targetOccurrences = (int)namespaces.size(); if (targetOccurrences == 1) @@ -274,7 +281,7 @@ void cmExportBuildFileGenerator tei = this->ExportSet->GetTargetExports()->begin(); tei != this->ExportSet->GetTargetExports()->end(); ++tei) { - targets.push_back((*tei)->Target->GetName()); + targets.push_back((*tei)->TargetName); } return; } @@ -284,10 +291,9 @@ void cmExportBuildFileGenerator //---------------------------------------------------------------------------- std::vector<std::string> cmExportBuildFileGenerator -::FindNamespaces(cmMakefile* mf, const std::string& name) +::FindNamespaces(cmGlobalGenerator* gg, const std::string& name) { std::vector<std::string> namespaces; - cmGlobalGenerator* gg = mf->GetGlobalGenerator(); std::map<std::string, cmExportBuildFileGenerator*>& exportSets = gg->GetBuildExportSets(); @@ -310,8 +316,8 @@ cmExportBuildFileGenerator //---------------------------------------------------------------------------- void cmExportBuildFileGenerator -::ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee, +::ComplainAboutMissingTarget(cmGeneratorTarget* depender, + cmGeneratorTarget* dependee, int occurrences) { if(cmSystemTools::GetErrorOccuredFlag()) diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 16695f1..85aae2f 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -54,12 +54,11 @@ protected: std::vector<std::string> &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, - cmTarget* depender, - cmTarget* dependee); + cmGeneratorTarget* depender, + cmGeneratorTarget* dependee); - void ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee, + void ComplainAboutMissingTarget(cmGeneratorTarget* depender, + cmGeneratorTarget* dependee, int occurrences); /** Fill in properties indicating built file locations. */ @@ -72,7 +71,7 @@ protected: const std::string& config); std::vector<std::string> - FindNamespaces(cmMakefile* mf, const std::string& name); + FindNamespaces(cmGlobalGenerator* gg, const std::string& name); std::vector<std::string> Targets; cmExportSet *ExportSet; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 6127626..1a84625 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -18,7 +18,6 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" -#include "cmTarget.h" #include "cmTargetExport.h" #include "cmVersion.h" #include "cmComputeLinkInformation.h" @@ -155,7 +154,7 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, - cmTarget *target, + cmGeneratorTarget *target, ImportPropertyMap &properties) { const char *input = target->GetProperty(propName); @@ -169,7 +168,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty( void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, const std::string& outputName, - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector<std::string> &missingTargets) @@ -206,7 +205,7 @@ void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os, //---------------------------------------------------------------------------- bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector<std::string> &missingTargets) @@ -271,7 +270,7 @@ static bool checkInterfaceDirs(const std::string &prepro, { if (prop == "INTERFACE_INCLUDE_DIRECTORIES") { - switch (target->Target->GetPolicyStatusCMP0041()) + switch (target->GetPolicyStatusCMP0041()) { case cmPolicies::WARN: messageType = cmake::WARNING; @@ -318,7 +317,7 @@ static bool checkInterfaceDirs(const std::string &prepro, { if (!shouldContinue) { - switch(target->Target->GetPolicyStatusCMP0052()) + switch(target->GetPolicyStatusCMP0052()) { case cmPolicies::WARN: { @@ -398,11 +397,11 @@ void cmExportFileGenerator::PopulateSourcesInterface( ImportPropertyMap &properties, std::vector<std::string> &missingTargets) { - cmTarget *target = tei->Target; + cmGeneratorTarget* gt = tei->Target; assert(preprocessRule == cmGeneratorExpression::InstallInterface); const char *propName = "INTERFACE_SOURCES"; - const char *input = target->GetProperty(propName); + const char *input = gt->GetProperty(propName); if (!input) { @@ -420,11 +419,9 @@ void cmExportFileGenerator::PopulateSourcesInterface( true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, + this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets); - cmGeneratorTarget* gt = target->GetMakefile() - ->GetGlobalGenerator()->GetGeneratorTarget(target); if (!checkInterfaceDirs(prepro, gt, propName)) { return; @@ -440,9 +437,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( ImportPropertyMap &properties, std::vector<std::string> &missingTargets) { - cmGeneratorTarget *target = tei->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tei->Target); + cmGeneratorTarget *target = tei->Target; assert(preprocessRule == cmGeneratorExpression::InstallInterface); const char *propName = "INTERFACE_INCLUDE_DIRECTORIES"; @@ -492,7 +487,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, + this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets); if (!checkInterfaceDirs(prepro, target, propName)) @@ -506,7 +501,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, - cmTarget *target, + cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, std::vector<std::string> &missingTargets) @@ -578,15 +573,14 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { - cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN", - target, properties); + gtarget, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX", - target, properties); + gtarget, properties); std::set<std::string> ifaceProperties; @@ -597,12 +591,12 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX", ifaceProperties); - if (target->GetType() != cmState::INTERFACE_LIBRARY) + if (gtarget->GetType() != cmState::INTERFACE_LIBRARY) { getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector<std::string> configNames; - target->GetMakefile()->GetConfigurations(configNames); + gtarget->Target->GetMakefile()->GetConfigurations(configNames); for (std::vector<std::string>::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) @@ -615,12 +609,13 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( it != ifaceProperties.end(); ++it) { this->PopulateInterfaceProperty("INTERFACE_" + *it, - target, properties); + gtarget, properties); } } //---------------------------------------------------------------------------- -void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, +void cmExportFileGenerator::GenerateInterfaceProperties( + const cmGeneratorTarget* target, std::ostream& os, const ImportPropertyMap &properties) { @@ -642,12 +637,12 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, //---------------------------------------------------------------------------- bool cmExportFileGenerator::AddTargetNamespace(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets) { - cmMakefile *mf = target->GetMakefile(); + cmLocalGenerator *lg = target->GetLocalGenerator(); - cmTarget *tgt = mf->FindTargetToUse(input); + cmGeneratorTarget *tgt = lg->FindGeneratorTargetToUse(input); if (!tgt) { return false; @@ -665,7 +660,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, { std::string namespacedTarget; this->HandleMissingTarget(namespacedTarget, missingTargets, - mf, target, tgt); + target, tgt); if (!namespacedTarget.empty()) { input = namespacedTarget; @@ -678,7 +673,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets, FreeTargetsReplace replace) { @@ -715,14 +710,12 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets) { std::string::size_type pos = 0; std::string::size_type lastPos = pos; - cmMakefile *mf = target->GetMakefile(); - while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos) { std::string::size_type nameStartPos = pos + @@ -783,7 +776,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( if (!errorString.empty()) { - mf->IssueMessage(cmake::FATAL_ERROR, errorString); + target->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, errorString); } } @@ -837,10 +830,8 @@ cmExportFileGenerator } const bool newCMP0022Behavior = - target->Target - ->GetPolicyStatusCMP0022() != cmPolicies::WARN - && target->Target - ->GetPolicyStatusCMP0022() != cmPolicies::OLD; + target->GetPolicyStatusCMP0022() != cmPolicies::WARN + && target->GetPolicyStatusCMP0022() != cmPolicies::OLD; if(newCMP0022Behavior && !this->ExportOld) { @@ -864,7 +855,7 @@ cmExportFileGenerator preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, + this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets, ReplaceFreeTargets); properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; @@ -966,7 +957,7 @@ cmExportFileGenerator sep = ";"; std::string temp = *li; - this->AddTargetNamespace(temp, target->Target, missingTargets); + this->AddTargetNamespace(temp, target, missingTargets); link_entries += temp; } @@ -1048,7 +1039,7 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportTargetCode(std::ostream& os, cmTarget const* target) +::GenerateImportTargetCode(std::ostream& os, const cmGeneratorTarget* target) { // Construct the imported target name. std::string targetName = this->Namespace; @@ -1114,7 +1105,7 @@ cmExportFileGenerator void cmExportFileGenerator ::GenerateImportPropertyCode(std::ostream& os, const std::string& config, - cmTarget const* target, + cmGeneratorTarget const* target, ImportPropertyMap const& properties) { // Construct the imported target name. @@ -1234,7 +1225,7 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, +::GenerateImportedFileChecksCode(std::ostream& os, cmGeneratorTarget* target, ImportPropertyMap const& properties, const std::set<std::string>& importedLocations) { diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 44f779b..18f0b00 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -75,11 +75,13 @@ protected: const std::string& config = ""); void GenerateImportFooterCode(std::ostream& os); void GenerateImportVersionCode(std::ostream& os); - void GenerateImportTargetCode(std::ostream& os, cmTarget const* target); + void GenerateImportTargetCode(std::ostream& os, + cmGeneratorTarget const* target); void GenerateImportPropertyCode(std::ostream& os, const std::string& config, - cmTarget const* target, + cmGeneratorTarget const* target, ImportPropertyMap const& properties); - void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, + void GenerateImportedFileChecksCode(std::ostream& os, + cmGeneratorTarget* target, ImportPropertyMap const& properties, const std::set<std::string>& importedLocations); void GenerateImportedFileCheckLoop(std::ostream& os); @@ -118,23 +120,24 @@ protected: * export set. */ virtual void HandleMissingTarget(std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, - cmTarget* depender, - cmTarget* dependee) = 0; + cmGeneratorTarget* depender, + cmGeneratorTarget* dependee) = 0; void PopulateInterfaceProperty(const std::string&, - cmTarget *target, + cmGeneratorTarget *target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); - bool PopulateInterfaceLinkLibrariesProperty(cmTarget *target, + bool PopulateInterfaceLinkLibrariesProperty(cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); - void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, + void PopulateInterfaceProperty(const std::string& propName, + cmGeneratorTarget* target, ImportPropertyMap &properties); void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); - void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, + void GenerateInterfaceProperties(cmGeneratorTarget const* target, + std::ostream& os, const ImportPropertyMap &properties); void PopulateIncludeDirectoriesInterface( cmTargetExport *target, @@ -159,7 +162,7 @@ protected: }; void ResolveTargetsInGeneratorExpressions(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets, FreeTargetsReplace replace = NoReplaceFreeTargets); @@ -182,20 +185,20 @@ protected: bool AppendMode; // The set of targets included in the export. - std::set<cmTarget*> ExportedTargets; + std::set<cmGeneratorTarget*> ExportedTargets; private: void PopulateInterfaceProperty(const std::string&, const std::string&, - cmTarget *target, + cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); - bool AddTargetNamespace(std::string &input, cmTarget* target, + bool AddTargetNamespace(std::string &input, cmGeneratorTarget* target, std::vector<std::string> &missingTargets); void ResolveTargetsInGeneratorExpression(std::string &input, - cmTarget* target, + cmGeneratorTarget* target, std::vector<std::string> &missingTargets); virtual void ReplaceInstallPrefix(std::string &input); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 5a51442..b695904 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -48,7 +48,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) { - expectedTargets += sep + this->Namespace + (*tei)->Target->GetExportName(); + expectedTargets += + sep + this->Namespace + (*tei)->Target->GetExportName(); sep = " "; cmTargetExport * te = *tei; if(this->ExportedTargets.insert(te->Target).second) @@ -131,12 +132,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) tei = allTargets.begin(); tei != allTargets.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gt = (*tei)->Target; requiresConfigFiles = requiresConfigFiles - || te->GetType() != cmState::INTERFACE_LIBRARY; + || gt->GetType() != cmState::INTERFACE_LIBRARY; - this->GenerateImportTargetCode(os, te); + this->GenerateImportTargetCode(os, gt); ImportPropertyMap properties; @@ -147,32 +148,32 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", - te, + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); const bool newCMP0022Behavior = - te->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->GetPolicyStatusCMP0022() != cmPolicies::OLD; + gt->GetPolicyStatusCMP0022() != cmPolicies::WARN + && gt->GetPolicyStatusCMP0022() != cmPolicies::OLD; if (newCMP0022Behavior) { - if (this->PopulateInterfaceLinkLibrariesProperty(te, + if (this->PopulateInterfaceLinkLibrariesProperty(gt, cmGeneratorExpression::InstallInterface, properties, missingTargets) && !this->ExportOld) @@ -180,11 +181,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) require2_8_12 = true; } } - if (te->GetType() == cmState::INTERFACE_LIBRARY) + if (gt->GetType() == cmState::INTERFACE_LIBRARY) { require3_0_0 = true; } - if(te->GetProperty("INTERFACE_SOURCES")) + if(gt->GetProperty("INTERFACE_SOURCES")) { // We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1 // can consume them. @@ -192,14 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) } this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", - te, properties); - cmGeneratorTarget *gtgt = te->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(te); + gt, properties); - this->PopulateCompatibleInterfaceProperties(gtgt, properties); + this->PopulateCompatibleInterfaceProperties(gt, properties); - this->GenerateInterfaceProperties(te, os, properties); + this->GenerateInterfaceProperties(gt, os, properties); } if (require3_1_0) @@ -362,8 +360,7 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - cmGeneratorTarget *gtgt = te->Target->GetMakefile() - ->GetGlobalGenerator()->GetGeneratorTarget(te->Target); + cmGeneratorTarget *gtgt = te->Target; this->SetImportDetailProperties(config, suffix, gtgt, properties, missingTargets); @@ -378,8 +375,8 @@ cmExportInstallFileGenerator // properties); // Generate code in the export file. - this->GenerateImportPropertyCode(os, config, te->Target, properties); - this->GenerateImportedFileChecksCode(os, te->Target, properties, + this->GenerateImportPropertyCode(os, config, gtgt, properties); + this->GenerateImportedFileChecksCode(os, gtgt, properties, importedLocations); } } @@ -402,7 +399,7 @@ cmExportInstallFileGenerator } // Get the target to be installed. - cmTarget* target = itgen->GetTarget()->Target; + cmGeneratorTarget* target = itgen->GetTarget(); // Construct the installed location of the target. std::string dest = itgen->GetDestination(config); @@ -456,12 +453,13 @@ cmExportInstallFileGenerator //---------------------------------------------------------------------------- void -cmExportInstallFileGenerator::HandleMissingTarget( - std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, cmTarget* depender, cmTarget* dependee) +cmExportInstallFileGenerator::HandleMissingTarget(std::string& link_libs, + std::vector<std::string>& missingTargets, + cmGeneratorTarget* depender, cmGeneratorTarget* dependee) { const std::string name = dependee->GetName(); - std::vector<std::string> namespaces = this->FindNamespaces(mf, name); + cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator(); + std::vector<std::string> namespaces = this->FindNamespaces(gg, name); int targetOccurrences = (int)namespaces.size(); if (targetOccurrences == 1) { @@ -482,10 +480,9 @@ cmExportInstallFileGenerator::HandleMissingTarget( //---------------------------------------------------------------------------- std::vector<std::string> cmExportInstallFileGenerator -::FindNamespaces(cmMakefile* mf, const std::string& name) +::FindNamespaces(cmGlobalGenerator* gg, const std::string& name) { std::vector<std::string> namespaces; - cmGlobalGenerator* gg = mf->GetGlobalGenerator(); const cmExportSetMap& exportSets = gg->GetExportSets(); for(cmExportSetMap::const_iterator expIt = exportSets.begin(); @@ -523,8 +520,8 @@ cmExportInstallFileGenerator //---------------------------------------------------------------------------- void cmExportInstallFileGenerator -::ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee, +::ComplainAboutMissingTarget(cmGeneratorTarget* depender, + cmGeneratorTarget* dependee, int occurrences) { std::ostringstream e; diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index b06fee5..13dae89 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -57,17 +57,16 @@ protected: std::vector<std::string> &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, std::vector<std::string>& missingTargets, - cmMakefile* mf, - cmTarget* depender, - cmTarget* dependee); + cmGeneratorTarget* depender, + cmGeneratorTarget* dependee); virtual void ReplaceInstallPrefix(std::string &input); - void ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee, + void ComplainAboutMissingTarget(cmGeneratorTarget* depender, + cmGeneratorTarget* dependee, int occurrences); - std::vector<std::string> FindNamespaces(cmMakefile* mf, + std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg, const std::string& name); diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx index 4148fb5..0059b64 100644 --- a/Source/cmExportSet.cxx +++ b/Source/cmExportSet.cxx @@ -13,12 +13,22 @@ #include "cmExportSet.h" #include "cmTargetExport.h" #include "cmAlgorithms.h" +#include "cmLocalGenerator.h" cmExportSet::~cmExportSet() { cmDeleteAll(this->TargetExports); } +void cmExportSet::Compute(cmLocalGenerator* lg) +{ + for (std::vector<cmTargetExport*>::iterator it = this->TargetExports.begin(); + it != this->TargetExports.end(); ++it) + { + (*it)->Target = lg->FindGeneratorTargetToUse((*it)->TargetName); + } +} + void cmExportSet::AddTargetExport(cmTargetExport* te) { this->TargetExports.push_back(te); diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h index a57aa12..d780a22 100644 --- a/Source/cmExportSet.h +++ b/Source/cmExportSet.h @@ -15,6 +15,7 @@ #include "cmSystemTools.h" class cmTargetExport; class cmInstallExportGenerator; +class cmLocalGenerator; /// A set of targets that were installed with the same EXPORT parameter. class cmExportSet @@ -25,6 +26,8 @@ public: /// Destructor ~cmExportSet(); + void Compute(cmLocalGenerator* lg); + void AddTargetExport(cmTargetExport* tgt); void AddInstallation(cmInstallExportGenerator const* installation); diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index d0e65e1..1daa67e 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -14,22 +14,25 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" #include "cmGeneratorExpressionDAGChecker.h" //---------------------------------------------------------------------------- cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator( - cmGlobalGenerator* gg) + cmGlobalGenerator* gg, + const std::vector<std::string>& targets, + cmMakefile* mf) { - gg->CreateGenerationObjects(cmGlobalGenerator::ImportedOnly); + gg->CreateImportedGenerationObjects(mf, targets, this->Exports); } bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) { - std::set<cmTarget const*> emitted; - std::set<cmTarget const*> emittedDeps; + std::set<cmGeneratorTarget const*> emitted; + std::set<cmGeneratorTarget const*> emittedDeps; while(!this->Exports.empty()) { - cmTarget const* te = this->Exports.back(); + cmGeneratorTarget const* te = this->Exports.back(); this->Exports.pop_back(); if (emitted.insert(te).second) { @@ -54,9 +57,9 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) } std::string cmExportTryCompileFileGenerator::FindTargets( - const std::string& propName, - cmTarget const* tgt, - std::set<cmTarget const*> &emitted) + const std::string& propName, + cmGeneratorTarget const* tgt, + std::set<cmGeneratorTarget const*> &emitted) { const char *prop = tgt->GetProperty(propName); if(!prop) @@ -74,24 +77,22 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmTarget dummyHead; dummyHead.SetType(cmState::EXECUTABLE, "try_compile_dummy_exe"); - dummyHead.SetMakefile(tgt->GetMakefile()); + dummyHead.SetMakefile(tgt->Target->GetMakefile()); - cmGeneratorTarget* gtgt = - tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt); - cmGeneratorTarget gDummyHead(&dummyHead, gtgt->GetLocalGenerator()); + cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); - std::string result = cge->Evaluate(gtgt->GetLocalGenerator(), this->Config, + std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config, false, &gDummyHead, - gtgt, &dagChecker); + tgt, &dagChecker); const std::set<cmGeneratorTarget const*> &allTargets = cge->GetAllTargetsSeen(); for(std::set<cmGeneratorTarget const*>::const_iterator li = allTargets.begin(); li != allTargets.end(); ++li) { - if(emitted.insert((*li)->Target).second) + if(emitted.insert(*li).second) { - this->Exports.push_back((*li)->Target); + this->Exports.push_back(*li); } } return result; @@ -99,11 +100,12 @@ std::string cmExportTryCompileFileGenerator::FindTargets( //---------------------------------------------------------------------------- void -cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, - ImportPropertyMap& properties, - std::set<cmTarget const*> &emitted) +cmExportTryCompileFileGenerator::PopulateProperties( + const cmGeneratorTarget* target, + ImportPropertyMap& properties, + std::set<cmGeneratorTarget const*> &emitted) { - cmPropertyMap props = target->GetProperties(); + cmPropertyMap props = target->Target->GetProperties(); for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) { properties[i->first] = i->second.GetValue(); @@ -120,7 +122,8 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, for(std::vector<std::string>::const_iterator li = depends.begin(); li != depends.end(); ++li) { - cmTarget *tgt = target->GetMakefile()->FindTargetToUse(*li); + cmGeneratorTarget *tgt = + target->GetLocalGenerator()->FindGeneratorTargetToUse(*li); if(tgt && emitted.insert(tgt).second) { this->Exports.push_back(tgt); diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 8838eca..fc135a4 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -20,11 +20,11 @@ class cmInstallTargetGenerator; class cmExportTryCompileFileGenerator: public cmExportFileGenerator { public: - cmExportTryCompileFileGenerator(cmGlobalGenerator* gg); + cmExportTryCompileFileGenerator(cmGlobalGenerator* gg, + std::vector<std::string> const& targets, + cmMakefile* mf); /** Set the list of targets to export. */ - void SetExports(const std::vector<cmTarget const*> &exports) - { this->Exports = exports; } void SetConfig(const std::string& config) { this->Config = config; } protected: @@ -37,22 +37,22 @@ protected: std::vector<std::string>&) {} virtual void HandleMissingTarget(std::string&, std::vector<std::string>&, - cmMakefile*, - cmTarget*, - cmTarget*) {} + cmGeneratorTarget*, + cmGeneratorTarget*) {} - void PopulateProperties(cmTarget const* target, + void PopulateProperties(cmGeneratorTarget const* target, ImportPropertyMap& properties, - std::set<cmTarget const*> &emitted); + std::set<const cmGeneratorTarget*>& emitted); std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: - std::string FindTargets(const std::string& prop, cmTarget const* tgt, - std::set<cmTarget const*> &emitted); + std::string FindTargets(const std::string& prop, + const cmGeneratorTarget* tgt, + std::set<const cmGeneratorTarget*>& emitted); - std::vector<cmTarget const*> Exports; + std::vector<cmGeneratorTarget const*> Exports; std::string Config; }; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 236fb7d..31c05fd 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -969,10 +969,6 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const for (cmGeneratorTargetsType::iterator l = targets.begin(); l != targets.end(); ++l) { - if (l->first->IsImported()) - { - continue; - } std::vector<std::string> includeDirs; std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); (*it)->GetIncludeDirectories(includeDirs, l->second, "C", config); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index d1599c4..ac0202b 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -388,7 +388,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, // } // Add shared-library flags if needed. - lg->AddCMP0018Flags(flags, gtgt->Target, language, config); + lg->AddCMP0018Flags(flags, gtgt, language, config); // Add include directory flags. { @@ -403,7 +403,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, lg->AppendFlags(flags, makefile->GetDefineFlags()); // Add target-specific flags. - lg->AddCompileOptions(flags, gtgt->Target, language, config); + lg->AddCompileOptions(flags, gtgt, language, config); // Add source file specific flags. lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); @@ -427,13 +427,13 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); // Add the export symbol definition for shared library objects. - if(const char* exportMacro = target->Target->GetExportMacro()) + if(const char* exportMacro = target->GetExportMacro()) { lg->AppendDefines(defines, exportMacro); } // Add preprocessor definitions for this target and configuration. - lg->AddCompileDefinitions(defines, target->Target, config, language); + lg->AddCompileDefinitions(defines, target, config, language); lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS")); { std::string defPropName = "COMPILE_DEFINITIONS_"; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 945c284..7a7e4ff 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1497,11 +1497,11 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode const char *policy = targetPolicyWhitelist[i]; if (parameters.front() == policy) { - cmMakefile *mf = context->HeadTarget->Target->GetMakefile(); + cmLocalGenerator* lg = context->HeadTarget->GetLocalGenerator(); switch(statusForTarget(context->HeadTarget, policy)) { case cmPolicies::WARN: - mf->IssueMessage(cmake::AUTHOR_WARNING, + lg->IssueMessage(cmake::AUTHOR_WARNING, cmPolicies::GetPolicyWarning(policyForString(policy))); case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: @@ -1579,7 +1579,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag> const GeneratorExpressionContent *content) { // The target soname file (.so.1). - if(target->Target->IsDLLPlatform()) + if(target->IsDLLPlatform()) { ::reportError(context, content->GetOriginalExpression(), "TARGET_SONAME_FILE is not allowed " @@ -1654,7 +1654,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> const GeneratorExpressionContent *content) { // The file used to link to the target (.so, .lib, .a). - if(!target->Target->IsLinkable()) + if(!target->IsLinkable()) { ::reportError(context, content->GetOriginalExpression(), "TARGET_LINKER_FILE is allowed only for libraries and " diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4fd9cec..713ab6a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -62,7 +62,7 @@ void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib, e << "but may contain only sources that compile, header files, and " "other files that would not affect linking of a normal library."; cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - target->Target->GetBacktrace()); + target->GetBacktrace()); } } @@ -304,6 +304,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetSourceEntries(), t->GetSourceBacktraces(), this->SourceEntries, true); + + this->DLLPlatform = (this->Makefile->IsOn("WIN32") || + this->Makefile->IsOn("CYGWIN") || + this->Makefile->IsOn("MINGW")); + + this->PolicyMap = t->PolicyMap; } cmGeneratorTarget::~cmGeneratorTarget() @@ -335,6 +341,26 @@ std::string cmGeneratorTarget::GetName() const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetExportName() const +{ + const char *exportName = this->GetProperty("EXPORT_NAME"); + + if (exportName && *exportName) + { + if (!cmGeneratorExpression::IsValidTargetName(exportName)) + { + std::ostringstream e; + e << "EXPORT_NAME property \"" << exportName << "\" for \"" + << this->GetName() << "\": is not valid."; + cmSystemTools::Error(e.str().c_str()); + return ""; + } + return exportName; + } + return this->GetName(); +} + +//---------------------------------------------------------------------------- const char *cmGeneratorTarget::GetProperty(const std::string& prop) const { return this->Target->GetProperty(prop); @@ -346,7 +372,7 @@ const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const switch(this->GetType()) { case cmState::SHARED_LIBRARY: - if(this->Target->IsDLLPlatform()) + if(this->IsDLLPlatform()) { if(implib) { @@ -463,7 +489,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, ->IssueMessage( cmake::FATAL_ERROR, "Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.", - this->Target->GetBacktrace()); + this->GetBacktrace()); } return i->second; } @@ -774,9 +800,8 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const for(std::set<std::string>::const_iterator i = utilities.begin(); i != utilities.end(); ++i) { - cmTarget* tgt = this->Makefile->FindTargetToUse(*i); - cmGeneratorTarget* gt = tgt ? this->GlobalGenerator - ->GetGeneratorTarget(tgt) : 0; + cmGeneratorTarget* gt = + this->LocalGenerator->FindGeneratorTargetToUse(*i); this->UtilityItems.insert(cmLinkItem(*i, gt)); } } @@ -797,7 +822,7 @@ void cmGeneratorTarget const char* cmGeneratorTarget::GetLocation(const std::string& config) const { static std::string location; - if (this->Target->IsImported()) + if (this->IsImported()) { location = this->Target->ImportedGetFullPath(config, false); } @@ -832,7 +857,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const location += cfgid; } - if(this->Target->IsAppBundleOnApple()) + if(this->IsAppBundleOnApple()) { std::string macdir = this->BuildMacContentDirectory("", "", false); @@ -986,9 +1011,9 @@ static bool processSources(cmGeneratorTarget const* tgt, { if(!e.empty()) { - cmake* cm = mf->GetCMakeInstance(); + cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance(); cm->IssueMessage(cmake::FATAL_ERROR, e, - tgt->Target->GetBacktrace()); + tgt->GetBacktrace()); } return contextDependent; } @@ -1044,7 +1069,7 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string> &files, { assert(this->GetType() != cmState::INTERFACE_LIBRARY); - if (!this->Makefile->GetGlobalGenerator()->GetConfigureDoneCMP0026()) + if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) { // At configure-time, this method can be called as part of getting the // LOCATION property or to export() a file to be include()d. However @@ -1089,7 +1114,7 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string> &files, "SOURCES") != debugProperties.end(); - if (this->Makefile->GetGlobalGenerator()->GetConfigureDoneCMP0026()) + if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) { this->DebugSourcesDone = true; } @@ -1365,7 +1390,8 @@ bool cmGeneratorTarget::IsImportedSharedLibWithoutSOName( { if(this->IsImported() && this->GetType() == cmState::SHARED_LIBRARY) { - if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) { return info->NoSOName; } @@ -1406,7 +1432,8 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir( else { // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) { if(!info->NoSOName && !info->SOName.empty()) { @@ -1448,9 +1475,9 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir( w << " This could be because you are using a Mac OS X version"; w << " less than 10.5 or because CMake's platform configuration is"; w << " corrupt."; - cmake* cm = this->Makefile->GetCMakeInstance(); + cmake* cm = this->LocalGenerator->GetCMakeInstance(); cm->IssueMessage(cmake::FATAL_ERROR, w.str(), - this->Target->GetBacktrace()); + this->GetBacktrace()); } return true; @@ -1471,11 +1498,11 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const return this->GetPropertyAsBool("MACOSX_RPATH"); } - cmPolicies::PolicyStatus cmp0042 = this->Target->GetPolicyStatusCMP0042(); + cmPolicies::PolicyStatus cmp0042 = this->GetPolicyStatusCMP0042(); if(cmp0042 == cmPolicies::WARN) { - this->Makefile->GetGlobalGenerator()-> + this->LocalGenerator->GetGlobalGenerator()-> AddCMP0042WarnTarget(this->GetName()); } @@ -1490,10 +1517,11 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { - if(this->Target->IsImported()) + if(this->IsImported()) { // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + if(cmGeneratorTarget::ImportInfo const* info = + this->GetImportInfo(config)) { if(info->NoSOName) { @@ -1550,9 +1578,9 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- bool cmGeneratorTarget::IsBundleOnApple() const { - return this->Target->IsFrameworkOnApple() - || this->Target->IsAppBundleOnApple() - || this->Target->IsCFBundleOnApple(); + return this->IsFrameworkOnApple() + || this->IsAppBundleOnApple() + || this->IsCFBundleOnApple(); } //---------------------------------------------------------------------------- @@ -1565,7 +1593,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, const char *ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { - if (this->Target->IsXCTestOnApple()) + if (this->IsXCTestOnApple()) { ext = "xctest"; } @@ -1604,9 +1632,9 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { - if(this->Target->IsImported()) + if(this->IsImported()) { - return this->Target->GetFullNameImported(config, implib); + return this->GetFullNameImported(config, implib); } else { @@ -1681,6 +1709,47 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } } +cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const +{ + return this->Target->GetBacktrace(); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const +{ + return + this->GetType() == cmState::STATIC_LIBRARY || + this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY || + this->GetType() == cmState::EXECUTABLE; +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetExportMacro() const +{ + // Define the symbol for targets that export symbols. + if(this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY || + this->IsExecutableWithExports()) + { + if(const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) + { + this->ExportMacro = custom_export_name; + } + else + { + std::string in = this->GetName(); + in += "_EXPORTS"; + this->ExportMacro = cmSystemTools::MakeCidentifier(in); + } + return this->ExportMacro.c_str(); + } + else + { + return 0; + } +} + //---------------------------------------------------------------------------- class cmTargetCollectLinkLanguages { @@ -1691,7 +1760,7 @@ public: cmGeneratorTarget const* head): Config(config), Languages(languages), HeadTarget(head), Makefile(target->Target->GetMakefile()), Target(target) - { this->Visited.insert(target->Target); } + { this->Visited.insert(target); } void Visit(cmLinkItem const& item) { @@ -1727,12 +1796,12 @@ public: "call is missing for an IMPORTED target, or an ALIAS target is " "missing?"; this->Target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage( - messageType, e.str(), this->Target->Target->GetBacktrace()); + messageType, e.str(), this->Target->GetBacktrace()); } } return; } - if(!this->Visited.insert(item.Target->Target).second) + if(!this->Visited.insert(item.Target).second) { return; } @@ -1758,7 +1827,7 @@ private: cmGeneratorTarget const* HeadTarget; cmMakefile* Makefile; const cmGeneratorTarget* Target; - std::set<cmTarget const*> Visited; + std::set<cmGeneratorTarget const*> Visited; }; //---------------------------------------------------------------------------- @@ -1783,14 +1852,12 @@ class cmTargetSelectLinker { int Preference; cmGeneratorTarget const* Target; - cmMakefile* Makefile; cmGlobalGenerator* GG; std::set<std::string> Preferred; public: cmTargetSelectLinker(cmGeneratorTarget const* target) : Preference(0), Target(target) { - this->Makefile = this->Target->Makefile; this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator(); } void Consider(const char* lang) @@ -1824,9 +1891,9 @@ public: e << " " << *li << "\n"; } e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); + cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance(); cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } return *this->Preferred.begin(); } @@ -1915,15 +1982,15 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, bool contentOnly) const { std::string fpath = base; - if(this->Target->IsAppBundleOnApple()) + if(this->IsAppBundleOnApple()) { fpath += this->GetAppBundleDirectory(config, contentOnly); } - if(this->Target->IsFrameworkOnApple()) + if(this->IsFrameworkOnApple()) { fpath += this->GetFrameworkDirectory(config, contentOnly); } - if(this->Target->IsCFBundleOnApple()) + if(this->IsCFBundleOnApple()) { fpath += this->GetCFBundleDirectory(config, contentOnly); } @@ -1939,7 +2006,7 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, std::string fpath = this->GetDirectory(config, implib); fpath += "/"; bool contentOnly = true; - if(this->Target->IsFrameworkOnApple()) + if(this->IsFrameworkOnApple()) { // additional files with a framework go into the version specific // directory @@ -1997,6 +2064,11 @@ cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const return data; } +bool cmGeneratorTarget::IsDLLPlatform() const +{ + return this->DLLPlatform; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs, @@ -2004,27 +2076,26 @@ cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs, { std::vector<cmSourceFile const*> objectFiles; this->GetExternalObjects(objectFiles, config); - std::vector<cmTarget*> objectLibraries; + std::vector<cmGeneratorTarget*> objectLibraries; for(std::vector<cmSourceFile const*>::const_iterator it = objectFiles.begin(); it != objectFiles.end(); ++it) { std::string objLib = (*it)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + if (cmGeneratorTarget* tgt = + this->LocalGenerator->FindGeneratorTargetToUse(objLib)) { objectLibraries.push_back(tgt); } } - std::vector<cmTarget*>::const_iterator end + std::vector<cmGeneratorTarget*>::const_iterator end = cmRemoveDuplicates(objectLibraries); - for(std::vector<cmTarget*>::const_iterator + for(std::vector<cmGeneratorTarget*>::const_iterator ti = objectLibraries.begin(); ti != end; ++ti) { - cmTarget* objLib = *ti; - cmGeneratorTarget* ogt = - this->GlobalGenerator->GetGeneratorTarget(objLib); + cmGeneratorTarget* ogt = *ti; std::vector<cmSourceFile const*> objectSources; ogt->GetObjectSources(objectSources, config); for(std::vector<cmSourceFile const*>::const_iterator @@ -2121,9 +2192,9 @@ public: cmTargetTraceDependencies(cmGeneratorTarget* target); void Trace(); private: - cmTarget* Target; cmGeneratorTarget* GeneratorTarget; cmMakefile* Makefile; + cmLocalGenerator* LocalGenerator; cmGlobalGenerator const* GlobalGenerator; typedef cmGeneratorTarget::SourceEntry SourceEntry; SourceEntry* CurrentEntry; @@ -2147,11 +2218,12 @@ private: //---------------------------------------------------------------------------- cmTargetTraceDependencies ::cmTargetTraceDependencies(cmGeneratorTarget* target): - Target(target->Target), GeneratorTarget(target) + GeneratorTarget(target) { // Convenience. - this->Makefile = this->Target->GetMakefile(); - this->GlobalGenerator = target->GetLocalGenerator()->GetGlobalGenerator(); + this->Makefile = target->Target->GetMakefile(); + this->LocalGenerator = target->GetLocalGenerator(); + this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); this->CurrentEntry = 0; // Queue all the source files already specified for the target. @@ -2194,9 +2266,12 @@ cmTargetTraceDependencies } // Queue pre-build, pre-link, and post-build rule dependencies. - this->CheckCustomCommands(this->Target->GetPreBuildCommands()); - this->CheckCustomCommands(this->Target->GetPreLinkCommands()); - this->CheckCustomCommands(this->Target->GetPostBuildCommands()); + this->CheckCustomCommands( + this->GeneratorTarget->Target->GetPreBuildCommands()); + this->CheckCustomCommands( + this->GeneratorTarget->Target->GetPreLinkCommands()); + this->CheckCustomCommands( + this->GeneratorTarget->Target->GetPostBuildCommands()); } //---------------------------------------------------------------------------- @@ -2325,7 +2400,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) tLocation = cmSystemTools::CollapseFullPath(tLocation); if(depLocation == tLocation) { - this->Target->AddUtility(util); + this->GeneratorTarget->Target->AddUtility(util); return true; } } @@ -2334,7 +2409,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) { // The original name of the dependency was not a full path. It // must name a target, so add the target-level dependency. - this->Target->AddUtility(util); + this->GeneratorTarget->Target->AddUtility(util); return true; } } @@ -2360,7 +2435,8 @@ cmTargetTraceDependencies { std::string const& command = *cit->begin(); // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(command)) + if(cmGeneratorTarget* t = + this->LocalGenerator->FindGeneratorTargetToUse(command)) { if(t->GetType() == cmState::EXECUTABLE) { @@ -2368,7 +2444,7 @@ cmTargetTraceDependencies // this project. Add the target-level dependency to make // sure the executable is up to date before this custom // command possibly runs. - this->Target->AddUtility(command); + this->GeneratorTarget->Target->AddUtility(command); } } @@ -2387,7 +2463,7 @@ cmTargetTraceDependencies for(std::set<cmGeneratorTarget*>::iterator ti = targets.begin(); ti != targets.end(); ++ti) { - this->Target->AddUtility((*ti)->GetName()); + this->GeneratorTarget->Target->AddUtility((*ti)->GetName()); } // Queue the custom command dependencies. @@ -2559,7 +2635,7 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, cmake::MessageType messageType = cmake::FATAL_ERROR; if (checkCMP0027) { - switch(tgt->Target->GetPolicyStatusCMP0027()) + switch(tgt->GetPolicyStatusCMP0027()) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n"; @@ -2598,7 +2674,7 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, } else { - switch(tgt->Target->GetPolicyStatusCMP0021()) + switch(tgt->GetPolicyStatusCMP0021()) { case cmPolicies::WARN: { @@ -3029,7 +3105,7 @@ void cmGeneratorTarget::GetCompileDefinitions(std::vector<std::string> &list, void cmGeneratorTarget::ComputeTargetManifest( const std::string& config) const { - if (this->Target->IsImported()) + if (this->IsImported()) { return; } @@ -3103,7 +3179,7 @@ void cmGeneratorTarget::ComputeTargetManifest( std::string cmGeneratorTarget::GetFullPath(const std::string& config, bool implib, bool realname) const { - if(this->Target->IsImported()) + if(this->IsImported()) { return this->Target->ImportedGetFullPath(config, implib); } @@ -3119,7 +3195,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, { std::string fpath = this->GetDirectory(config, implib); fpath += "/"; - if(this->Target->IsAppBundleOnApple()) + if(this->IsAppBundleOnApple()) { fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; @@ -3148,7 +3224,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. - if(this->Target->IsImported()) + if(this->IsImported()) { std::string msg = "NormalGetRealName called on imported target: "; msg += this->GetName(); @@ -3190,7 +3266,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. - if(this->Target->IsImported()) + if(this->IsImported()) { std::string msg = "GetLibraryNames called on imported target: "; msg += this->GetName(); @@ -3203,7 +3279,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); if(!this->HasSOName(config) || - this->Target->IsFrameworkOnApple()) + this->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. @@ -3231,7 +3307,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // The library name. name = prefix+base+suffix; - if(this->Target->IsFrameworkOnApple()) + if(this->IsFrameworkOnApple()) { realName = prefix; if(!this->Makefile->PlatformIsAppleIos()) @@ -3246,11 +3322,11 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, else { // The library's soname. - this->Target->ComputeVersionedName(soName, prefix, base, suffix, + this->ComputeVersionedName(soName, prefix, base, suffix, name, soversion); // The library's real name on disk. - this->Target->ComputeVersionedName(realName, prefix, base, suffix, + this->ComputeVersionedName(realName, prefix, base, suffix, name, version); } @@ -3279,7 +3355,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. - if(this->Target->IsImported()) + if(this->IsImported()) { std::string msg = "GetExecutableNames called on imported target: "; @@ -3343,6 +3419,24 @@ std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- +const char* +cmGeneratorTarget::ImportedGetLocation(const std::string& config) const +{ + static std::string location; + assert(this->IsImported()); + location = this->Target->ImportedGetFullPath(config, false); + return location.c_str(); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameImported(const std::string& config, + bool implib) const +{ + return cmSystemTools::GetFilenameName( + this->Target->ImportedGetFullPath(config, implib)); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameInternal(const std::string& config, bool implib, std::string& outPrefix, @@ -3396,8 +3490,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, configPostfix = this->GetProperty(configProp); // Mac application bundles and frameworks have no postfix. if(configPostfix && - (this->Target->IsAppBundleOnApple() - || this->Target->IsFrameworkOnApple())) + (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) { configPostfix = 0; } @@ -3434,7 +3527,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, // frameworks have directory prefix but no suffix std::string fw_prefix; - if(this->Target->IsFrameworkOnApple()) + if(this->IsFrameworkOnApple()) { fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; @@ -3442,7 +3535,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, targetSuffix = 0; } - if(this->Target->IsCFBundleOnApple()) + if(this->IsCFBundleOnApple()) { fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; @@ -4377,6 +4470,61 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetTargetVersion(int& major, int& minor) const +{ + int patch; + this->GetTargetVersion(false, major, minor, patch); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetTargetVersion(bool soversion, + int& major, int& minor, int& patch) const +{ + // Set the default values. + major = 0; + minor = 0; + patch = 0; + + assert(this->GetType() != cmState::INTERFACE_LIBRARY); + + // Look for a VERSION or SOVERSION property. + const char* prop = soversion? "SOVERSION" : "VERSION"; + if(const char* version = this->GetProperty(prop)) + { + // Try to parse the version number and store the results that were + // successfully parsed. + int parsed_major; + int parsed_minor; + int parsed_patch; + switch(sscanf(version, "%d.%d.%d", + &parsed_major, &parsed_minor, &parsed_patch)) + { + case 3: patch = parsed_patch; // no break! + case 2: minor = parsed_minor; // no break! + case 1: major = parsed_major; // no break! + default: break; + } + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeVersionedName(std::string& vName, + std::string const& prefix, + std::string const& base, + std::string const& suffix, + std::string const& name, + const char* version) const +{ + vName = this->Makefile->IsOn("APPLE") ? (prefix+base) : name; + if(version) + { + vName += "."; + vName += version; + } + vName += this->Makefile->IsOn("APPLE") ? suffix : std::string(); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4423,7 +4571,7 @@ void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names, for(std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) { - std::string name = this->Target->CheckCMP0004(*i); + std::string name = this->CheckCMP0004(*i); if(name == this->GetName() || name.empty()) { continue; @@ -4475,7 +4623,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config, // Link interfaces are not supported for executables that do not // export symbols. if(this->GetType() == cmState::EXECUTABLE && - !this->Target->IsExecutableWithExports()) + !this->IsExecutableWithExports()) { return 0; } @@ -4558,8 +4706,8 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config, } } } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmLinkImplementationLibraries const* @@ -4624,7 +4772,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, // Link interfaces are not supported for executables that do not // export symbols. if(this->GetType() == cmState::EXECUTABLE && - !this->Target->IsExecutableWithExports()) + !this->IsExecutableWithExports()) { return 0; } @@ -4658,7 +4806,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config, std::string cmGeneratorTarget::GetDirectory(const std::string& config, bool implib) const { - if (this->Target->IsImported()) + if (this->IsImported()) { // Return the directory from which the target is imported. return @@ -4692,7 +4840,7 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( } // Only libraries and executables have well-defined output files. - if(!this->Target->HaveWellDefinedOutputFiles()) + if(!this->HaveWellDefinedOutputFiles()) { std::string msg = "cmGeneratorTarget::GetOutputInfo called for "; msg += this->GetName(); @@ -4735,7 +4883,7 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( this->LocalGenerator->GetCMakeInstance()->IssueMessage( cmake::FATAL_ERROR, "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", - this->Target->GetBacktrace()); + this->GetBacktrace()); return 0; } return &i->second; @@ -4782,7 +4930,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, // Skip per-configuration subdirectory. conf = ""; } - else if(const char* outdir = this->Target->GetProperty(propertyName)) + else if(const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. cmGeneratorExpression ge; @@ -4820,7 +4968,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, // specified as a relative path. Treat a relative path as // relative to the current output directory for this makefile. out = (cmSystemTools::CollapseFullPath - (out, this->Makefile->GetCurrentBinaryDirectory())); + (out, this->LocalGenerator->GetCurrentBinaryDirectory())); // The generator may add the configuration's subdirectory. if(!conf.empty()) @@ -4885,7 +5033,7 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind, // specified as a relative path. Treat a relative path as // relative to the current output directory for this makefile. out = (cmSystemTools::CollapseFullPath - (out, this->Makefile->GetCurrentBinaryDirectory())); + (out, this->LocalGenerator->GetCurrentBinaryDirectory())); // The generator may add the configuration's subdirectory. if(!conf.empty()) @@ -4927,15 +5075,15 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD && - this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN) + if(this->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->GetPolicyStatusCMP0022() != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; explicitLibraries = this->GetProperty(linkIfaceProp); } else if(this->GetType() == cmState::SHARED_LIBRARY || - this->Target->IsExecutableWithExports()) + this->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -4954,7 +5102,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( } if(explicitLibraries && - this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + this->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the @@ -4999,8 +5147,8 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( iface.Libraries, iface.HadHeadSensitiveCondition); } - else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD) + else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back @@ -5011,7 +5159,7 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries( this->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); - if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN && + if(this->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the @@ -5061,7 +5209,7 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, cmGeneratorTarget const* headTarget, bool usage_requirements_only) const { - cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config); + cmGeneratorTarget::ImportInfo const* info = this->GetImportInfo(config); if(!info) { return 0; @@ -5099,6 +5247,223 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config, return &iface; } +//---------------------------------------------------------------------------- +cmGeneratorTarget::ImportInfo const* +cmGeneratorTarget::GetImportInfo(const std::string& config) const +{ + // There is no imported information for non-imported targets. + if(!this->IsImported()) + { + return 0; + } + + // Lookup/compute/cache the import information for this + // configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + else + { + config_upper = "NOCONFIG"; + } + + ImportInfoMapType::const_iterator i = + this->ImportInfoMap.find(config_upper); + if(i == this->ImportInfoMap.end()) + { + ImportInfo info; + this->ComputeImportInfo(config_upper, info); + ImportInfoMapType::value_type entry(config_upper, info); + i = this->ImportInfoMap.insert(entry).first; + } + + if(this->GetType() == cmState::INTERFACE_LIBRARY) + { + return &i->second; + } + // If the location is empty then the target is not available for + // this configuration. + if(i->second.Location.empty() && i->second.ImportLibrary.empty()) + { + return 0; + } + + // Return the import information. + return &i->second; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, + ImportInfo& info) const +{ + // This method finds information about an imported target from its + // properties. The "IMPORTED_" namespace is reserved for properties + // defined by the project exporting the target. + + // Initialize members. + info.NoSOName = false; + + const char* loc = 0; + const char* imp = 0; + std::string suffix; + if (!this->Target->GetMappedConfig(desired_config, &loc, &imp, suffix)) + { + return; + } + + // Get the link interface. + { + std::string linkProp = "INTERFACE_LINK_LIBRARIES"; + const char *propertyLibs = this->GetProperty(linkProp); + + if (this->GetType() != cmState::INTERFACE_LIBRARY) + { + if(!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + linkProp += suffix; + propertyLibs = this->GetProperty(linkProp); + } + + if(!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + propertyLibs = this->GetProperty(linkProp); + } + } + if(propertyLibs) + { + info.LibrariesProp = linkProp; + info.Libraries = propertyLibs; + } + } + if(this->GetType() == cmState::INTERFACE_LIBRARY) + { + return; + } + + // A provided configuration has been chosen. Load the + // configuration's properties. + + // Get the location. + if(loc) + { + info.Location = loc; + } + else + { + std::string impProp = "IMPORTED_LOCATION"; + impProp += suffix; + if(const char* config_location = this->GetProperty(impProp)) + { + info.Location = config_location; + } + else if(const char* location = this->GetProperty("IMPORTED_LOCATION")) + { + info.Location = location; + } + } + + // Get the soname. + if(this->GetType() == cmState::SHARED_LIBRARY) + { + std::string soProp = "IMPORTED_SONAME"; + soProp += suffix; + if(const char* config_soname = this->GetProperty(soProp)) + { + info.SOName = config_soname; + } + else if(const char* soname = this->GetProperty("IMPORTED_SONAME")) + { + info.SOName = soname; + } + } + + // Get the "no-soname" mark. + if(this->GetType() == cmState::SHARED_LIBRARY) + { + std::string soProp = "IMPORTED_NO_SONAME"; + soProp += suffix; + if(const char* config_no_soname = this->GetProperty(soProp)) + { + info.NoSOName = cmSystemTools::IsOn(config_no_soname); + } + else if(const char* no_soname = this->GetProperty("IMPORTED_NO_SONAME")) + { + info.NoSOName = cmSystemTools::IsOn(no_soname); + } + } + + // Get the import library. + if(imp) + { + info.ImportLibrary = imp; + } + else if(this->GetType() == cmState::SHARED_LIBRARY || + this->IsExecutableWithExports()) + { + std::string impProp = "IMPORTED_IMPLIB"; + impProp += suffix; + if(const char* config_implib = this->GetProperty(impProp)) + { + info.ImportLibrary = config_implib; + } + else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB")) + { + info.ImportLibrary = implib; + } + } + + // Get the link dependencies. + { + std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES"; + linkProp += suffix; + if(const char* config_libs = this->GetProperty(linkProp)) + { + info.SharedDeps = config_libs; + } + else if(const char* libs = + this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) + { + info.SharedDeps = libs; + } + } + + // Get the link languages. + if(this->Target->LinkLanguagePropagatesToDependents()) + { + std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES"; + linkProp += suffix; + if(const char* config_libs = this->GetProperty(linkProp)) + { + info.Languages = config_libs; + } + else if(const char* libs = + this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) + { + info.Languages = libs; + } + } + + // Get the cyclic repetition count. + if(this->GetType() == cmState::STATIC_LIBRARY) + { + std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; + linkProp += suffix; + if(const char* config_reps = this->GetProperty(linkProp)) + { + sscanf(config_reps, "%u", &info.Multiplicity); + } + else if(const char* reps = + this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) + { + sscanf(reps, "%u", &info.Multiplicity); + } + } +} + cmHeadToLinkInterfaceMap& cmGeneratorTarget::GetHeadToLinkInterfaceMap(const std::string &config) const { @@ -5119,7 +5484,7 @@ const cmLinkImplementation * cmGeneratorTarget::GetLinkImplementation(const std::string& config) const { // There is no link implementation for imported targets. - if(this->Target->IsImported()) + if(this->IsImported()) { return 0; } @@ -5197,6 +5562,105 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetObjectLibrariesCMP0026( + std::vector<cmGeneratorTarget*>& objlibs) const +{ + // At configure-time, this method can be called as part of getting the + // LOCATION property or to export() a file to be include()d. However + // there is no cmGeneratorTarget at configure-time, so search the SOURCES + // for TARGET_OBJECTS instead for backwards compatibility with OLD + // behavior of CMP0024 and CMP0026 only. + cmStringRange rng = this->Target->GetSourceEntries(); + for(std::vector<std::string>::const_iterator + i = rng.begin(); i != rng.end(); ++i) + { + std::string const& entry = *i; + + std::vector<std::string> files; + cmSystemTools::ExpandListArgument(entry, files); + for (std::vector<std::string>::const_iterator + li = files.begin(); li != files.end(); ++li) + { + if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") && + (*li)[li->size() - 1] == '>') + { + std::string objLibName = li->substr(17, li->size()-18); + + if (cmGeneratorExpression::Find(objLibName) != std::string::npos) + { + continue; + } + cmGeneratorTarget *objLib = + this->LocalGenerator->FindGeneratorTargetToUse(objLibName); + if(objLib) + { + objlibs.push_back(objLib); + } + } + } + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const +{ + // Strip whitespace off the library names because we used to do this + // in case variables were expanded at generate time. We no longer + // do the expansion but users link to libraries like " ${VAR} ". + std::string lib = item; + std::string::size_type pos = lib.find_first_not_of(" \t\r\n"); + if(pos != lib.npos) + { + lib = lib.substr(pos, lib.npos); + } + pos = lib.find_last_not_of(" \t\r\n"); + if(pos != lib.npos) + { + lib = lib.substr(0, pos+1); + } + if(lib != item) + { + cmake* cm = this->LocalGenerator->GetCMakeInstance(); + switch(this->GetPolicyStatusCMP0004()) + { + case cmPolicies::WARN: + { + std::ostringstream w; + w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n" + << "Target \"" << this->GetName() << "\" links to item \"" + << item << "\" which has leading or trailing whitespace."; + cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + this->GetBacktrace()); + } + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + { + std::ostringstream e; + e << "Target \"" << this->GetName() << "\" links to item \"" + << item << "\" which has leading or trailing whitespace. " + << "This is now an error according to policy CMP0004."; + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->GetBacktrace()); + } + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + { + std::ostringstream e; + e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0004) << "\n" + << "Target \"" << this->GetName() << "\" links to item \"" + << item << "\" which has leading or trailing whitespace."; + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->GetBacktrace()); + } + break; + } + } + return lib; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, const std::string& config) const { @@ -5216,14 +5680,13 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, std::vector<cmSourceFile const*> externalObjects; if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) { - std::vector<cmTarget*> objectTargets; - this->Target->GetObjectLibrariesCMP0026(objectTargets); + std::vector<cmGeneratorTarget*> objectTargets; + this->GetObjectLibrariesCMP0026(objectTargets); objectLibraries.reserve(objectTargets.size()); - for (std::vector<cmTarget*>::const_iterator it = objectTargets.begin(); - it != objectTargets.end(); ++it) + for (std::vector<cmGeneratorTarget*>::const_iterator it = + objectTargets.begin(); it != objectTargets.end(); ++it) { - objectLibraries.push_back(this->GlobalGenerator - ->GetGeneratorTarget(*it)); + objectLibraries.push_back(*it); } } else @@ -5233,10 +5696,10 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages, i = externalObjects.begin(); i != externalObjects.end(); ++i) { std::string objLib = (*i)->GetObjectLibrary(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + if (cmGeneratorTarget* tgt = + this->LocalGenerator->FindGeneratorTargetToUse(objLib)) { - objectLibraries.push_back(this->GlobalGenerator - ->GetGeneratorTarget(tgt)); + objectLibraries.push_back(tgt); } } } @@ -5358,7 +5821,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( li != llibs.end(); ++li) { // Skip entries that resolve to the target itself or are empty. - std::string name = this->Target->CheckCMP0004(*li); + std::string name = this->CheckCMP0004(*li); if(name == this->GetName() || name.empty()) { if(name == this->GetName()) @@ -5366,7 +5829,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; std::ostringstream e; - switch(this->Target->GetPolicyStatusCMP0038()) + switch(this->GetPolicyStatusCMP0038()) { case cmPolicies::WARN: { @@ -5387,7 +5850,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( { e << "Target \"" << this->GetName() << "\" links to itself."; this->LocalGenerator->GetCMakeInstance()->IssueMessage( - messageType, e.str(), this->Target->GetBacktrace()); + messageType, e.str(), this->GetBacktrace()); if (messageType == cmake::FATAL_ERROR) { return; @@ -5416,7 +5879,12 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( this->MaxLanguageStandards); } - cmTargetLinkLibraryType linkType = this->Target->ComputeLinkType(config); + // Get the list of configurations considered to be DEBUG. + std::vector<std::string> debugConfigs = + this->Makefile->GetCMakeInstance()->GetDebugConfigs(); + + cmTargetLinkLibraryType linkType = + CMP0003_ComputeLinkType(config, debugConfigs); cmTarget::LinkLibraryVectorType const& oldllibs = this->Target->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); @@ -5424,7 +5892,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( { if(li->second != GENERAL_LibraryType && li->second != linkType) { - std::string name = this->Target->CheckCMP0004(li->first); + std::string name = this->CheckCMP0004(li->first); if(name == this->GetName() || name.empty()) { continue; @@ -5440,7 +5908,8 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( cmGeneratorTarget* cmGeneratorTarget::FindTargetToLink(std::string const& name) const { - cmTarget const* tgt = this->Makefile->FindTargetToUse(name); + cmGeneratorTarget* tgt = + this->LocalGenerator->FindGeneratorTargetToUse(name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -5459,17 +5928,13 @@ cmGeneratorTarget::FindTargetToLink(std::string const& name) const "allowed. " "One may link only to STATIC or SHARED libraries, or to executables " "with the ENABLE_EXPORTS property set."; - cmake* cm = this->Makefile->GetCMakeInstance(); + cmake* cm = this->LocalGenerator->GetCMakeInstance(); cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->GetBacktrace()); tgt = 0; } - if (!tgt) - { - return 0; - } - return this->GlobalGenerator->GetGeneratorTarget(tgt); + return tgt; } //---------------------------------------------------------------------------- @@ -5506,17 +5971,24 @@ bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsExecutableWithExports() const +{ + return (this->GetType() == cmState::EXECUTABLE && + this->GetPropertyAsBool("ENABLE_EXPORTS")); +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasImportLibrary() const { - return (this->Target->IsDLLPlatform() && + return (this->IsDLLPlatform() && (this->GetType() == cmState::SHARED_LIBRARY || - this->Target->IsExecutableWithExports())); + this->IsExecutableWithExports())); } //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSupportDirectory() const { - std::string dir = this->Makefile->GetCurrentBinaryDirectory(); + std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory(); dir += cmake::GetCMakeFilesDirectory(); dir += "/"; dir += this->GetName(); @@ -5527,3 +5999,45 @@ std::string cmGeneratorTarget::GetSupportDirectory() const #endif return dir; } + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkable() const +{ + return (this->GetType() == cmState::STATIC_LIBRARY || + this->GetType() == cmState::SHARED_LIBRARY || + this->GetType() == cmState::MODULE_LIBRARY || + this->GetType() == cmState::UNKNOWN_LIBRARY || + this->GetType() == cmState::INTERFACE_LIBRARY || + this->IsExecutableWithExports()); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsFrameworkOnApple() const +{ + return (this->GetType() == cmState::SHARED_LIBRARY && + this->Makefile->IsOn("APPLE") && + this->GetPropertyAsBool("FRAMEWORK")); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsAppBundleOnApple() const +{ + return (this->GetType() == cmState::EXECUTABLE && + this->Makefile->IsOn("APPLE") && + this->GetPropertyAsBool("MACOSX_BUNDLE")); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsXCTestOnApple() const +{ + return (this->IsCFBundleOnApple() && + this->GetPropertyAsBool("XCTEST")); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsCFBundleOnApple() const +{ + return (this->GetType() == cmState::MODULE_LIBRARY && + this->Makefile->IsOn("APPLE") && + this->GetPropertyAsBool("BUNDLE")); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 05a7d4d..2dc3a6f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -33,6 +33,14 @@ public: bool IsImported() const; const char *GetLocation(const std::string& config) const; +#define DECLARE_TARGET_POLICY(POLICY) \ + cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \ + { return this->PolicyMap.Get(cmPolicies::POLICY); } + + CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY) + +#undef DECLARE_TARGET_POLICY + /** Get the location of the target in the build tree with a placeholder referencing the configuration in the native build system. This location is suitable for use as the LOCATION target property. */ @@ -43,6 +51,8 @@ public: cmState::TargetType GetType() const; std::string GetName() const; + std::string GetExportName() const; + const char *GetProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector<cmSourceFile*>& files, @@ -164,6 +174,12 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; + cmListFileBacktrace GetBacktrace() const; + + /** Get the macro to define when building sources in this target. + If no macro should be defined null is returned. */ + const char* GetExportMacro() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; @@ -188,6 +204,12 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Return whether or not the target is for a DLL platform. */ + bool IsDLLPlatform() const; + + /** @return whether this target have a well defined output file name. */ + bool HaveWellDefinedOutputFiles() const; + /** Link information from the transitive closure of the link implementation and the interfaces of its dependencies. */ struct LinkClosure @@ -226,6 +248,12 @@ public: void GetLanguages(std::set<std::string>& languages, std::string const& config) const; + void + GetObjectLibrariesCMP0026(std::vector<cmGeneratorTarget*>& objlibs) const; + + std::string GetFullNameImported(const std::string& config, + bool implib) const; + bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const; bool HaveBuildTreeRPATH(const std::string& config) const; @@ -398,12 +426,30 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; + bool IsExecutableWithExports() const; + /** Return whether or not the target has a DLL import library. */ bool HasImportLibrary() const; /** Get a build-tree directory in which to place target support files. */ std::string GetSupportDirectory() const; + /** Return whether this target may be used to link another target. */ + bool IsLinkable() const; + + /** Return whether this target is a shared library Framework on + Apple. */ + bool IsFrameworkOnApple() const; + + /** Return whether this target is an executable Bundle on Apple. */ + bool IsAppBundleOnApple() const; + + /** Return whether this target is a XCTest on Apple. */ + bool IsXCTestOnApple() const; + + /** Return whether this target is a CFBundle (plugin) on Apple. */ + bool IsCFBundleOnApple() const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -437,6 +483,19 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; + const char* ImportedGetLocation(const std::string& config) const; + + /** Get the target major and minor version numbers interpreted from + the VERSION property. Version 0 is returned if the property is + not set or cannot be parsed. */ + void GetTargetVersion(int& major, int& minor) const; + + /** Get the target major, minor, and patch version numbers + interpreted from the VERSION or SOVERSION property. Version 0 + is returned if the property is not set or cannot be parsed. */ + void + GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector<cmSourceFile*> Depends; }; @@ -446,6 +505,8 @@ private: std::set<cmSourceFile const*> ExplicitObjectName; mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache; + mutable std::string ExportMacro; + void ConstructSourceFileFlags() const; mutable bool SourceFileFlagsConstructed; mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; @@ -464,6 +525,13 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; + void ComputeVersionedName(std::string& vName, + std::string const& prefix, + std::string const& base, + std::string const& suffix, + std::string const& name, + const char* version) const; + struct CompatibleInterfacesBase { std::set<std::string> PropsBool; @@ -508,6 +576,31 @@ private: cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap( std::string const& config) const; + // Cache import information from properties for each configuration. + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + + typedef std::map<std::string, ImportInfo> ImportInfoMapType; + mutable ImportInfoMapType ImportInfoMap; + void ComputeImportInfo(std::string const& desired_config, + ImportInfo& info) const; + ImportInfo const* GetImportInfo(const std::string& config) const; + + /** Strip off leading and trailing whitespace from an item named in + the link dependencies of this target. */ + std::string CheckCMP0004(std::string const& item) const; + cmLinkInterface const* GetImportLinkInterface(const std::string& config, const cmGeneratorTarget* head, @@ -556,6 +649,7 @@ private: typedef std::map<OutputNameKey, std::string> OutputNameMapType; mutable OutputNameMapType OutputNameMap; mutable std::set<cmLinkItem> UtilityItems; + cmPolicies::PolicyMap PolicyMap; mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; mutable bool DebugCompileOptionsDone; @@ -564,6 +658,7 @@ private: mutable bool DebugSourcesDone; mutable bool LinkImplementationLanguageIsContextDependent; mutable bool UtilityItemsDone; + bool DLLPlatform; bool ComputePDBOutputDir(const std::string& kind, const std::string& config, std::string& out) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index c687ba7..01e6f8c 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -265,8 +265,11 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config, this->LocalGenerator->AddLanguageFlags( flags, lang + std::string("_GHS_KERNEL"), config); } - this->LocalGenerator->AddCMP0018Flags(flags, this->Target, lang, config); - this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, lang); + this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, + lang, config); + this->LocalGenerator->AddVisibilityPresetFlags(flags, + this->GeneratorTarget, + lang); // Append old-style preprocessor definition flags. if (std::string(" ") != std::string(this->Makefile->GetDefineFlags())) @@ -276,7 +279,8 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config, } // Add target-specific flags. - this->LocalGenerator->AddCompileOptions(flags, this->Target, lang, config); + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, + lang, config); std::map<std::string, std::string>::value_type entry(language, flags); i = this->FlagsByLanguage.insert(entry).first; @@ -293,13 +297,14 @@ std::string cmGhsMultiTargetGenerator::GetDefines(const std::string &language, std::set<std::string> defines; const char *lang = language.c_str(); // Add the export symbol definition for shared library objects. - if (const char *exportMacro = this->Target->GetExportMacro()) + if (const char *exportMacro = this->GeneratorTarget->GetExportMacro()) { this->LocalGenerator->AppendDefines(defines, exportMacro); } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AddCompileDefinitions(defines, this->Target, config, + this->LocalGenerator->AddCompileDefinitions(defines, + this->GeneratorTarget, config, language); std::string definesString; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a42ea22..086ff25 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1199,6 +1199,27 @@ void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes) cmDeleteAll(this->GeneratorTargets); this->GeneratorTargets.clear(); this->CreateGeneratorTargets(targetTypes); + this->ComputeBuildFileGenerators(); +} + +void cmGlobalGenerator::CreateImportedGenerationObjects(cmMakefile* mf, + const std::vector<std::string>& targets, + std::vector<const cmGeneratorTarget*>& exports) +{ + this->CreateGenerationObjects(ImportedOnly); + std::vector<cmMakefile*>::iterator mfit = + std::find(this->Makefiles.begin(), this->Makefiles.end(), mf); + cmLocalGenerator* lg = + this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)]; + for (std::vector<std::string>::const_iterator it = targets.begin(); + it != targets.end(); ++it) + { + cmGeneratorTarget* gt = lg->FindGeneratorTargetToUse(*it); + if (gt) + { + exports.push_back(gt); + } + } } cmExportBuildFileGenerator* @@ -1279,8 +1300,6 @@ bool cmGlobalGenerator::Compute() this->CreateQtAutoGeneratorsTargets(); #endif - this->ComputeBuildFileGenerators(); - unsigned int i; // Add generator specific helper commands @@ -1555,7 +1574,6 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, cmLocalGenerator *lg) { - cmGeneratorTargetsType generatorTargets; cmMakefile* mf = lg->GetMakefile(); if (targetTypes == AllTargets) { @@ -1566,7 +1584,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, cmTarget* t = &ti->second; cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; - generatorTargets[t] = gt; + lg->AddGeneratorTarget(t, gt); } } @@ -1576,9 +1594,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, { cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg); this->GeneratorTargets[*j] = gt; - generatorTargets[*j] = gt; } - lg->SetGeneratorTargets(generatorTargets); } //---------------------------------------------------------------------------- @@ -2189,7 +2205,8 @@ cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const if(cmTarget* tgt = this->FindTarget(libname)) { - if(tgt->IsFrameworkOnApple()) + cmGeneratorTarget* gt = this->GetGeneratorTarget(tgt); + if(gt->IsFrameworkOnApple()) { return true; } @@ -2684,13 +2701,13 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, for (cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { cmTarget* target = &l->second; - if(this->IsRootOnlyTarget(target) && + cmGeneratorTarget* gt = this->GetGeneratorTarget(target); + if(this->IsRootOnlyTarget(gt) && target->GetMakefile() != root->GetMakefile()) { continue; } // put the target in the set of original targets - cmGeneratorTarget* gt = this->GetGeneratorTarget(target); originalTargets.insert(gt); // Get the set of targets that depend on target this->AddTargetDepends(gt, projectTargets); @@ -2699,7 +2716,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const +bool cmGlobalGenerator::IsRootOnlyTarget(cmGeneratorTarget* target) const { return (target->GetType() == cmState::GLOBAL_TARGET || target->GetName() == this->GetAllTargetName()); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 6887409..c59d42d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -91,6 +91,9 @@ public: ImportedOnly }; + void CreateImportedGenerationObjects(cmMakefile* mf, + std::vector<std::string> const& targets, + std::vector<cmGeneratorTarget const*>& exports); void CreateGenerationObjects(TargetTypes targetTypes = AllTargets); /** @@ -365,8 +368,6 @@ public: bool GetConfigureDoneCMP0026() const { return this->ConfigureDoneCMP0026AndCMP0024; } - void ComputeBuildFileGenerators(); - std::string MakeSilentFlag; protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; @@ -375,7 +376,7 @@ protected: void GetTargetSets(TargetDependSet& projectTargets, TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); - bool IsRootOnlyTarget(cmTarget* target) const; + bool IsRootOnlyTarget(cmGeneratorTarget* target) const; void AddTargetDepends(const cmGeneratorTarget* target, TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); @@ -471,6 +472,8 @@ private: void CheckCompilerIdCompatibility(cmMakefile* mf, std::string const& lang) const; + void ComputeBuildFileGenerators(); + cmExternalMakefileProjectGenerator* ExtraGenerator; // track files replaced during a Generate diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 02da028..89a6dff 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -917,11 +917,13 @@ cmGlobalNinjaGenerator std::string configName = target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); + // for frameworks, we want the real name, not smple name // frameworks always appear versioned, and the build.ninja // will always attempt to manage symbolic links instead // of letting cmOSXBundleGenerator do it. - bool realname = target->IsFrameworkOnApple(); + bool realname = gtgt->IsFrameworkOnApple(); switch (target->GetType()) { case cmState::EXECUTABLE: @@ -929,7 +931,6 @@ cmGlobalNinjaGenerator case cmState::STATIC_LIBRARY: case cmState::MODULE_LIBRARY: { - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); outputs.push_back(this->ConvertToNinjaPath( gtgt->GetFullPath(configName, false, realname))); break; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ee31e28..44e3de6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -473,10 +473,6 @@ cmGlobalUnixMakefileGenerator3 (type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY)) { - if(gtarget->Target->IsImported()) - { - continue; - } // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || @@ -632,10 +628,6 @@ cmGlobalUnixMakefileGenerator3 t != targets.end(); ++t) { cmGeneratorTarget* gtarget = t->second; - if(gtarget->Target->IsImported()) - { - continue; - } // Don't emit the same rule twice (e.g. two targets with the same // simple name) int type = gtarget->GetType(); @@ -733,10 +725,6 @@ cmGlobalUnixMakefileGenerator3 t != targets.end(); ++t) { cmGeneratorTarget* gtarget = t->second; - if(gtarget->Target->IsImported()) - { - continue; - } int type = gtarget->GetType(); std::string name = gtarget->GetName(); if (!name.empty() diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 0c41964..61b19cf 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -257,6 +257,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); lg->AddGeneratorTarget(tgt, gt); + this->AddGeneratorTarget(tgt, gt); // Organize in the "predefined targets" folder: // diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index d81d3b8..91ca9a3 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -88,6 +88,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); gen[0]->AddGeneratorTarget(allBuild, gt); + this->AddGeneratorTarget(allBuild, gt); #if 0 // Can't activate this code because we want ALL_BUILD @@ -385,7 +386,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -static bool VSLinkable(cmTarget const* t) +static bool VSLinkable(cmGeneratorTarget const* t) { return t->IsLinkable() || t->GetType() == cmState::OBJECT_LIBRARY; } @@ -475,7 +476,8 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) di != utilDepends.end(); ++di) { cmTarget const* dep = *di; - if(allowLinkable || !VSLinkable(dep) || linked.count(dep)) + cmGeneratorTarget* dgt = this->GetGeneratorTarget(dep); + if(allowLinkable || !VSLinkable(dgt) || linked.count(dep)) { // Direct dependency allowed. vsTargetDepend.insert(dep->GetName()); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0e3af88..576827c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -460,6 +460,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); root->AddGeneratorTarget(allbuild, allBuildGt); + root->GetGlobalGenerator()->AddGeneratorTarget(allbuild, allBuildGt); // Refer to the main build configuration file for easy editing. std::string listfile = root->GetCurrentSourceDirectory(); @@ -495,6 +496,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); root->AddGeneratorTarget(check, checkGt); + root->GetGlobalGenerator()->AddGeneratorTarget(check, checkGt); } // now make the allbuild depend on all the non-utility targets @@ -787,14 +789,16 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, // Is this a resource file in this target? Add it to the resources group... // + + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); cmGeneratorTarget::SourceFileFlags tsFlags = - this->GetGeneratorTarget(&cmtarget)->GetTargetSourceFileFlags(sf); + gtgt->GetTargetSourceFileFlags(sf); bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource; // Is this a "private" or "public" framework header file? // Set the ATTRIBUTES attribute appropriately... // - if(cmtarget.IsFrameworkOnApple()) + if(gtgt->IsFrameworkOnApple()) { if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) { @@ -1193,9 +1197,9 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, } // some build phases only apply to bundles and/or frameworks - bool isFrameworkTarget = cmtarget.IsFrameworkOnApple(); + bool isFrameworkTarget = gtgt->IsFrameworkOnApple(); bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"); - bool isCFBundleTarget = cmtarget.IsCFBundleOnApple(); + bool isCFBundleTarget = gtgt->IsCFBundleOnApple(); cmXCodeObject* buildFiles = 0; @@ -1289,7 +1293,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, copyFilesBuildPhase->AddAttribute("dstSubfolderSpec", this->CreateString("6")); std::ostringstream ostr; - if (cmtarget.IsFrameworkOnApple()) + if (gtgt->IsFrameworkOnApple()) { // dstPath in frameworks is relative to Versions/<version> ostr << mit->first; @@ -1467,8 +1471,10 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, std::vector<cmCustomCommand> postbuild = cmtarget.GetPostBuildCommands(); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + if(cmtarget.GetType() == cmState::SHARED_LIBRARY && - !cmtarget.IsFrameworkOnApple()) + !gtgt->IsFrameworkOnApple()) { cmCustomCommandLines cmd; cmd.resize(1); @@ -1500,7 +1506,6 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector<cmSourceFile*> classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); if (!gtgt->GetConfigCommonSourceFiles(classes)) { return; @@ -1847,14 +1852,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName); // Add shared-library flags if needed. - this->CurrentLocalGenerator->AddCMP0018Flags(flags, &target, + this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt, lang, configName); - this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, &target, + this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, gtgt, lang); this->CurrentLocalGenerator-> - AddCompileOptions(flags, &target, lang, configName); + AddCompileOptions(flags, gtgt, lang, configName); } std::string llang = gtgt->GetLinkerLanguage(configName); @@ -1878,7 +1883,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\""); } - if(const char* exportMacro = target.GetExportMacro()) + if(const char* exportMacro = gtgt->GetExportMacro()) { // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); @@ -1917,7 +1922,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CurrentLocalGenerator ->GetStaticLibraryFlags(extraLinkOptions, cmSystemTools::UpperCase(configName), - &target); + gtgt); } else { @@ -1976,7 +1981,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || gtgt->IsFrameworkOnApple()) { version = 0; soversion = 0; @@ -2023,7 +2028,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, pndir = gtgt->GetDirectory(configName); } - if(target.IsFrameworkOnApple() || target.IsCFBundleOnApple()) + if(gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple()) { pnprefix = ""; } @@ -2076,7 +2081,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("BUNDLE")); - if (target.IsCFBundleOnApple()) + if (gtgt->IsCFBundleOnApple()) { // It turns out that a BUNDLE is basically the same // in many ways as an application bundle, as far as @@ -2095,7 +2100,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // a per-configuration Info.plist file. The cfbundle plist // is very similar to the application bundle plist this->CurrentLocalGenerator - ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateAppleInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2144,7 +2149,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // so let it replace the framework name. This avoids creating // a per-configuration Info.plist file. this->CurrentLocalGenerator - ->GenerateFrameworkInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateFrameworkInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2187,7 +2192,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // so let it replace the executable name. This avoids creating // a per-configuration Info.plist file. this->CurrentLocalGenerator - ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + ->GenerateAppleInfoPList(gtgt, "$(EXECUTABLE_NAME)", plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); @@ -2454,7 +2459,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, int patch; // VERSION -> current_version - target.GetTargetVersion(false, major, minor, patch); + gtgt->GetTargetVersion(false, major, minor, patch); std::ostringstream v; // Xcode always wants at least 1.0.0 or nothing @@ -2466,7 +2471,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(v.str().c_str())); // SOVERSION -> compatibility_version - target.GetTargetVersion(true, major, minor, patch); + gtgt->GetTargetVersion(true, major, minor, patch); std::ostringstream vso; // Xcode always wants at least 1.0.0 or nothing @@ -2671,23 +2676,24 @@ cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(cmTarget const& cmtarget) const } //---------------------------------------------------------------------------- -const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) +const char* cmGlobalXCodeGenerator::GetTargetFileType( + cmGeneratorTarget* target) { - switch(cmtarget.GetType()) + switch(target->GetType()) { case cmState::OBJECT_LIBRARY: case cmState::STATIC_LIBRARY: return "archive.ar"; case cmState::MODULE_LIBRARY: - if (cmtarget.IsXCTestOnApple()) + if (target->IsXCTestOnApple()) return "wrapper.cfbundle"; - else if (cmtarget.IsCFBundleOnApple()) + else if (target->IsCFBundleOnApple()) return "wrapper.plug-in"; else return ((this->XcodeVersion >= 22)? "compiled.mach-o.executable" : "compiled.mach-o.dylib"); case cmState::SHARED_LIBRARY: - return (cmtarget.GetPropertyAsBool("FRAMEWORK")? + return (target->GetPropertyAsBool("FRAMEWORK")? "wrapper.framework" : "compiled.mach-o.dylib"); case cmState::EXECUTABLE: return "compiled.mach-o.executable"; @@ -2697,28 +2703,29 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) } //---------------------------------------------------------------------------- -const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget) +const char* cmGlobalXCodeGenerator::GetTargetProductType( + cmGeneratorTarget* target) { - switch(cmtarget.GetType()) + switch(target->GetType()) { case cmState::OBJECT_LIBRARY: case cmState::STATIC_LIBRARY: return "com.apple.product-type.library.static"; case cmState::MODULE_LIBRARY: - if (cmtarget.IsXCTestOnApple()) + if (target->IsXCTestOnApple()) return "com.apple.product-type.bundle.unit-test"; - else if (cmtarget.IsCFBundleOnApple()) + else if (target->IsCFBundleOnApple()) return "com.apple.product-type.bundle"; else return ((this->XcodeVersion >= 22)? "com.apple.product-type.tool" : "com.apple.product-type.library.dynamic"); case cmState::SHARED_LIBRARY: - return (cmtarget.GetPropertyAsBool("FRAMEWORK")? + return (target->GetPropertyAsBool("FRAMEWORK")? "com.apple.product-type.framework" : "com.apple.product-type.library.dynamic"); case cmState::EXECUTABLE: - return (cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")? + return (target->GetPropertyAsBool("MACOSX_BUNDLE")? "com.apple.product-type.application" : "com.apple.product-type.tool"); default: break; @@ -2759,9 +2766,11 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); - if(const char* fileType = this->GetTargetFileType(cmtarget)) + if(const char* fileType = this->GetTargetFileType(gtgt)) { fileRef->AddAttribute("explicitFileType", this->CreateString(fileType)); } @@ -2774,7 +2783,6 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); @@ -2784,7 +2792,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, fileRef->SetComment(cmtarget.GetName().c_str()); target->AddAttribute("productReference", this->CreateObjectReference(fileRef)); - if(const char* productType = this->GetTargetProductType(cmtarget)) + if(const char* productType = this->GetTargetProductType(gtgt)) { target->AddAttribute("productType", this->CreateString(productType)); } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 791324d..2becb0d 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -137,8 +137,8 @@ private: void ForceLinkerLanguages(); void ForceLinkerLanguage(cmTarget& cmtarget); const char* GetTargetLinkFlagsVar(cmTarget const& cmtarget) const; - const char* GetTargetFileType(cmTarget& cmtarget); - const char* GetTargetProductType(cmTarget& cmtarget); + const char* GetTargetFileType(cmGeneratorTarget* target); + const char* GetTargetProductType(cmGeneratorTarget* target); std::string AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget); void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr, const char* value); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index a03808f..5964ef1 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -107,7 +107,14 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmake::MessageType messType; - cmConditionEvaluator conditionEvaluator(mf); + cmListFileContext conditionContext = + cmConditionEvaluator::GetConditionContext( + &mf, this->Functions[c], + this->GetStartingContext().FilePath); + + cmConditionEvaluator conditionEvaluator( + mf, conditionContext, + mf.GetBacktrace(this->Functions[c])); bool isTrue = conditionEvaluator.IsTrue( expandedArguments, errorString, messType); @@ -196,7 +203,16 @@ bool cmIfCommand cmake::MessageType status; - cmConditionEvaluator conditionEvaluator(*(this->Makefile)); + cmListFileContext execContext = this->Makefile->GetExecutionContext(); + + cmCommandContext commandContext; + commandContext.Line = execContext.Line; + commandContext.Name = execContext.Name; + + cmConditionEvaluator conditionEvaluator( + *(this->Makefile), cmConditionEvaluator::GetConditionContext( + this->Makefile, commandContext, execContext.FilePath), + this->Makefile->GetBacktrace()); bool isTrue = conditionEvaluator.IsTrue( expandedArguments, errorString, status); diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 97d4d56..8890e2b 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -126,7 +126,6 @@ bool cmIncludeCommand } } gg->CreateGenerationObjects(); - gg->ComputeBuildFileGenerators(); gg->GenerateImportFile(fname_abs); } diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c22edf3..6b06fce 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -773,7 +773,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) if(!exports.GetString().empty() && !namelinkOnly) { cmTargetExport *te = new cmTargetExport; - te->Target = ⌖ + te->TargetName = target.GetName(); te->ArchiveGenerator = archiveGenerator; te->BundleGenerator = bundleGenerator; te->FrameworkGenerator = frameworkGenerator; @@ -1379,16 +1379,17 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) tei != exportSet->GetTargetExports()->end(); ++tei) { cmTargetExport const* te = *tei; + cmTarget* tgt = this->Makefile->FindTarget(te->TargetName); const bool newCMP0022Behavior = - te->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD; + tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN + && tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD; if(!newCMP0022Behavior) { std::ostringstream e; e << "INSTALL(EXPORT) given keyword \"" << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \"" - << te->Target->GetName() + << te->TargetName << "\" does not have policy CMP0022 set to NEW."; this->SetError(e.str()); return false; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index f7c9cc2..9570ba3 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -56,6 +56,7 @@ cmInstallExportGenerator::~cmInstallExportGenerator() void cmInstallExportGenerator::Compute(cmLocalGenerator* lg) { this->LocalGenerator = lg; + this->ExportSet->Compute(lg); } //---------------------------------------------------------------------------- diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 2f08165..a97cc5f 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -150,7 +150,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string to1 = toDir + targetName; // Handle OSX Bundles. - if(this->Target->Target->IsAppBundleOnApple()) + if(this->Target->IsAppBundleOnApple()) { // Install the whole app bundle directory. type = cmInstallType_DIRECTORY; @@ -208,7 +208,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, // An import library looks like a static library. type = cmInstallType_STATIC_LIBRARY; } - else if(this->Target->Target->IsFrameworkOnApple()) + else if(this->Target->IsFrameworkOnApple()) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -226,7 +226,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); } - else if(this->Target->Target->IsCFBundleOnApple()) + else if(this->Target->IsCFBundleOnApple()) { // Install the whole app bundle directory. type = cmInstallType_DIRECTORY; @@ -359,34 +359,31 @@ cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const { NameType nameType = this->ImportLibrary? NameImplib : NameNormal; return - cmInstallTargetGenerator::GetInstallFilename(this->Target->Target, config, + cmInstallTargetGenerator::GetInstallFilename(this->Target, config, nameType); } //---------------------------------------------------------------------------- std::string -cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, +cmInstallTargetGenerator::GetInstallFilename(cmGeneratorTarget const* target, const std::string& config, NameType nameType) { std::string fname; // Compute the name of the library. - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); if(target->GetType() == cmState::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - gtgt->GetExecutableNames(targetName, targetNameReal, + target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { // Use the import library name. - if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname, + if(!target->GetImplibGNUtoMS(targetNameImport, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { fname = targetNameImport; @@ -410,12 +407,12 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, + target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { // Use the import library name. - if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname, + if(!target->GetImplibGNUtoMS(targetNameImport, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { fname = targetNameImport; @@ -585,7 +582,7 @@ cmInstallTargetGenerator // The directory portions differ. Append the filename to // create the mapping. std::string fname = - this->GetInstallFilename(tgt->Target, config, NameSO); + this->GetInstallFilename(tgt, config, NameSO); // Map from the build-tree install_name. for_build += fname; @@ -608,7 +605,7 @@ cmInstallTargetGenerator std::string for_install = this->Target->GetInstallNameDirForInstallTree(); - if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) + if(this->Target->IsFrameworkOnApple() && for_install.empty()) { // Frameworks seem to have an id corresponding to their own full // path. @@ -622,7 +619,7 @@ cmInstallTargetGenerator { // Prepare to refer to the install-tree install_name. new_id = for_install; - new_id += this->GetInstallFilename(this->Target->Target, config, NameSO); + new_id += this->GetInstallFilename(this->Target, config, NameSO); } } diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index a8f4a75..ec89c05 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -14,7 +14,6 @@ #include "cmInstallGenerator.h" -class cmTarget; class cmGeneratorTarget; /** \class cmInstallTargetGenerator @@ -54,7 +53,7 @@ public: NameReal }; - static std::string GetInstallFilename(cmTarget const* target, + static std::string GetInstallFilename(const cmGeneratorTarget* target, const std::string& config, NameType nameType = NameNormal); diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index b875cc0..b603bcc 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -14,6 +14,7 @@ #define cmLinkItem_h #include "cmListFileCache.h" +#include "cmSystemTools.h" class cmGeneratorTarget; @@ -118,4 +119,27 @@ struct cmOptionalLinkImplementation: public cmLinkImplementation bool HadHeadSensitiveCondition; }; +/** Compute the link type to use for the given configuration. */ +inline cmTargetLinkLibraryType +CMP0003_ComputeLinkType(const std::string& config, + std::vector<std::string> const& debugConfigs) +{ + // No configuration is always optimized. + if(config.empty()) + { + return OPTIMIZED_LibraryType; + } + + // Check if any entry in the list matches this configuration. + std::string configUpper = cmSystemTools::UpperCase(config); + if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) != + debugConfigs.end()) + { + return DEBUG_LibraryType; + } + // The current configuration is not a debug configuration. + return OPTIMIZED_LibraryType; +} + + #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e4cfcde..8a76c21 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -136,8 +136,7 @@ void cmLocalGenerator::TraceDependencies() for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->Target->IsImported() - || t->second->GetType() == cmState::INTERFACE_LIBRARY) + if (t->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -452,7 +451,6 @@ void cmLocalGenerator::GenerateInstallRules() void cmLocalGenerator::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) { this->GeneratorTargets[t] = gt; - this->GetGlobalGenerator()->AddGeneratorTarget(t, gt); } //---------------------------------------------------------------------------- @@ -476,10 +474,6 @@ void cmLocalGenerator::ComputeTargetManifest() { continue; } - if (target.Target->IsImported()) - { - continue; - } for(std::vector<std::string>::iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { @@ -920,7 +914,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s, } //---------------------------------------------------------------------------- -const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, +const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target, const std::string& prop) { if(target) @@ -934,7 +928,8 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, +void cmLocalGenerator::InsertRuleLauncher(std::string& s, + cmGeneratorTarget* target, const std::string& prop) { if(const char* val = this->GetRuleLauncher(target, prop)) @@ -1087,27 +1082,23 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, - cmTarget const* target, + cmGeneratorTarget const* target, const std::string& config, const std::string& lang) { std::vector<std::string> targetDefines; - cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); - gtgt->GetCompileDefinitions(targetDefines, config, lang); + target->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( - std::string& flags, cmTarget* target, + std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1118,7 +1109,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector<std::string>::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1139,7 +1130,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector<std::string> opts; - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector<std::string>::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1148,19 +1139,19 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector<std::string> features; - gtgt->GetCompileFeatures(features, config); + target->GetCompileFeatures(features, config); for(std::vector<std::string>::const_iterator it = features.begin(); it != features.end(); ++it) { - if (!this->Makefile->AddRequiredTargetFeature(target, *it)) + if (!this->Makefile->AddRequiredTargetFeature(target->Target, *it)) { return; } } for(std::map<std::string, std::string>::const_iterator it - = gtgt->GetMaxLanguageStandards().begin(); - it != gtgt->GetMaxLanguageStandards().end(); ++it) + = target->GetMaxLanguageStandards().begin(); + it != target->GetMaxLanguageStandards().end(); ++it) { const char* standard = target->GetProperty(it->first + "_STANDARD"); if(!standard) @@ -1314,7 +1305,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, std::string const& config, - cmTarget* target) + cmGeneratorTarget* target) { this->AppendFlags(flags, this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS")); @@ -1348,7 +1339,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, switch(target->GetType()) { case cmState::STATIC_LIBRARY: - this->GetStaticLibraryFlags(linkFlags, buildType, target->Target); + this->GetStaticLibraryFlags(linkFlags, buildType, target); break; case cmState::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; @@ -1421,7 +1412,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target->Target->GetName().c_str()); + target->GetName().c_str()); return; } this->AddLanguageFlags(flags, linkLanguage, buildType); @@ -1447,7 +1438,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } - if (target->Target->IsExecutableWithExports()) + if (target->IsExecutableWithExports()) { std::string exportFlagVar = "CMAKE_EXE_EXPORTS_"; exportFlagVar += linkLanguage; @@ -1554,7 +1545,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) { bool add_shlib_flags = false; - switch(tgt.Target->GetPolicyStatusCMP0065()) + switch(tgt.GetPolicyStatusCMP0065()) { case cmPolicies::WARN: if(!tgt.GetPropertyAsBool("ENABLE_EXPORTS") && @@ -1904,7 +1895,8 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator:: -AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, +AddCompilerRequirementFlag(std::string &flags, + cmGeneratorTarget const* target, const std::string& lang) { if (lang.empty()) @@ -1942,7 +1934,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, "CMAKE_" + lang + standardProp + "_" + type + "_COMPILE_OPTION"; - const char *opt = target->GetMakefile()->GetDefinition(option_flag); + const char *opt = target->Target->GetMakefile() + ->GetDefinition(option_flag); if (!opt) { std::ostringstream e; @@ -2007,7 +2000,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, + "_" + type + "_COMPILE_OPTION"; const char *opt = - target->GetMakefile()->GetRequiredDefinition(option_flag); + target->Target->GetMakefile()->GetRequiredDefinition(option_flag); this->AppendFlagEscape(flags, opt); return; } @@ -2018,7 +2011,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION"; - if (const char *opt = target->GetMakefile()->GetDefinition(option_flag)) + if (const char *opt = target->Target + ->GetMakefile()->GetDefinition(option_flag)) { this->AppendFlagEscape(flags, opt); return; @@ -2094,7 +2088,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags, //---------------------------------------------------------------------------- void cmLocalGenerator -::AddVisibilityPresetFlags(std::string &flags, cmTarget const* target, +::AddVisibilityPresetFlags(std::string &flags, cmGeneratorTarget const* target, const std::string& lang) { if (lang.empty()) @@ -2120,11 +2114,12 @@ void cmLocalGenerator } } - AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063); + AddVisibilityCompileOption(flags, target->Target, this, lang, pWarnCMP0063); if(lang == "CXX") { - AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063); + AddInlineVisibilityCompileOption(flags, target->Target, + this, pWarnCMP0063); } if (!warnCMP0063.empty() && @@ -2138,14 +2133,15 @@ void cmLocalGenerator "has the following visibility properties set for " << lang << ":\n" << warnCMP0063 << "For compatibility CMake is not honoring them for this target."; - target->GetMakefile()->GetCMakeInstance() - ->IssueMessage(cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace()); + target->Target->GetMakefile()->GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + target->GetBacktrace()); } } //---------------------------------------------------------------------------- void cmLocalGenerator::AddCMP0018Flags(std::string &flags, - cmTarget const* target, + cmGeneratorTarget const* target, std::string const& lang, const std::string& config) { @@ -2169,9 +2165,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if (gtgt->GetLinkInterfaceDependentBoolProperty( + if (target->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { @@ -3012,7 +3006,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const } //---------------------------------------------------------------------------- -static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, +static void cmLGInfoProp(cmMakefile* mf, cmGeneratorTarget* target, const std::string& prop) { if(const char* val = target->GetProperty(prop)) @@ -3022,7 +3016,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, +void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, const std::string& targetName, const char* fname) { @@ -3066,7 +3060,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, +void cmLocalGenerator::GenerateFrameworkInfoPList(cmGeneratorTarget* target, const std::string& targetName, const char* fname) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index ee0a618..307c67f 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -20,7 +20,6 @@ class cmMakefile; class cmGlobalGenerator; class cmGeneratorTarget; -class cmTarget; class cmTargetManifest; class cmSourceFile; class cmCustomCommand; @@ -91,13 +90,15 @@ public: void AddLanguageFlags(std::string& flags, const std::string& lang, const std::string& config); - void AddCMP0018Flags(std::string &flags, cmTarget const* target, + void AddCMP0018Flags(std::string &flags, cmGeneratorTarget const* target, std::string const& lang, const std::string& config); - void AddVisibilityPresetFlags(std::string &flags, cmTarget const* target, + void AddVisibilityPresetFlags(std::string &flags, + cmGeneratorTarget const* target, const std::string& lang); void AddConfigVariableFlags(std::string& flags, const std::string& var, const std::string& config); - void AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, + void AddCompilerRequirementFlag(std::string &flags, + cmGeneratorTarget const* target, const std::string& lang); ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const std::string& newFlags); @@ -117,10 +118,6 @@ public: return this->GeneratorTargets; } - void SetGeneratorTargets(const cmGeneratorTargetsType &targets) - { - this->GeneratorTargets = targets; - } void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt); cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; @@ -188,10 +185,10 @@ public: const std::string& lang = "C", const std::string& config = "", bool stripImplicitInclDirs = true) const; - void AddCompileOptions(std::string& flags, cmTarget* target, + void AddCompileOptions(std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config); void AddCompileDefinitions(std::set<std::string>& defines, - cmTarget const* target, + cmGeneratorTarget const* target, const std::string& config, const std::string& lang); @@ -212,7 +209,7 @@ public: { memset(this, 0, sizeof(*this)); } - cmTarget* CMTarget; + cmGeneratorTarget* CMTarget; const char* TargetPDB; const char* TargetCompilePDB; const char* TargetVersionMajor; @@ -278,13 +275,14 @@ public: /** * Generate a Mac OS X application bundle Info.plist file. */ - void GenerateAppleInfoPList(cmTarget* target, const std::string& targetName, + void GenerateAppleInfoPList(cmGeneratorTarget* target, + const std::string& targetName, const char* fname); /** * Generate a Mac OS X framework Info.plist file. */ - void GenerateFrameworkInfoPList(cmTarget* target, + void GenerateFrameworkInfoPList(cmGeneratorTarget* target, const std::string& targetName, const char* fname); /** Construct a comment for a custom command. */ @@ -298,7 +296,7 @@ public: /** Fill out the static linker flags for the given target. */ void GetStaticLibraryFlags(std::string& flags, std::string const& config, - cmTarget* target); + cmGeneratorTarget* target); /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ @@ -341,8 +339,9 @@ protected: std::string ExpandRuleVariable(std::string const& variable, const RuleVariables& replaceValues); - const char* GetRuleLauncher(cmTarget* target, const std::string& prop); - void InsertRuleLauncher(std::string& s, cmTarget* target, + const char* GetRuleLauncher(cmGeneratorTarget* target, + const std::string& prop); + void InsertRuleLauncher(std::string& s, cmGeneratorTarget* target, const std::string& prop); // Handle old-style install rules stored in the targets. @@ -367,7 +366,7 @@ protected: std::string::size_type ObjectPathMax; std::set<std::string> ObjectMaxPathViolations; - std::set<cmTarget const*> WarnCMP0063; + std::set<cmGeneratorTarget const*> WarnCMP0063; cmGeneratorTargetsType GeneratorTargets; bool EmitUniversalBinaryFlags; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 2535d2f..869ba2c 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -31,8 +31,7 @@ void cmLocalGhsMultiGenerator::Generate() for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if (l->second->GetType() == cmState::INTERFACE_LIBRARY - || l->second->Target->IsImported()) + if (l->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 4da77e0..756c139 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -77,8 +77,7 @@ void cmLocalNinjaGenerator::Generate() for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->GetType() == cmState::INTERFACE_LIBRARY - || t->second->Target->IsImported()) + if (t->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f3ee2e3..5485da4 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -119,8 +119,7 @@ void cmLocalUnixMakefileGenerator3::Generate() for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->GetType() == cmState::INTERFACE_LIBRARY - || t->second->Target->IsImported()) + if (t->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -430,11 +429,6 @@ void cmLocalUnixMakefileGenerator3 (t->second->GetType() == cmState::OBJECT_LIBRARY) || (t->second->GetType() == cmState::UTILITY)) { - if (t->second->Target->IsImported()) - { - continue; - } - emitted.insert(t->second->GetName()); // for subdirs add a rule to build this specific target by name. @@ -1034,7 +1028,7 @@ void cmLocalUnixMakefileGenerator3 ::AppendCustomCommands(std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs, - cmTarget* target, + cmGeneratorTarget* target, cmLocalGenerator::RelativeRoot relative) { for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin(); @@ -1050,7 +1044,7 @@ void cmLocalUnixMakefileGenerator3 ::AppendCustomCommand(std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg, - cmTarget* target, + cmGeneratorTarget* target, bool echo_comment, cmLocalGenerator::RelativeRoot relative, std::ostream* content) @@ -1181,7 +1175,7 @@ cmLocalUnixMakefileGenerator3 std::string cmLocalUnixMakefileGenerator3::MakeLauncher( cmCustomCommandGenerator const& ccg, - cmTarget* target, RelativeRoot relative) + cmGeneratorTarget* target, RelativeRoot relative) { // Short-circuit if there is no launcher. const char* prop = "RULE_LAUNCH_CUSTOM"; @@ -1788,6 +1782,9 @@ void cmLocalUnixMakefileGenerator3 this->AppendEcho(commands, text, cmLocalUnixMakefileGenerator3::EchoGlobal); + cmGeneratorTarget* gt = this->GlobalGenerator + ->GetGeneratorTarget(&glIt->second); + // Global targets store their rules in pre- and post-build commands. this->AppendCustomDepends(depends, glIt->second.GetPreBuildCommands()); @@ -1795,11 +1792,11 @@ void cmLocalUnixMakefileGenerator3 glIt->second.GetPostBuildCommands()); this->AppendCustomCommands(commands, glIt->second.GetPreBuildCommands(), - &glIt->second, + gt, cmLocalGenerator::START_OUTPUT); this->AppendCustomCommands(commands, glIt->second.GetPostBuildCommands(), - &glIt->second, + gt, cmLocalGenerator::START_OUTPUT); std::string targetName = glIt->second.GetName(); this->WriteMakeRule(ruleFileStream, targetString.c_str(), @@ -1976,10 +1973,11 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, void cmLocalUnixMakefileGenerator3 -::WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &target) +::WriteDependLanguageInfo(std::ostream& cmakefileStream, + cmGeneratorTarget* target) { ImplicitDependLanguageMap const& implicitLangs = - this->GetImplicitDepends(target); + this->GetImplicitDepends(*target->Target); // list the languages cmakefileStream @@ -2030,7 +2028,7 @@ void cmLocalUnixMakefileGenerator3 // Build a list of preprocessor definitions for the target. std::set<std::string> defines; - this->AddCompileDefinitions(defines, &target, + this->AddCompileDefinitions(defines, target, this->ConfigName, l->first); if(!defines.empty()) { @@ -2056,12 +2054,10 @@ void cmLocalUnixMakefileGenerator3 << "set(CMAKE_" << l->first << "_TARGET_INCLUDE_PATH\n"; std::vector<std::string> includes; - cmGeneratorTarget* gt = this->GetGlobalGenerator() - ->GetGeneratorTarget(&target); const std::string& config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->GetIncludeDirectories(includes, gt, + this->GetIncludeDirectories(includes, target, l->first, config); for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) @@ -2084,7 +2080,7 @@ void cmLocalUnixMakefileGenerator3 cmSystemTools::ExpandListArgument(xform, transformRules); } if(const char* xform = - target.GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) + target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { cmSystemTools::ExpandListArgument(xform, transformRules); } diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 586dda0..7e0f248 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -19,7 +19,6 @@ class cmCustomCommand; class cmCustomCommandGenerator; -class cmDependInformation; class cmDepends; class cmMakefileTargetGenerator; class cmTarget; @@ -182,7 +181,8 @@ protected: // write the depend info - void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &tgt); + void WriteDependLanguageInfo(std::ostream& cmakefileStream, + cmGeneratorTarget *tgt); // write the local help rule void WriteHelpRule(std::ostream& ruleFileStream); @@ -215,12 +215,12 @@ protected: cmCustomCommandGenerator const& cc); void AppendCustomCommands(std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs, - cmTarget* target, + cmGeneratorTarget* target, cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::HOME_OUTPUT); void AppendCustomCommand(std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg, - cmTarget* target, + cmGeneratorTarget* target, bool echo_comment=false, cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::HOME_OUTPUT, @@ -237,7 +237,7 @@ protected: private: std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root); std::string MakeLauncher(cmCustomCommandGenerator const& ccg, - cmTarget* target, RelativeRoot relative); + cmGeneratorTarget* target, RelativeRoot relative); virtual void ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index b6f5aed..a51eb67 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1319,7 +1319,7 @@ void cmLocalVisualStudio6Generator { int major; int minor; - target.GetTargetVersion(major, minor); + gt->GetTargetVersion(major, minor); std::ostringstream targetVersionStream; targetVersionStream << "/version:" << major << "." << minor; targetVersionFlag = targetVersionStream.str(); @@ -1543,7 +1543,7 @@ void cmLocalVisualStudio6Generator // Add the export symbol definition for shared library objects. std::string exportSymbol; - if(const char* exportMacro = target.GetExportMacro()) + if(const char* exportMacro = gt->GetExportMacro()) { exportSymbol = exportMacro; } @@ -1750,12 +1750,12 @@ void cmLocalVisualStudio6Generator flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; - this->AddCompileOptions(flags, &target, linkLanguage, ""); - this->AddCompileOptions(flagsDebug, &target, linkLanguage, "Debug"); - this->AddCompileOptions(flagsRelease, &target, linkLanguage, "Release"); - this->AddCompileOptions(flagsMinSizeRel, &target, linkLanguage, + this->AddCompileOptions(flags, gt, linkLanguage, ""); + this->AddCompileOptions(flagsDebug, gt, linkLanguage, "Debug"); + this->AddCompileOptions(flagsRelease, gt, linkLanguage, "Release"); + this->AddCompileOptions(flagsMinSizeRel, gt, linkLanguage, "MinSizeRel"); - this->AddCompileOptions(flagsRelWithDebInfo, &target, linkLanguage, + this->AddCompileOptions(flagsRelWithDebInfo, gt, linkLanguage, "RelWithDebInfo"); // if _UNICODE and _SBCS are not found, then add -D_MBCS @@ -1775,14 +1775,14 @@ void cmLocalVisualStudio6Generator std::set<std::string> minsizeDefinesSet; std::set<std::string> debugrelDefinesSet; - this->AddCompileDefinitions(definesSet, &target, "", linkLanguage); - this->AddCompileDefinitions(debugDefinesSet, &target, + this->AddCompileDefinitions(definesSet, gt, "", linkLanguage); + this->AddCompileDefinitions(debugDefinesSet, gt, "DEBUG", linkLanguage); - this->AddCompileDefinitions(releaseDefinesSet, &target, + this->AddCompileDefinitions(releaseDefinesSet, gt, "RELEASE", linkLanguage); - this->AddCompileDefinitions(minsizeDefinesSet, &target, + this->AddCompileDefinitions(minsizeDefinesSet, gt, "MINSIZEREL", linkLanguage); - this->AddCompileDefinitions(debugrelDefinesSet, &target, + this->AddCompileDefinitions(debugrelDefinesSet, gt, "RELWITHDEBINFO", linkLanguage); std::string defines = " "; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 1122919..819998c 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -733,7 +733,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } // Add the target-specific flags. - this->AddCompileOptions(flags, &target, linkLanguage, configName); + this->AddCompileOptions(flags, gt, linkLanguage, configName); } if(this->FortranProject) @@ -777,7 +777,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.AddDefine(configDefine); // Add the export symbol definition for shared library objects. - if(const char* exportMacro = target.GetExportMacro()) + if(const char* exportMacro = gt->GetExportMacro()) { targetOptions.AddDefine(exportMacro); } @@ -1152,7 +1152,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } } std::string libflags; - this->GetStaticLibraryFlags(libflags, configTypeUpper, &target); + this->GetStaticLibraryFlags(libflags, configTypeUpper, gt); if(!libflags.empty()) { fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n"; @@ -1215,7 +1215,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, temp += targetNameFull; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; - this->WriteTargetVersionAttribute(fout, target); + this->WriteTargetVersionAttribute(fout, gt); linkOptions.OutputFlagMap(fout, "\t\t\t\t"); fout << "\t\t\t\tAdditionalLibraryDirectories=\""; this->OutputLibraryDirectories(fout, cli.GetDirectories()); @@ -1314,7 +1314,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, temp += targetNameFull; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; - this->WriteTargetVersionAttribute(fout, target); + this->WriteTargetVersionAttribute(fout, gt); linkOptions.OutputFlagMap(fout, "\t\t\t\t"); fout << "\t\t\t\tAdditionalLibraryDirectories=\""; this->OutputLibraryDirectories(fout, cli.GetDirectories()); @@ -1384,11 +1384,11 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, //---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator -::WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target) +::WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt) { int major; int minor; - target.GetTargetVersion(major, minor); + gt->GetTargetVersion(major, minor); fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n"; } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index ba6a72b..16cf004 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -106,7 +106,8 @@ private: const char* source, const cmCustomCommand& command, FCInfo& fcinfo); - void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target); + void WriteTargetVersionAttribute(std::ostream& fout, + cmGeneratorTarget* gt); bool WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx deleted file mode 100644 index cbc7e02..0000000 --- a/Source/cmMakeDepend.cxx +++ /dev/null @@ -1,361 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmMakeDepend.h" -#include "cmSystemTools.h" -#include "cmGeneratorExpression.h" -#include "cmAlgorithms.h" - -#include <cmsys/RegularExpression.hxx> -#include <cmsys/FStream.hxx> - -void cmDependInformation::AddDependencies(cmDependInformation* info) -{ - if(this != info) - { - this->DependencySet.insert(info); - } -} - -cmMakeDepend::cmMakeDepend() -{ - this->Verbose = false; - this->IncludeFileRegularExpression.compile("^.*$"); - this->ComplainFileRegularExpression.compile("^$"); -} - - -cmMakeDepend::~cmMakeDepend() -{ - cmDeleteAll(this->DependInformationMap); -} - - -// Set the makefile that depends will be made from. -// The pointer is kept so the cmSourceFile array can -// be updated with the depend information in the cmMakefile. - -void cmMakeDepend::SetMakefile(cmMakefile* makefile) -{ - this->Makefile = makefile; - - // Now extract the include file regular expression from the makefile. - this->IncludeFileRegularExpression.compile( - this->Makefile->GetIncludeRegularExpression()); - this->ComplainFileRegularExpression.compile( - this->Makefile->ComplainFileRegularExpression.c_str()); - - // Now extract any include paths from the targets - std::set<std::string> uniqueIncludes; - std::vector<std::string> orderedAndUniqueIncludes; - cmTargets &targets = this->Makefile->GetTargets(); - for (cmTargets::iterator l = targets.begin(); - l != targets.end(); ++l) - { - const char *incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES"); - if (!incDirProp) - { - continue; - } - - std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp, - cmGeneratorExpression::StripAllGeneratorExpressions); - - std::vector<std::string> includes; - cmSystemTools::ExpandListArgument(incDirs, includes); - - for(std::vector<std::string>::const_iterator j = includes.begin(); - j != includes.end(); ++j) - { - std::string path = *j; - this->Makefile->ExpandVariablesInString(path); - if(uniqueIncludes.insert(path).second) - { - orderedAndUniqueIncludes.push_back(path); - } - } - } - - for(std::vector<std::string>::const_iterator - it = orderedAndUniqueIncludes.begin(); - it != orderedAndUniqueIncludes.end(); - ++it) - { - this->AddSearchPath(*it); - } -} - - -const cmDependInformation* cmMakeDepend::FindDependencies(const char* file) -{ - cmDependInformation* info = this->GetDependInformation(file,0); - this->GenerateDependInformation(info); - return info; -} - -void cmMakeDepend::GenerateDependInformation(cmDependInformation* info) -{ - // If dependencies are already done, stop now. - if(info->DependDone) - { - return; - } - else - { - // Make sure we don't visit the same file more than once. - info->DependDone = true; - } - const char* path = info->FullPath.c_str(); - if(!path) - { - cmSystemTools::Error( - "Attempt to find dependencies for file without path!"); - return; - } - - bool found = false; - - // If the file exists, use it to find dependency information. - if(cmSystemTools::FileExists(path, true)) - { - // Use the real file to find its dependencies. - this->DependWalk(info); - found = true; - } - - - // See if the cmSourceFile for it has any files specified as - // dependency hints. - if(info->SourceFile != 0) - { - - // Get the cmSourceFile corresponding to this. - const cmSourceFile& cFile = *(info->SourceFile); - // See if there are any hints for finding dependencies for the missing - // file. - if(!cFile.GetDepends().empty()) - { - // Dependency hints have been given. Use them to begin the - // recursion. - for(std::vector<std::string>::const_iterator file = - cFile.GetDepends().begin(); file != cFile.GetDepends().end(); - ++file) - { - this->AddDependency(info, file->c_str()); - } - - // Found dependency information. We are done. - found = true; - } - } - - if(!found) - { - // Try to find the file amongst the sources - cmSourceFile *srcFile = this->Makefile->GetSource - (cmSystemTools::GetFilenameWithoutExtension(path)); - if (srcFile) - { - if (srcFile->GetFullPath() == path) - { - found=true; - } - else - { - //try to guess which include path to use - for(std::vector<std::string>::iterator t = - this->IncludeDirectories.begin(); - t != this->IncludeDirectories.end(); ++t) - { - std::string incpath = *t; - if (!incpath.empty() && incpath[incpath.size() - 1] != '/') - { - incpath = incpath + "/"; - } - incpath = incpath + path; - if (srcFile->GetFullPath() == incpath) - { - // set the path to the guessed path - info->FullPath = incpath; - found=true; - } - } - } - } - } - - if(!found) - { - // Couldn't find any dependency information. - if(this->ComplainFileRegularExpression.find(info->IncludeName.c_str())) - { - cmSystemTools::Error("error cannot find dependencies for ", path); - } - else - { - // Destroy the name of the file so that it won't be output as a - // dependency. - info->FullPath = ""; - } - } -} - -// This function actually reads the file specified and scans it for -// #include directives -void cmMakeDepend::DependWalk(cmDependInformation* info) -{ - cmsys::RegularExpression includeLine - ("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]"); - cmsys::ifstream fin(info->FullPath.c_str()); - if(!fin) - { - cmSystemTools::Error("Cannot open ", info->FullPath.c_str()); - return; - } - - // TODO: Write real read loop (see cmSystemTools::CopyFile). - std::string line; - while( cmSystemTools::GetLineFromStream(fin, line) ) - { - if(includeLine.find(line.c_str())) - { - // extract the file being included - std::string includeFile = includeLine.match(1); - // see if the include matches the regular expression - if(!this->IncludeFileRegularExpression.find(includeFile)) - { - if(this->Verbose) - { - std::string message = "Skipping "; - message += includeFile; - message += " for file "; - message += info->FullPath.c_str(); - cmSystemTools::Error(message.c_str(), 0); - } - continue; - } - - // Add this file and all its dependencies. - this->AddDependency(info, includeFile.c_str()); - } - } -} - - -void cmMakeDepend::AddDependency(cmDependInformation* info, const char* file) -{ - cmDependInformation* dependInfo = - this->GetDependInformation(file, info->PathOnly.c_str()); - this->GenerateDependInformation(dependInfo); - info->AddDependencies(dependInfo); -} - -cmDependInformation* cmMakeDepend::GetDependInformation(const char* file, - const char *extraPath) -{ - // Get the full path for the file so that lookup is unambiguous. - std::string fullPath = this->FullPath(file, extraPath); - - // Try to find the file's instance of cmDependInformation. - DependInformationMapType::const_iterator result = - this->DependInformationMap.find(fullPath); - if(result != this->DependInformationMap.end()) - { - // Found an instance, return it. - return result->second; - } - else - { - // Didn't find an instance. Create a new one and save it. - cmDependInformation* info = new cmDependInformation; - info->FullPath = fullPath; - info->PathOnly = cmSystemTools::GetFilenamePath(fullPath); - info->IncludeName = file; - this->DependInformationMap[fullPath] = info; - return info; - } -} - - -// find the full path to fname by searching the this->IncludeDirectories array -std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) -{ - DirectoryToFileToPathMapType::iterator m; - if(extraPath) - { - m = this->DirectoryToFileToPathMap.find(extraPath); - } - else - { - m = this->DirectoryToFileToPathMap.find(""); - } - - if(m != this->DirectoryToFileToPathMap.end()) - { - FileToPathMapType& map = m->second; - FileToPathMapType::iterator p = map.find(fname); - if(p != map.end()) - { - return p->second; - } - } - - if(cmSystemTools::FileExists(fname, true)) - { - std::string fp = cmSystemTools::CollapseFullPath(fname); - this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; - return fp; - } - - for(std::vector<std::string>::iterator i = this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) - { - std::string path = *i; - if (!path.empty() && path[path.size() - 1] != '/') - { - path = path + "/"; - } - path = path + fname; - if(cmSystemTools::FileExists(path.c_str(), true) - && !cmSystemTools::FileIsDirectory(path)) - { - std::string fp = cmSystemTools::CollapseFullPath(path); - this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; - return fp; - } - } - - if (extraPath) - { - std::string path = extraPath; - if (!path.empty() && path[path.size() - 1] != '/') - { - path = path + "/"; - } - path = path + fname; - if(cmSystemTools::FileExists(path.c_str(), true) - && !cmSystemTools::FileIsDirectory(path)) - { - std::string fp = cmSystemTools::CollapseFullPath(path); - this->DirectoryToFileToPathMap[extraPath][fname] = fp; - return fp; - } - } - - // Couldn't find the file. - return std::string(fname); -} - -// Add a directory to the search path -void cmMakeDepend::AddSearchPath(const std::string& path) -{ - this->IncludeDirectories.push_back(path); -} diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h deleted file mode 100644 index 2c9d515..0000000 --- a/Source/cmMakeDepend.h +++ /dev/null @@ -1,150 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmMakeDepend_h -#define cmMakeDepend_h - -#include "cmMakefile.h" -#include "cmSourceFile.h" - -#include <cmsys/RegularExpression.hxx> - -/** \class cmDependInformation - * \brief Store dependency information for a single source file. - * - * This structure stores the depend information for a single source file. - */ -class cmDependInformation -{ -public: - /** - * Construct with dependency generation marked not done; instance - * not placed in cmMakefile's list. - */ - cmDependInformation(): DependDone(false), SourceFile(0) {} - - /** - * The set of files on which this one depends. - */ - typedef std::set<cmDependInformation*> DependencySetType; - DependencySetType DependencySet; - - /** - * This flag indicates whether dependency checking has been - * performed for this file. - */ - bool DependDone; - - /** - * If this object corresponds to a cmSourceFile instance, this points - * to it. - */ - const cmSourceFile *SourceFile; - - /** - * Full path to this file. - */ - std::string FullPath; - - /** - * Full path not including file name. - */ - std::string PathOnly; - - /** - * Name used to #include this file. - */ - std::string IncludeName; - - /** - * This method adds the dependencies of another file to this one. - */ - void AddDependencies(cmDependInformation*); -}; - - -// cmMakeDepend is used to generate dependancy information for -// the classes in a makefile -class cmMakeDepend -{ -public: - /** - * Construct the object with verbose turned off. - */ - cmMakeDepend(); - - /** - * Destructor. - */ - virtual ~cmMakeDepend(); - - /** - * Set the makefile that is used as a source of classes. - */ - virtual void SetMakefile(cmMakefile* makefile); - - /** - * Add a directory to the search path for include files. - */ - virtual void AddSearchPath(const std::string&); - - /** - * Generate dependencies for the file given. Returns a pointer to - * the cmDependInformation object for the file. - */ - const cmDependInformation* FindDependencies(const char* file); - -protected: - /** - * Compute the depend information for this class. - */ - virtual void DependWalk(cmDependInformation* info); - - /** - * Add a dependency. Possibly walk it for more dependencies. - */ - virtual void AddDependency(cmDependInformation* info, const char* file); - - /** - * Fill in the given object with dependency information. If the - * information is already complete, nothing is done. - */ - void GenerateDependInformation(cmDependInformation* info); - - /** - * Get an instance of cmDependInformation corresponding to the given file - * name. - */ - cmDependInformation* GetDependInformation(const char* file, - const char *extraPath); - - /** - * Find the full path name for the given file name. - * This uses the include directories. - * TODO: Cache path conversions to reduce FileExists calls. - */ - std::string FullPath(const char *filename, const char *extraPath); - - cmMakefile* Makefile; - bool Verbose; - cmsys::RegularExpression IncludeFileRegularExpression; - cmsys::RegularExpression ComplainFileRegularExpression; - std::vector<std::string> IncludeDirectories; - typedef std::map<std::string, std::string> FileToPathMapType; - typedef std::map<std::string, FileToPathMapType> - DirectoryToFileToPathMapType; - typedef std::map<std::string, cmDependInformation*> - DependInformationMapType; - DependInformationMapType DependInformationMap; - DirectoryToFileToPathMapType DirectoryToFileToPathMap; -}; - -#endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a1f143a..264b169 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4569,9 +4569,10 @@ bool cmMakefile::SetPolicyVersion(const char *version) } //---------------------------------------------------------------------------- -bool cmMakefile::HasCMP0054AlreadyBeenReported() const +bool cmMakefile::HasCMP0054AlreadyBeenReported( + cmListFileContext const& context) const { - return !this->CMP0054ReportedIds.insert(this->GetExecutionContext()).second; + return !this->CMP0054ReportedIds.insert(context).second; } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4215b72..725448b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -41,7 +41,6 @@ class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; -class cmMakeDepend; class cmSourceFile; class cmTest; class cmTestGenerator; @@ -331,7 +330,7 @@ public: * Determine if the given context, name pair has already been reported * in context of CMP0054. */ - bool HasCMP0054AlreadyBeenReported() const; + bool HasCMP0054AlreadyBeenReported(const cmListFileContext &context) const; bool IgnoreErrorsCMP0061() const; @@ -856,9 +855,6 @@ private: bool EnforceUniqueDir(const std::string& srcPath, const std::string& binPath) const; - friend class cmMakeDepend; // make depend needs direct access - // to the Sources array - typedef std::vector<cmFunctionBlocker*> FunctionBlockersType; FunctionBlockersType FunctionBlockers; std::vector<FunctionBlockersType::size_type> FunctionBlockerBarriers; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2d2de5f..020e64c 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -100,7 +100,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Construct the full path version of the names. std::string outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); - if(this->Target->IsAppBundleOnApple()) + if(this->GeneratorTarget->IsAppBundleOnApple()) { this->OSXBundleGenerator->CreateAppBundle(targetName, outpath); } @@ -168,7 +168,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", - this->Target->GetName().c_str(), "\"."); + this->GeneratorTarget->GetName().c_str(), "\"."); return; } @@ -197,7 +197,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->ConfigName); - if(this->Target->GetPropertyAsBool("WIN32_EXECUTABLE")) + if(this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) { this->LocalGenerator->AppendFlags (linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); @@ -209,7 +209,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } // Add symbol export flags if necessary. - if(this->Target->IsExecutableWithExports()) + if(this->GeneratorTarget->IsExecutableWithExports()) { std::string export_flag_var = "CMAKE_EXE_EXPORTS_"; export_flag_var += linkLanguage; @@ -226,11 +226,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Add target-specific linker flags. this->LocalGenerator->AppendFlags - (linkFlags, this->Target->GetProperty("LINK_FLAGS")); + (linkFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS")); std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (linkFlags, this->Target->GetProperty(linkFlagsConfig)); + (linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->AddModuleDefinitionFlag(linkFlags); @@ -280,10 +280,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) { this->LocalGenerator ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), - this->Target); + this->GeneratorTarget); this->LocalGenerator ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), - this->Target); + this->GeneratorTarget); } // Determine whether a link script will be used. @@ -297,7 +297,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector<std::string> commands1; cmSystemTools::ExpandListArgument(linkRule, real_link_commands); - if(this->Target->IsExecutableWithExports()) + if(this->GeneratorTarget->IsExecutableWithExports()) { // If a separate rule for creating an import library is specified // add it now. @@ -358,7 +358,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->Target; + vars.CMTarget = this->GeneratorTarget; vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); @@ -382,7 +382,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::ostringstream minorStream; int major; int minor; - this->Target->GetTargetVersion(major, minor); + this->GeneratorTarget->GetTargetVersion(major, minor); majorStream << major; minorStream << minor; targetVersionMajor = majorStream.str(); @@ -449,7 +449,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) { this->LocalGenerator-> AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), - this->Target); + this->GeneratorTarget); } // Write the build rule. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a0aa10b..df2a8c9 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -115,18 +115,18 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() // Add post-build rules. this->LocalGenerator-> AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), - this->Target); + this->GeneratorTarget); // Depend on the object files. this->AppendObjectDepends(depends); // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - this->Target->GetName(), + this->GeneratorTarget->GetName(), depends, commands, true); // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(this->Target->GetName(), false); + this->WriteTargetDriverRule(this->GeneratorTarget->GetName(), false); } //---------------------------------------------------------------------------- @@ -146,14 +146,14 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() std::string extraFlags; this->LocalGenerator->GetStaticLibraryFlags(extraFlags, - cmSystemTools::UpperCase(this->ConfigName), this->Target); + cmSystemTools::UpperCase(this->ConfigName), this->GeneratorTarget); this->WriteLibraryRules(linkRuleVar, extraFlags, false); } //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) { - if(this->Target->IsFrameworkOnApple()) + if(this->GeneratorTarget->IsFrameworkOnApple()) { this->WriteFrameworkRules(relink); return; @@ -166,11 +166,11 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) std::string extraFlags; this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty("LINK_FLAGS")); + (extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS")); std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig)); + (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName); @@ -190,11 +190,11 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) std::string extraFlags; this->LocalGenerator->AppendFlags(extraFlags, - this->Target->GetProperty("LINK_FLAGS")); + this->GeneratorTarget->GetProperty("LINK_FLAGS")); std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig)); + (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName); this->AddModuleDefinitionFlag(extraFlags); @@ -213,11 +213,11 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) std::string extraFlags; this->LocalGenerator->AppendFlags(extraFlags, - this->Target->GetProperty("LINK_FLAGS")); + this->GeneratorTarget->GetProperty("LINK_FLAGS")); std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig)); + (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName); @@ -244,7 +244,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", - this->Target->GetName().c_str(), "\"."); + this->GeneratorTarget->GetName().c_str(), "\"."); return; } @@ -273,13 +273,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Construct the full path version of the names. std::string outpath; std::string outpathImp; - if(this->Target->IsFrameworkOnApple()) + if(this->GeneratorTarget->IsFrameworkOnApple()) { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); this->OSXBundleGenerator->CreateFramework(targetName, outpath); outpath += "/"; } - else if(this->Target->IsCFBundleOnApple()) + else if(this->GeneratorTarget->IsCFBundleOnApple()) { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); this->OSXBundleGenerator->CreateCFBundle(targetName, outpath); @@ -360,7 +360,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules buildEcho += " shared library "; break; case cmState::MODULE_LIBRARY: - if (this->Target->IsCFBundleOnApple()) + if (this->GeneratorTarget->IsCFBundleOnApple()) buildEcho += " CFBundle"; buildEcho += " shared module "; break; @@ -458,10 +458,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { this->LocalGenerator ->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), - this->Target); + this->GeneratorTarget); this->LocalGenerator ->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), - this->Target); + this->GeneratorTarget); } // Determine whether a link script will be used. @@ -569,12 +569,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if(this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + if(this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { std::string name_of_def_file = this->GeneratorTarget->GetSupportDirectory(); name_of_def_file += std::string("/") + - this->Target->GetName(); + this->GeneratorTarget->GetName(); name_of_def_file += ".def"; std::string cmd = cmSystemTools::GetCMakeCommand(); cmd = this->Convert(cmd, cmLocalGenerator::NONE, @@ -630,7 +630,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::ostringstream minorStream; int major; int minor; - this->Target->GetTargetVersion(major, minor); + this->GeneratorTarget->GetTargetVersion(major, minor); majorStream << major; minorStream << minor; targetVersionMajor = majorStream.str(); @@ -640,7 +640,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.TargetVersionMinor = targetVersionMinor.c_str(); vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->Target; + vars.CMTarget = this->GeneratorTarget; vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); @@ -791,7 +791,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Add a rule to create necessary symlinks for the library. // Frameworks are handled by cmOSXBundleGenerator. - if(targetOutPath != targetOutPathReal && !this->Target->IsFrameworkOnApple()) + if(targetOutPath != targetOutPathReal + && !this->GeneratorTarget->IsFrameworkOnApple()) { std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_library "; symlink += targetOutPathReal; @@ -811,7 +812,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { this->LocalGenerator-> AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), - this->Target); + this->GeneratorTarget); } // Compute the list of outputs. @@ -862,7 +863,7 @@ cmMakefileLibraryTargetGenerator int major; int minor; int patch; - this->Target->GetTargetVersion(so, major, minor, patch); + this->GeneratorTarget->GetTargetVersion(so, major, minor, patch); if(major > 0 || minor > 0 || patch > 0) { // Append the flag since a non-zero version is specified. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 48a29b3..b7970fd 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -248,7 +248,8 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() // Write an empty dependency file. cmGeneratedFileStream depFileStream(dependFileNameFull.c_str()); depFileStream - << "# Empty dependencies file for " << this->Target->GetName() << ".\n" + << "# Empty dependencies file for " + << this->GeneratorTarget->GetName() << ".\n" << "# This may be replaced when dependencies are built." << std::endl; } @@ -394,7 +395,7 @@ void cmMakefileTargetGenerator err << "Warning: Source file \"" << source.GetFullPath() << "\" is listed multiple times for target \"" - << this->Target->GetName() + << this->GeneratorTarget->GetName() << "\"."; cmSystemTools::Message(err.str().c_str(), "Warning"); return; @@ -588,7 +589,7 @@ cmMakefileTargetGenerator } cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; - vars.CMTarget = this->Target; + vars.CMTarget = this->GeneratorTarget; vars.Language = lang.c_str(); vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); @@ -666,7 +667,7 @@ cmMakefileTargetGenerator if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) { std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE"; - const char *iwyu = this->Target->GetProperty(iwyu_prop); + const char *iwyu = this->GeneratorTarget->GetProperty(iwyu_prop); if (iwyu && *iwyu) { std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_iwyu --iwyu="; @@ -680,7 +681,7 @@ cmMakefileTargetGenerator if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; - const char *clauncher = this->Target->GetProperty(clauncher_prop); + const char *clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); if (clauncher && *clauncher) { std::vector<std::string> launcher_cmd; @@ -1039,7 +1040,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() return; } this->LocalGenerator-> - WriteDependLanguageInfo(*this->InfoFileStream,*this->Target); + WriteDependLanguageInfo(*this->InfoFileStream, this->GeneratorTarget); // Store multiple output pairs in the depend info file. if(!this->MultipleOutputPairs.empty()) @@ -1210,7 +1211,8 @@ void cmMakefileTargetGenerator // Now append the actual user-specified commands. std::ostringstream content; - this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false, + this->LocalGenerator->AppendCustomCommand(commands, ccg, + this->GeneratorTarget, false, cmLocalGenerator::HOME_OUTPUT, &content); @@ -1267,10 +1269,10 @@ cmMakefileTargetGenerator // Write a make variable assignment that lists all objects for the // target. variableName = - this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), + this->LocalGenerator->CreateMakeVariable(this->GeneratorTarget->GetName(), "_OBJECTS"); *this->BuildFileStream - << "# Object files for target " << this->Target->GetName() << "\n" + << "# Object files for target " << this->GeneratorTarget->GetName() << "\n" << variableName << " ="; std::string object; const char* lineContinue = @@ -1292,12 +1294,12 @@ cmMakefileTargetGenerator // Write a make variable assignment that lists all external objects // for the target. variableNameExternal = - this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), + this->LocalGenerator->CreateMakeVariable(this->GeneratorTarget->GetName(), "_EXTERNAL_OBJECTS"); *this->BuildFileStream << "\n" << "# External object files for target " - << this->Target->GetName() << "\n" + << this->GeneratorTarget->GetName() << "\n" << variableNameExternal << " ="; for(std::vector<std::string>::const_iterator i = this->ExternalObjects.begin(); @@ -1512,7 +1514,7 @@ void cmMakefileTargetGenerator // Add user-specified dependencies. if(const char* linkDepends = - this->Target->GetProperty("LINK_DEPENDS")) + this->GeneratorTarget->GetProperty("LINK_DEPENDS")) { cmSystemTools::ExpandListArgument(linkDepends, depends); } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index fd4527b..e38c50b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -18,7 +18,6 @@ #include "cmOSXBundleGenerator.h" class cmCustomCommandGenerator; -class cmDependInformation; class cmDepends; class cmGeneratorTarget; class cmGeneratedFileStream; diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 303ca63..11601c5 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -42,7 +42,8 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() this->CreateRuleFile(); *this->BuildFileStream - << "# Utility rule file for " << this->Target->GetName() << ".\n\n"; + << "# Utility rule file for " + << this->GeneratorTarget->GetName() << ".\n\n"; if(!this->NoRuleMessages) { @@ -73,13 +74,13 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() (depends, this->Target->GetPostBuildCommands()); this->LocalGenerator->AppendCustomCommands - (commands, this->Target->GetPreBuildCommands(), this->Target); + (commands, this->Target->GetPreBuildCommands(), this->GeneratorTarget); // Depend on all custom command outputs for sources this->DriveCustomCommands(depends); this->LocalGenerator->AppendCustomCommands - (commands, this->Target->GetPostBuildCommands(), this->Target); + (commands, this->Target->GetPostBuildCommands(), this->GeneratorTarget); // Add dependencies on targets that must be built first. this->AppendTargetDepends(depends); @@ -101,11 +102,11 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - this->Target->GetName(), + this->GeneratorTarget->GetName(), depends, commands, true); // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(this->Target->GetName(), false); + this->WriteTargetDriverRule(this->GeneratorTarget->GetName(), false); // Write clean target this->WriteTargetCleanRules(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 066c64e..dafbda9 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -77,7 +77,7 @@ void cmNinjaNormalTargetGenerator::Generate() if (this->TargetLinkLanguage.empty()) { cmSystemTools::Error("CMake can not determine linker language for " "target: ", - this->GetTarget()->GetName().c_str()); + this->GetGeneratorTarget()->GetName().c_str()); return; } @@ -139,7 +139,7 @@ const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const case cmState::SHARED_LIBRARY: return "shared library"; case cmState::MODULE_LIBRARY: - if (this->GetTarget()->IsCFBundleOnApple()) + if (this->GetGeneratorTarget()->IsCFBundleOnApple()) return "CFBundle shared module"; else return "shared module"; @@ -158,7 +158,8 @@ cmNinjaNormalTargetGenerator + "_" + cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) + "_LINKER__" - + cmGlobalNinjaGenerator::EncodeRuleName(this->GetTarget()->GetName()) + + cmGlobalNinjaGenerator::EncodeRuleName( + this->GetGeneratorTarget()->GetName()) ; } @@ -177,7 +178,7 @@ cmNinjaNormalTargetGenerator if (!this->GetGlobalGenerator()->HasRule(ruleName)) { cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->GetTarget(); + vars.CMTarget = this->GetGeneratorTarget(); vars.Language = this->TargetLinkLanguage.c_str(); std::string responseFlag; @@ -227,7 +228,7 @@ cmNinjaNormalTargetGenerator std::ostringstream minorStream; int major; int minor; - this->GetTarget()->GetTargetVersion(major, minor); + this->GetGeneratorTarget()->GetTargetVersion(major, minor); majorStream << major; minorStream << minor; targetVersionMajor = majorStream.str(); @@ -280,7 +281,7 @@ cmNinjaNormalTargetGenerator } if (this->TargetNameOut != this->TargetNameReal && - !this->GetTarget()->IsFrameworkOnApple()) { + !this->GetGeneratorTarget()->IsFrameworkOnApple()) { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); @@ -411,7 +412,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() gt.GetFullPath(cfgName, /*implib=*/true)); - if (target.IsAppBundleOnApple()) + if (gt.IsAppBundleOnApple()) { // Create the app bundle std::string outpath = gt.GetDirectory(cfgName); @@ -427,13 +428,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() targetOutputReal += this->TargetNameReal; targetOutputReal = this->ConvertToNinjaPath(targetOutputReal); } - else if (target.IsFrameworkOnApple()) + else if (gt.IsFrameworkOnApple()) { // Create the library framework. this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, gt.GetDirectory(cfgName)); } - else if(target.IsCFBundleOnApple()) + else if(gt.IsCFBundleOnApple()) { // Create the core foundation bundle. this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, @@ -731,7 +732,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() &usedResponseFile); this->WriteLinkRule(usedResponseFile); - if (targetOutput != targetOutputReal && !target.IsFrameworkOnApple()) + if (targetOutput != targetOutputReal && !gt.IsFrameworkOnApple()) { if (targetType == cmState::EXECUTABLE) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0eba0b3..b018005 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -92,7 +92,7 @@ std::string cmNinjaTargetGenerator::LanguageCompilerRule( const std::string& lang) const { return lang + "_COMPILER__" + - cmGlobalNinjaGenerator::EncodeRuleName(this->Target->GetName()); + cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()); } std::string @@ -148,17 +148,9 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags, bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const { - if (lang == "C" || lang == "CXX") - { - cmMakefile* mf = this->GetMakefile(); - return ( - strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "MSVC") == 0 || - strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "MSVC") == 0 || - strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "MSVC") == 0 || - strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "MSVC") == 0 - ); - } - return false; + return strcmp( + this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" + lang), + "msvc") == 0; } // TODO: Refactor with @@ -218,7 +210,8 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const } // Add user-specified dependencies. - if (const char* linkDepends = this->Target->GetProperty("LINK_DEPENDS")) + if (const char* linkDepends = + this->GeneratorTarget->GetProperty("LINK_DEPENDS")) { std::vector<std::string> linkDeps; cmSystemTools::ExpandListArgument(linkDepends, linkDeps); @@ -271,7 +264,7 @@ cmNinjaTargetGenerator std::string cmNinjaTargetGenerator::GetTargetName() const { - return this->Target->GetName(); + return this->GeneratorTarget->GetName(); } @@ -334,7 +327,7 @@ cmNinjaTargetGenerator { cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; - vars.CMTarget = this->GetTarget(); + vars.CMTarget = this->GetGeneratorTarget(); vars.Language = lang.c_str(); vars.Source = "$in"; vars.Object = "$out"; @@ -358,7 +351,7 @@ cmNinjaTargetGenerator depfile = ""; flags += " /showIncludes"; } - else if (lang == "RC" && this->NeedDepTypeMSVC("C")) + else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_"+lang)) { // For the MS resource compiler we need cmcldeps, but skip dependencies // for source-file try_compile cases because they are always fresh. @@ -410,7 +403,7 @@ cmNinjaTargetGenerator if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) { std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE"; - const char *iwyu = this->Target->GetProperty(iwyu_prop); + const char *iwyu = this->GeneratorTarget->GetProperty(iwyu_prop); if (iwyu && *iwyu) { std::string run_iwyu = @@ -427,7 +420,7 @@ cmNinjaTargetGenerator if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; - const char *clauncher = this->Target->GetProperty(clauncher_prop); + const char *clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); if (clauncher && *clauncher) { std::vector<std::string> launcher_cmd; diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 9feb7ac..5bbe268 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -90,7 +90,8 @@ void cmNinjaUtilityTargetGenerator::Generate() } else { std::string command = this->GetLocalGenerator()->BuildCommandLine(commands); - const char *echoStr = this->GetTarget()->GetProperty("EchoString"); + const char *echoStr = + this->GetGeneratorTarget()->GetProperty("EchoString"); std::string desc; if (echoStr) desc = echoStr; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 4fe99e3..e9dc433 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -34,7 +34,7 @@ cmOSXBundleGenerator(cmGeneratorTarget* target, //---------------------------------------------------------------------------- bool cmOSXBundleGenerator::MustSkip() { - return !this->GT->Target->HaveWellDefinedOutputFiles(); + return !this->GT->HaveWellDefinedOutputFiles(); } //---------------------------------------------------------------------------- @@ -59,7 +59,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, plist += "/"; plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; - this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, + this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName, plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); @@ -90,7 +90,7 @@ void cmOSXBundleGenerator::CreateFramework( std::string plist = newoutpath; plist += "/Resources/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); - this->LocalGenerator->GenerateFrameworkInfoPList(this->GT->Target, + this->LocalGenerator->GenerateFrameworkInfoPList(this->GT, name, plist.c_str()); @@ -182,7 +182,7 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); - this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, + this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 35ee127..e3eedc7 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -555,7 +555,7 @@ void cmOrderDirectories::FindImplicitConflicts() << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() ->IssueMessage(cmake::WARNING, w.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -637,5 +637,5 @@ void cmOrderDirectories::DiagnoseCycle() e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() ->IssueMessage(cmake::WARNING, e.str(), - this->Target->Target->GetBacktrace()); + this->Target->GetBacktrace()); } diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 2d57d3b..54208ac 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -10,108 +10,239 @@ See the License for more information. ============================================================================*/ #include "cmOutputRequiredFilesCommand.h" -#include "cmMakeDepend.h" #include "cmAlgorithms.h" #include <cmsys/FStream.hxx> -class cmLBDepend : public cmMakeDepend +/** \class cmDependInformation + * \brief Store dependency information for a single source file. + * + * This structure stores the depend information for a single source file. + */ +class cmDependInformation { +public: /** - * Compute the depend information for this class. + * Construct with dependency generation marked not done; instance + * not placed in cmMakefile's list. */ - virtual void DependWalk(cmDependInformation* info); -}; + cmDependInformation(): DependDone(false), SourceFile(0) {} -void cmLBDepend::DependWalk(cmDependInformation* info) -{ - cmsys::ifstream fin(info->FullPath.c_str()); - if(!fin) + /** + * The set of files on which this one depends. + */ + typedef std::set<cmDependInformation*> DependencySetType; + DependencySetType DependencySet; + + /** + * This flag indicates whether dependency checking has been + * performed for this file. + */ + bool DependDone; + + /** + * If this object corresponds to a cmSourceFile instance, this points + * to it. + */ + const cmSourceFile *SourceFile; + + /** + * Full path to this file. + */ + std::string FullPath; + + /** + * Full path not including file name. + */ + std::string PathOnly; + + /** + * Name used to #include this file. + */ + std::string IncludeName; + + /** + * This method adds the dependencies of another file to this one. + */ + void AddDependencies(cmDependInformation* info) + { + if(this != info) { - cmSystemTools::Error("error can not open ", info->FullPath.c_str()); - return; + this->DependencySet.insert(info); } + } +}; - std::string line; - while(cmSystemTools::GetLineFromStream(fin, line)) - { - if(cmHasLiteralPrefix(line.c_str(), "#include")) - { - // if it is an include line then create a string class - std::string currentline = line; - size_t qstart = currentline.find('\"', 8); - size_t qend; - // if a quote is not found look for a < - if(qstart == std::string::npos) - { - qstart = currentline.find('<', 8); - // if a < is not found then move on - if(qstart == std::string::npos) - { - cmSystemTools::Error("unknown include directive ", - currentline.c_str() ); - continue; - } - else - { - qend = currentline.find('>', qstart+1); - } - } - else +class cmLBDepend +{ +public: + /** + * Construct the object with verbose turned off. + */ + cmLBDepend() + { + this->Verbose = false; + this->IncludeFileRegularExpression.compile("^.*$"); + this->ComplainFileRegularExpression.compile("^$"); + } + + /** + * Destructor. + */ + ~cmLBDepend() + { + cmDeleteAll(this->DependInformationMap); + } + + /** + * Set the makefile that is used as a source of classes. + */ + void SetMakefile(cmMakefile* makefile) + { + this->Makefile = makefile; + + // Now extract the include file regular expression from the makefile. + this->IncludeFileRegularExpression.compile( + this->Makefile->GetIncludeRegularExpression()); + this->ComplainFileRegularExpression.compile( + this->Makefile->GetComplainRegularExpression()); + + // Now extract any include paths from the targets + std::set<std::string> uniqueIncludes; + std::vector<std::string> orderedAndUniqueIncludes; + cmTargets &targets = this->Makefile->GetTargets(); + for (cmTargets::iterator l = targets.begin(); + l != targets.end(); ++l) + { + const char *incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES"); + if (!incDirProp) { - qend = currentline.find('\"', qstart+1); + continue; } - // extract the file being included - std::string includeFile = currentline.substr(qstart+1, qend - qstart-1); - // see if the include matches the regular expression - if(!this->IncludeFileRegularExpression.find(includeFile)) + + std::string incDirs = + cmGeneratorExpression::Preprocess(incDirProp, + cmGeneratorExpression::StripAllGeneratorExpressions); + + std::vector<std::string> includes; + cmSystemTools::ExpandListArgument(incDirs, includes); + + for(std::vector<std::string>::const_iterator j = includes.begin(); + j != includes.end(); ++j) { - if(this->Verbose) + std::string path = *j; + this->Makefile->ExpandVariablesInString(path); + if(uniqueIncludes.insert(path).second) { - std::string message = "Skipping "; - message += includeFile; - message += " for file "; - message += info->FullPath.c_str(); - cmSystemTools::Error(message.c_str(), 0); + orderedAndUniqueIncludes.push_back(path); } - continue; } + } - // Add this file and all its dependencies. - this->AddDependency(info, includeFile.c_str()); - /// add the cxx file if it exists - std::string cxxFile = includeFile; - std::string::size_type pos = cxxFile.rfind('.'); - if(pos != std::string::npos) + for(std::vector<std::string>::const_iterator + it = orderedAndUniqueIncludes.begin(); + it != orderedAndUniqueIncludes.end(); + ++it) + { + this->AddSearchPath(*it); + } + } + + /** + * Add a directory to the search path for include files. + */ + void AddSearchPath(const std::string& path) + { + this->IncludeDirectories.push_back(path); + } + + /** + * Generate dependencies for the file given. Returns a pointer to + * the cmDependInformation object for the file. + */ + const cmDependInformation* FindDependencies(const char* file) + { + cmDependInformation* info = this->GetDependInformation(file,0); + this->GenerateDependInformation(info); + return info; + } + +protected: + /** + * Compute the depend information for this class. + */ + + void DependWalk(cmDependInformation* info) + { + cmsys::ifstream fin(info->FullPath.c_str()); + if(!fin) + { + cmSystemTools::Error("error can not open ", info->FullPath.c_str()); + return; + } + + std::string line; + while(cmSystemTools::GetLineFromStream(fin, line)) + { + if(cmHasLiteralPrefix(line.c_str(), "#include")) { - std::string root = cxxFile.substr(0, pos); - cxxFile = root + ".cxx"; - bool found = false; - // try jumping to .cxx .cpp and .c in order - if(cmSystemTools::FileExists(cxxFile.c_str())) + // if it is an include line then create a string class + std::string currentline = line; + size_t qstart = currentline.find('\"', 8); + size_t qend; + // if a quote is not found look for a < + if(qstart == std::string::npos) { - found = true; + qstart = currentline.find('<', 8); + // if a < is not found then move on + if(qstart == std::string::npos) + { + cmSystemTools::Error("unknown include directive ", + currentline.c_str() ); + continue; + } + else + { + qend = currentline.find('>', qstart+1); + } } - for(std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) + else + { + qend = currentline.find('\"', qstart+1); + } + // extract the file being included + std::string includeFile = + currentline.substr(qstart+1, qend - qstart-1); + // see if the include matches the regular expression + if(!this->IncludeFileRegularExpression.find(includeFile)) { - std::string path = *i; - path = path + "/"; - path = path + cxxFile; - if(cmSystemTools::FileExists(path.c_str())) + if(this->Verbose) { - found = true; + std::string message = "Skipping "; + message += includeFile; + message += " for file "; + message += info->FullPath.c_str(); + cmSystemTools::Error(message.c_str(), 0); } + continue; } - if (!found) + + // Add this file and all its dependencies. + this->AddDependency(info, includeFile.c_str()); + /// add the cxx file if it exists + std::string cxxFile = includeFile; + std::string::size_type pos = cxxFile.rfind('.'); + if(pos != std::string::npos) { - cxxFile = root + ".cpp"; + std::string root = cxxFile.substr(0, pos); + cxxFile = root + ".cxx"; + bool found = false; + // try jumping to .cxx .cpp and .c in order if(cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } for(std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); + this->IncludeDirectories.begin(); i != this->IncludeDirectories.end(); ++i) { std::string path = *i; @@ -122,55 +253,314 @@ void cmLBDepend::DependWalk(cmDependInformation* info) found = true; } } - } - if (!found) - { - cxxFile = root + ".c"; - if(cmSystemTools::FileExists(cxxFile.c_str())) + if (!found) { - found = true; - } - for(std::vector<std::string>::iterator i = - this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) - { - std::string path = *i; - path = path + "/"; - path = path + cxxFile; - if(cmSystemTools::FileExists(path.c_str())) + cxxFile = root + ".cpp"; + if(cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } + for(std::vector<std::string>::iterator i = + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) + { + std::string path = *i; + path = path + "/"; + path = path + cxxFile; + if(cmSystemTools::FileExists(path.c_str())) + { + found = true; + } + } } - } - if (!found) - { - cxxFile = root + ".txx"; - if(cmSystemTools::FileExists(cxxFile.c_str())) + if (!found) { - found = true; - } - for(std::vector<std::string>::iterator i = + cxxFile = root + ".c"; + if(cmSystemTools::FileExists(cxxFile.c_str())) + { + found = true; + } + for(std::vector<std::string>::iterator i = this->IncludeDirectories.begin(); - i != this->IncludeDirectories.end(); ++i) + i != this->IncludeDirectories.end(); ++i) + { + std::string path = *i; + path = path + "/"; + path = path + cxxFile; + if(cmSystemTools::FileExists(path.c_str())) + { + found = true; + } + } + } + if (!found) { - std::string path = *i; - path = path + "/"; - path = path + cxxFile; - if(cmSystemTools::FileExists(path.c_str())) + cxxFile = root + ".txx"; + if(cmSystemTools::FileExists(cxxFile.c_str())) { found = true; } + for(std::vector<std::string>::iterator i = + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) + { + std::string path = *i; + path = path + "/"; + path = path + cxxFile; + if(cmSystemTools::FileExists(path.c_str())) + { + found = true; + } + } + } + if (found) + { + this->AddDependency(info, cxxFile.c_str()); } } - if (found) + } + } + } + + /** + * Add a dependency. Possibly walk it for more dependencies. + */ + void AddDependency(cmDependInformation* info, const char* file) + { + cmDependInformation* dependInfo = + this->GetDependInformation(file, info->PathOnly.c_str()); + this->GenerateDependInformation(dependInfo); + info->AddDependencies(dependInfo); + } + + /** + * Fill in the given object with dependency information. If the + * information is already complete, nothing is done. + */ + void GenerateDependInformation(cmDependInformation* info) + { + // If dependencies are already done, stop now. + if(info->DependDone) + { + return; + } + else + { + // Make sure we don't visit the same file more than once. + info->DependDone = true; + } + const char* path = info->FullPath.c_str(); + if(!path) + { + cmSystemTools::Error( + "Attempt to find dependencies for file without path!"); + return; + } + + bool found = false; + + // If the file exists, use it to find dependency information. + if(cmSystemTools::FileExists(path, true)) + { + // Use the real file to find its dependencies. + this->DependWalk(info); + found = true; + } + + + // See if the cmSourceFile for it has any files specified as + // dependency hints. + if(info->SourceFile != 0) + { + + // Get the cmSourceFile corresponding to this. + const cmSourceFile& cFile = *(info->SourceFile); + // See if there are any hints for finding dependencies for the missing + // file. + if(!cFile.GetDepends().empty()) + { + // Dependency hints have been given. Use them to begin the + // recursion. + for(std::vector<std::string>::const_iterator file = + cFile.GetDepends().begin(); file != cFile.GetDepends().end(); + ++file) { - this->AddDependency(info, cxxFile.c_str()); + this->AddDependency(info, file->c_str()); } + + // Found dependency information. We are done. + found = true; } } - } -} + + if(!found) + { + // Try to find the file amongst the sources + cmSourceFile *srcFile = this->Makefile->GetSource + (cmSystemTools::GetFilenameWithoutExtension(path)); + if (srcFile) + { + if (srcFile->GetFullPath() == path) + { + found=true; + } + else + { + //try to guess which include path to use + for(std::vector<std::string>::iterator t = + this->IncludeDirectories.begin(); + t != this->IncludeDirectories.end(); ++t) + { + std::string incpath = *t; + if (!incpath.empty() && incpath[incpath.size() - 1] != '/') + { + incpath = incpath + "/"; + } + incpath = incpath + path; + if (srcFile->GetFullPath() == incpath) + { + // set the path to the guessed path + info->FullPath = incpath; + found=true; + } + } + } + } + } + + if(!found) + { + // Couldn't find any dependency information. + if(this->ComplainFileRegularExpression.find(info->IncludeName.c_str())) + { + cmSystemTools::Error("error cannot find dependencies for ", path); + } + else + { + // Destroy the name of the file so that it won't be output as a + // dependency. + info->FullPath = ""; + } + } + } + + /** + * Get an instance of cmDependInformation corresponding to the given file + * name. + */ + cmDependInformation* GetDependInformation(const char* file, + const char *extraPath) + { + // Get the full path for the file so that lookup is unambiguous. + std::string fullPath = this->FullPath(file, extraPath); + + // Try to find the file's instance of cmDependInformation. + DependInformationMapType::const_iterator result = + this->DependInformationMap.find(fullPath); + if(result != this->DependInformationMap.end()) + { + // Found an instance, return it. + return result->second; + } + else + { + // Didn't find an instance. Create a new one and save it. + cmDependInformation* info = new cmDependInformation; + info->FullPath = fullPath; + info->PathOnly = cmSystemTools::GetFilenamePath(fullPath); + info->IncludeName = file; + this->DependInformationMap[fullPath] = info; + return info; + } + } + + /** + * Find the full path name for the given file name. + * This uses the include directories. + * TODO: Cache path conversions to reduce FileExists calls. + */ + std::string FullPath(const char *fname, const char *extraPath) + { + DirectoryToFileToPathMapType::iterator m; + if(extraPath) + { + m = this->DirectoryToFileToPathMap.find(extraPath); + } + else + { + m = this->DirectoryToFileToPathMap.find(""); + } + + if(m != this->DirectoryToFileToPathMap.end()) + { + FileToPathMapType& map = m->second; + FileToPathMapType::iterator p = map.find(fname); + if(p != map.end()) + { + return p->second; + } + } + + if(cmSystemTools::FileExists(fname, true)) + { + std::string fp = cmSystemTools::CollapseFullPath(fname); + this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; + return fp; + } + + for(std::vector<std::string>::iterator i = + this->IncludeDirectories.begin(); + i != this->IncludeDirectories.end(); ++i) + { + std::string path = *i; + if (!path.empty() && path[path.size() - 1] != '/') + { + path = path + "/"; + } + path = path + fname; + if(cmSystemTools::FileExists(path.c_str(), true) + && !cmSystemTools::FileIsDirectory(path)) + { + std::string fp = cmSystemTools::CollapseFullPath(path); + this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; + return fp; + } + } + + if (extraPath) + { + std::string path = extraPath; + if (!path.empty() && path[path.size() - 1] != '/') + { + path = path + "/"; + } + path = path + fname; + if(cmSystemTools::FileExists(path.c_str(), true) + && !cmSystemTools::FileIsDirectory(path)) + { + std::string fp = cmSystemTools::CollapseFullPath(path); + this->DirectoryToFileToPathMap[extraPath][fname] = fp; + return fp; + } + } + + // Couldn't find the file. + return std::string(fname); + } + + cmMakefile* Makefile; + bool Verbose; + cmsys::RegularExpression IncludeFileRegularExpression; + cmsys::RegularExpression ComplainFileRegularExpression; + std::vector<std::string> IncludeDirectories; + typedef std::map<std::string, std::string> FileToPathMapType; + typedef std::map<std::string, FileToPathMapType> + DirectoryToFileToPathMapType; + typedef std::map<std::string, cmDependInformation*> + DependInformationMapType; + DependInformationMapType DependInformationMap; + DirectoryToFileToPathMapType DirectoryToFileToPathMap; +}; // cmOutputRequiredFilesCommand bool cmOutputRequiredFilesCommand diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h index 6a09673..b5eb932 100644 --- a/Source/cmOutputRequiredFilesCommand.h +++ b/Source/cmOutputRequiredFilesCommand.h @@ -13,7 +13,8 @@ #define cmOutputRequiredFilesCommand_h #include "cmCommand.h" -#include "cmMakeDepend.h" + +class cmDependInformation; class cmOutputRequiredFilesCommand : public cmCommand { diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a549d18..5023055 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -230,6 +230,23 @@ class cmPolicy; #define CM_FOR_EACH_POLICY_ID(POLICY) \ CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID) +#define CM_FOR_EACH_TARGET_POLICY(F) \ + F(CMP0003) \ + F(CMP0004) \ + F(CMP0008) \ + F(CMP0020) \ + F(CMP0021) \ + F(CMP0022) \ + F(CMP0027) \ + F(CMP0038) \ + F(CMP0041) \ + F(CMP0042) \ + F(CMP0046) \ + F(CMP0052) \ + F(CMP0060) \ + F(CMP0063) \ + F(CMP0065) + /** \class cmPolicies * \brief Handles changes in CMake behavior and policies diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index f9875b3..16b8942 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -120,7 +120,7 @@ static void GetCompileDefinitionsAndDirectories( incs = cmJoin(includeDirs, ";"); std::set<std::string> defines; - localGen->AddCompileDefinitions(defines, target->Target, config, "CXX"); + localGen->AddCompileDefinitions(defines, target, config, "CXX"); defs += cmJoin(defines, ";"); } @@ -132,6 +132,7 @@ static void SetupAutoMocTarget(cmGeneratorTarget const* target, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines) { + cmLocalGenerator* lg = target->GetLocalGenerator(); cmMakefile* makefile = target->Target->GetMakefile(); const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); @@ -188,7 +189,8 @@ static void SetupAutoMocTarget(cmGeneratorTarget const* target, const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (strcmp(qtVersion, "5") == 0) { - cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc"); + cmGeneratorTarget *qt5Moc = + lg->FindGeneratorTargetToUse("Qt5::moc"); if (!qt5Moc) { cmSystemTools::Error("Qt5::moc target not found ", @@ -200,7 +202,8 @@ static void SetupAutoMocTarget(cmGeneratorTarget const* target, } else if (strcmp(qtVersion, "4") == 0) { - cmTarget *qt4Moc = makefile->FindTargetToUse("Qt4::moc"); + cmGeneratorTarget *qt4Moc = + lg->FindGeneratorTargetToUse("Qt4::moc"); if (!qt4Moc) { cmSystemTools::Error("Qt4::moc target not found ", @@ -230,6 +233,7 @@ static void SetupAutoUicTarget(cmGeneratorTarget const* target, std::vector<std::string> const& skipUic, std::map<std::string, std::string> &configUicOptions) { + cmLocalGenerator* lg = target->GetLocalGenerator(); cmMakefile *makefile = target->Target->GetMakefile(); std::set<std::string> skipped; @@ -303,7 +307,8 @@ static void SetupAutoUicTarget(cmGeneratorTarget const* target, std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) { - cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic"); + cmGeneratorTarget *qt5Uic = + lg->FindGeneratorTargetToUse("Qt5::uic"); if (!qt5Uic) { // Project does not use Qt5Widgets, but has AUTOUIC ON anyway @@ -316,7 +321,8 @@ static void SetupAutoUicTarget(cmGeneratorTarget const* target, } else if (strcmp(qtVersion, "4") == 0) { - cmTarget *qt4Uic = makefile->FindTargetToUse("Qt4::uic"); + cmGeneratorTarget *qt4Uic = + lg->FindGeneratorTargetToUse("Qt4::uic"); if (!qt4Uic) { cmSystemTools::Error("Qt4::uic target not found ", @@ -335,6 +341,7 @@ static void SetupAutoUicTarget(cmGeneratorTarget const* target, static std::string GetRccExecutable(cmGeneratorTarget const* target) { + cmLocalGenerator* lg = target->GetLocalGenerator(); cmMakefile *makefile = target->Target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -355,7 +362,8 @@ static std::string GetRccExecutable(cmGeneratorTarget const* target) std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) { - cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc"); + cmGeneratorTarget *qt5Rcc = + lg->FindGeneratorTargetToUse("Qt5::rcc"); if (!qt5Rcc) { cmSystemTools::Error("Qt5::rcc target not found ", @@ -366,7 +374,8 @@ static std::string GetRccExecutable(cmGeneratorTarget const* target) } else if (strcmp(qtVersion, "4") == 0) { - cmTarget *qt4Rcc = makefile->FindTargetToUse("Qt4::rcc"); + cmGeneratorTarget *qt4Rcc = + lg->FindGeneratorTargetToUse("Qt4::rcc"); if (!qt4Rcc) { cmSystemTools::Error("Qt4::rcc target not found ", @@ -887,6 +896,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); lg->AddGeneratorTarget(autogenTarget, gt); + lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt); // Set target folder const char* autogenFolder = makefile->GetState() diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fecdc45..e056469 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -345,17 +345,6 @@ bool cmTarget::IsExecutableWithExports() const } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkable() const -{ - return (this->GetType() == cmState::STATIC_LIBRARY || - this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY || - this->GetType() == cmState::UNKNOWN_LIBRARY || - this->GetType() == cmState::INTERFACE_LIBRARY || - this->IsExecutableWithExports()); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImportLibrary() const { return (this->DLLPlatform && @@ -380,21 +369,6 @@ bool cmTarget::IsAppBundleOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsCFBundleOnApple() const -{ - return (this->GetType() == cmState::MODULE_LIBRARY && - this->Makefile->IsOn("APPLE") && - this->GetPropertyAsBool("BUNDLE")); -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsXCTestOnApple() const -{ - return (this->IsCFBundleOnApple() && - this->GetPropertyAsBool("XCTEST")); -} - -//---------------------------------------------------------------------------- void cmTarget::AddTracedSources(std::vector<std::string> const& srcs) { if (!srcs.empty()) @@ -609,31 +583,6 @@ const std::vector<std::string>& cmTarget::GetLinkDirectories() const } //---------------------------------------------------------------------------- -cmTargetLinkLibraryType cmTarget::ComputeLinkType( - const std::string& config) const -{ - // No configuration is always optimized. - if(config.empty()) - { - return OPTIMIZED_LibraryType; - } - - // Get the list of configurations considered to be DEBUG. - std::vector<std::string> debugConfigs = - this->Makefile->GetCMakeInstance()->GetDebugConfigs(); - - // Check if any entry in the list matches this configuration. - std::string configUpper = cmSystemTools::UpperCase(config); - if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) != - debugConfigs.end()) - { - return DEBUG_LibraryType; - } - // The current configuration is not a debug configuration. - return OPTIMIZED_LibraryType; -} - -//---------------------------------------------------------------------------- void cmTarget::ClearDependencyInformation( cmMakefile& mf, const std::string& target ) { @@ -662,13 +611,6 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf, } //---------------------------------------------------------------------------- -bool cmTarget::NameResolvesToFramework(const std::string& libname) const -{ - return this->Makefile->GetGlobalGenerator()-> - NameResolvesToFramework(libname); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value, cmTargetLinkLibraryType llt) const { @@ -1316,7 +1258,6 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) else { this->Properties.SetProperty(prop, value); - this->MaybeInvalidatePropertyCache(prop); } } @@ -1409,31 +1350,10 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, else { this->Properties.AppendProperty(prop, value, asString); - this->MaybeInvalidatePropertyCache(prop); } } //---------------------------------------------------------------------------- -std::string cmTarget::GetExportName() const -{ - const char *exportName = this->GetProperty("EXPORT_NAME"); - - if (exportName && *exportName) - { - if (!cmGeneratorExpression::IsValidTargetName(exportName)) - { - std::ostringstream e; - e << "EXPORT_NAME property \"" << exportName << "\" for \"" - << this->GetName() << "\": is not valid."; - cmSystemTools::Error(e.str().c_str()); - return ""; - } - return exportName; - } - return this->GetName(); -} - -//---------------------------------------------------------------------------- void cmTarget::AppendBuildInterfaceIncludes() { if(this->GetType() != cmState::SHARED_LIBRARY && @@ -1508,16 +1428,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, } //---------------------------------------------------------------------------- -void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) -{ - // Wipe out maps caching information affected by this property. - if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) - { - this->ImportInfoMap.clear(); - } -} - -//---------------------------------------------------------------------------- static void cmTargetCheckLINK_INTERFACE_LIBRARIES( const std::string& prop, const char* value, cmMakefile* context, bool imported) @@ -1618,63 +1528,6 @@ void cmTarget::MarkAsImported() } //---------------------------------------------------------------------------- -bool cmTarget::HaveWellDefinedOutputFiles() const -{ - return - this->GetType() == cmState::STATIC_LIBRARY || - this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY || - this->GetType() == cmState::EXECUTABLE; -} - -//---------------------------------------------------------------------------- -const char* cmTarget::ImportedGetLocation(const std::string& config) const -{ - static std::string location; - assert(this->IsImported()); - location = this->ImportedGetFullPath(config, false); - return location.c_str(); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetTargetVersion(int& major, int& minor) const -{ - int patch; - this->GetTargetVersion(false, major, minor, patch); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetTargetVersion(bool soversion, - int& major, int& minor, int& patch) const -{ - // Set the default values. - major = 0; - minor = 0; - patch = 0; - - assert(this->GetType() != cmState::INTERFACE_LIBRARY); - - // Look for a VERSION or SOVERSION property. - const char* prop = soversion? "SOVERSION" : "VERSION"; - if(const char* version = this->GetProperty(prop)) - { - // Try to parse the version number and store the results that were - // successfully parsed. - int parsed_major; - int parsed_minor; - int parsed_patch; - switch(sscanf(version, "%d.%d.%d", - &parsed_major, &parsed_minor, &parsed_patch)) - { - case 3: patch = parsed_patch; // no break! - case 2: minor = parsed_minor; // no break! - case 1: major = parsed_major; // no break! - default: break; - } - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const { if (this->IsImported()) @@ -2100,21 +1953,75 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const //---------------------------------------------------------------------------- std::string -cmTarget::GetFullNameImported(const std::string& config, bool implib) const +cmTarget::ImportedGetFullPath(const std::string& config, bool pimplib) const { - return cmSystemTools::GetFilenameName( - this->ImportedGetFullPath(config, implib)); -} + assert(this->IsImported()); + + // Lookup/compute/cache the import information for this + // configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + else + { + config_upper = "NOCONFIG"; + } -//---------------------------------------------------------------------------- -std::string -cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const -{ std::string result; - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) + + const char* loc = 0; + const char* imp = 0; + std::string suffix; + + if(this->GetType() != cmState::INTERFACE_LIBRARY + && this->GetMappedConfig(config_upper, &loc, &imp, suffix)) { - result = implib? info->ImportLibrary : info->Location; + if (!pimplib) + { + if(loc) + { + result = loc; + } + else + { + std::string impProp = "IMPORTED_LOCATION"; + impProp += suffix; + if(const char* config_location = this->GetProperty(impProp)) + { + result = config_location; + } + else if(const char* location = + this->GetProperty("IMPORTED_LOCATION")) + { + result = location; + } + } + } + else + { + if(imp) + { + result = imp; + } + else if(this->GetType() == cmState::SHARED_LIBRARY || + this->IsExecutableWithExports()) + { + std::string impProp = "IMPORTED_IMPLIB"; + impProp += suffix; + if(const char* config_implib = this->GetProperty(impProp)) + { + result = config_implib; + } + else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB")) + { + result = implib; + } + } + } } + if(result.empty()) { result = this->GetName(); @@ -2124,23 +2031,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::ComputeVersionedName(std::string& vName, - std::string const& prefix, - std::string const& base, - std::string const& suffix, - std::string const& name, - const char* version) const -{ - vName = this->IsApple? (prefix+base) : name; - if(version) - { - vName += "."; - vName += version; - } - vName += this->IsApple? suffix : std::string(); -} - -//---------------------------------------------------------------------------- void cmTarget::SetPropertyDefault(const std::string& property, const char* default_value) { @@ -2177,118 +2067,6 @@ std::string cmTarget::GetFrameworkVersion() const } } -//---------------------------------------------------------------------------- -const char* cmTarget::GetExportMacro() const -{ - // Define the symbol for targets that export symbols. - if(this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY || - this->IsExecutableWithExports()) - { - if(const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) - { - this->ExportMacro = custom_export_name; - } - else - { - std::string in = this->GetName(); - in += "_EXPORTS"; - this->ExportMacro = cmSystemTools::MakeCindentifier(in); - } - return this->ExportMacro.c_str(); - } - else - { - return 0; - } -} - -//---------------------------------------------------------------------------- -void -cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const -{ - // At configure-time, this method can be called as part of getting the - // LOCATION property or to export() a file to be include()d. However - // there is no cmGeneratorTarget at configure-time, so search the SOURCES - // for TARGET_OBJECTS instead for backwards compatibility with OLD - // behavior of CMP0024 and CMP0026 only. - for(std::vector<std::string>::const_iterator - i = this->Internal->SourceEntries.begin(); - i != this->Internal->SourceEntries.end(); ++i) - { - std::string const& entry = *i; - - std::vector<std::string> files; - cmSystemTools::ExpandListArgument(entry, files); - for (std::vector<std::string>::const_iterator - li = files.begin(); li != files.end(); ++li) - { - if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") && - (*li)[li->size() - 1] == '>') - { - std::string objLibName = li->substr(17, li->size()-18); - - if (cmGeneratorExpression::Find(objLibName) != std::string::npos) - { - continue; - } - cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName); - if(objLib) - { - objlibs.push_back(objLib); - } - } - } - } -} - -//---------------------------------------------------------------------------- -cmTarget::ImportInfo const* -cmTarget::GetImportInfo(const std::string& config) const -{ - // There is no imported information for non-imported targets. - if(!this->IsImported()) - { - return 0; - } - - // Lookup/compute/cache the import information for this - // configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - else - { - config_upper = "NOCONFIG"; - } - - ImportInfoMapType::const_iterator i = - this->ImportInfoMap.find(config_upper); - if(i == this->ImportInfoMap.end()) - { - ImportInfo info; - this->ComputeImportInfo(config_upper, info); - ImportInfoMapType::value_type entry(config_upper, info); - i = this->ImportInfoMap.insert(entry).first; - } - - if(this->GetType() == cmState::INTERFACE_LIBRARY) - { - return &i->second; - } - // If the location is empty then the target is not available for - // this configuration. - if(i->second.Location.empty() && i->second.ImportLibrary.empty()) - { - return 0; - } - - // Return the import information. - return &i->second; -} - bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, @@ -2421,233 +2199,6 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, } //---------------------------------------------------------------------------- -void cmTarget::ComputeImportInfo(std::string const& desired_config, - ImportInfo& info) const -{ - // This method finds information about an imported target from its - // properties. The "IMPORTED_" namespace is reserved for properties - // defined by the project exporting the target. - - // Initialize members. - info.NoSOName = false; - - const char* loc = 0; - const char* imp = 0; - std::string suffix; - if (!this->GetMappedConfig(desired_config, &loc, &imp, suffix)) - { - return; - } - - // Get the link interface. - { - std::string linkProp = "INTERFACE_LINK_LIBRARIES"; - const char *propertyLibs = this->GetProperty(linkProp); - - if (this->GetType() != cmState::INTERFACE_LIBRARY) - { - if(!propertyLibs) - { - linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - linkProp += suffix; - propertyLibs = this->GetProperty(linkProp); - } - - if(!propertyLibs) - { - linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - propertyLibs = this->GetProperty(linkProp); - } - } - if(propertyLibs) - { - info.LibrariesProp = linkProp; - info.Libraries = propertyLibs; - } - } - if(this->GetType() == cmState::INTERFACE_LIBRARY) - { - return; - } - - // A provided configuration has been chosen. Load the - // configuration's properties. - - // Get the location. - if(loc) - { - info.Location = loc; - } - else - { - std::string impProp = "IMPORTED_LOCATION"; - impProp += suffix; - if(const char* config_location = this->GetProperty(impProp)) - { - info.Location = config_location; - } - else if(const char* location = this->GetProperty("IMPORTED_LOCATION")) - { - info.Location = location; - } - } - - // Get the soname. - if(this->GetType() == cmState::SHARED_LIBRARY) - { - std::string soProp = "IMPORTED_SONAME"; - soProp += suffix; - if(const char* config_soname = this->GetProperty(soProp)) - { - info.SOName = config_soname; - } - else if(const char* soname = this->GetProperty("IMPORTED_SONAME")) - { - info.SOName = soname; - } - } - - // Get the "no-soname" mark. - if(this->GetType() == cmState::SHARED_LIBRARY) - { - std::string soProp = "IMPORTED_NO_SONAME"; - soProp += suffix; - if(const char* config_no_soname = this->GetProperty(soProp)) - { - info.NoSOName = cmSystemTools::IsOn(config_no_soname); - } - else if(const char* no_soname = this->GetProperty("IMPORTED_NO_SONAME")) - { - info.NoSOName = cmSystemTools::IsOn(no_soname); - } - } - - // Get the import library. - if(imp) - { - info.ImportLibrary = imp; - } - else if(this->GetType() == cmState::SHARED_LIBRARY || - this->IsExecutableWithExports()) - { - std::string impProp = "IMPORTED_IMPLIB"; - impProp += suffix; - if(const char* config_implib = this->GetProperty(impProp)) - { - info.ImportLibrary = config_implib; - } - else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB")) - { - info.ImportLibrary = implib; - } - } - - // Get the link dependencies. - { - std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES"; - linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp)) - { - info.SharedDeps = config_libs; - } - else if(const char* libs = - this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) - { - info.SharedDeps = libs; - } - } - - // Get the link languages. - if(this->LinkLanguagePropagatesToDependents()) - { - std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES"; - linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp)) - { - info.Languages = config_libs; - } - else if(const char* libs = - this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) - { - info.Languages = libs; - } - } - - // Get the cyclic repetition count. - if(this->GetType() == cmState::STATIC_LIBRARY) - { - std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; - linkProp += suffix; - if(const char* config_reps = this->GetProperty(linkProp)) - { - sscanf(config_reps, "%u", &info.Multiplicity); - } - else if(const char* reps = - this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) - { - sscanf(reps, "%u", &info.Multiplicity); - } - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::CheckCMP0004(std::string const& item) const -{ - // Strip whitespace off the library names because we used to do this - // in case variables were expanded at generate time. We no longer - // do the expansion but users link to libraries like " ${VAR} ". - std::string lib = item; - std::string::size_type pos = lib.find_first_not_of(" \t\r\n"); - if(pos != lib.npos) - { - lib = lib.substr(pos, lib.npos); - } - pos = lib.find_last_not_of(" \t\r\n"); - if(pos != lib.npos) - { - lib = lib.substr(0, pos+1); - } - if(lib != item) - { - cmake* cm = this->Makefile->GetCMakeInstance(); - switch(this->GetPolicyStatusCMP0004()) - { - case cmPolicies::WARN: - { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n" - << "Target \"" << this->GetName() << "\" links to item \"" - << item << "\" which has leading or trailing whitespace."; - cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->GetBacktrace()); - } - case cmPolicies::OLD: - break; - case cmPolicies::NEW: - { - std::ostringstream e; - e << "Target \"" << this->GetName() << "\" links to item \"" - << item << "\" which has leading or trailing whitespace. " - << "This is now an error according to policy CMP0004."; - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); - } - break; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - { - std::ostringstream e; - e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0004) << "\n" - << "Target \"" << this->GetName() << "\" links to item \"" - << item << "\" which has leading or trailing whitespace."; - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace()); - } - break; - } - } - return lib; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c0b9e09..e8c05da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -26,23 +26,6 @@ # endif #endif -#define CM_FOR_EACH_TARGET_POLICY(F) \ - F(CMP0003) \ - F(CMP0004) \ - F(CMP0008) \ - F(CMP0020) \ - F(CMP0021) \ - F(CMP0022) \ - F(CMP0027) \ - F(CMP0038) \ - F(CMP0041) \ - F(CMP0042) \ - F(CMP0046) \ - F(CMP0052) \ - F(CMP0060) \ - F(CMP0063) \ - F(CMP0065) - class cmake; class cmMakefile; class cmSourceFile; @@ -96,7 +79,6 @@ public: ///! Set/Get the name of the target const std::string& GetName() const {return this->Name;} - std::string GetExportName() const; ///! Set the cmMakefile that owns this target void SetMakefile(cmMakefile *mf); @@ -141,16 +123,11 @@ public: const LinkLibraryVectorType &GetOriginalLinkLibraries() const {return this->OriginalLinkLibraries;} - /** Compute the link type to use for the given configuration. */ - cmTargetLinkLibraryType ComputeLinkType(const std::string& config) const; - /** * Clear the dependency information recorded for this target, if any. */ void ClearDependencyInformation(cmMakefile& mf, const std::string& target); - // Check to see if a library is a framework and treat it different on Mac - bool NameResolvesToFramework(const std::string& libname) const; void AddLinkLibrary(cmMakefile& mf, const std::string& target, const std::string& lib, cmTargetLinkLibraryType llt); @@ -213,25 +190,6 @@ public: bool IsImported() const {return this->IsImportedTarget;} - void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const; - - /** Strip off leading and trailing whitespace from an item named in - the link dependencies of this target. */ - std::string CheckCMP0004(std::string const& item) const; - - const char* ImportedGetLocation(const std::string& config) const; - - /** Get the target major and minor version numbers interpreted from - the VERSION property. Version 0 is returned if the property is - not set or cannot be parsed. */ - void GetTargetVersion(int& major, int& minor) const; - - /** Get the target major, minor, and patch version numbers - interpreted from the VERSION or SOVERSION property. Version 0 - is returned if the property is not set or cannot be parsed. */ - void - GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -240,30 +198,14 @@ public: const char** imp, std::string& suffix) const; - /** Get the macro to define when building sources in this target. - If no macro should be defined null is returned. */ - const char* GetExportMacro() const; - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports() const; - /** Return whether this target may be used to link another target. */ - bool IsLinkable() const; - - /** Return whether or not the target is for a DLL platform. */ - bool IsDLLPlatform() const { return this->DLLPlatform; } - /** Return whether this target is a shared library Framework on Apple. */ bool IsFrameworkOnApple() const; - /** Return whether this target is a CFBundle (plugin) on Apple. */ - bool IsCFBundleOnApple() const; - - /** Return whether this target is a XCTest on Apple. */ - bool IsXCTestOnApple() const; - /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; @@ -274,9 +216,6 @@ public: /** Get a backtrace from the creation of the target. */ cmListFileBacktrace const& GetBacktrace() const; - /** @return whether this target have a well defined output file name. */ - bool HaveWellDefinedOutputFiles() const; - void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before = false); @@ -385,9 +324,6 @@ private: void SetPropertyDefault(const std::string& property, const char* default_value); - std::string GetFullNameImported(const std::string& config, - bool implib) const; - std::string ImportedGetFullPath(const std::string& config, bool implib) const; @@ -401,7 +337,6 @@ private: std::string Name; std::string InstallPath; std::string RuntimeInstallPath; - mutable std::string ExportMacro; std::vector<std::string> LinkDirectories; std::vector<cmCustomCommand> PreBuildCommands; std::vector<cmCustomCommand> PreLinkCommands; @@ -426,32 +361,8 @@ private: bool LinkLibrariesForVS6Analyzed; #endif - // Cache import information from properties for each configuration. - struct ImportInfo - { - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; - }; - - typedef std::map<std::string, ImportInfo> ImportInfoMapType; - mutable ImportInfoMapType ImportInfoMap; - - ImportInfo const* GetImportInfo(const std::string& config) const; - void ComputeImportInfo(std::string const& desired_config, - ImportInfo& info) const; - std::string ProcessSourceItemCMP0049(const std::string& s); - void MaybeInvalidatePropertyCache(const std::string& prop); - /** Return whether or not the target has a DLL import library. */ bool HasImportLibrary() const; @@ -460,13 +371,6 @@ private: friend class cmGeneratorTarget; friend class cmTargetTraceDependencies; - void ComputeVersionedName(std::string& vName, - std::string const& prefix, - std::string const& base, - std::string const& suffix, - std::string const& name, - const char* version) const; - cmListFileBacktrace Backtrace; }; diff --git a/Source/cmTargetExport.h b/Source/cmTargetExport.h index 7665888..2781337 100644 --- a/Source/cmTargetExport.h +++ b/Source/cmTargetExport.h @@ -14,7 +14,7 @@ #include "cmStandardIncludes.h" -class cmTarget; +class cmGeneratorTarget; class cmInstallTargetGenerator; class cmInstallFilesGenerator; @@ -25,7 +25,8 @@ class cmInstallFilesGenerator; class cmTargetExport { public: - cmTarget* Target; ///< The target + std::string TargetName; + cmGeneratorTarget* Target; ///@name Generators ///@{ diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 7968412..f4c632d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -178,7 +178,7 @@ cmVisualStudio10TargetGenerator(cmTarget* target, this->LocalGenerator = (cmLocalVisualStudio7Generator*) this->GeneratorTarget->GetLocalGenerator(); - this->Name = this->Target->GetName(); + this->Name = this->GeneratorTarget->GetName(); this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str()); this->Platform = gg->GetPlatformName(); this->NsightTegra = gg->IsNsightTegra(); @@ -270,7 +270,7 @@ void cmVisualStudio10TargetGenerator::Generate() { // do not generate external ms projects if(this->GeneratorTarget->GetType() == cmState::INTERFACE_LIBRARY - || this->Target->GetProperty("EXTERNAL_MSPROJECT")) + || this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) { return; } @@ -368,7 +368,7 @@ void cmVisualStudio10TargetGenerator::Generate() } const char* vsProjectTypes = - this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES"); + this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES"); if(vsProjectTypes) { this->WriteString("<ProjectTypes>", 2); @@ -376,9 +376,12 @@ void cmVisualStudio10TargetGenerator::Generate() "</ProjectTypes>\n"; } - const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME"); - const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH"); - const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER"); + const char* vsProjectName = + this->GeneratorTarget->GetProperty("VS_SCC_PROJECTNAME"); + const char* vsLocalPath = + this->GeneratorTarget->GetProperty("VS_SCC_LOCALPATH"); + const char* vsProvider = + this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER"); if( vsProjectName && vsLocalPath && vsProvider ) { @@ -392,7 +395,8 @@ void cmVisualStudio10TargetGenerator::Generate() (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider) << "</SccProvider>\n"; - const char* vsAuxPath = this->Target->GetProperty("VS_SCC_AUXPATH"); + const char* vsAuxPath = + this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH"); if( vsAuxPath ) { this->WriteString("<SccAuxPath>", 2); @@ -401,13 +405,13 @@ void cmVisualStudio10TargetGenerator::Generate() } } - if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT")) + if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) { this->WriteString("<WinMDAssembly>true</WinMDAssembly>\n", 2); } const char* vsGlobalKeyword = - this->Target->GetProperty("VS_GLOBAL_KEYWORD"); + this->GeneratorTarget->GetProperty("VS_GLOBAL_KEYWORD"); if(!vsGlobalKeyword) { this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2); @@ -420,7 +424,7 @@ void cmVisualStudio10TargetGenerator::Generate() } const char* vsGlobalRootNamespace = - this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE"); + this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE"); if(vsGlobalRootNamespace) { this->WriteString("<RootNamespace>", 2); @@ -431,14 +435,14 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("<Platform>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform) << "</Platform>\n"; - const char* projLabel = this->Target->GetProperty("PROJECT_LABEL"); + const char* projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL"); if(!projLabel) { projLabel = this->Name.c_str(); } this->WriteString("<ProjectName>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(projLabel) << "</ProjectName>\n"; - if(const char* targetFrameworkVersion = this->Target->GetProperty( + if(const char* targetFrameworkVersion = this->GeneratorTarget->GetProperty( "VS_DOTNET_TARGET_FRAMEWORK_VERSION")) { this->WriteString("<TargetFrameworkVersion>", 2); @@ -497,7 +501,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() { std::vector<std::string> references; if(const char* vsDotNetReferences = - this->Target->GetProperty("VS_DOTNET_REFERENCES")) + this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES")) { cmSystemTools::ExpandListArgument(vsDotNetReferences, references); } @@ -543,7 +547,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() i != this->Configurations.end(); ++i) { this->WritePlatformConfigTag("LogicalName", i->c_str(), 3); - if(this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE")) + if(this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE")) { (*this->BuildFileStream ) << "$(RootNamespace)."; } @@ -610,7 +614,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences() { std::vector<std::string> references; if(const char* vsWinRTReferences = - this->Target->GetProperty("VS_WINRT_REFERENCES")) + this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES")) { cmSystemTools::ExpandListArgument(vsWinRTReferences, references); } @@ -679,7 +683,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() break; case cmState::EXECUTABLE: if(this->NsightTegra && - !this->Target->GetPropertyAsBool("ANDROID_GUI")) + !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) { // Android executables are .so too. configType += "DynamicLibrary"; @@ -746,10 +750,10 @@ void cmVisualStudio10TargetGenerator if((this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY && this->ClOptions[config]->UsingUnicode()) || - this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") || + this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") || this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsStore() || - this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) + this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); } @@ -769,8 +773,8 @@ void cmVisualStudio10TargetGenerator pts += "</PlatformToolset>\n"; this->WriteString(pts.c_str(), 2); } - if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") || - this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) + if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") || + this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->WriteString("<WindowsAppContainer>true" "</WindowsAppContainer>\n", 2); @@ -788,27 +792,29 @@ void cmVisualStudio10TargetGenerator ntv += toolset? toolset : "Default"; ntv += "</NdkToolchainVersion>\n"; this->WriteString(ntv.c_str(), 2); - if(const char* minApi = this->Target->GetProperty("ANDROID_API_MIN")) + if(const char* minApi = + this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) { this->WriteString("<AndroidMinAPI>", 2); (*this->BuildFileStream ) << "android-" << cmVS10EscapeXML(minApi) << "</AndroidMinAPI>\n"; } - if(const char* api = this->Target->GetProperty("ANDROID_API")) + if(const char* api = this->GeneratorTarget->GetProperty("ANDROID_API")) { this->WriteString("<AndroidTargetAPI>", 2); (*this->BuildFileStream ) << "android-" << cmVS10EscapeXML(api) << "</AndroidTargetAPI>\n"; } - if(const char* cpuArch = this->Target->GetProperty("ANDROID_ARCH")) + if(const char* cpuArch = this->GeneratorTarget->GetProperty("ANDROID_ARCH")) { this->WriteString("<AndroidArch>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(cpuArch) << "</AndroidArch>\n"; } - if(const char* stlType = this->Target->GetProperty("ANDROID_STL_TYPE")) + if(const char* stlType = + this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) { this->WriteString("<AndroidStlType>", 2); (*this->BuildFileStream) << cmVS10EscapeXML(stlType) << @@ -1775,7 +1781,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() if(ttype == cmState::OBJECT_LIBRARY) { outDir = intermediateDir; - targetNameFull = this->Target->GetName(); + targetNameFull = this->GeneratorTarget->GetName(); targetNameFull += ".lib"; } else @@ -1926,7 +1932,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( { clOptions.AddFlag("CompileAs", "CompileAsCpp"); } - this->LocalGenerator->AddCompileOptions(flags, this->Target, + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, linkLanguage, configName.c_str()); // Get preprocessor definitions for this directory. @@ -1955,7 +1961,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( configDefine += configName; configDefine += "\""; clOptions.AddDefine(configDefine); - if(const char* exportMacro = this->Target->GetExportMacro()) + if(const char* exportMacro = + this->GeneratorTarget->GetExportMacro()) { clOptions.AddDefine(exportMacro); } @@ -1963,7 +1970,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( if (this->MSTools) { // If we have the VS_WINRT_COMPONENT set then force Compile as WinRT. - if (this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT")) + if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) { clOptions.AddFlag("CompileAsWinRT", "true"); // For WinRT components, add the _WINRT_DLL define to produce a lib @@ -2012,7 +2019,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( if(this->NsightTegra) { if(const char* processMax = - this->Target->GetProperty("ANDROID_PROCESS_MAX")) + this->GeneratorTarget->GetProperty("ANDROID_PROCESS_MAX")) { this->WriteString("<ProcessMax>", 3); *this->BuildFileStream << cmVS10EscapeXML(processMax) << @@ -2183,7 +2190,7 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) } std::string libflags; this->LocalGenerator->GetStaticLibraryFlags(libflags, - cmSystemTools::UpperCase(config), this->Target); + cmSystemTools::UpperCase(config), this->GeneratorTarget); if(!libflags.empty()) { this->WriteString("<Lib>\n", 2); @@ -2270,18 +2277,18 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( cmVS10EscapeXML(antBuildPath) << "</AntBuildPath>\n"; } - if (this->Target->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP")) + if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP")) { this->WriteString("<SkipAntStep>true</SkipAntStep>\n", 3); } - if (this->Target->GetPropertyAsBool("ANDROID_PROGUARD")) + if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_PROGUARD")) { this->WriteString("<EnableProGuard>true</EnableProGuard>\n", 3); } if (const char* proGuardConfigLocation = - this->Target->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) + this->GeneratorTarget->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) { this->WriteString("<ProGuardConfigLocation>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(proGuardConfigLocation) << @@ -2289,7 +2296,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* securePropertiesLocation = - this->Target->GetProperty("ANDROID_SECURE_PROPS_PATH")) + this->GeneratorTarget->GetProperty("ANDROID_SECURE_PROPS_PATH")) { this->WriteString("<SecurePropertiesLocation>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(securePropertiesLocation) << @@ -2297,7 +2304,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* nativeLibDirectoriesExpression = - this->Target->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) + this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) { cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = @@ -2310,7 +2317,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* nativeLibDependenciesExpression = - this->Target->GetProperty("ANDROID_NATIVE_LIB_DEPENDENCIES")) + this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DEPENDENCIES")) { cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = @@ -2323,7 +2330,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* javaSourceDir = - this->Target->GetProperty("ANDROID_JAVA_SOURCE_DIR")) + this->GeneratorTarget->GetProperty("ANDROID_JAVA_SOURCE_DIR")) { this->WriteString("<JavaSourceDir>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(javaSourceDir) << @@ -2331,7 +2338,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* jarDirectoriesExpression = - this->Target->GetProperty("ANDROID_JAR_DIRECTORIES")) + this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) { cmGeneratorExpression ge; cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = @@ -2344,7 +2351,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* jarDeps = - this->Target->GetProperty("ANDROID_JAR_DEPENDENCIES")) + this->GeneratorTarget->GetProperty("ANDROID_JAR_DEPENDENCIES")) { this->WriteString("<JarDependencies>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(jarDeps) << @@ -2352,7 +2359,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* assetsDirectories = - this->Target->GetProperty("ANDROID_ASSETS_DIRECTORIES")) + this->GeneratorTarget->GetProperty("ANDROID_ASSETS_DIRECTORIES")) { this->WriteString("<AssetsDirectories>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(assetsDirectories) << @@ -2368,7 +2375,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( } if (const char* antAdditionalOptions = - this->Target->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) + this->GeneratorTarget->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) { this->WriteString("<AdditionalOptions>", 3); (*this->BuildFileStream) << cmVS10EscapeXML(antAdditionalOptions) << @@ -2439,7 +2446,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) flags += " "; flags += this-> Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str()); - const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS"); + const char* targetLinkFlags = + this->GeneratorTarget->GetProperty("LINK_FLAGS"); if(targetLinkFlags) { flags += " "; @@ -2447,7 +2455,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } std::string flagsProp = "LINK_FLAGS_"; flagsProp += CONFIG; - if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str())) + if(const char* flagsConfig = + this->GeneratorTarget->GetProperty(flagsProp.c_str())) { flags += " "; flags += flagsConfig; @@ -2525,7 +2534,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) { linkOptions.AddFlag("Version", ""); - if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) + if ( this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE") ) { if (this->GlobalGenerator->TargetsWindowsCE()) { @@ -2597,7 +2606,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) // A Windows Runtime component uses internal .NET metadata, // so does not have an import library. - if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") && + if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") && this->GeneratorTarget->GetType() != cmState::EXECUTABLE) { linkOptions.AddFlag("GenerateWindowsMetadata", "true"); @@ -2639,7 +2648,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + if (this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)exportall.def"); } @@ -2783,7 +2792,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->WriteManifestOptions(*i); if(this->NsightTegra && this->GeneratorTarget->GetType() == cmState::EXECUTABLE && - this->Target->GetPropertyAsBool("ANDROID_GUI")) + this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) { this->WriteAntBuildOptions(*i); } @@ -2798,7 +2807,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName) if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { - if (this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + if (this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { addedPrelink = true; std::vector<cmCustomCommand> commands = @@ -2911,14 +2920,14 @@ void cmVisualStudio10TargetGenerator::WritePlatformExtensions() cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0")) { const char* desktopExtensionsVersion = - this->Target->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION"); + this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION"); if (desktopExtensionsVersion) { this->WriteSinglePlatformExtension("WindowsDesktop", desktopExtensionsVersion); } const char* mobileExtensionsVersion = - this->Target->GetProperty("VS_MOBILE_EXTENSIONS_VERSION"); + this->GeneratorTarget->GetProperty("VS_MOBILE_EXTENSIONS_VERSION"); if (mobileExtensionsVersion) { this->WriteSinglePlatformExtension("WindowsMobile", @@ -2958,11 +2967,11 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences() cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0")) { const char* desktopExtensionsVersion = - this->Target->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION"); + this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION"); const char* mobileExtensionsVersion = - this->Target->GetProperty("VS_MOBILE_EXTENSIONS_VERSION"); + this->GeneratorTarget->GetProperty("VS_MOBILE_EXTENSIONS_VERSION"); const char* iotExtensionsVersion = - this->Target->GetProperty("VS_IOT_EXTENSIONS_VERSION"); + this->GeneratorTarget->GetProperty("VS_IOT_EXTENSIONS_VERSION"); if(desktopExtensionsVersion || mobileExtensionsVersion || iotExtensionsVersion) @@ -3194,7 +3203,8 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() "</WindowsTargetPlatformVersion>\n"; } const char* targetPlatformMinVersion = - this->Target->GetProperty("VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION"); + this->GeneratorTarget + ->GetProperty("VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION"); if(targetPlatformMinVersion) { this->WriteString("<WindowsTargetPlatformMinVersion>", 2); @@ -3213,7 +3223,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() } // Added IoT Startup Task support - if(this->Target->GetPropertyAsBool("VS_IOT_STARTUP_TASK")) + if(this->GeneratorTarget->GetPropertyAsBool("VS_IOT_STARTUP_TASK")) { this->WriteString("<ContainsStartupTask>true</ContainsStartupTask>\n", 2); } @@ -3325,7 +3335,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); @@ -3408,7 +3419,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81() this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); @@ -3468,7 +3480,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80() this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); @@ -3520,7 +3533,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81() this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); @@ -3577,7 +3591,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0() this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName()); + std::string targetNameXML = + cmVS10EscapeXML(this->GeneratorTarget->GetName()); cmGeneratedFileStream fout(manifestFile.c_str()); fout.SetCopyIfDifferent(true); diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 012c580..4b7afd8 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -49,7 +49,20 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, mf.ExpandArguments(this->Args, expandedArguments); cmake::MessageType messageType; - cmConditionEvaluator conditionEvaluator(mf); + cmListFileContext execContext = this->GetStartingContext(); + + cmCommandContext commandContext; + commandContext.Line = execContext.Line; + commandContext.Name = execContext.Name; + + cmListFileContext conditionContext = + cmConditionEvaluator::GetConditionContext( + &mf, commandContext, + this->GetStartingContext().FilePath); + + cmConditionEvaluator conditionEvaluator( + mf, conditionContext, + mf.GetBacktrace(commandContext)); bool isTrue = conditionEvaluator.IsTrue( expandedArguments, errorString, messageType); diff --git a/Source/kwsys/Terminal.c b/Source/kwsys/Terminal.c index d13f79a..a8abb6c 100644 --- a/Source/kwsys/Terminal.c +++ b/Source/kwsys/Terminal.c @@ -184,14 +184,25 @@ static const char* kwsysTerminalVT100Names[] = static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100, int default_tty) { + /* Force color according to http://bixense.com/clicolors/ convention. */ + { + const char* clicolor_force = getenv("CLICOLOR_FORCE"); + if (clicolor_force && *clicolor_force && strcmp(clicolor_force, "0") != 0) + { + return 1; + } + } + /* If running inside emacs the terminal is not VT100. Some emacs seem to claim the TERM is xterm even though they do not support VT100 escapes. */ + { const char* emacs = getenv("EMACS"); if(emacs && *emacs == 't') { return 0; } + } /* Check for a valid terminal. */ if(!default_vt100) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 3f28c25..ae61bca 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2587,8 +2587,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release "${CMake_BINARY_DIR}/Testing/DelphiCoverage/DartConfiguration.tcl") file(COPY "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/src" DESTINATION "${CMake_BINARY_DIR}/Testing/DelphiCoverage") - file(COPY "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html" - DESTINATION "${CMake_BINARY_DIR}/Testing/DelphiCoverage") + configure_file( + "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html.in" + "${CMake_BINARY_DIR}/Testing/DelphiCoverage/UTCovTest(UTCovTest.pas).html") add_test(NAME CTestDelphiCoverage COMMAND cmake -E chdir ${CMake_BINARY_DIR}/Testing/DelphiCoverage diff --git a/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html b/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html.in index 9caaea3..9caaea3 100644 --- a/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html +++ b/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html.in diff --git a/Tests/RunCMake/CMP0054/CMP0054-WARN-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-WARN-stderr.txt index 3d875ae..3cfa5d2 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0054/CMP0054-WARN-stderr.txt @@ -9,3 +9,15 @@ CMake Warning \(dev\) at CMP0054-WARN.cmake:3 \(if\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0054-WARN.cmake:5 \(elseif\): + Policy CMP0054 is not set: Only interpret if\(\) arguments as variables or + keywords when unquoted. Run "cmake --help-policy CMP0054" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + Quoted variables like "FOO" will no longer be dereferenced when the policy + is set to NEW. Since the policy is not set the OLD behavior will be used. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0054/CMP0054-WARN.cmake b/Tests/RunCMake/CMP0054/CMP0054-WARN.cmake index 37855fc..a608929 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-WARN.cmake +++ b/Tests/RunCMake/CMP0054/CMP0054-WARN.cmake @@ -2,4 +2,6 @@ set(FOO "BAR") if(NOT "FOO" STREQUAL "BAR") message(FATAL_ERROR "The given literals should match") +elseif("FOO" STREQUAL "BING") + message(FATAL_ERROR "The given literals should not match") endif() diff --git a/Tests/RunCMake/CMP0054/CMP0054-keywords-WARN-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-keywords-WARN-stderr.txt index b1ebd49..5a8c263 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-keywords-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0054/CMP0054-keywords-WARN-stderr.txt @@ -10,3 +10,16 @@ CMake Warning \(dev\) at CMP0054-keywords-WARN.cmake:1 \(if\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at CMP0054-keywords-WARN.cmake:3 \(elseif\): + Policy CMP0054 is not set: Only interpret if\(\) arguments as variables or + keywords when unquoted. Run "cmake --help-policy CMP0054" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + Quoted keywords like "DEFINED" will no longer be interpreted as keywords + when the policy is set to NEW. Since the policy is not set the OLD + behavior will be used. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0054/CMP0054-keywords-WARN.cmake b/Tests/RunCMake/CMP0054/CMP0054-keywords-WARN.cmake index ee0a623..118ab3d 100644 --- a/Tests/RunCMake/CMP0054/CMP0054-keywords-WARN.cmake +++ b/Tests/RunCMake/CMP0054/CMP0054-keywords-WARN.cmake @@ -1,3 +1,5 @@ if("NOT" 1) message(FATAL_ERROR "[\"NOT\" 1] evaluated true") +elseif("DEFINED" NotDefined) + message(FATAL_ERROR "[\"DEFINED\" NotDefined] evaluated true") endif() diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 00895cc..2bc3693 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -78,6 +78,21 @@ endfunction() run_LabelCount() +function(run_SerialFailed) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SerialFailed) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " +add_test(NoSuchCommand no_such_command) +set_tests_properties(NoSuchCommand PROPERTIES RUN_SERIAL ON) +add_test(Echo \"${CMAKE_COMMAND}\" -E echo \"EchoTest\") +") + + run_cmake_command(SerialFailed ${CMAKE_CTEST_COMMAND} -V) +endfunction() +run_SerialFailed() + function(run_TestLoad name load) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestLoad) set(RunCMake_TEST_NO_CLEAN 1) diff --git a/Tests/RunCMake/CTestCommandLine/SerialFailed-result.txt b/Tests/RunCMake/CTestCommandLine/SerialFailed-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/SerialFailed-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/CTestCommandLine/SerialFailed-stderr.txt b/Tests/RunCMake/CTestCommandLine/SerialFailed-stderr.txt new file mode 100644 index 0000000..cafe565 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/SerialFailed-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: no_such_command diff --git a/Tests/RunCMake/CTestCommandLine/SerialFailed-stdout.txt b/Tests/RunCMake/CTestCommandLine/SerialFailed-stdout.txt new file mode 100644 index 0000000..d7144f7 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/SerialFailed-stdout.txt @@ -0,0 +1,10 @@ +Could not find executable no_such_command +.* +2/2 Test #2: Echo ............................. Passed +[0-9.]+ sec ++ +50% tests passed, 1 tests failed out of 2 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[ ]+1 - NoSuchCommand \(Not Run\)$ diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt new file mode 100644 index 0000000..b8d726f --- /dev/null +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe-stderr.txt @@ -0,0 +1,15 @@ +CMake Warning \(dev\) at CMP0063-WARN-exe.cmake:[0-9]+ \(add_executable\): + Policy CMP0063 is not set: Honor visibility properties for all target + types. Run "cmake --help-policy CMP0063" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "myexe" of type "EXECUTABLE" has the following visibility properties + set for CXX: + + CXX_VISIBILITY_PRESET + VISIBILITY_INLINES_HIDDEN + + For compatibility CMake is not honoring them for this target. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-yes.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe.cmake index 3388e4d..cef1d75 100644 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-yes.cmake +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-exe.cmake @@ -5,4 +5,7 @@ enable_language(CXX) set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") -include(CMP0063-Common.cmake) +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +add_executable(myexe lib.cpp) diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt new file mode 100644 index 0000000..3a7732a --- /dev/null +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj-stderr.txt @@ -0,0 +1,15 @@ +CMake Warning \(dev\) at CMP0063-WARN-obj.cmake:[0-9]+ \(add_library\): + Policy CMP0063 is not set: Honor visibility properties for all target + types. Run "cmake --help-policy CMP0063" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "myobject" of type "OBJECT_LIBRARY" has the following visibility + properties set for CXX: + + CXX_VISIBILITY_PRESET + VISIBILITY_INLINES_HIDDEN + + For compatibility CMake is not honoring them for this target. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj.cmake new file mode 100644 index 0000000..81d1c33 --- /dev/null +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-obj.cmake @@ -0,0 +1,11 @@ + +enable_language(CXX) + +# Ensure CMake warns even if toolchain does not really have these flags. +set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") +set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +add_library(myobject OBJECT lib.cpp) diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt new file mode 100644 index 0000000..1efa1b5 --- /dev/null +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta-stderr.txt @@ -0,0 +1,15 @@ +CMake Warning \(dev\) at CMP0063-WARN-sta.cmake:[0-9]+ \(add_library\): + Policy CMP0063 is not set: Honor visibility properties for all target + types. Run "cmake --help-policy CMP0063" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "mystatic" of type "STATIC_LIBRARY" has the following visibility + properties set for CXX: + + CXX_VISIBILITY_PRESET + VISIBILITY_INLINES_HIDDEN + + For compatibility CMake is not honoring them for this target. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta.cmake b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta.cmake new file mode 100644 index 0000000..132e076 --- /dev/null +++ b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-sta.cmake @@ -0,0 +1,11 @@ + +enable_language(CXX) + +# Ensure CMake warns even if toolchain does not really have these flags. +set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") +set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +add_library(mystatic STATIC lib.cpp) diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-yes-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-yes-stderr.txt deleted file mode 100644 index 59a4b8f..0000000 --- a/Tests/RunCMake/VisibilityPreset/CMP0063-WARN-yes-stderr.txt +++ /dev/null @@ -1,50 +0,0 @@ -^CMake Warning \(dev\) at CMP0063-Common.cmake:[0-9]+ \(add_executable\): - Policy CMP0063 is not set: Honor visibility properties for all target - types. Run "cmake --help-policy CMP0063" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - Target "myexe" of type "EXECUTABLE" has the following visibility properties - set for CXX: - - CXX_VISIBILITY_PRESET - VISIBILITY_INLINES_HIDDEN - - For compatibility CMake is not honoring them for this target. -Call Stack \(most recent call first\): - CMP0063-WARN-yes.cmake:[0-9]+ \(include\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. -+ -CMake Warning \(dev\) at CMP0063-Common.cmake:[0-9]+ \(add_library\): - Policy CMP0063 is not set: Honor visibility properties for all target - types. Run "cmake --help-policy CMP0063" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - Target "myobject" of type "OBJECT_LIBRARY" has the following visibility - properties set for CXX: - - CXX_VISIBILITY_PRESET - VISIBILITY_INLINES_HIDDEN - - For compatibility CMake is not honoring them for this target. -Call Stack \(most recent call first\): - CMP0063-WARN-yes.cmake:[0-9]+ \(include\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it. -+ -CMake Warning \(dev\) at CMP0063-Common.cmake:[0-9]+ \(add_library\): - Policy CMP0063 is not set: Honor visibility properties for all target - types. Run "cmake --help-policy CMP0063" for policy details. Use the - cmake_policy command to set the policy and suppress this warning. - - Target "mystatic" of type "STATIC_LIBRARY" has the following visibility - properties set for CXX: - - CXX_VISIBILITY_PRESET - VISIBILITY_INLINES_HIDDEN - - For compatibility CMake is not honoring them for this target. -Call Stack \(most recent call first\): - CMP0063-WARN-yes.cmake:[0-9]+ \(include\) - CMakeLists.txt:[0-9]+ \(include\) -This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake b/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake index c7eb808..7a000ee 100644 --- a/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake +++ b/Tests/RunCMake/VisibilityPreset/RunCMakeTest.cmake @@ -2,6 +2,8 @@ include(RunCMake) run_cmake(PropertyTypo) run_cmake(CMP0063-OLD) -run_cmake(CMP0063-WARN-yes) +run_cmake(CMP0063-WARN-exe) +run_cmake(CMP0063-WARN-obj) +run_cmake(CMP0063-WARN-sta) run_cmake(CMP0063-WARN-no) run_cmake(CMP0063-NEW) @@ -259,7 +259,6 @@ CMAKE_CXX_SOURCES="\ cmPropertyMap \ cmPropertyDefinition \ cmPropertyDefinitionMap \ - cmMakeDepend \ cmMakefile \ cmExportBuildFileGenerator \ cmExportFileGenerator \ |