diff options
24 files changed, 527 insertions, 104 deletions
diff --git a/Help/release/dev/deb-on-windows.rst b/Help/release/dev/deb-on-windows.rst new file mode 100644 index 0000000..b307720 --- /dev/null +++ b/Help/release/dev/deb-on-windows.rst @@ -0,0 +1,7 @@ +deb-on-windows +-------------- + +* The CPack ``DEB`` generator, configured by the :module:`CPackDeb` module, + was enabled on Windows. While not fully featured (due to the lack of + external UNIX tools) this will allow building basic cross-platform Debian + packages. diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index ddf8b23..daba7d5 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -497,6 +497,16 @@ # # This value is not interpreted. It is possible to pass an optional # revision number of the referenced source package as well. +# +# Building Debian packages on Windows +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# To communicate UNIX file permissions from the install stage +# to the CPack DEB generator the "cmake_mode_t" NTFS +# alternate data stream (ADT) is used. +# +# When a filesystem without ADT support is used only owner read/write +# permissions can be preserved. # CPack script for creating Debian package # Author: Mathieu Malaterre @@ -507,10 +517,6 @@ if(CMAKE_BINARY_DIR) message(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.") endif() -if(NOT UNIX) - message(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.") -endif() - function(cpack_deb_variable_fallback OUTPUT_VAR_NAME) set(FALLBACK_VAR_NAMES ${ARGN}) diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 26d44b9..fb16f20 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -619,7 +619,7 @@ if(TARGET Doxygen::doxygen) # If doxygen was found, use it to generate a minimal default Doxyfile. # We will delete this file after we have finished using it below to # generate the other files that doxygen_add_docs() will use. - set(_Doxygen_tpl "${PROJECT_BINARY_DIR}/CMakeDoxyfile.tpl") + set(_Doxygen_tpl "${CMAKE_BINARY_DIR}/CMakeDoxyfile.tpl") execute_process( COMMAND "${DOXYGEN_EXECUTABLE}" -s -g "${_Doxygen_tpl}" OUTPUT_QUIET @@ -646,8 +646,8 @@ if(TARGET Doxygen::doxygen) # content is only dependent on the version of Doxygen being used. Therefore # we always put them at the top of the build tree so that they are in a # predictable location. - set(_doxyfile_in "${PROJECT_BINARY_DIR}/CMakeDoxyfile.in") - set(_doxyfile_defaults "${PROJECT_BINARY_DIR}/CMakeDoxygenDefaults.cmake") + set(_doxyfile_in "${CMAKE_BINARY_DIR}/CMakeDoxyfile.in") + set(_doxyfile_defaults "${CMAKE_BINARY_DIR}/CMakeDoxygenDefaults.cmake") file(WRITE "${_doxyfile_in}" ${_Doxygen_dne_header}) file(WRITE "${_doxyfile_defaults}" ${_Doxygen_dne_header}) @@ -896,7 +896,7 @@ doxygen_add_docs() for target ${targetName}") # Now bring in Doxgen's defaults for those things the project has not # already set and we have not provided above - include("${PROJECT_BINARY_DIR}/CMakeDoxygenDefaults.cmake" OPTIONAL) + include("${CMAKE_BINARY_DIR}/CMakeDoxygenDefaults.cmake" OPTIONAL) # Cleanup built HTMLs on "make clean" # TODO Any other dirs? @@ -1025,7 +1025,7 @@ doxygen_add_docs() for target ${targetName}") endforeach() # Prepare doxygen configuration file - set(_doxyfile_template "${PROJECT_BINARY_DIR}/CMakeDoxyfile.in") + set(_doxyfile_template "${CMAKE_BINARY_DIR}/CMakeDoxyfile.in") set(_target_doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.${targetName}") configure_file("${_doxyfile_template}" "${_target_doxyfile}") diff --git a/Modules/FindXCTest.cmake b/Modules/FindXCTest.cmake index ffdf677..8497336 100644 --- a/Modules/FindXCTest.cmake +++ b/Modules/FindXCTest.cmake @@ -136,7 +136,7 @@ function(xctest_add_bundle target testee) XCODE_ATTRIBUTE_TEST_HOST "$<TARGET_FILE:${testee}>") if(NOT XCODE_VERSION VERSION_LESS 7.3) set_target_properties(${target} PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "$<TARGET_FILE_DIR:${testee}>/../PlugIns") + LIBRARY_OUTPUT_DIRECTORY "$<TARGET_BUNDLE_CONTENT_DIR:${testee}>/PlugIns") endif() else(XCODE) target_link_libraries(${target} @@ -183,7 +183,7 @@ function(xctest_add_test name bundle) add_test( NAME ${name} - COMMAND ${XCTest_EXECUTABLE} $<TARGET_LINKER_FILE_DIR:${bundle}>/../..) + COMMAND ${XCTest_EXECUTABLE} $<TARGET_BUNDLE_DIR:${bundle}>) # point loader to testee in case rpath is disabled diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 660d632..e556ca6 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -876,6 +876,7 @@ set(CPACK_SRCS CPack/cmCPackTarCompressGenerator.cxx CPack/cmCPackZIPGenerator.cxx CPack/cmCPack7zGenerator.cxx + CPack/cmCPackDebGenerator.cxx ) # CPack IFW generator set(CPACK_SRCS ${CPACK_SRCS} @@ -902,7 +903,6 @@ option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF) if(UNIX) set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackDebGenerator.cxx CPack/cmCPackRPMGenerator.cxx ) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b1fcf31..182bc31 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 9) -set(CMake_VERSION_PATCH 20170629) +set(CMake_VERSION_PATCH 20170630) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index af54fce..00d017e 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -479,6 +479,25 @@ int cmCPackDebGenerator::createDeb() cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \"" << relativeDir << "\"" << std::endl); +#ifdef WIN32 + std::string mode_t_adt_filename = *fileIt + ":cmake_mode_t"; + cmsys::ifstream permissionStream(mode_t_adt_filename.c_str()); + + mode_t permissions = 0; + + if (permissionStream) { + permissionStream >> std::oct >> permissions; + } + + if (permissions != 0) { + data_tar.SetPermissions(permissions); + } else if (cmSystemTools::FileIsDirectory(*fileIt)) { + data_tar.SetPermissions(0755); + } else { + data_tar.ClearPermissions(); + } +#endif + // do not recurse because the loop will do it if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:" @@ -553,8 +572,8 @@ int cmCPackDebGenerator::createDeb() and https://lintian.debian.org/tags/control-file-has-bad-permissions.html */ - const mode_t permission644 = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; - const mode_t permissionExecute = S_IXUSR | S_IXGRP | S_IXOTH; + const mode_t permission644 = 0644; + const mode_t permissionExecute = 0111; const mode_t permission755 = permission644 | permissionExecute; // for md5sum and control (that we have generated here), we use 644 @@ -831,7 +850,7 @@ static int copy_ar(CF* cfp, off_t size) ? static_cast<size_t>(sz) : sizeof(buf), from)) > 0) { - sz -= nr; + sz -= static_cast<off_t>(nr); for (size_t off = 0; off < nr; nr -= off, off += nw) { if ((nw = fwrite(buf + off, 1, nr, to)) < nr) { return -1; @@ -854,7 +873,6 @@ static int copy_ar(CF* cfp, off_t size) static int put_arobj(CF* cfp, struct stat* sb) { int result = 0; - struct ar_hdr* hdr; /* If passed an sb structure, reading a file from disk. Get stat(2) * information, build a name and construct a header. (Files are named @@ -873,7 +891,7 @@ static int put_arobj(CF* cfp, struct stat* sb) if (gid > USHRT_MAX) { gid = USHRT_MAX; } - if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) { + if (lname > sizeof(ar_hdr().ar_name) || strchr(name, ' ')) { (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size + lname, ARFMAG); diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index f135059..834913d 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -12,6 +12,7 @@ #ifdef HAVE_FREEBSD_PKG #include "cmCPackFreeBSDGenerator.h" #endif +#include "cmCPackDebGenerator.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmCPackNSISGenerator.h" @@ -37,7 +38,6 @@ #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \ !defined(__HAIKU__) -#include "cmCPackDebGenerator.h" #include "cmCPackRPMGenerator.h" #endif @@ -102,6 +102,10 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("TZ", "Tar Compress compression", cmCPackTarCompressGenerator::CreateGenerator); } + if (cmCPackDebGenerator::CanGenerate()) { + this->RegisterGenerator("DEB", "Debian packages", + cmCPackDebGenerator::CreateGenerator); + } #ifdef __APPLE__ if (cmCPackDragNDropGenerator::CanGenerate()) { this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop", @@ -126,10 +130,6 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() #endif #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \ !defined(__HAIKU__) - if (cmCPackDebGenerator::CanGenerate()) { - this->RegisterGenerator("DEB", "Debian packages", - cmCPackDebGenerator::CreateGenerator); - } if (cmCPackRPMGenerator::CanGenerate()) { this->RegisterGenerator("RPM", "RPM packages", cmCPackRPMGenerator::CreateGenerator); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 5777fb2..b769a56 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -55,14 +55,14 @@ class cmSystemToolsFileTime; static mode_t mode_owner_read = S_IREAD; static mode_t mode_owner_write = S_IWRITE; static mode_t mode_owner_execute = S_IEXEC; -static mode_t mode_group_read = 0; -static mode_t mode_group_write = 0; -static mode_t mode_group_execute = 0; -static mode_t mode_world_read = 0; -static mode_t mode_world_write = 0; -static mode_t mode_world_execute = 0; -static mode_t mode_setuid = 0; -static mode_t mode_setgid = 0; +static mode_t mode_group_read = 040; +static mode_t mode_group_write = 020; +static mode_t mode_group_execute = 010; +static mode_t mode_world_read = 04; +static mode_t mode_world_write = 02; +static mode_t mode_world_execute = 01; +static mode_t mode_setuid = 04000; +static mode_t mode_setgid = 02000; #else static mode_t mode_owner_read = S_IRUSR; static mode_t mode_owner_write = S_IWUSR; @@ -1076,11 +1076,26 @@ protected: bool SetPermissions(const char* toFile, mode_t permissions) { - if (permissions && !cmSystemTools::SetPermissions(toFile, permissions)) { - std::ostringstream e; - e << this->Name << " cannot set permissions on \"" << toFile << "\""; - this->FileCommand->SetError(e.str()); - return false; + if (permissions) { +#ifdef WIN32 + if (Makefile->IsOn("CMAKE_CROSSCOMPILING")) { + std::string mode_t_adt_filename = + std::string(toFile) + ":cmake_mode_t"; + + cmsys::ofstream permissionStream(mode_t_adt_filename.c_str()); + + if (permissionStream) { + permissionStream << std::oct << permissions << std::endl; + } + } +#endif + + if (!cmSystemTools::SetPermissions(toFile, permissions)) { + std::ostringstream e; + e << this->Name << " cannot set permissions on \"" << toFile << "\""; + this->FileCommand->SetError(e.str()); + return false; + } } return true; } diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 0e02b0a..e3835ff 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -130,6 +130,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( this->DefaultNasmFlagTable = cmVS10NASMFlagTable; this->DefaultRcFlagTable = cmVS10RCFlagTable; this->Version = VS10; + this->PlatformToolsetNeedsDebugEnum = false; } bool cmGlobalVisualStudio10Generator::MatchesGeneratorName( @@ -195,6 +196,24 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( return false; } + if (cmHasLiteralPrefix(this->GetPlatformToolsetString(), "v140")) { + // The GenerateDebugInformation link setting for the v140 toolset + // in VS 2015 was originally an enum with "No" and "Debug" values, + // differing from the "false" and "true" values used in older toolsets. + // A VS 2015 update changed it back. Parse the "link.xml" file to + // discover which one we need. + std::string const link_xml = this->VCTargetsPath + "/1033/link.xml"; + cmsys::ifstream fin(link_xml.c_str()); + std::string line; + while (fin && cmSystemTools::GetLineFromStream(fin, line)) { + if (line.find(" Switch=\"DEBUG\" ") != std::string::npos) { + this->PlatformToolsetNeedsDebugEnum = + line.find(" Name=\"Debug\" ") != std::string::npos; + break; + } + } + } + if (this->GeneratorToolsetCuda.empty()) { // Find the highest available version of the CUDA tools. std::vector<std::string> cudaTools; diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 20f992a..4a5c245 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -59,6 +59,13 @@ public: const char* GetPlatformToolsetCuda() const; std::string const& GetPlatformToolsetCudaString() const; + /** Return whether we need to use No/Debug instead of false/true + for GenerateDebugInformation. */ + bool GetPlatformToolsetNeedsDebugEnum() const + { + return this->PlatformToolsetNeedsDebugEnum; + } + /** Return the CMAKE_SYSTEM_NAME. */ std::string const& GetSystemName() const { return this->SystemName; } @@ -169,6 +176,8 @@ private: virtual std::string FindDevEnvCommand(); virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); } + bool PlatformToolsetNeedsDebugEnum; + bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); std::string VCTargetsPath; diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index df086d3..c8cf02c 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -8,8 +8,8 @@ #include "cmMakefile.h" #include "cmVS140CLFlagTable.h" #include "cmVS140CSharpFlagTable.h" +#include "cmVS140LinkFlagTable.h" #include "cmVS14LibFlagTable.h" -#include "cmVS14LinkFlagTable.h" #include "cmVS14MASMFlagTable.h" #include "cmVS14RCFlagTable.h" @@ -93,7 +93,7 @@ cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator( this->DefaultClFlagTable = cmVS140CLFlagTable; this->DefaultCSharpFlagTable = cmVS140CSharpFlagTable; this->DefaultLibFlagTable = cmVS14LibFlagTable; - this->DefaultLinkFlagTable = cmVS14LinkFlagTable; + this->DefaultLinkFlagTable = cmVS140LinkFlagTable; this->DefaultMasmFlagTable = cmVS14MASMFlagTable; this->DefaultRcFlagTable = cmVS14RCFlagTable; this->Version = VS14; diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx index da2bf8c..ce1ba00 100644 --- a/Source/cmGlobalVisualStudio15Generator.cxx +++ b/Source/cmGlobalVisualStudio15Generator.cxx @@ -8,6 +8,7 @@ #include "cmMakefile.h" #include "cmVS141CLFlagTable.h" #include "cmVS141CSharpFlagTable.h" +#include "cmVS141LinkFlagTable.h" #include "cmVSSetupHelper.h" static const char vs15generatorName[] = "Visual Studio 15 2017"; @@ -85,6 +86,7 @@ cmGlobalVisualStudio15Generator::cmGlobalVisualStudio15Generator( this->DefaultPlatformToolset = "v141"; this->DefaultClFlagTable = cmVS141CLFlagTable; this->DefaultCSharpFlagTable = cmVS141CSharpFlagTable; + this->DefaultLinkFlagTable = cmVS141LinkFlagTable; this->Version = VS15; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 45c1764..4be3c80 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -147,7 +147,7 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator( this->XcodeBuildCommandInitialized = false; this->ObjectDirArchDefault = "$(CURRENT_ARCH)"; - this->ComputeObjectDirArch(); + this->ObjectDirArch = this->ObjectDirArchDefault; cm->GetState()->SetIsGeneratorMultiConfig(true); } @@ -3087,12 +3087,12 @@ void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) } } - this->ComputeObjectDirArch(); + this->ComputeObjectDirArch(mf); } -void cmGlobalXCodeGenerator::ComputeObjectDirArch() +void cmGlobalXCodeGenerator::ComputeObjectDirArch(cmMakefile* mf) { - if (this->Architectures.size() > 1) { + if (this->Architectures.size() > 1 || this->UseEffectivePlatformName(mf)) { this->ObjectDirArch = "$(CURRENT_ARCH)"; } else if (!this->Architectures.empty()) { this->ObjectDirArch = this->Architectures[0]; @@ -3298,6 +3298,31 @@ void cmGlobalXCodeGenerator::OutputXCodeProject( void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( const std::string& xcProjDir) { + // collect all tests for the targets + std::map<std::string, cmXCodeScheme::TestObjects> testables; + + for (std::vector<cmXCodeObject*>::const_iterator i = + this->XCodeObjects.begin(); + i != this->XCodeObjects.end(); ++i) { + cmXCodeObject* obj = *i; + if (obj->GetType() != cmXCodeObject::OBJECT || + obj->GetIsA() != cmXCodeObject::PBXNativeTarget) { + continue; + } + + if (!obj->GetTarget()->IsXCTestOnApple()) { + continue; + } + + const char* testee = obj->GetTarget()->GetProperty("XCTEST_TESTEE"); + if (!testee) { + continue; + } + + testables[testee].push_back(obj); + } + + // generate scheme for (std::vector<cmXCodeObject*>::const_iterator i = this->XCodeObjects.begin(); i != this->XCodeObjects.end(); ++i) { @@ -3305,8 +3330,9 @@ void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes( if (obj->GetType() == cmXCodeObject::OBJECT && (obj->GetIsA() == cmXCodeObject::PBXNativeTarget || obj->GetIsA() == cmXCodeObject::PBXAggregateTarget)) { - cmXCodeScheme schm(obj, this->CurrentConfigurationTypes, - this->XcodeVersion); + const std::string& targetName = obj->GetTarget()->GetName(); + cmXCodeScheme schm(obj, testables[targetName], + this->CurrentConfigurationTypes, this->XcodeVersion); schm.WriteXCodeSharedScheme(xcProjDir, this->RelativeToSource(xcProjDir.c_str())); } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index f38fa3c..e69793b 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -247,7 +247,7 @@ private: const cmGeneratorTarget* t) const; void ComputeArchitectures(cmMakefile* mf); - void ComputeObjectDirArch(); + void ComputeObjectDirArch(cmMakefile* mf); void addObject(cmXCodeObject* obj); std::string PostBuildMakeTarget(std::string const& tName, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8e00303..9049a42 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -451,6 +451,19 @@ void cmLocalGenerator::GenerateInstallRules() /* clang-format on */ } + // Copy cmake cross compile state to install code. + if (const char* crosscompiling = + this->Makefile->GetDefinition("CMAKE_CROSSCOMPILING")) { + /* clang-format off */ + fout << + "# Is this installation the result of a crosscompile?\n" + "if(NOT DEFINED CMAKE_CROSSCOMPILING)\n" + " set(CMAKE_CROSSCOMPILING \"" << crosscompiling << "\")\n" + "endif()\n" + "\n"; + /* clang-format on */ + } + // Ask each install generator to write its code. std::vector<cmInstallGenerator*> const& installers = this->Makefile->GetInstallGenerators(); diff --git a/Source/cmVS14LinkFlagTable.h b/Source/cmVS140LinkFlagTable.h index 596f880..ceb1d78 100644 --- a/Source/cmVS14LinkFlagTable.h +++ b/Source/cmVS140LinkFlagTable.h @@ -1,4 +1,4 @@ -static cmVS7FlagTable cmVS14LinkFlagTable[] = { +static cmVS7FlagTable cmVS140LinkFlagTable[] = { // Enum Properties { "ShowProgress", "", "Not Set", "NotSet", 0 }, @@ -38,7 +38,12 @@ static cmVS7FlagTable cmVS14LinkFlagTable[] = { { "GenerateDebugInformation", "DEBUG:FASTLINK", "Optimize for faster linking", "DebugFastLink", cmVS7FlagTable::CaseInsensitive }, - { "GenerateDebugInformation", "DEBUG", "Optimize for debugging", "Debug", + { "GenerateDebugInformation", "DEBUG:FULL", "Optimize for debugging", "true", + cmVS7FlagTable::CaseInsensitive }, + { "GenerateDebugInformation", "DEBUG:NONE", + "Produces no debugging information", "false", + cmVS7FlagTable::CaseInsensitive }, + { "GenerateDebugInformation", "DEBUG", "Optimize for debugging", "true", cmVS7FlagTable::CaseInsensitive }, { "SubSystem", "", "Not Set", "NotSet", 0 }, diff --git a/Source/cmVS141LinkFlagTable.h b/Source/cmVS141LinkFlagTable.h new file mode 100644 index 0000000..d7faf81 --- /dev/null +++ b/Source/cmVS141LinkFlagTable.h @@ -0,0 +1,286 @@ +static cmVS7FlagTable cmVS141LinkFlagTable[] = { + + // Enum Properties + { "ShowProgress", "", "Not Set", "NotSet", 0 }, + { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose", + 0 }, + { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib", + 0 }, + { "ShowProgress", "VERBOSE:ICF", + "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 }, + { "ShowProgress", "VERBOSE:REF", + "About data removed during optimized linking", "LinkVerboseREF", 0 }, + { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH", + "LinkVerboseSAFESEH", 0 }, + { "ShowProgress", "VERBOSE:CLR", + "About linker activity related to managed code", "LinkVerboseCLR", 0 }, + + { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 }, + { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only", + "MultiplyDefinedSymbolOnly", 0 }, + { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only", + "UndefinedSymbolOnly", 0 }, + + { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 }, + { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only", + "X86Image", 0 }, + { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only", + "X64Image", 0 }, + { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only", + "ItaniumImage", 0 }, + + { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 }, + { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable", + "HighestAvailable", 0 }, + { "UACExecutionLevel", "level='requireAdministrator'", + "requireAdministrator", "RequireAdministrator", 0 }, + + { "GenerateDebugInformation", "DEBUG:FASTLINK", + "Generate Debug Information optimized for faster links", "DebugFastLink", + cmVS7FlagTable::CaseInsensitive }, + { "GenerateDebugInformation", "DEBUG:FULL", + "Generate Debug Information optimized for sharing and publishing", + "DebugFull", cmVS7FlagTable::CaseInsensitive }, + { "GenerateDebugInformation", "DEBUG:NONE", + "Produces no debugging information", "false", + cmVS7FlagTable::CaseInsensitive }, + { "GenerateDebugInformation", "DEBUG", "Generate Debug Information", "true", + cmVS7FlagTable::CaseInsensitive }, + + { "SubSystem", "", "Not Set", "NotSet", 0 }, + { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 }, + { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 }, + { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 }, + { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application", + "EFI Application", 0 }, + { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER", + "EFI Boot Service Driver", "EFI Boot Service Driver", 0 }, + { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 }, + { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime", + 0 }, + { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 }, + + { "Driver", "", "Not Set", "NotSet", 0 }, + { "Driver", "Driver", "Driver", "Driver", 0 }, + { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 }, + { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 }, + + { "LinkTimeCodeGeneration", "", "Default", "Default", 0 }, + { "LinkTimeCodeGeneration", "LTCG:incremental", + "Use Fast Link Time Code Generation", "UseFastLinkTimeCodeGeneration", 0 }, + { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation", + "UseLinkTimeCodeGeneration", 0 }, + { "LinkTimeCodeGeneration", "LTCG:PGInstrument", + "Profile Guided Optimization - Instrument", "PGInstrument", 0 }, + { "LinkTimeCodeGeneration", "LTCG:PGOptimize", + "Profile Guided Optimization - Optimization", "PGOptimization", 0 }, + { "LinkTimeCodeGeneration", "LTCG:PGUpdate", + "Profile Guided Optimization - Update", "PGUpdate", 0 }, + + { "GenerateWindowsMetadata", "WINMD", "Yes", "true", 0 }, + { "GenerateWindowsMetadata", "WINMD:NO", "No", "false", 0 }, + + { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1", "SHA1", "SHA1", 0 }, + { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256", "SHA256", "SHA256", 0 }, + { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384", "SHA384", "SHA384", 0 }, + { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512", "SHA512", "SHA512", 0 }, + + { "TargetMachine", "", "Not Set", "NotSet", 0 }, + { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 }, + { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 }, + { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 }, + { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 }, + { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 }, + { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU", + 0 }, + { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16", + "MachineMIPSFPU16", 0 }, + { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 }, + { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 }, + { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 }, + { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 }, + + { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute", + "MTAThreadingAttribute", 0 }, + { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute", + "STAThreadingAttribute", 0 }, + { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE", + "Default threading attribute", "DefaultThreadingAttribute", 0 }, + + { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage", + 0 }, + { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image", + "ForcePureILImage", 0 }, + { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image", + "ForceSafeILImage", 0 }, + { "CLRImageType", "", "Default image type", "Default", 0 }, + + { "SignHash", "CLRSIGNHASH:SHA1", "SHA1", "SHA1", 0 }, + { "SignHash", "CLRSIGNHASH:SHA256", "SHA256", "SHA256", 0 }, + { "SignHash", "CLRSIGNHASH:SHA384", "SHA384", "SHA384", 0 }, + { "SignHash", "CLRSIGNHASH:SHA512", "SHA512", "SHA512", 0 }, + + { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately", + "PromptImmediately", 0 }, + { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login", + "QueueForNextLogin", 0 }, + { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report", + "SendErrorReport", 0 }, + { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report", + "NoErrorReport", 0 }, + + { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 }, + { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled", + 0 }, + { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only", + "SystemDlls", 0 }, + + { "LinkControlFlowGuard", "guard:cf", "Enable Security Check with Guard", + "Guard", 0 }, + + // Bool Properties + { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 }, + { "LinkIncremental", "INCREMENTAL", "", "true", 0 }, + { "SuppressStartupBanner", "NOLOGO", "", "true", 0 }, + { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 }, + { "LinkStatus", "LTCG:STATUS", "", "true", 0 }, + { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 }, + { "PreventDllBinding", "ALLOWBIND", "", "true", 0 }, + { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 }, + { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 }, + { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 }, + { "GenerateManifest", "MANIFEST:NO", "", "false", 0 }, + { "GenerateManifest", "MANIFEST", "", "true", 0 }, + { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 }, + { "UACUIAccess", "uiAccess='false'", "", "false", 0 }, + { "UACUIAccess", "uiAccess='true'", "", "true", 0 }, + { "ManifestEmbed", "manifest:embed", "", "true", 0 }, + { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 }, + { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 }, + { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 }, + { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 }, + { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 }, + { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 }, + { "TerminalServerAware", "TSAWARE", "", "true", 0 }, + { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 }, + { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 }, + { "OptimizeReferences", "OPT:NOREF", "", "false", 0 }, + { "OptimizeReferences", "OPT:REF", "", "true", 0 }, + { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 }, + { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 }, + { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 }, + { "AppContainer", "APPCONTAINER", "", "true", 0 }, + { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0 }, + { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0 }, + { "NoEntryPoint", "NOENTRY", "", "true", 0 }, + { "SetChecksum", "RELEASE", "", "true", 0 }, + { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 }, + { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 }, + { "FixedBaseAddress", "FIXED:NO", "", "false", 0 }, + { "FixedBaseAddress", "FIXED", "", "true", 0 }, + { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 }, + { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 }, + { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 }, + { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 }, + { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 }, + { "Profile", "PROFILE", "", "true", 0 }, + { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 }, + { "LinkDelaySign", "DELAYSIGN", "", "true", 0 }, + { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 }, + { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 }, + { "DetectOneDefinitionRule", "ODR", "", "true", 0 }, + { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 }, + { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 }, + { "LinkDLL", "DLL", "", "true", 0 }, + + // Bool Properties With Argument + { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 }, + { "EnableUAC", "MANIFESTUAC:", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, + { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "", + cmVS7FlagTable::UserValueRequired }, + { "GenerateMapFile", "MAP", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, + { "MapFileName", "MAP:", "Generate Map File", "", + cmVS7FlagTable::UserValueRequired }, + + // String List Properties + { "AdditionalLibraryDirectories", "LIBPATH:", + "Additional Library Directories", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "Natvis", "NATVIS:", "Natvis files", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + // Skip [AdditionalDependencies] - no command line Switch. + { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:", + "Ignore Specific Default Libraries", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly", + "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:", + "Embed Managed Resource File", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource", + "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:", + "Additional Manifest Dependencies", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "ManifestInput", "manifestinput:", "Manifest Input", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + + // String Properties + { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue }, + { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue }, + { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "", + cmVS7FlagTable::UserValue }, + { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "", + cmVS7FlagTable::UserValue }, + // Skip [TrackerLogDirectory] - no command line Switch. + { "ModuleDefinitionFile", "DEF:", "Module Definition File", "", + cmVS7FlagTable::UserValue }, + { "ManifestFile", "ManifestFile:", "Manifest File", "", + cmVS7FlagTable::UserValue }, + { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "", + cmVS7FlagTable::UserValue }, + { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "", + cmVS7FlagTable::UserValue }, + // Skip [MapFileName] - no command line Switch. + // Skip [MinimumRequiredVersion] - no command line Switch. + { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "", + cmVS7FlagTable::UserValue }, + // Skip [HeapCommitSize] - no command line Switch. + { "StackReserveSize", "STACK:", "Stack Reserve Size", "", + cmVS7FlagTable::UserValue }, + // Skip [StackCommitSize] - no command line Switch. + { "FunctionOrder", "ORDER:@", "Function Order", "", + cmVS7FlagTable::UserValue }, + { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "", + cmVS7FlagTable::UserValue }, + { "MidlCommandFile", "MIDL:@", "MIDL Commands", "", + cmVS7FlagTable::UserValue }, + { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "", + cmVS7FlagTable::UserValue }, + { "TypeLibraryFile", "TLBOUT:", "Type Library", "", + cmVS7FlagTable::UserValue }, + { "WindowsMetadataFile", "WINMDFILE:", "Windows Metadata File", "", + cmVS7FlagTable::UserValue }, + { "WindowsMetadataLinkKeyFile", "WINMDKEYFILE:", "Windows Metadata Key File", + "", cmVS7FlagTable::UserValue }, + { "WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:", + "Windows Metadata Key Container", "", cmVS7FlagTable::UserValue }, + { "EntryPointSymbol", "ENTRY:", "Entry Point", "", + cmVS7FlagTable::UserValue }, + { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue }, + { "ImportLibrary", "IMPLIB:", "Import Library", "", + cmVS7FlagTable::UserValue }, + { "MergeSections", "MERGE:", "Merge Sections", "", + cmVS7FlagTable::UserValue }, + { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue }, + { "KeyContainer", "KEYCONTAINER:", "Key Container", "", + cmVS7FlagTable::UserValue }, + // Skip [AdditionalOptions] - no command line Switch. + { 0, 0, 0, 0, 0 } +}; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b45b5f8..e4a4d6f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -17,8 +17,6 @@ #include "cm_auto_ptr.hxx" -static std::string const kWINDOWS_7_1_SDK = "Windows7.1SDK"; - static std::string cmVS10EscapeXML(std::string arg) { cmSystemTools::ReplaceString(arg, "&", "&"); @@ -3232,12 +3230,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkOptions.AddFlag("StackReserveSize", stackVal); } - if (this->LocalGenerator->GetVersion() >= - cmGlobalVisualStudioGenerator::VS14) { - linkOptions.AddFlag("GenerateDebugInformation", "No"); - } else { - linkOptions.AddFlag("GenerateDebugInformation", "false"); - } + linkOptions.AddFlag("GenerateDebugInformation", "false"); std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); pdb += "/"; @@ -3284,26 +3277,14 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( "%(IgnoreSpecificDefaultLibraries)"); } - // Hack to fix flag version selection in a common use case. - // FIXME: Select flag table based on toolset instead of VS version. - if (this->LocalGenerator->GetVersion() >= - cmGlobalVisualStudioGenerator::VS14) { - const char* toolset = gg->GetPlatformToolset(); - if (toolset && - (toolset == kWINDOWS_7_1_SDK || /* clang-format please break here */ - cmHasLiteralPrefix(toolset, "v80") || - cmHasLiteralPrefix(toolset, "v90") || - cmHasLiteralPrefix(toolset, "v100") || - cmHasLiteralPrefix(toolset, "v110") || - cmHasLiteralPrefix(toolset, "v120"))) { - if (const char* debug = - linkOptions.GetFlag("GenerateDebugInformation")) { - // Convert value from enumeration back to boolean for older toolsets. - if (strcmp(debug, "No") == 0) { - linkOptions.AddFlag("GenerateDebugInformation", "false"); - } else if (strcmp(debug, "Debug") == 0) { - linkOptions.AddFlag("GenerateDebugInformation", "true"); - } + // VS 2015 without all updates has a v140 toolset whose + // GenerateDebugInformation expects No/Debug instead of false/true. + if (gg->GetPlatformToolsetNeedsDebugEnum()) { + if (const char* debug = linkOptions.GetFlag("GenerateDebugInformation")) { + if (strcmp(debug, "false") == 0) { + linkOptions.AddFlag("GenerateDebugInformation", "No"); + } else if (strcmp(debug, "true") == 0) { + linkOptions.AddFlag("GenerateDebugInformation", "Debug"); } } } diff --git a/Source/cmVisualStudio10ToolsetOptions.cxx b/Source/cmVisualStudio10ToolsetOptions.cxx index afca216..9a1d950 100644 --- a/Source/cmVisualStudio10ToolsetOptions.cxx +++ b/Source/cmVisualStudio10ToolsetOptions.cxx @@ -26,10 +26,11 @@ #include "cmVS12RCFlagTable.h" #include "cmVS140CLFlagTable.h" #include "cmVS140CSharpFlagTable.h" +#include "cmVS140LinkFlagTable.h" #include "cmVS141CLFlagTable.h" #include "cmVS141CSharpFlagTable.h" +#include "cmVS141LinkFlagTable.h" #include "cmVS14LibFlagTable.h" -#include "cmVS14LinkFlagTable.h" #include "cmVS14MASMFlagTable.h" #include "cmVS14RCFlagTable.h" @@ -114,8 +115,10 @@ cmIDEFlagTable const* cmVisualStudio10ToolsetOptions::GetLinkFlagTable( { std::string const useToolset = this->GetToolsetName(name, toolset); - if ((useToolset == "v140") || (useToolset == "v141")) { - return cmVS14LinkFlagTable; + if (useToolset == "v141") { + return cmVS141LinkFlagTable; + } else if (useToolset == "v140") { + return cmVS140LinkFlagTable; } else if (useToolset == "v120") { return cmVS12LinkFlagTable; } else if (useToolset == "v110") { diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index 5c22531..bca39af 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -10,13 +10,12 @@ #include "cmGeneratorTarget.h" #include "cmXMLSafe.h" -cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, +cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, const TestObjects& tests, const std::vector<std::string>& configList, unsigned int xcVersion) : Target(xcObj) + , Tests(tests) , TargetName(xcObj->GetTarget()->GetName()) - , BuildableName(xcObj->GetTarget()->GetFullName()) - , TargetId(xcObj->GetId()) , ConfigList(configList) , XcodeVersion(xcVersion) { @@ -58,7 +57,7 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout, xout.Attribute("version", "1.3"); WriteBuildAction(xout, container); - WriteTestAction(xout, FindConfiguration("Debug")); + WriteTestAction(xout, FindConfiguration("Debug"), container); WriteLaunchAction(xout, FindConfiguration("Debug"), container); WriteProfileAction(xout, FindConfiguration("Release")); WriteAnalyzeAction(xout, FindConfiguration("Debug")); @@ -84,14 +83,7 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout, xout.Attribute("buildForArchiving", "YES"); xout.Attribute("buildForAnalyzing", "YES"); - xout.StartElement("BuildableReference"); - xout.BreakAttributes(); - xout.Attribute("BuildableIdentifier", "primary"); - xout.Attribute("BlueprintIdentifier", this->TargetId); - xout.Attribute("BuildableName", this->BuildableName); - xout.Attribute("BlueprintName", this->TargetName); - xout.Attribute("ReferencedContainer", "container:" + container); - xout.EndElement(); + WriteBuildableReference(xout, this->Target, container); xout.EndElement(); // BuildActionEntry xout.EndElement(); // BuildActionEntries @@ -99,7 +91,8 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout, } void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout, - std::string configuration) + std::string configuration, + const std::string& container) { xout.StartElement("TestAction"); xout.BreakAttributes(); @@ -111,8 +104,22 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout, xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES"); xout.StartElement("Testables"); + for (TestObjects::const_iterator it = this->Tests.begin(); + it != this->Tests.end(); ++it) { + xout.StartElement("TestableReference"); + xout.BreakAttributes(); + xout.Attribute("skipped", "NO"); + WriteBuildableReference(xout, *it, container); + xout.EndElement(); // TestableReference + } xout.EndElement(); + if (IsTestable()) { + xout.StartElement("MacroExpansion"); + WriteBuildableReference(xout, this->Target, container); + xout.EndElement(); // MacroExpansion + } + xout.StartElement("AdditionalOptions"); xout.EndElement(); @@ -146,14 +153,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, xout.StartElement("MacroExpansion"); } - xout.StartElement("BuildableReference"); - xout.BreakAttributes(); - xout.Attribute("BuildableIdentifier", "primary"); - xout.Attribute("BlueprintIdentifier", this->TargetId); - xout.Attribute("BuildableName", this->BuildableName); - xout.Attribute("BlueprintName", this->TargetName); - xout.Attribute("ReferencedContainer", "container:" + container); - xout.EndElement(); + WriteBuildableReference(xout, this->Target, container); xout.EndElement(); // MacroExpansion @@ -195,6 +195,20 @@ void cmXCodeScheme::WriteArchiveAction(cmXMLWriter& xout, xout.EndElement(); } +void cmXCodeScheme::WriteBuildableReference(cmXMLWriter& xout, + const cmXCodeObject* xcObj, + const std::string& container) +{ + xout.StartElement("BuildableReference"); + xout.BreakAttributes(); + xout.Attribute("BuildableIdentifier", "primary"); + xout.Attribute("BlueprintIdentifier", xcObj->GetId()); + xout.Attribute("BuildableName", xcObj->GetTarget()->GetFullName()); + xout.Attribute("BlueprintName", xcObj->GetTarget()->GetName()); + xout.Attribute("ReferencedContainer", "container:" + container); + xout.EndElement(); +} + std::string cmXCodeScheme::WriteVersionString() { std::ostringstream v; @@ -215,6 +229,11 @@ std::string cmXCodeScheme::FindConfiguration(const std::string& name) return name; } +bool cmXCodeScheme::IsTestable() const +{ + return !this->Tests.empty() || IsExecutable(this->Target); +} + bool cmXCodeScheme::IsExecutable(const cmXCodeObject* target) { cmGeneratorTarget* gt = target->GetTarget(); diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h index 379afed..def75b1 100644 --- a/Source/cmXCodeScheme.h +++ b/Source/cmXCodeScheme.h @@ -5,6 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <vector> + #include "cmGlobalXCodeGenerator.h" #include "cmSystemTools.h" #include "cmXCodeObject.h" @@ -16,7 +18,9 @@ class cmXCodeScheme { public: - cmXCodeScheme(cmXCodeObject* xcObj, + typedef std::vector<const cmXCodeObject*> TestObjects; + + cmXCodeScheme(cmXCodeObject* xcObj, const TestObjects& tests, const std::vector<std::string>& configList, unsigned int xcVersion); @@ -25,25 +29,30 @@ public: private: const cmXCodeObject* const Target; + const TestObjects Tests; const std::string& TargetName; - const std::string BuildableName; - const std::string& TargetId; const std::vector<std::string>& ConfigList; const unsigned int XcodeVersion; void WriteXCodeXCScheme(std::ostream& fout, const std::string& container); void WriteBuildAction(cmXMLWriter& xout, const std::string& container); - void WriteTestAction(cmXMLWriter& xout, std::string configuration); + void WriteTestAction(cmXMLWriter& xout, std::string configuration, + const std::string& container); void WriteLaunchAction(cmXMLWriter& xout, std::string configuration, const std::string& container); void WriteProfileAction(cmXMLWriter& xout, std::string configuration); void WriteAnalyzeAction(cmXMLWriter& xout, std::string configuration); void WriteArchiveAction(cmXMLWriter& xout, std::string configuration); + void WriteBuildableReference(cmXMLWriter& xout, const cmXCodeObject* xcObj, + const std::string& container); + std::string WriteVersionString(); std::string FindConfiguration(const std::string& name); + bool IsTestable() const; + static bool IsExecutable(const cmXCodeObject* target); }; diff --git a/Source/cm_sys_stat.h b/Source/cm_sys_stat.h index 26e4baa..796f027 100644 --- a/Source/cm_sys_stat.h +++ b/Source/cm_sys_stat.h @@ -7,6 +7,11 @@ typedef unsigned short mode_t; #endif +#if defined(WIN32) +typedef unsigned short uid_t; +typedef unsigned short gid_t; +#endif + #include <sys/types.h> // include sys/stat.h after sys/types.h #include <sys/stat.h> diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt index d40c40e..d0b07ea 100644 --- a/Tests/XCTest/CMakeLists.txt +++ b/Tests/XCTest/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(XCTest) +project(XCTest C) enable_testing() find_package(XCTest REQUIRED) |