diff options
53 files changed, 836 insertions, 321 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 31b2389..344bc09 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -152,6 +152,7 @@ Properties on Targets /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX /prop_tgt/CROSSCOMPILING_EMULATOR + /prop_tgt/CUDA_PTX_COMPILATION /prop_tgt/CUDA_SEPARABLE_COMPILATION /prop_tgt/CUDA_EXTENSIONS /prop_tgt/CUDA_STANDARD diff --git a/Help/prop_tgt/CUDA_PTX_COMPILATION.rst b/Help/prop_tgt/CUDA_PTX_COMPILATION.rst new file mode 100644 index 0000000..0ee372b --- /dev/null +++ b/Help/prop_tgt/CUDA_PTX_COMPILATION.rst @@ -0,0 +1,12 @@ +CUDA_PTX_COMPILATION +-------------------- + +Compile CUDA sources to ``.ptx`` files instead of ``.obj`` files +within :ref:`Object Libraries`. + +For example: + +.. code-block:: cmake + + add_library(myptx OBJECT a.cu b.cu) + set_property(TARGET myptx PROPERTY CUDA_PTX_COMPILATION ON) diff --git a/Help/release/dev/enable_ptx_compilation.rst b/Help/release/dev/enable_ptx_compilation.rst new file mode 100644 index 0000000..965247f --- /dev/null +++ b/Help/release/dev/enable_ptx_compilation.rst @@ -0,0 +1,6 @@ +enable_ptx_compilation +---------------------- + +* The :prop_tgt:`CUDA_PTX_COMPILATION` target property was added to + :ref:`Object Libraries` to support compiling to ``.ptx`` files + instead of host object files. diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in index fcecb6c..5e945bc 100644 --- a/Modules/AutogenInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -21,6 +21,7 @@ set(AM_MOC_INCLUDES @_moc_incs@) set(AM_MOC_OPTIONS @_moc_options@) set(AM_MOC_RELAXED_MODE @_moc_relaxed_mode@) set(AM_MOC_DEPEND_FILTERS @_moc_depend_filters@) +set(AM_MOC_PREDEFS_CMD @_moc_predefs_cmd@) # UIC settings set(AM_UIC_SKIP @_uic_skip@) set(AM_UIC_TARGET_OPTIONS @_uic_target_options@) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index cc54032..fa2a6e4 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -911,6 +911,19 @@ # # * Mandatory : YES # * Default : "/" +# +# .. VARIABLE:: CPACK_RPM_BUILDREQUIRES +# +# List of source rpm build dependencies. +# +# * Mandatory : NO +# * Default : - +# +# May be used to set source RPM build dependencies (BuildRequires). Note that +# you must enclose the complete build requirements string between quotes, for +# example:: +# +# set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8") # Author: Eric Noulard with the help of Alexander Neundorf. diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake index 02968b4..06d01f1 100644 --- a/Modules/Compiler/Intel.cmake +++ b/Modules/Compiler/Intel.cmake @@ -22,5 +22,7 @@ else() string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os") string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3") string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g") + + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") endmacro() endif() diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index bc906e5..af4daf0 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -893,6 +893,28 @@ else() endif() endif() +# Check that all libraries are present, as wx-config does not check it +set(_wx_lib_missing "") +foreach(_wx_lib_ ${wxWidgets_LIBRARIES}) + if("${_wx_lib_}" MATCHES "^-l(.*)") + set(_wx_lib_name "${CMAKE_MATCH_1}") + unset(_wx_lib_found CACHE) + find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS}) + if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND) + list(APPEND _wx_lib_missing ${_wx_lib_name}) + endif() + unset(_wx_lib_found CACHE) + endif() +endforeach() + +if (_wx_lib_missing) + string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}") + DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}") + set(wxWidgets_FOUND FALSE) + unset(wxWidgets_LIBRARIES) +endif() +unset(_wx_lib_missing) + # Check if a specfic version was requested by find_package(). if(wxWidgets_FOUND) find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH) diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index 9599f27..64bd09e 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -45,6 +45,8 @@ # modifiable architecture-independent data (``com``) # ``LOCALSTATEDIR`` # modifiable single-machine data (``var``) +# ``RUNSTATEDIR`` +# run-time variable data (``LOCALSTATEDIR/run``) # ``LIBDIR`` # object code libraries (``lib`` or ``lib64`` # or ``lib/<multiarch-tuple>`` on Debian) @@ -75,10 +77,10 @@ # # ``/`` # -# For ``<dir>`` other than the ``SYSCONFDIR`` and ``LOCALSTATEDIR``, -# the value of ``CMAKE_INSTALL_<dir>`` is prefixed with ``usr/`` if -# it is not user-specified as an absolute path. For example, the -# ``INCLUDEDIR`` value ``include`` becomes ``usr/include``. +# For ``<dir>`` other than the ``SYSCONFDIR``, ``LOCALSTATEDIR`` and +# ``RUNSTATEDIR``, the value of ``CMAKE_INSTALL_<dir>`` is prefixed +# with ``usr/`` if it is not user-specified as an absolute path. +# For example, the ``INCLUDEDIR`` value ``include`` becomes ``usr/include``. # This is required by the `GNU Coding Standards`_, which state: # # When building the complete GNU system, the prefix will be empty @@ -86,20 +88,21 @@ # # ``/usr`` # -# For ``<dir>`` equal to ``SYSCONFDIR`` or ``LOCALSTATEDIR``, the -# ``CMAKE_INSTALL_FULL_<dir>`` is computed by prepending just ``/`` -# to the value of ``CMAKE_INSTALL_<dir>`` if it is not user-specified -# as an absolute path. For example, the ``SYSCONFDIR`` value ``etc`` -# becomes ``/etc``. This is required by the `GNU Coding Standards`_. +# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or +# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by +# prepending just ``/`` to the value of ``CMAKE_INSTALL_<dir>`` +# if it is not user-specified as an absolute path. +# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc``. +# This is required by the `GNU Coding Standards`_. # # ``/opt/...`` # -# For ``<dir>`` equal to ``SYSCONFDIR`` or ``LOCALSTATEDIR``, the -# ``CMAKE_INSTALL_FULL_<dir>`` is computed by *appending* the prefix -# to the value of ``CMAKE_INSTALL_<dir>`` if it is not user-specified -# as an absolute path. For example, the ``SYSCONFDIR`` value ``etc`` -# becomes ``/etc/opt/...``. This is defined by the -# `Filesystem Hierarchy Standard`_. +# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or +# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by +# *appending* the prefix to the value of ``CMAKE_INSTALL_<dir>`` +# if it is not user-specified as an absolute path. +# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``. +# This is defined by the `Filesystem Hierarchy Standard`_. # # .. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html # @@ -287,6 +290,9 @@ _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DAT _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}" "Documentation root (DATAROOTDIR/doc/PROJECT_NAME)") +_GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_RUNSTATEDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/run" + "Run-time variable data (LOCALSTATEDIR/run)") + #----------------------------------------------------------------------------- mark_as_advanced( @@ -296,6 +302,7 @@ mark_as_advanced( CMAKE_INSTALL_SYSCONFDIR CMAKE_INSTALL_SHAREDSTATEDIR CMAKE_INSTALL_LOCALSTATEDIR + CMAKE_INSTALL_RUNSTATEDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_OLDINCLUDEDIR @@ -314,7 +321,7 @@ macro(GNUInstallDirs_get_absolute_install_dir absvar var) # - CMAKE_INSTALL_PREFIX == /usr # - CMAKE_INSTALL_PREFIX == /opt/... if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/") - if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") + if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR") set(${absvar} "/${${var}}") else() if (NOT "${${var}}" MATCHES "^usr/") @@ -323,13 +330,13 @@ macro(GNUInstallDirs_get_absolute_install_dir absvar var) set(${absvar} "/${${var}}") endif() elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$") - if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") + if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR") set(${absvar} "/${${var}}") else() set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}") endif() elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/.*") - if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR") + if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR") set(${absvar} "/${${var}}${CMAKE_INSTALL_PREFIX}") else() set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}") @@ -351,6 +358,7 @@ foreach(dir SYSCONFDIR SHAREDSTATEDIR LOCALSTATEDIR + RUNSTATEDIR LIBDIR INCLUDEDIR OLDINCLUDEDIR diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake index 6878254..ce30a26 100644 --- a/Modules/Platform/Linux-GNU.cmake +++ b/Modules/Platform/Linux-GNU.cmake @@ -12,4 +12,5 @@ macro(__linux_compiler_gnu lang) # We pass this for historical reasons. Projects may have # executables that use dlopen but do not set ENABLE_EXPORTS. set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") + set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") endmacro() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ea6e0e2..fcb0b8b 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 8) -set(CMake_VERSION_PATCH 20170421) +set(CMake_VERSION_PATCH 20170424) #set(CMake_VERSION_RC 1) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 80e7e7d..b273443 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -500,7 +500,10 @@ bool cmComputeLinkInformation::Compute() cmGeneratorTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); - std::string lib = tgt->GetFullPath(this->Config, implib, true); + cmStateEnums::ArtifactType artifact = implib + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + std::string lib = tgt->GetFullPath(this->Config, artifact, true); this->OldLinkDirItems.push_back(lib); } } @@ -596,8 +599,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // platform. Add it now. std::string linkItem; linkItem = this->LoaderFlag; + cmStateEnums::ArtifactType artifact = this->UseImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; - std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true); + std::string exe = tgt->GetFullPath(config, artifact, true); linkItem += exe; this->Items.push_back(Item(linkItem, true, tgt)); this->Depends.push_back(exe); @@ -617,9 +623,12 @@ void cmComputeLinkInformation::AddItem(std::string const& item, bool implib = (this->UseImportLibrary && (impexe || tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); + cmStateEnums::ArtifactType artifact = implib + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; // Pass the full path to the target file. - std::string lib = tgt->GetFullPath(config, implib, true); + std::string lib = tgt->GetFullPath(config, artifact, true); if (!this->LinkDependsNoShared || tgt->GetType() != cmStateEnums::SHARED_LIBRARY) { this->Depends.push_back(lib); @@ -689,7 +698,10 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, // linked will be able to find it. std::string lib; if (tgt) { - lib = tgt->GetFullPath(this->Config, this->UseImportLibrary); + cmStateEnums::ArtifactType artifact = this->UseImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + lib = tgt->GetFullPath(this->Config, artifact); this->AddLibraryRuntimeInfo(lib, tgt); } else { lib = item; diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 978a7a1..a1c424a 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -200,9 +200,11 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( prop += suffix; std::string value; if (target->IsAppBundleOnApple()) { - value = target->GetFullPath(config, false); + value = + target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); } else { - value = target->GetFullPath(config, false, true); + value = target->GetFullPath(config, + cmStateEnums::RuntimeBinaryArtifact, true); } properties[prop] = value; } @@ -212,7 +214,8 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { std::string prop = "IMPORTED_IMPLIB"; prop += suffix; - std::string value = target->GetFullPath(config, true); + std::string value = + target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact); target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 77a4962..e065a74 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1607,7 +1607,10 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> "executables with ENABLE_EXPORTS."); return std::string(); } - return target->GetFullPath(context->Config, target->HasImportLibrary()); + cmStateEnums::ArtifactType artifact = target->HasImportLibrary() + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + return target->GetFullPath(context->Config, artifact); } }; @@ -1668,7 +1671,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactNameTag> cmGeneratorExpressionContext* context, const GeneratorExpressionContent* /*unused*/) { - return target->GetFullPath(context->Config, false, true); + return target->GetFullPath(context->Config, + cmStateEnums::RuntimeBinaryArtifact, true); } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a38f968..a0f677b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -216,52 +216,60 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const return this->Target->GetProperty(prop); } -const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const +const char* cmGeneratorTarget::GetOutputTargetType( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::SHARED_LIBRARY: if (this->IsDLLPlatform()) { - if (implib) { - // A DLL import library is treated as an archive target. - return "ARCHIVE"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // A DLL shared library is treated as a runtime target. + return "RUNTIME"; + case cmStateEnums::ImportLibraryArtifact: + // A DLL import library is treated as an archive target. + return "ARCHIVE"; } - // A DLL shared library is treated as a runtime target. - return "RUNTIME"; } else { // For non-DLL platforms shared libraries are treated as // library targets. return "LIBRARY"; } + break; case cmStateEnums::STATIC_LIBRARY: // Static libraries are always treated as archive targets. return "ARCHIVE"; case cmStateEnums::MODULE_LIBRARY: - if (implib) { - // Module libraries are always treated as library targets. - return "ARCHIVE"; - } else { - // Module import libraries are treated as archive targets. - return "LIBRARY"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Module import libraries are treated as archive targets. + return "LIBRARY"; + case cmStateEnums::ImportLibraryArtifact: + // Module libraries are always treated as library targets. + return "ARCHIVE"; } + break; case cmStateEnums::EXECUTABLE: - if (implib) { - // Executable import libraries are treated as archive targets. - return "ARCHIVE"; - } else { - // Executables are always treated as runtime targets. - return "RUNTIME"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Executables are always treated as runtime targets. + return "RUNTIME"; + case cmStateEnums::ImportLibraryArtifact: + // Executable import libraries are treated as archive targets. + return "ARCHIVE"; } + break; default: break; } return ""; } -std::string cmGeneratorTarget::GetOutputName(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetOutputName( + const std::string& config, cmStateEnums::ArtifactType artifact) const { // Lookup/compute/cache the output name for this configuration. - OutputNameKey key(config, implib); + OutputNameKey key(config, artifact); cmGeneratorTarget::OutputNameMapType::iterator i = this->OutputNameMap.find(key); if (i == this->OutputNameMap.end()) { @@ -271,7 +279,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, // Compute output name. std::vector<std::string> props; - std::string type = this->GetOutputTargetType(implib); + std::string type = this->GetOutputTargetType(artifact); std::string configUpper = cmSystemTools::UpperCase(config); if (!type.empty() && !configUpper.empty()) { // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG> @@ -528,6 +536,18 @@ const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) return this->Objects[file]; } +const char* cmGeneratorTarget::GetCustomObjectExtension() const +{ + static std::string extension; + const bool has_ptx_extension = + this->GetPropertyAsBool("CUDA_PTX_COMPILATION"); + if (has_ptx_extension) { + extension = ".ptx"; + return extension.c_str(); + } + return CM_NULLPTR; +} + void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) { this->ExplicitObjectName.insert(sf); @@ -641,9 +661,10 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const { static std::string location; if (this->IsImported()) { - location = this->Target->ImportedGetFullPath(config, false); + location = this->Target->ImportedGetFullPath( + config, cmStateEnums::RuntimeBinaryArtifact); } else { - location = this->GetFullPath(config, false); + location = this->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); } return location.c_str(); } @@ -680,7 +701,8 @@ const char* cmGeneratorTarget::GetLocationForBuild() const { static std::string location; if (this->IsImported()) { - location = this->Target->ImportedGetFullPath("", false); + location = this->Target->ImportedGetFullPath( + "", cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } @@ -700,7 +722,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->GetFullName("", false); + location += this->GetFullName("", cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } @@ -1145,7 +1167,8 @@ std::string cmGeneratorTarget::GetCompilePDBName( std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -1506,7 +1529,8 @@ static bool shouldAddContentLevel( std::string cmGeneratorTarget::GetAppBundleDirectory( const std::string& config, BundleDirectoryLevel level) const { - std::string fpath = this->GetFullName(config, false); + std::string fpath = + this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1532,7 +1556,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory( const std::string& config, BundleDirectoryLevel level) const { std::string fpath; - fpath += this->GetOutputName(config, false); + fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1556,7 +1580,7 @@ std::string cmGeneratorTarget::GetFrameworkDirectory( const std::string& config, BundleDirectoryLevel level) const { std::string fpath; - fpath += this->GetOutputName(config, false); + fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1570,13 +1594,13 @@ std::string cmGeneratorTarget::GetFrameworkDirectory( return fpath; } -std::string cmGeneratorTarget::GetFullName(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullName( + const std::string& config, cmStateEnums::ArtifactType artifact) const { if (this->IsImported()) { - return this->GetFullNameImported(config, implib); + return this->GetFullNameImported(config, artifact); } - return this->GetFullNameInternal(config, implib); + return this->GetFullNameInternal(config, artifact); } std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -1869,13 +1893,11 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } } -void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, - std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const +void cmGeneratorTarget::GetFullNameComponents( + std::string& prefix, std::string& base, std::string& suffix, + const std::string& config, cmStateEnums::ArtifactType artifact) const { - this->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, artifact, prefix, base, suffix); } std::string cmGeneratorTarget::BuildBundleDirectory( @@ -1896,10 +1918,10 @@ std::string cmGeneratorTarget::BuildBundleDirectory( } std::string cmGeneratorTarget::GetMacContentDirectory( - const std::string& config, bool implib) const + const std::string& config, cmStateEnums::ArtifactType artifact) const { // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, artifact); fpath += "/"; BundleDirectoryLevel level = ContentLevel; if (this->IsFrameworkOnApple()) { @@ -2860,7 +2882,8 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const } // Get the directory. - std::string dir = this->GetDirectory(config, false); + std::string dir = + this->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact); // Add each name. std::string f; @@ -2889,7 +2912,7 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const gg->AddToManifest(f); } if (!impName.empty()) { - f = this->GetDirectory(config, true); + f = this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); f += "/"; f += impName; gg->AddToManifest(f); @@ -2907,19 +2930,20 @@ std::string cmGeneratorTarget::GetImportedLibName( } std::string cmGeneratorTarget::GetFullPath(const std::string& config, - bool implib, bool realname) const + cmStateEnums::ArtifactType artifact, + bool realname) const { if (this->IsImported()) { - return this->Target->ImportedGetFullPath(config, implib); + return this->Target->ImportedGetFullPath(config, artifact); } - return this->NormalGetFullPath(config, implib, realname); + return this->NormalGetFullPath(config, artifact, realname); } -std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, - bool implib, - bool realname) const +std::string cmGeneratorTarget::NormalGetFullPath( + const std::string& config, cmStateEnums::ArtifactType artifact, + bool realname) const { - std::string fpath = this->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, artifact); fpath += "/"; if (this->IsAppBundleOnApple()) { fpath = this->BuildBundleDirectory(fpath, config, FullLevel); @@ -2927,12 +2951,18 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } // Add the full name of the target. - if (implib) { - fpath += this->GetFullName(config, true); - } else if (realname) { - fpath += this->NormalGetRealName(config); - } else { - fpath += this->GetFullName(config, false); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + if (realname) { + fpath += this->NormalGetRealName(config); + } else { + fpath += + this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact); + } + break; + case cmStateEnums::ImportLibraryArtifact: + fpath += this->GetFullName(config, cmStateEnums::ImportLibraryArtifact); + break; } return fpath; } @@ -3009,7 +3039,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // The library name. name = prefix + base + suffix; @@ -3034,7 +3065,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, // The import library name. if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::MODULE_LIBRARY) { - impName = this->GetFullNameInternal(config, true); + impName = + this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); } else { impName = ""; } @@ -3075,7 +3107,8 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // The executable name. name = prefix + base + suffix; @@ -3095,19 +3128,20 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->GetFullNameInternal(config, true); + impName = + this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); // The program database file name. pdbName = this->GetPDBName(config); } -std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullNameInternal( + const std::string& config, cmStateEnums::ArtifactType artifact) const { std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, artifact, prefix, base, suffix); return prefix + base + suffix; } @@ -3116,22 +3150,21 @@ const char* cmGeneratorTarget::ImportedGetLocation( { static std::string location; assert(this->IsImported()); - location = this->Target->ImportedGetFullPath(config, false); + location = this->Target->ImportedGetFullPath( + config, cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } -std::string cmGeneratorTarget::GetFullNameImported(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullNameImported( + const std::string& config, cmStateEnums::ArtifactType artifact) const { return cmSystemTools::GetFilenameName( - this->Target->ImportedGetFullPath(config, implib)); + this->Target->ImportedGetFullPath(config, artifact)); } -void cmGeneratorTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const +void cmGeneratorTarget::GetFullNameInternal( + const std::string& config, cmStateEnums::ArtifactType artifact, + std::string& outPrefix, std::string& outBase, std::string& outSuffix) const { // Use just the target name for non-main target types. if (this->GetType() != cmStateEnums::STATIC_LIBRARY && @@ -3144,9 +3177,12 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, return; } + const bool isImportedLibraryArtifact = + (artifact == cmStateEnums::ImportLibraryArtifact); + // Return an empty name for the import library if this platform // does not support import libraries. - if (implib && + if (isImportedLibraryArtifact && !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { outPrefix = ""; outBase = ""; @@ -3159,14 +3195,16 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if (this->GetType() != cmStateEnums::SHARED_LIBRARY && this->GetType() != cmStateEnums::MODULE_LIBRARY && this->GetType() != cmStateEnums::EXECUTABLE) { - implib = false; + artifact = cmStateEnums::RuntimeBinaryArtifact; } // Compute the full name for main target types. - const char* targetPrefix = (implib ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); + const char* targetPrefix = + (isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = + (isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); const char* configPostfix = CM_NULLPTR; if (!config.empty()) { std::string configProp = cmSystemTools::UpperCase(config); @@ -3178,8 +3216,8 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, configPostfix = CM_NULLPTR; } } - const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); - const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact); + const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact); // Check for language-specific default prefix and suffix. std::string ll = this->GetLinkerLanguage(config); @@ -3223,14 +3261,15 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix ? targetPrefix : ""; // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); + outBase += this->GetOutputName(config, artifact); // Append the per-configuration postfix. outBase += configPostfix ? configPostfix : ""; // Name shared libraries with their version number on some platforms. if (const char* soversion = this->GetProperty("SOVERSION")) { - if (this->GetType() == cmStateEnums::SHARED_LIBRARY && !implib && + if (this->GetType() == cmStateEnums::SHARED_LIBRARY && + !isImportedLibraryArtifact && this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) { outBase += "-"; outBase += soversion; @@ -3252,7 +3291,8 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); std::vector<std::string> props; std::string configUpper = cmSystemTools::UpperCase(config); @@ -4396,26 +4436,31 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries( return iface.Exists ? &iface : CM_NULLPTR; } -std::string cmGeneratorTarget::GetDirectory(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetDirectory( + const std::string& config, cmStateEnums::ArtifactType artifact) const { if (this->IsImported()) { // Return the directory from which the target is imported. return cmSystemTools::GetFilenamePath( - this->Target->ImportedGetFullPath(config, implib)); + this->Target->ImportedGetFullPath(config, artifact)); } if (OutputInfo const* info = this->GetOutputInfo(config)) { // Return the directory in which the target will be built. - return implib ? info->ImpDir : info->OutDir; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return info->OutDir; + case cmStateEnums::ImportLibraryArtifact: + return info->ImpDir; + } } return ""; } -bool cmGeneratorTarget::UsesDefaultOutputDir(const std::string& config, - bool implib) const +bool cmGeneratorTarget::UsesDefaultOutputDir( + const std::string& config, cmStateEnums::ArtifactType artifact) const { std::string dir; - return this->ComputeOutputDir(config, implib, dir); + return this->ComputeOutputDir(config, artifact, dir); } cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( @@ -4449,8 +4494,10 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( i = this->OutputInfoMap.insert(entry).first; // Compute output directories. - this->ComputeOutputDir(config, false, info.OutDir); - this->ComputeOutputDir(config, true, info.ImpDir); + this->ComputeOutputDir(config, cmStateEnums::RuntimeBinaryArtifact, + info.OutDir); + this->ComputeOutputDir(config, cmStateEnums::ImportLibraryArtifact, + info.ImpDir); if (!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } @@ -4470,14 +4517,15 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( } bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, - bool implib, std::string& out) const + cmStateEnums::ArtifactType artifact, + std::string& out) const { bool usesDefaultOutputDir = false; std::string conf = config; // Look for a target property defining the target output directory // based on the target type. - std::string targetTypeName = this->GetOutputTargetType(implib); + std::string targetTypeName = this->GetOutputTargetType(artifact); const char* propertyName = CM_NULLPTR; std::string propertyNameStr = targetTypeName; if (!propertyNameStr.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 5b903de..8a687e8 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,7 @@ public: void GetObjectSources(std::vector<cmSourceFile const*>&, const std::string& config) const; const std::string& GetObjectName(cmSourceFile const* file); + const char* GetCustomObjectExtension() const; bool HasExplicitObjectName(cmSourceFile const* file) const; void AddExplicitObjectName(cmSourceFile const* sf); @@ -203,9 +204,12 @@ public: /** Get the full path to the target according to the settings in its makefile and the configuration type. */ - std::string GetFullPath(const std::string& config = "", bool implib = false, - bool realname = false) const; - std::string NormalGetFullPath(const std::string& config, bool implib, + std::string GetFullPath( + const std::string& config = "", + cmStateEnums::ArtifactType artifact = cmStateEnums::RuntimeBinaryArtifact, + bool realname = false) const; + std::string NormalGetFullPath(const std::string& config, + cmStateEnums::ArtifactType artifact, bool realname) const; std::string NormalGetRealName(const std::string& config) const; @@ -233,7 +237,8 @@ public: /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** @return the Mac framework directory without the base. */ std::string GetFrameworkDirectory(const std::string& config, @@ -278,7 +283,8 @@ public: void GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** Append to @a base the bundle directory hierarchy up to a certain @a level * and return it. */ @@ -287,8 +293,8 @@ public: BundleDirectoryLevel level) const; /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config = CM_NULLPTR, - bool implib = false) const; + std::string GetMacContentDirectory( + const std::string& config, cmStateEnums::ArtifactType artifact) const; /** @return folder prefix for IDEs. */ std::string GetEffectiveFolderName() const; @@ -355,7 +361,7 @@ public: std::vector<cmGeneratorTarget*>& objlibs) const; std::string GetFullNameImported(const std::string& config, - bool implib) const; + cmStateEnums::ArtifactType artifact) const; /** Get source files common to all configurations and diagnose cases with per-config sources. Excludes sources added by a TARGET_OBJECTS @@ -415,7 +421,8 @@ public: subdirectory for that configuration. Otherwise just the canonical output directory is given. */ std::string GetDirectory(const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** Get the directory in which to place the target compiler .pdb file. If the configuration name is given then the generator will add its @@ -429,7 +436,8 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const std::string& config, bool implib) const; + bool UsesDefaultOutputDir(const std::string& config, + cmStateEnums::ArtifactType artifact) const; // Cache target output paths for each configuration. struct OutputInfo @@ -470,7 +478,8 @@ public: std::string GetCompilePDBPath(const std::string& config = "") const; // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; + std::string GetOutputName(const std::string& config, + cmStateEnums::ArtifactType artifact) const; void AddSource(const std::string& src); void AddTracedSources(std::vector<std::string> const& srcs); @@ -653,8 +662,9 @@ private: mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, + cmStateEnums::ArtifactType artifact) const; + void GetFullNameInternal(const std::string& config, + cmStateEnums::ArtifactType artifact, std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; @@ -662,7 +672,7 @@ private: mutable LinkClosureMapType LinkClosureMap; // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. - const char* GetOutputTargetType(bool implib) const; + const char* GetOutputTargetType(cmStateEnums::ArtifactType artifact) const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, std::string const& suffix, @@ -788,7 +798,8 @@ private: cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal( const std::string& config, const cmGeneratorTarget* head) const; - bool ComputeOutputDir(const std::string& config, bool implib, + bool ComputeOutputDir(const std::string& config, + cmStateEnums::ArtifactType artifact, std::string& out) const; typedef std::map<std::string, OutputInfo> OutputInfoMapType; @@ -800,7 +811,7 @@ private: void ComputeModuleDefinitionInfo(std::string const& config, ModuleDefinitionInfo& info) const; - typedef std::pair<std::string, bool> OutputNameKey; + typedef std::pair<std::string, cmStateEnums::ArtifactType> OutputNameKey; typedef std::map<OutputNameKey, std::string> OutputNameMapType; mutable OutputNameMapType OutputNameMap; mutable std::set<cmLinkItem> UtilityItems; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index aae01ca..e61cbd9 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -246,7 +246,7 @@ void cmGlobalNinjaGenerator::WriteBuild( bool useResponseFile = false; if (cmdLineLimit < 0 || (cmdLineLimit > 0 && - (args.size() + buildstr.size() + assignments.size()) > + (args.size() + buildstr.size() + assignments.size() + 1000) > static_cast<size_t>(cmdLineLimit))) { variable_assignments.str(std::string()); cmGlobalNinjaGenerator::WriteVariable(variable_assignments, "RSP_FILE", @@ -983,8 +983,8 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { - outputs.push_back(this->ConvertToNinjaPath( - target->GetFullPath(configName, false, realname))); + outputs.push_back(this->ConvertToNinjaPath(target->GetFullPath( + configName, cmStateEnums::RuntimeBinaryArtifact, realname))); break; } case cmStateEnums::OBJECT_LIBRARY: diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8c1c0e7..4213751 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1817,7 +1817,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, gtgt->GetType() == cmStateEnums::MODULE_LIBRARY || gtgt->GetType() == cmStateEnums::EXECUTABLE) { if (this->XcodeVersion >= 21) { - if (!gtgt->UsesDefaultOutputDir(configName, false)) { + if (!gtgt->UsesDefaultOutputDir(configName, + cmStateEnums::RuntimeBinaryArtifact)) { std::string pncdir = gtgt->GetDirectory(configName); buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", this->CreateString(pncdir)); @@ -2009,6 +2010,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); + BuildObjectListOrString sysdirs(this, this->XcodeVersion >= 30); + BuildObjectListOrString sysfdirs(this, this->XcodeVersion >= 30); + const bool emitSystemIncludes = this->XcodeVersion >= 83; + std::vector<std::string> includes; this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", configName); @@ -2022,11 +2027,22 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, frameworkDir += "/../"; frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); if (emitted.insert(frameworkDir).second) { - fdirs.Add(this->XCodeEscapePath(frameworkDir)); + std::string incpath = this->XCodeEscapePath(frameworkDir); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(frameworkDir, configName)) { + sysfdirs.Add(incpath); + } else { + fdirs.Add(incpath); + } } } else { std::string incpath = this->XCodeEscapePath(*i); - dirs.Add(incpath); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(*i, configName)) { + sysdirs.Add(incpath); + } else { + dirs.Add(incpath); + } } } // Add framework search paths needed for linking. @@ -2035,7 +2051,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, for (std::vector<std::string>::const_iterator fdi = fwDirs.begin(); fdi != fwDirs.end(); ++fdi) { if (emitted.insert(*fdi).second) { - fdirs.Add(this->XCodeEscapePath(*fdi)); + std::string incpath = this->XCodeEscapePath(*fdi); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(*fdi, configName)) { + sysfdirs.Add(incpath); + } else { + fdirs.Add(incpath); + } } } } @@ -2045,8 +2067,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (!dirs.IsEmpty()) { buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList()); } + if (!sysfdirs.IsEmpty()) { + buildSettings->AddAttribute("SYSTEM_FRAMEWORK_SEARCH_PATHS", + sysfdirs.CreateList()); + } + if (!sysdirs.IsEmpty()) { + buildSettings->AddAttribute("SYSTEM_HEADER_SEARCH_PATHS", + sysdirs.CreateList()); + } - if (this->XcodeVersion >= 60) { + if (this->XcodeVersion >= 60 && !emitSystemIncludes) { // Add those per-language flags in addition to HEADER_SEARCH_PATHS to gain // system include directory awareness. We need to also keep on setting // HEADER_SEARCH_PATHS to work around a missing compile options flag for diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 6ecf42d..1827ed3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -103,7 +103,10 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( fromDirConfig += cmake::GetCMakeFilesDirectory(); fromDirConfig += "/CMakeRelink.dir/"; } else { - fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); + cmStateEnums::ArtifactType artifact = this->ImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + fromDirConfig = this->Target->GetDirectory(config, artifact); fromDirConfig += "/"; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 93db192..424ab6f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2162,7 +2162,7 @@ bool cmLocalGenerator::IsNMake() const std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( const cmSourceFile& source, std::string const& dir_max, - bool* hasSourceExtension) + bool* hasSourceExtension, char const* customOutputExtension) { // Construct the object file name using the full path to the source // file which is its only unique identification. @@ -2223,7 +2223,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( } // Remove the source extension if it is to be replaced. - if (replaceExt) { + if (replaceExt || customOutputExtension) { keptSourceExtension = false; std::string::size_type dot_pos = objectName.rfind('.'); if (dot_pos != std::string::npos) { @@ -2232,7 +2232,11 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( } // Store the new extension. - objectName += this->GlobalGenerator->GetLanguageOutputExtension(source); + if (customOutputExtension) { + objectName += customOutputExtension; + } else { + objectName += this->GlobalGenerator->GetLanguageOutputExtension(source); + } } if (hasSourceExtension) { *hasSourceExtension = keptSourceExtension; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 3047257..1459a05 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -273,7 +273,8 @@ public: // Compute object file names. std::string GetObjectFileNameWithoutTarget( const cmSourceFile& source, std::string const& dir_max, - bool* hasSourceExtension = CM_NULLPTR); + bool* hasSourceExtension = CM_NULLPTR, + char const* customOutputExtension = CM_NULLPTR); /** Fill out the static linker flags for the given target. */ void GetStaticLibraryFlags(std::string& flags, std::string const& config, diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index c2d9d57..00f5e4b 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -249,12 +249,15 @@ void cmLocalNinjaGenerator::ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt) { + // Determine if these object files should use a custom extension + char const* custom_ext = gt->GetCustomObjectExtension(); for (std::map<cmSourceFile const*, std::string>::iterator si = mapping.begin(); si != mapping.end(); ++si) { cmSourceFile const* sf = si->first; - si->second = - this->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); + bool keptSourceExtension; + si->second = this->GetObjectFileNameWithoutTarget( + *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext); } } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 3313127..5f52786 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -159,12 +159,15 @@ void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt) { + // Determine if these object files should use a custom extension + char const* custom_ext = gt->GetCustomObjectExtension(); for (std::map<cmSourceFile const*, std::string>::iterator si = mapping.begin(); si != mapping.end(); ++si) { cmSourceFile const* sf = si->first; - si->second = - this->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); + bool keptSourceExtension; + si->second = this->GetObjectFileNameWithoutTarget( + *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext); } } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7535ef4..f86c034 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1130,7 +1130,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n"; } - temp = target->GetDirectory(configName, true); + temp = + target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" @@ -1227,7 +1228,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\""; } - temp = target->GetDirectory(configName, true); + temp = + target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index e20fe50..41025af 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -32,6 +32,7 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt) { + char const* custom_ext = gt->GetCustomObjectExtension(); std::string dir_max = this->ComputeLongestObjectDirectory(gt); // Count the number of object files with each name. Note that @@ -44,7 +45,12 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( cmSourceFile const* sf = si->first; std::string objectNameLower = cmSystemTools::LowerCase( cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); - objectNameLower += this->GlobalGenerator->GetLanguageOutputExtension(*sf); + if (custom_ext) { + objectNameLower += custom_ext; + } else { + objectNameLower += + this->GlobalGenerator->GetLanguageOutputExtension(*sf); + } counts[objectNameLower] += 1; } @@ -57,10 +63,16 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames( cmSourceFile const* sf = si->first; std::string objectName = cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); + if (custom_ext) { + objectName += custom_ext; + } else { + objectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); + } if (counts[cmSystemTools::LowerCase(objectName)] > 1) { const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf); - objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max); + bool keptSourceExtension; + objectName = this->GetObjectFileNameWithoutTarget( + *sf, dir_max, &keptSourceExtension, custom_ext); } si->second = objectName; } @@ -80,8 +92,10 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, !(isFortran && target->GetType() == cmStateEnums::SHARED_LIBRARY)) { return pcc; } - std::string outDir = target->GetDirectory(config, false); - std::string impDir = target->GetDirectory(config, true); + std::string outDir = + target->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact); + std::string impDir = + target->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); if (impDir == outDir) { return pcc; } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 493f474..a93b42d 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -21,6 +21,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" #include "cmake.h" @@ -332,7 +333,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } else { cmSystemTools::MakeDirectory(outpath.c_str()); if (!targetNameImport.empty()) { - outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory( + this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index cc8a6b3..e017b29 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -514,7 +514,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( cmSystemTools::MakeDirectory(outpath.c_str()); outpath += "/"; if (!targetNameImport.empty()) { - outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory( + this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ed38024..9c0520e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -30,10 +30,6 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -#ifndef _WIN32 -#include <unistd.h> -#endif - cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) : cmCommonTargetGenerator(target) , OSXBundleGenerator(CM_NULLPTR) @@ -509,8 +505,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { - targetFullPathReal = - this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); + targetFullPathReal = this->GeneratorTarget->GetFullPath( + this->ConfigName, cmStateEnums::RuntimeBinaryArtifact, true); targetFullPathPDB = this->GeneratorTarget->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; @@ -593,6 +589,9 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_SEPARABLE_COMPILATION")) { cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"); + } else if (this->GeneratorTarget->GetPropertyAsBool( + "CUDA_PTX_COMPILATION")) { + cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION"); } else { cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"); } @@ -1492,15 +1491,6 @@ void cmMakefileTargetGenerator::CreateLinkScript( makefile_depends.push_back(linkScriptName); } -static size_t calculateCommandLineLengthLimit() -{ -#if defined(_SC_ARG_MAX) - return ((size_t)sysconf(_SC_ARG_MAX)) - 1000; -#else - return 0; -#endif -} - bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( std::string const& l) const { @@ -1514,7 +1504,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( } // Check for a system limit. - if (size_t const limit = calculateCommandLineLengthLimit()) { + if (size_t const limit = cmSystemTools::CalculateCommandLineLengthLimit()) { // Compute the total length of our list of object files with room // for argument separation and quoting. This does not convert paths // relative to CMAKE_CURRENT_BINARY_DIR like the final list will be, so the diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index aaeb659..cfc91bd 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -5,11 +5,9 @@ #include <algorithm> #include <assert.h> #include <iterator> -#include <limits> #include <map> #include <set> #include <sstream> -#include <stddef.h> #include "cmAlgorithms.h" #include "cmCustomCommand.h" @@ -35,10 +33,6 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -#ifndef _WIN32 -#include <unistd.h> -#endif - cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( cmGeneratorTarget* target) : cmNinjaTargetGenerator(target) @@ -491,10 +485,9 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName)); - std::string targetOutputReal = - this->ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/false, - /*realname=*/true)); + std::string targetOutputReal = this->ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true)); cmakeCommand += targetOutputReal; cmakeCommand += " || true"; linkCmds.push_back(cmakeCommand); @@ -546,36 +539,6 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() return std::vector<std::string>(); } -static int calculateCommandLineLengthLimit(int linkRuleLength) -{ - static int const limits[] = { -#ifdef _WIN32 - 8000, -#endif -#if defined(__linux) - // #define MAX_ARG_STRLEN (PAGE_SIZE * 32) in Linux's binfmts.h - ((int)sysconf(_SC_PAGESIZE) * 32) - 1000, -#endif - std::numeric_limits<int>::max() - }; - - size_t const arrSz = cmArraySize(limits); - int sz = *std::min_element(limits, limits + arrSz); -#if defined(_SC_ARG_MAX) - // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac - int const szArgMax = static_cast<int>(sysconf(_SC_ARG_MAX)); - // a return value of -1 signifies an unrestricted value - if (szArgMax != -1) { - sz = std::min(sz, szArgMax - 1000); - } -#endif - if (sz == std::numeric_limits<int>::max()) { - return 0; - } - - return sz - linkRuleLength; -} - void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() { cmGeneratorTarget& genTarget = *this->GetGeneratorTarget(); @@ -616,9 +579,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() std::string const targetOutputReal = ConvertToNinjaPath( genTarget.ObjectDirectory + "cmake_device_link" + objExt); - std::string const targetOutputImplib = - ConvertToNinjaPath(genTarget.GetFullPath(cfgName, - /*implib=*/true)); + std::string const targetOutputImplib = ConvertToNinjaPath( + genTarget.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact)); this->DeviceLinkObject = targetOutputReal; @@ -761,8 +723,9 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() // Device linking currently doesn't support response files so // do not check if the user has explicitly forced a response file. - int const commandLineLengthLimit = calculateCommandLineLengthLimit( - globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule())); + int const commandLineLengthLimit = + static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) - + globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule()); const std::string rspfile = std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + @@ -788,13 +751,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName)); - std::string targetOutputReal = - ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/false, - /*realname=*/true)); - std::string targetOutputImplib = - ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/true)); + std::string targetOutputReal = ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true)); + std::string targetOutputImplib = ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact)); if (gt.IsAppBundleOnApple()) { // Create the app bundle @@ -1048,8 +1009,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() !(this->TargetLinkLanguage == "RC" || this->TargetLinkLanguage == "CUDA"); int commandLineLengthLimit = -1; if (!lang_supports_response || !this->ForceResponseFile()) { - commandLineLengthLimit = calculateCommandLineLengthLimit( - globalGen.GetRuleCmdLength(this->LanguageLinkerRule())); + commandLineLengthLimit = + static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) - + globalGen.GetRuleCmdLength(this->LanguageLinkerRule()); } const std::string rspfile = diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b008158..7c417a4 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -589,6 +589,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_SEPARABLE_COMPILATION")) { cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"); + } else if (this->GeneratorTarget->GetPropertyAsBool( + "CUDA_PTX_COMPILATION")) { + cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION"); } else { cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"); } diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index c09feef..332fa83 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -7,6 +7,7 @@ #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -213,8 +214,8 @@ std::string cmOSXBundleGenerator::InitMacOSXContentDirectory( { // Construct the full path to the content subdirectory. - std::string macdir = this->GT->GetMacContentDirectory(this->ConfigName, - /*implib*/ false); + std::string macdir = this->GT->GetMacContentDirectory( + this->ConfigName, cmStateEnums::RuntimeBinaryArtifact); macdir += "/"; macdir += pkgloc; cmSystemTools::MakeDirectory(macdir.c_str()); diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 82de9a2..239b18d 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -96,6 +96,41 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target) return qtMajorVersion; } +static std::string GetQtMinorVersion(cmGeneratorTarget const* target, + const std::string& qtMajorVersion) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + std::string qtMinorVersion; + if (qtMajorVersion == "5") { + qtMinorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR"); + } + if (qtMinorVersion.empty()) { + qtMinorVersion = makefile->GetSafeDefinition("QT_VERSION_MINOR"); + } + + const char* targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", ""); + if (targetQtVersion != CM_NULLPTR) { + qtMinorVersion = targetQtVersion; + } + return qtMinorVersion; +} + +static bool QtVersionGreaterOrEqual(const std::string& major, + const std::string& minor, + unsigned long requestMajor, + unsigned long requestMinor) +{ + unsigned long majorUL(0); + unsigned long minorUL(0); + if (cmSystemTools::StringToULong(major.c_str(), &majorUL) && + cmSystemTools::StringToULong(minor.c_str(), &minorUL)) { + return (majorUL > requestMajor) || + (majorUL == requestMajor && minorUL >= requestMinor); + } + return false; +} + static void GetCompileDefinitionsAndDirectories( cmGeneratorTarget const* target, const std::string& config, std::string& incs, std::string& defs) @@ -258,6 +293,12 @@ static void MocSetupAutoTarget( AddDefinitionEscaped(makefile, "_moc_depend_filters", GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS")); + if (QtVersionGreaterOrEqual( + qtMajorVersion, GetQtMinorVersion(target, qtMajorVersion), 5, 8)) { + AddDefinitionEscaped( + makefile, "_moc_predefs_cmd", + makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND")); + } // Moc includes and compile definitions { std::string _moc_incs; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 88ec9e8..d142693 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -360,6 +360,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( InfoGet(makefile, "AM_QT_MOC_EXECUTABLE", this->MocExecutable); InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable); InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable); + + InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); // Check Qt version if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) { this->LogError("AutoGen: Error: Unsupported Qt version: " + @@ -579,6 +581,12 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile) this->MocCppFilenameAbs = this->CurrentBinaryDir + this->MocCppFilenameRel; + // Moc predefs file + if (!this->MocPredefsCmd.empty()) { + this->MocPredefsFileRel = this->AutogenBuildSubDir + "moc_predefs.h"; + this->MocPredefsFileAbs = this->CurrentBinaryDir + this->MocPredefsFileRel; + } + // Init file path checksum generator fpathCheckSum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir, this->ProjectSourceDir, @@ -1142,6 +1150,50 @@ bool cmQtAutoGenerators::MocGenerateAll( return true; } + // Generate moc_predefs + if (!this->MocPredefsCmd.empty()) { + if (!this->MakeParentDirectory(this->MocPredefsFileAbs)) { + this->LogError("AutoMoc: Error creating directory for " + + this->MocPredefsFileRel); + return false; + } + this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel); + + std::vector<std::string> cmd = this->MocPredefsCmd; + cmd.insert(cmd.end(), this->MocIncludes.begin(), this->MocIncludes.end()); + for (std::vector<std::string>::const_iterator it = + this->MocDefinitions.begin(); + it != this->MocDefinitions.end(); ++it) { + cmd.push_back("-D" + (*it)); + } + cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end()); + + std::string output; + bool moc_predefsGenerated = this->RunCommand(cmd, output, false); + if (!moc_predefsGenerated) { + return false; + } + + // actually write the file + cmsys::ofstream outfile; + outfile.open(this->MocPredefsFileAbs.c_str(), std::ios::trunc); + if (!outfile) { + moc_predefsGenerated = false; + this->LogError("AutoMoc: Error opening " + this->MocPredefsFileRel); + } else { + outfile << output; + // Check for write errors + if (!outfile.good()) { + moc_predefsGenerated = false; + this->LogError("AutoMoc: Error writing " + this->MocPredefsFileRel); + } + } + + if (!moc_predefsGenerated) { + return false; + } + } + bool mocCompFileGenerated = false; bool mocCompChanged = false; @@ -1305,6 +1357,10 @@ bool cmQtAutoGenerators::MocGenerateFile( cmd.push_back("-D" + (*it)); } cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end()); + if (!this->MocPredefsFileAbs.empty()) { + cmd.push_back("--include"); + cmd.push_back(this->MocPredefsFileAbs); + } #ifdef _WIN32 cmd.push_back("-DWIN32"); #endif @@ -1805,7 +1861,7 @@ bool cmQtAutoGenerators::MakeParentDirectory(const std::string& filename) const * @return True on success */ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command, - std::string& output) const + std::string& output, bool verbose) const { // Log command if (this->Verbose) { @@ -1813,8 +1869,9 @@ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command, } // Execute command int retVal = 0; - bool res = - cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); + bool res = cmSystemTools::RunSingleCommand( + command, &output, &output, &retVal, CM_NULLPTR, + verbose ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE); return (res && (retVal == 0)); } diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index d359059..24c0a33 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -143,8 +143,8 @@ private: const char* basePrefix, const char* baseSuffix) const; bool MakeParentDirectory(const std::string& filename) const; - bool RunCommand(const std::vector<std::string>& command, - std::string& output) const; + bool RunCommand(const std::vector<std::string>& command, std::string& output, + bool verbose = true) const; bool FindHeader(std::string& header, const std::string& testBasePath) const; @@ -177,6 +177,8 @@ private: // - Moc std::string MocCppFilenameRel; std::string MocCppFilenameAbs; + std::string MocPredefsFileRel; + std::string MocPredefsFileAbs; std::vector<std::string> MocSkipList; std::vector<std::string> MocIncludePaths; std::vector<std::string> MocIncludes; @@ -198,6 +200,8 @@ private: MacroFilter MacroFilters[2]; cmsys::RegularExpression RegExpMocInclude; cmsys::RegularExpression RegExpUicInclude; + // - moc_predefs + std::vector<std::string> MocPredefsCmd; // - Flags bool IncludeProjectDirsBefore; bool Verbose; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index a5c1a23..8227ab7 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -763,9 +763,11 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, if (target->HaveWellDefinedOutputFiles()) { Json::Value artifacts = Json::arrayValue; - artifacts.append(target->GetFullPath(config, false)); + artifacts.append( + target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact)); if (target->IsDLLPlatform()) { - artifacts.append(target->GetFullPath(config, true)); + artifacts.append( + target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact)); const cmGeneratorTarget::OutputInfo* output = target->GetOutputInfo(config); if (output && !output->PdbDir.empty()) { diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h index b2b12b4..7d6158e 100644 --- a/Source/cmStateTypes.h +++ b/Source/cmStateTypes.h @@ -53,6 +53,12 @@ enum CacheEntryType STATIC, UNINITIALIZED }; + +enum ArtifactType +{ + RuntimeBinaryArtifact, + ImportLibraryArtifact +}; } #endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9d3d91f..6d620d9 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -570,6 +570,46 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command) return args; } +size_t cmSystemTools::CalculateCommandLineLengthLimit() +{ + size_t sz = +#ifdef _WIN32 + // There's a maximum of 65536 bytes and thus 32768 WCHARs on Windows + // However, cmd.exe itself can only handle 8191 WCHARs and Ninja for + // example uses it to spawn processes. + size_t(8191); +#elif defined(__linux) + // MAX_ARG_STRLEN is the maximum length of a string permissible for + // the execve() syscall on Linux. It's defined as (PAGE_SIZE * 32) + // in Linux's binfmts.h + static_cast<size_t>(sysconf(_SC_PAGESIZE) * 32); +#else + size_t(0); +#endif + +#if defined(_SC_ARG_MAX) + // ARG_MAX is the maximum size of the command and environment + // that can be passed to the exec functions on UNIX. + // The value in limits.h does not need to be present and may + // depend upon runtime memory constraints, hence sysconf() + // should be used to query it. + long szArgMax = sysconf(_SC_ARG_MAX); + // A return value of -1 signifies an undetermined limit, but + // it does not imply an infinite limit, and thus is ignored. + if (szArgMax != -1) { + // We estimate the size of the environment block to be 1000. + // This isn't accurate at all, but leaves some headroom. + szArgMax = szArgMax < 1000 ? 0 : szArgMax - 1000; +#if defined(_WIN32) || defined(__linux) + sz = std::min(sz, static_cast<size_t>(szArgMax)); +#else + sz = static_cast<size_t>(szArgMax); +#endif + } +#endif + return sz; +} + bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, std::string* captureStdOut, std::string* captureStdErr, int* retVal, diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 86d92be..a8a9995 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -253,6 +253,8 @@ public: static void ParseUnixCommandLine(const char* command, std::vector<std::string>& args); + static size_t CalculateCommandLineLengthLimit(); + static void EnableMessages() { s_DisableMessages = false; } static void DisableMessages() { s_DisableMessages = true; } static void DisableRunCommandOutput() { s_DisableRunCommandOutput = true; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0b1bb06..f675833 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -35,7 +35,7 @@ const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>( { static std::string loc; if (tgt->IsImported()) { - loc = tgt->ImportedGetFullPath("", false); + loc = tgt->ImportedGetFullPath("", cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -54,7 +54,8 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>( { static std::string loc; if (tgt->IsImported()) { - loc = tgt->ImportedGetFullPath(config, false); + loc = + tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -63,7 +64,7 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>( gg->CreateGenerationObjects(); } cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName()); - loc = gt->GetFullPath(config, false); + loc = gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -940,6 +941,14 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") && !this->CheckImportedLibName(prop, value ? value : "")) { /* error was reported by check method */ + } else if (prop == "CUDA_PTX_COMPILATION" && + this->GetType() != cmStateEnums::OBJECT_LIBRARY) { + std::ostringstream e; + e << "CUDA_PTX_COMPILATION property can only be applied to OBJECT " + "targets (\"" + << this->Name << "\")\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; } else { this->Properties.SetProperty(prop, value); } @@ -1294,58 +1303,88 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const return cmSystemTools::IsOn(this->GetProperty(prop)); } -const char* cmTarget::GetSuffixVariableInternal(bool implib) const +const char* cmTarget::GetSuffixVariableInternal( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_SUFFIX"; case cmStateEnums::SHARED_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_SHARED_LIBRARY_SUFFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_LIBRARY_SUFFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; case cmStateEnums::MODULE_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_SHARED_MODULE_SUFFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_MODULE_SUFFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; case cmStateEnums::EXECUTABLE: - return (implib - ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - // Android GUI application packages store the native - // binary as a shared library. - : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") - ? "CMAKE_SHARED_LIBRARY_SUFFIX" - : "CMAKE_EXECUTABLE_SUFFIX")); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Android GUI application packages store the native + // binary as a shared library. + return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + ? "CMAKE_SHARED_LIBRARY_SUFFIX" + : "CMAKE_EXECUTABLE_SUFFIX"); + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; default: break; } return ""; } -const char* cmTarget::GetPrefixVariableInternal(bool implib) const +const char* cmTarget::GetPrefixVariableInternal( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_PREFIX"; case cmStateEnums::SHARED_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" - : "CMAKE_SHARED_LIBRARY_PREFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_LIBRARY_PREFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; case cmStateEnums::MODULE_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" - : "CMAKE_SHARED_MODULE_PREFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_MODULE_PREFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; case cmStateEnums::EXECUTABLE: - return (implib - ? "CMAKE_IMPORT_LIBRARY_PREFIX" - // Android GUI application packages store the native - // binary as a shared library. - : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") - ? "CMAKE_SHARED_LIBRARY_PREFIX" - : "")); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Android GUI application packages store the native + // binary as a shared library. + return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + ? "CMAKE_SHARED_LIBRARY_PREFIX" + : ""); + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; default: break; } return ""; } -std::string cmTarget::ImportedGetFullPath(const std::string& config, - bool pimplib) const +std::string cmTarget::ImportedGetFullPath( + const std::string& config, cmStateEnums::ArtifactType artifact) const { assert(this->IsImported()); @@ -1364,32 +1403,37 @@ std::string cmTarget::ImportedGetFullPath(const std::string& config, if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetMappedConfig(desired_config, &loc, &imp, suffix)) { - 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; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + 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() == cmStateEnums::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; + break; + + case cmStateEnums::ImportLibraryArtifact: + if (imp) { + result = imp; + } else if (this->GetType() == cmStateEnums::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; + } } - } + break; } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c67143a..1f00c01 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -267,11 +267,13 @@ public: }; std::string ImportedGetFullPath(const std::string& config, - bool implib) const; + cmStateEnums::ArtifactType artifact) const; private: - const char* GetSuffixVariableInternal(bool implib) const; - const char* GetPrefixVariableInternal(bool implib) const; + const char* GetSuffixVariableInternal( + cmStateEnums::ArtifactType artifact) const; + const char* GetPrefixVariableInternal( + cmStateEnums::ArtifactType artifact) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f0f04a8..d83662e 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1051,8 +1051,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( std::string postfixName = cmSystemTools::UpperCase(config); postfixName += "_POSTFIX"; - std::string assemblyName = - this->GeneratorTarget->GetOutputName(config, false); + std::string assemblyName = this->GeneratorTarget->GetOutputName( + config, cmStateEnums::RuntimeBinaryArtifact); if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) { assemblyName += postfix; } @@ -2467,6 +2467,12 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( if (this->GeneratorTarget->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION")) { cudaOptions.AddFlag("GenerateRelocatableDeviceCode", "true"); + } else if (this->GeneratorTarget->GetPropertyAsBool( + "CUDA_PTX_COMPILATION")) { + cudaOptions.AddFlag("NvccCompilation", "ptx"); + // We drop the %(Extension) component as CMake expects all PTX files + // to not have the source file extension at all + cudaOptions.AddFlag("CompileOut", "$(IntDir)%(Filename).ptx"); } // Convert the host compiler options to the toolset's abstractions @@ -3014,8 +3020,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); pdb += "/"; pdb += targetNamePDB; - std::string imLib = - this->GeneratorTarget->GetDirectory(config.c_str(), true); + std::string imLib = this->GeneratorTarget->GetDirectory( + config.c_str(), cmStateEnums::ImportLibraryArtifact); imLib += "/"; imLib += targetNameImport; @@ -3395,13 +3401,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() this->ConvertToWindowsSlash(path); (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n"; this->WriteString("<Project>", 3); - if (csproj == this->ProjectType) { - (*this->BuildFileStream) << "{"; - } - (*this->BuildFileStream) << this->GlobalGenerator->GetGUID(name.c_str()); - if (csproj == this->ProjectType) { - (*this->BuildFileStream) << "}"; - } + (*this->BuildFileStream) + << "{" << this->GlobalGenerator->GetGUID(name.c_str()) << "}"; (*this->BuildFileStream) << "</Project>\n"; this->WriteString("<Name>", 3); (*this->BuildFileStream) << name << "</Name>\n"; diff --git a/Source/kwsys/.gitattributes b/Source/kwsys/.gitattributes index 3583f39..7065eb5 100644 --- a/Source/kwsys/.gitattributes +++ b/Source/kwsys/.gitattributes @@ -1,15 +1,13 @@ .git* export-ignore -*.c our-c-style -*.c.in our-c-style -*.cxx our-c-style -*.h our-c-style -*.h.in our-c-style -*.hxx our-c-style -*.hxx.in our-c-style +*.c kwsys-c-style +*.c.in kwsys-c-style +*.cxx kwsys-c-style +*.h kwsys-c-style +*.h.in kwsys-c-style +*.hxx kwsys-c-style +*.hxx.in kwsys-c-style *.cmake whitespace=tab-in-indent *.rst whitespace=tab-in-indent conflict-marker-size=79 *.txt whitespace=tab-in-indent - -* -format.clang-format diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 85a2051..a3bd707 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -1,4 +1,5 @@ ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) +ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt new file mode 100644 index 0000000..10249c6 --- /dev/null +++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt @@ -0,0 +1,82 @@ +cmake_minimum_required(VERSION 3.8) +project (CudaOnlyExportPTX CUDA) + +#Goal for this example: +# How to generate PTX files instead of OBJECT files +# How to reference PTX files for custom commands +# How to install PTX files + +add_library(CudaPTX OBJECT kernelA.cu kernelB.cu) +set_property(TARGET CudaPTX PROPERTY CUDA_PTX_COMPILATION ON) + +#Test ObjectFiles with file(GENERATE) +file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gen_$<LOWER_CASE:$<CONFIG>/>path_to_objs.h + CONTENT [[ + +#include <vector> +#include <string> + +#ifndef path_to_objs +#define path_to_objs + +static std::string ptx_paths = "$<TARGET_OBJECTS:CudaPTX>"; + +#endif + +]] +) +#We are going to need a wrapper around bin2c for multiple reasons +# 1. bin2c only converts a single file at a time +# 2. bin2c has only standard out support, so we have to manually +# redirect to a cmake buffer +# 3. We want to pack everything into a single output file, so we +# need to also pass the --name option +set(output_file ${CMAKE_CURRENT_BINARY_DIR}/embedded_objs.h) + +get_filename_component(cuda_compiler_bin "${CMAKE_CUDA_COMPILER}" DIRECTORY) +find_program(bin_to_c + NAMES bin2c + PATHS ${cuda_compiler_bin} + ) +if(NOT bin_to_c) + message(FATAL_ERROR + "bin2c not found:\n" + " CMAKE_CUDA_COMPILER='${CMAKE_CUDA_COMPILER}'\n" + " cuda_compiler_bin='${cuda_compiler_bin}'\n" + ) +endif() + +add_custom_command( + OUTPUT "${output_file}" + COMMAND ${CMAKE_COMMAND} + "-DBIN_TO_C_COMMAND=${bin_to_c}" + "-DOBJECTS=$<TARGET_OBJECTS:CudaPTX>" + "-DOUTPUT=${output_file}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/bin2c_wrapper.cmake + VERBATIM + DEPENDS $<TARGET_OBJECTS:CudaPTX> + COMMENT "Converting Object files to a C header" + ) + +add_executable(CudaOnlyExportPTX main.cu ${output_file}) +add_dependencies(CudaOnlyExportPTX CudaPTX) +target_include_directories(CudaOnlyExportPTX PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} ) +target_compile_definitions(CudaOnlyExportPTX PRIVATE + "CONFIG_TYPE=gen_$<LOWER_CASE:$<CONFIG>>") + +if(APPLE) + # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that + # the static cuda runtime can find it at runtime. + target_link_libraries(CudaOnlyExportPTX PRIVATE -Wl,-rpath,/usr/local/cuda/lib) +endif() + +#Verify that we can install object targets properly +install(TARGETS CudaPTX CudaOnlyExportPTX + EXPORT cudaPTX + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + OBJECTS DESTINATION objs + ) +install(EXPORT cudaPTX DESTINATION lib/cudaPTX) diff --git a/Tests/CudaOnly/ExportPTX/bin2c_wrapper.cmake b/Tests/CudaOnly/ExportPTX/bin2c_wrapper.cmake new file mode 100644 index 0000000..0baf934 --- /dev/null +++ b/Tests/CudaOnly/ExportPTX/bin2c_wrapper.cmake @@ -0,0 +1,19 @@ + +set(file_contents) +foreach(obj ${OBJECTS}) + get_filename_component(obj_ext ${obj} EXT) + get_filename_component(obj_name ${obj} NAME_WE) + get_filename_component(obj_dir ${obj} DIRECTORY) + + if(obj_ext MATCHES ".ptx") + set(args --name ${obj_name} ${obj}) + execute_process(COMMAND "${BIN_TO_C_COMMAND}" ${args} + WORKING_DIRECTORY ${obj_dir} + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE error_var + ) + set(file_contents "${file_contents} \n${output}") + endif() +endforeach() +file(WRITE "${OUTPUT}" "${file_contents}") diff --git a/Tests/CudaOnly/ExportPTX/kernelA.cu b/Tests/CudaOnly/ExportPTX/kernelA.cu new file mode 100644 index 0000000..fbe0d26 --- /dev/null +++ b/Tests/CudaOnly/ExportPTX/kernelA.cu @@ -0,0 +1,7 @@ + +__global__ void kernelA(float* r, float* x, float* y, float* z, int size) +{ + for (int i = threadIdx.x; i < size; i += blockDim.x) { + r[i] = x[i] * y[i] + z[i]; + } +} diff --git a/Tests/CudaOnly/ExportPTX/kernelB.cu b/Tests/CudaOnly/ExportPTX/kernelB.cu new file mode 100644 index 0000000..11872e4 --- /dev/null +++ b/Tests/CudaOnly/ExportPTX/kernelB.cu @@ -0,0 +1,8 @@ + + +__global__ void kernelB(float* r, float* x, float* y, float* z, int size) +{ + for (int i = threadIdx.x; i < size; i += blockDim.x) { + r[i] = x[i] * y[i] + z[i]; + } +} diff --git a/Tests/CudaOnly/ExportPTX/main.cu b/Tests/CudaOnly/ExportPTX/main.cu new file mode 100644 index 0000000..132377c --- /dev/null +++ b/Tests/CudaOnly/ExportPTX/main.cu @@ -0,0 +1,28 @@ + +#include <iostream> + +/* + Define GENERATED_HEADER macro to allow c++ files to include headers + generated based on different configuration types. +*/ + +/* clang-format off */ +#define GENERATED_HEADER(x) GENERATED_HEADER0(CONFIG_TYPE/x) +/* clang-format on */ +#define GENERATED_HEADER0(x) GENERATED_HEADER1(x) +#define GENERATED_HEADER1(x) <x> + +#include GENERATED_HEADER(path_to_objs.h) + +#include "embedded_objs.h" + +int main(int argc, char** argv) +{ + (void)argc; + (void)argv; + + unsigned char* ka = kernelA; + unsigned char* kb = kernelB; + + return (ka != NULL && kb != NULL) ? 0 : 1; +} diff --git a/Tests/RunCMake/GNUInstallDirs/Common.cmake b/Tests/RunCMake/GNUInstallDirs/Common.cmake index eff2d54..5f119af 100644 --- a/Tests/RunCMake/GNUInstallDirs/Common.cmake +++ b/Tests/RunCMake/GNUInstallDirs/Common.cmake @@ -15,6 +15,7 @@ set(dirs LIBEXECDIR LOCALEDIR LOCALSTATEDIR + RUNSTATEDIR MANDIR SBINDIR SHAREDSTATEDIR diff --git a/Tests/RunCMake/GNUInstallDirs/Opt-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Opt-stderr.txt index aee8552..3e18410 100644 --- a/Tests/RunCMake/GNUInstallDirs/Opt-stderr.txt +++ b/Tests/RunCMake/GNUInstallDirs/Opt-stderr.txt @@ -8,6 +8,7 @@ CMAKE_INSTALL_LIBDIR='(lib|lib64)' CMAKE_INSTALL_LIBEXECDIR='libexec' CMAKE_INSTALL_LOCALEDIR='share/locale' CMAKE_INSTALL_LOCALSTATEDIR='var' +CMAKE_INSTALL_RUNSTATEDIR='var/run' CMAKE_INSTALL_MANDIR='share/man' CMAKE_INSTALL_SBINDIR='sbin' CMAKE_INSTALL_SHAREDSTATEDIR='com' @@ -22,6 +23,7 @@ CMAKE_INSTALL_FULL_LIBDIR='/opt/Opt/(lib|lib64)' CMAKE_INSTALL_FULL_LIBEXECDIR='/opt/Opt/libexec' CMAKE_INSTALL_FULL_LOCALEDIR='/opt/Opt/share/locale' CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var/opt/Opt' +CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run/opt/Opt' CMAKE_INSTALL_FULL_MANDIR='/opt/Opt/share/man' CMAKE_INSTALL_FULL_SBINDIR='/opt/Opt/sbin' CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/opt/Opt/com' diff --git a/Tests/RunCMake/GNUInstallDirs/Root-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Root-stderr.txt index a95400e..8c13368 100644 --- a/Tests/RunCMake/GNUInstallDirs/Root-stderr.txt +++ b/Tests/RunCMake/GNUInstallDirs/Root-stderr.txt @@ -8,6 +8,7 @@ CMAKE_INSTALL_LIBDIR='usr/(lib|lib64)' CMAKE_INSTALL_LIBEXECDIR='usr/libexec' CMAKE_INSTALL_LOCALEDIR='usr/share/locale' CMAKE_INSTALL_LOCALSTATEDIR='var' +CMAKE_INSTALL_RUNSTATEDIR='var/run' CMAKE_INSTALL_MANDIR='usr/share/man' CMAKE_INSTALL_SBINDIR='usr/sbin' CMAKE_INSTALL_SHAREDSTATEDIR='usr/com' @@ -22,6 +23,7 @@ CMAKE_INSTALL_FULL_LIBDIR='/usr/(lib|lib64)' CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/libexec' CMAKE_INSTALL_FULL_LOCALEDIR='/usr/share/locale' CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var' +CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run' CMAKE_INSTALL_FULL_MANDIR='/usr/share/man' CMAKE_INSTALL_FULL_SBINDIR='/usr/sbin' CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/com' diff --git a/Tests/RunCMake/GNUInstallDirs/Usr-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Usr-stderr.txt index e10c4c5..a591436 100644 --- a/Tests/RunCMake/GNUInstallDirs/Usr-stderr.txt +++ b/Tests/RunCMake/GNUInstallDirs/Usr-stderr.txt @@ -8,6 +8,7 @@ CMAKE_INSTALL_LIBDIR='(lib|lib64|lib/arch)' CMAKE_INSTALL_LIBEXECDIR='libexec' CMAKE_INSTALL_LOCALEDIR='share/locale' CMAKE_INSTALL_LOCALSTATEDIR='var' +CMAKE_INSTALL_RUNSTATEDIR='var/run' CMAKE_INSTALL_MANDIR='share/man' CMAKE_INSTALL_SBINDIR='sbin' CMAKE_INSTALL_SHAREDSTATEDIR='com' @@ -22,6 +23,7 @@ CMAKE_INSTALL_FULL_LIBDIR='/usr/(lib|lib64|lib/arch)' CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/libexec' CMAKE_INSTALL_FULL_LOCALEDIR='/usr/share/locale' CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var' +CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run' CMAKE_INSTALL_FULL_MANDIR='/usr/share/man' CMAKE_INSTALL_FULL_SBINDIR='/usr/sbin' CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/com' diff --git a/Tests/RunCMake/GNUInstallDirs/UsrLocal-stderr.txt b/Tests/RunCMake/GNUInstallDirs/UsrLocal-stderr.txt index 8dcf25b..f957e0e 100644 --- a/Tests/RunCMake/GNUInstallDirs/UsrLocal-stderr.txt +++ b/Tests/RunCMake/GNUInstallDirs/UsrLocal-stderr.txt @@ -8,6 +8,7 @@ CMAKE_INSTALL_LIBDIR='(lib|lib64)' CMAKE_INSTALL_LIBEXECDIR='libexec' CMAKE_INSTALL_LOCALEDIR='share/locale' CMAKE_INSTALL_LOCALSTATEDIR='var' +CMAKE_INSTALL_RUNSTATEDIR='var/run' CMAKE_INSTALL_MANDIR='share/man' CMAKE_INSTALL_SBINDIR='sbin' CMAKE_INSTALL_SHAREDSTATEDIR='com' @@ -22,6 +23,7 @@ CMAKE_INSTALL_FULL_LIBDIR='/usr/local/(lib|lib64)' CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/local/libexec' CMAKE_INSTALL_FULL_LOCALEDIR='/usr/local/share/locale' CMAKE_INSTALL_FULL_LOCALSTATEDIR='/usr/local/var' +CMAKE_INSTALL_FULL_RUNSTATEDIR='/usr/local/var/run' CMAKE_INSTALL_FULL_MANDIR='/usr/local/share/man' CMAKE_INSTALL_FULL_SBINDIR='/usr/local/sbin' CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/local/com' diff --git a/Utilities/Scripts/update-kwsys.bash b/Utilities/Scripts/update-kwsys.bash index d5485aa..dfbd366 100755 --- a/Utilities/Scripts/update-kwsys.bash +++ b/Utilities/Scripts/update-kwsys.bash @@ -15,7 +15,8 @@ readonly paths=" extract_source () { git_archive - disable_custom_gitattributes + sed -i -e '/import off/,/import on/d' "$extractdir/$name-reduced/.gitattributes" + sed -i -e 's/project=KWSys/project=PublicDashboard/' "$extractdir/$name-reduced/CTestConfig.cmake" } export HOOKS_ALLOW_KWSYS=1 |