diff options
79 files changed, 457 insertions, 199 deletions
diff --git a/Help/command/include_directories.rst b/Help/command/include_directories.rst index f694934..e797b5d 100644 --- a/Help/command/include_directories.rst +++ b/Help/command/include_directories.rst @@ -33,3 +33,9 @@ Arguments to ``include_directories`` may use "generator expressions" with the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. + +.. note:: + + Prefer the :command:`target_include_directories` command to add include + directories to individual targets and optionally propagate/export them + to dependents. diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index c9a38fc..8ccd7f6 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -301,6 +301,7 @@ Properties on Targets /prop_tgt/SOVERSION /prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG /prop_tgt/STATIC_LIBRARY_FLAGS + /prop_tgt/STATIC_LIBRARY_OPTIONS /prop_tgt/SUFFIX /prop_tgt/TYPE /prop_tgt/VERSION diff --git a/Help/prop_tgt/LINK_FLAGS.rst b/Help/prop_tgt/LINK_FLAGS.rst index 3a344e6..92cd3c0 100644 --- a/Help/prop_tgt/LINK_FLAGS.rst +++ b/Help/prop_tgt/LINK_FLAGS.rst @@ -3,11 +3,12 @@ LINK_FLAGS Additional flags to use when linking this target if it is a shared library, module library, or an executable. Static libraries need to use -:prop_tgt:`STATIC_LIBRARY_FLAGS`. +:prop_tgt:`STATIC_LIBRARY_OPTIONS` or :prop_tgt:`STATIC_LIBRARY_FLAGS` +properties. -The LINK_FLAGS property, managed as a string, can be used to add extra flags -to the link step of a target. :prop_tgt:`LINK_FLAGS_<CONFIG>` will add to the -configuration ``<CONFIG>``, for example, ``DEBUG``, ``RELEASE``, +The ``LINK_FLAGS`` property, managed as a string, can be used to add extra +flags to the link step of a target. :prop_tgt:`LINK_FLAGS_<CONFIG>` will add +to the configuration ``<CONFIG>``, for example, ``DEBUG``, ``RELEASE``, ``MINSIZEREL``, ``RELWITHDEBINFO``, ... .. note:: diff --git a/Help/prop_tgt/LINK_FLAGS_CONFIG.rst b/Help/prop_tgt/LINK_FLAGS_CONFIG.rst index c30ecf1..e3918ca 100644 --- a/Help/prop_tgt/LINK_FLAGS_CONFIG.rst +++ b/Help/prop_tgt/LINK_FLAGS_CONFIG.rst @@ -1,7 +1,8 @@ LINK_FLAGS_<CONFIG> ------------------- -Per-configuration linker flags for a shared library, module or executable target. +Per-configuration linker flags for a shared library, module or executable +target. This is the configuration-specific version of :prop_tgt:`LINK_FLAGS`. diff --git a/Help/prop_tgt/LINK_OPTIONS.rst b/Help/prop_tgt/LINK_OPTIONS.rst index c5263a2..bd5e937 100644 --- a/Help/prop_tgt/LINK_OPTIONS.rst +++ b/Help/prop_tgt/LINK_OPTIONS.rst @@ -1,7 +1,10 @@ LINK_OPTIONS ------------ -List of options to use when linking this target. +List of options to use for the link step of shared library, module +and executable targets. Targets that are static libraries need to use +the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property. + This property holds a :ref:`;-list <CMake Language Lists>` of options specified so far for its target. Use the :command:`target_link_options` diff --git a/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst b/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst index c91b1ae..66e0e8b 100644 --- a/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst +++ b/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst @@ -2,11 +2,16 @@ STATIC_LIBRARY_FLAGS -------------------- Archiver (or MSVC librarian) flags for a static library target. -Targets that are shared libraries, modules, or executables can use -the :prop_tgt:`LINK_OPTIONS` or :prop_tgt:`LINK_FLAGS` target property. +Targets that are shared libraries, modules, or executables need to use +the :prop_tgt:`LINK_OPTIONS` or :prop_tgt:`LINK_FLAGS` target properties. -The STATIC_LIBRARY_FLAGS property, managed as a string, can be used to add +The ``STATIC_LIBRARY_FLAGS`` property, managed as a string, can be used to add extra flags to the link step of a static library target. :prop_tgt:`STATIC_LIBRARY_FLAGS_<CONFIG>` will add to the configuration ``<CONFIG>``, for example, ``DEBUG``, ``RELEASE``, ``MINSIZEREL``, ``RELWITHDEBINFO``, ... + +.. note:: + + This property has been superseded by :prop_tgt:`STATIC_LIBRARY_OPTIONS` + property. diff --git a/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst b/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst index b867ac4..5b97941 100644 --- a/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst +++ b/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst @@ -1,6 +1,12 @@ STATIC_LIBRARY_FLAGS_<CONFIG> ----------------------------- -Per-configuration archiver (or MSVC librarian) flags for a static library target. +Per-configuration archiver (or MSVC librarian) flags for a static library +target. This is the configuration-specific version of :prop_tgt:`STATIC_LIBRARY_FLAGS`. + +.. note:: + + This property has been superseded by :prop_tgt:`STATIC_LIBRARY_OPTIONS` + property. diff --git a/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst b/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst new file mode 100644 index 0000000..6e03185 --- /dev/null +++ b/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst @@ -0,0 +1,20 @@ +STATIC_LIBRARY_OPTIONS +---------------------- + +Archiver (or MSVC librarian) flags for a static library target. +Targets that are shared libraries, modules, or executables need to use +the :prop_tgt:`LINK_OPTIONS` target property. + +This property holds a :ref:`;-list <CMake Language Lists>` of options +specified so far for its target. Use :command:`set_target_properties` or +:command:`set_property` commands to set its content. + +Contents of ``STATIC_LIBRARY_OPTIONS`` may use "generator expressions" with the +syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual +for available expressions. See the :manual:`cmake-buildsystem(7)` manual +for more on defining buildsystem properties. + +.. note:: + + This property must be used in preference to :prop_tgt:`STATIC_LIBRARY_FLAGS` + property. diff --git a/Help/release/dev/STATIC_LIBRARY_OPTIONS.rst b/Help/release/dev/STATIC_LIBRARY_OPTIONS.rst new file mode 100644 index 0000000..087dc76 --- /dev/null +++ b/Help/release/dev/STATIC_LIBRARY_OPTIONS.rst @@ -0,0 +1,4 @@ +STATIC_LIBRARY_OPTIONS +---------------------- + +* static library targets gained new :prop_tgt:`STATIC_LIBRARY_OPTIONS` property. diff --git a/Help/variable/CMAKE_ANDROID_STL_TYPE.rst b/Help/variable/CMAKE_ANDROID_STL_TYPE.rst index cfb76aa..d174575 100644 --- a/Help/variable/CMAKE_ANDROID_STL_TYPE.rst +++ b/Help/variable/CMAKE_ANDROID_STL_TYPE.rst @@ -30,7 +30,8 @@ set to specify the STL variant to be used. The value may be one of: ``stlport_shared`` STLport Shared -The default value is ``gnustl_static``. Note that this default differs from +The default value is ``gnustl_static`` on NDK versions that provide it +and otherwise ``c++_static``. Note that this default differs from the native NDK build system because CMake may be used to build projects for Android that are not natively implemented for it and use the C++ standard library. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 16dde65..dc4d9be 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -355,6 +355,12 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} else() set(id_development_team "") endif() + if(DEFINED CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY) + set(id_code_sign_identity + "CODE_SIGN_IDENTITY = \"${CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY}\";") + else() + set(id_code_sign_identity "") + endif() configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in ${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY) unset(_ENV_MACOSX_DEPLOYMENT_TARGET) diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake index 3a72622..55e0373 100644 --- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake +++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake @@ -66,10 +66,10 @@ macro(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines #message(STATUS "m1: -${CMAKE_MATCH_1}- m2: -${CMAKE_MATCH_2}- m3: -${CMAKE_MATCH_3}-") list(APPEND ${_resultDefines} "${_name}") - if(_value) - list(APPEND ${_resultDefines} "${_value}") - else() + if ("${_value}" STREQUAL "") list(APPEND ${_resultDefines} " ") + else() + list(APPEND ${_resultDefines} "${_value}") endif() endforeach() diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake index a1899e6..ff97e92 100644 --- a/Modules/Compiler/Cray-CXX.cmake +++ b/Modules/Compiler/Cray-CXX.cmake @@ -13,6 +13,10 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu) + endif() + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.6) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -h std=c++14) + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -h std=c++14,gnu) endif () endif () diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 94bcbf8..4686b64 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -73,6 +73,7 @@ isa = XCBuildConfiguration; buildSettings = { @id_development_team@ + @id_code_sign_identity@ PRODUCT_NAME = CompilerId@id_lang@; }; name = Debug; diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index b57a46e..e86c15c 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -42,13 +42,6 @@ cmake_policy(SET CMP0012 NEW) # For while(TRUE) unset(_lua_include_subdirs) unset(_lua_library_names) unset(_lua_append_versions) -set(_lua_additional_paths - ~/Library/Frameworks - /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt) # this is a function only to have all the variables inside go away automatically function(_lua_get_versions) @@ -161,7 +154,6 @@ function(_lua_find_header) HINTS ENV LUA_DIR PATH_SUFFIXES ${subdir} - PATHS ${_lua_additional_paths} ) if (LUA_INCLUDE_DIR) break() @@ -209,7 +201,6 @@ find_library(LUA_LIBRARY HINTS ENV LUA_DIR PATH_SUFFIXES lib - PATHS ${_lua_additional_paths} ) unset(_lua_library_names) diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 9e13fc3..f2ada3b 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -1167,21 +1167,24 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve # return the updated value set(${matlab_final_version} ${Matlab_VERSION_STRING_INTERNAL} PARENT_SCOPE) - else() + elseif(EXISTS "${matlab_root}/VersionInfo.xml") # MCR # we cannot run anything in order to extract the version. We assume that the file # VersionInfo.xml exists under the MatlabRoot, we look for it and extract the version from there set(_matlab_version_tmp "unknown") file(STRINGS "${matlab_root}/VersionInfo.xml" versioninfo_string NEWLINE_CONSUME) - # parses "<version>9.2.0.538062</version>" - string(REGEX MATCH "<version>(.*)</version>" - version_reg_match - ${versioninfo_string} - ) - - if(NOT "${version_reg_match}" STREQUAL "") - if("${CMAKE_MATCH_1}" MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*") - set(_matlab_version_tmp "${CMAKE_MATCH_1}") + + if(versioninfo_string) + # parses "<version>9.2.0.538062</version>" + string(REGEX MATCH "<version>(.*)</version>" + version_reg_match + ${versioninfo_string} + ) + + if(NOT "${version_reg_match}" STREQUAL "") + if("${CMAKE_MATCH_1}" MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*") + set(_matlab_version_tmp "${CMAKE_MATCH_1}") + endif() endif() endif() set(${matlab_final_version} "${_matlab_version_tmp}" PARENT_SCOPE) @@ -1189,8 +1192,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve "${_matlab_version_tmp}" CACHE INTERNAL "Matlab (MCR) version (automatically determined)" FORCE) - - endif() # Matlab or MCR + endif() # Matlab or MCR endfunction() diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index a5c04ac..1a4635a 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -58,10 +58,12 @@ if(ZLIB_ROOT) endif() # Normal search. +set(_ZLIB_x86 "(x86)") set(_ZLIB_SEARCH_NORMAL - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" - "$ENV{PROGRAMFILES}/zlib" - ) + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" + "$ENV{ProgramFiles}/zlib" + "$ENV{ProgramFiles${_ZLIB_x86}}/zlib") +unset(_ZLIB_x86) list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) set(ZLIB_NAMES z zlib zdll zlib1) diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake index 80a8f41..f8b9346 100644 --- a/Modules/Platform/Android-Common.cmake +++ b/Modules/Platform/Android-Common.cmake @@ -32,8 +32,10 @@ if(CMAKE_ANDROID_NDK) ) endif() unset(_ANDROID_STL_TYPE_FOUND) - else() + elseif(IS_DIRECTORY ${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++) set(CMAKE_ANDROID_STL_TYPE "gnustl_static") + else() + set(CMAKE_ANDROID_STL_TYPE "c++_static") endif() unset(_ANDROID_STL_TYPES) diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake index 0649925..5f2cc52 100644 --- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake +++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake @@ -35,7 +35,18 @@ elseif(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION) endif() set(_ANDROID_TOOL_PATTERNS "*-${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}") else() - set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]") + # If we can find any gcc toolchains then use one by default. + # Otherwise we look for clang toolchains (e.g. NDK r18+). + file(GLOB _ANDROID_CONFIG_MKS_FOR_GCC + "${CMAKE_ANDROID_NDK}/build/core/toolchains/*-[0-9].[0-9]/config.mk" + "${CMAKE_ANDROID_NDK}/toolchains/*-[0-9].[0-9]/config.mk" + ) + if(_ANDROID_CONFIG_MKS_FOR_GCC) + set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]") + else() + set(_ANDROID_TOOL_PATTERNS "*-clang") + endif() + unset(_ANDROID_CONFIG_MKS_FOR_GCC) endif() set(_ANDROID_CONFIG_MK_PATTERNS) foreach(base "build/core/toolchains" "toolchains") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index dc64c6c..e88f20e 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 12) -set(CMake_VERSION_PATCH 20180827) +set(CMake_VERSION_PATCH 20180830) #set(CMake_VERSION_RC 1) diff --git a/Source/QtDialog/CMakeSetup.icns b/Source/QtDialog/CMakeSetup.icns Binary files differindex 4a50c04..e0bf8fd 100644 --- a/Source/QtDialog/CMakeSetup.icns +++ b/Source/QtDialog/CMakeSetup.icns diff --git a/Source/QtDialog/CMakeSetup.ico b/Source/QtDialog/CMakeSetup.ico Binary files differindex e13bb15..1ac13c8 100644 --- a/Source/QtDialog/CMakeSetup.ico +++ b/Source/QtDialog/CMakeSetup.ico diff --git a/Source/QtDialog/CMakeSetup128.png b/Source/QtDialog/CMakeSetup128.png Binary files differindex 12f1d9a..728ef02 100644 --- a/Source/QtDialog/CMakeSetup128.png +++ b/Source/QtDialog/CMakeSetup128.png diff --git a/Source/QtDialog/CMakeSetup32.png b/Source/QtDialog/CMakeSetup32.png Binary files differindex 7bbcee4..1c36b31 100644 --- a/Source/QtDialog/CMakeSetup32.png +++ b/Source/QtDialog/CMakeSetup32.png diff --git a/Source/QtDialog/CMakeSetup64.png b/Source/QtDialog/CMakeSetup64.png Binary files differindex 43a8cc6..44eb171 100644 --- a/Source/QtDialog/CMakeSetup64.png +++ b/Source/QtDialog/CMakeSetup64.png diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 1e3faef..91ccdf7 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -320,7 +320,7 @@ bool cmAddCustomCommandCommand::InitialPass( // Convert working directory to a full path. if (!working.empty()) { - const char* build_dir = this->Makefile->GetCurrentBinaryDirectory(); + const std::string& build_dir = this->Makefile->GetCurrentBinaryDirectory(); working = cmSystemTools::CollapseFullPath(working, build_dir); } diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 4655f58..82ee6b4 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -183,7 +183,7 @@ bool cmAddCustomTargetCommand::InitialPass( // Convert working directory to a full path. if (!working_directory.empty()) { - const char* build_dir = this->Makefile->GetCurrentBinaryDirectory(); + const std::string& build_dir = this->Makefile->GetCurrentBinaryDirectory(); working_directory = cmSystemTools::CollapseFullPath(working_directory, build_dir); } diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index f673c72..75bd6fb 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -80,17 +80,17 @@ bool cmAddSubDirectoryCommand::InitialPass( // Remove the CurrentDirectory from the srcPath and replace it // with the CurrentOutputDirectory. - const char* src = this->Makefile->GetCurrentSourceDirectory(); - const char* bin = this->Makefile->GetCurrentBinaryDirectory(); - size_t srcLen = strlen(src); - size_t binLen = strlen(bin); + const std::string& src = this->Makefile->GetCurrentSourceDirectory(); + const std::string& bin = this->Makefile->GetCurrentBinaryDirectory(); + size_t srcLen = src.length(); + size_t binLen = bin.length(); if (srcLen > 0 && src[srcLen - 1] == '/') { --srcLen; } if (binLen > 0 && bin[binLen - 1] == '/') { --binLen; } - binPath = std::string(bin, binLen) + srcPath.substr(srcLen); + binPath = bin.substr(0, binLen) + srcPath.substr(srcLen); } else { // Use the binary directory specified. // Interpret a relative path with respect to the current binary directory. diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index be3d2f4..3aa59d6 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -118,22 +118,22 @@ const char* CCONV cmGetHomeOutputDirectory(void* arg) const char* CCONV cmGetStartDirectory(void* arg) { cmMakefile* mf = static_cast<cmMakefile*>(arg); - return mf->GetCurrentSourceDirectory(); + return mf->GetCurrentSourceDirectory().c_str(); } const char* CCONV cmGetStartOutputDirectory(void* arg) { cmMakefile* mf = static_cast<cmMakefile*>(arg); - return mf->GetCurrentBinaryDirectory(); + return mf->GetCurrentBinaryDirectory().c_str(); } const char* CCONV cmGetCurrentDirectory(void* arg) { cmMakefile* mf = static_cast<cmMakefile*>(arg); - return mf->GetCurrentSourceDirectory(); + return mf->GetCurrentSourceDirectory().c_str(); } const char* CCONV cmGetCurrentOutputDirectory(void* arg) { cmMakefile* mf = static_cast<cmMakefile*>(arg); - return mf->GetCurrentBinaryDirectory(); + return mf->GetCurrentBinaryDirectory().c_str(); } const char* CCONV cmGetDefinition(void* arg, const char* def) { diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index 6b996e4..2267ef9 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -90,7 +90,7 @@ void cmDocumentationFormatter::SetIndent(const char* indent) void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text) { - // Print text arranged in an indented column of fixed witdh. + // Print text arranged in an indented column of fixed width. const char* l = text; long column = 0; bool newSentence = false; diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index c6ec5bf..f965a29 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -254,12 +254,12 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args) // We store the current build directory in the registry as a value // named by a hash of its own content. This is deterministic and is // unique with high probability. - const char* outDir = this->Makefile->GetCurrentBinaryDirectory(); + const std::string& outDir = this->Makefile->GetCurrentBinaryDirectory(); std::string hash = cmSystemTools::ComputeStringMD5(outDir); #if defined(_WIN32) && !defined(__CYGWIN__) - this->StorePackageRegistryWin(package, outDir, hash.c_str()); + this->StorePackageRegistryWin(package, outDir.c_str(), hash.c_str()); #else - this->StorePackageRegistryDir(package, outDir, hash.c_str()); + this->StorePackageRegistryDir(package, outDir.c_str(), hash.c_str()); #endif return true; diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 582a2e7..fe5c7bb 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -122,7 +122,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget( for (cmLocalGenerator* lg : lgs) { for (cmGeneratorTarget* lt : lg->GetGeneratorTargets()) { cmStateEnums::TargetType type = lt->GetType(); - std::string outputDir = lg->GetCurrentBinaryDirectory(); + std::string const& outputDir = lg->GetCurrentBinaryDirectory(); std::string targetName = lt->GetName(); std::string filename = outputDir + "/" + targetName + ".project"; retval.push_back(targetName); @@ -161,7 +161,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps( // for each sub project in the workspace create a codelite project for (auto const& it : this->GlobalGenerator->GetProjectMap()) { - std::string outputDir = it.second[0]->GetCurrentBinaryDirectory(); + std::string const& outputDir = it.second[0]->GetCurrentBinaryDirectory(); std::string projectName = it.second[0]->GetProjectName(); retval.push_back(projectName); std::string filename = outputDir + "/" + projectName + ".project"; @@ -184,7 +184,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps( void cmExtraCodeLiteGenerator::CreateProjectFile( const std::vector<cmLocalGenerator*>& lgs) { - std::string outputDir = lgs[0]->GetCurrentBinaryDirectory(); + std::string const& outputDir = lgs[0]->GetCurrentBinaryDirectory(); std::string projectName = lgs[0]->GetProjectName(); std::string filename = outputDir + "/"; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 0c80319..795eb37 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3463,7 +3463,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args) } if (!cmsys::SystemTools::FileIsFullPath(path)) { - path = this->Makefile->GetCurrentSourceDirectory() + ("/" + path); + path = this->Makefile->GetCurrentSourceDirectory() + "/" + path; } // Unify path (remove '//', '/../', ...) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index b1b2b88..6823cd5 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -386,11 +386,11 @@ void cmCompiledGeneratorExpression::GetMaxLanguageStandard( } } -const char* cmGeneratorExpressionInterpreter::Evaluate( +const std::string& cmGeneratorExpressionInterpreter::Evaluate( const char* expression, const std::string& property) { if (this->Target.empty()) { - return this->EvaluateExpression(expression).c_str(); + return this->EvaluateExpression(expression); } // Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS @@ -398,5 +398,5 @@ const char* cmGeneratorExpressionInterpreter::Evaluate( this->Target, property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr, nullptr); - return this->EvaluateExpression(expression, &dagChecker).c_str(); + return this->EvaluateExpression(expression, &dagChecker); } diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 1ceb7da..2b7df91 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -179,17 +179,10 @@ public: { } - const char* Evaluate(const char* expression) - { - return this->EvaluateExpression(expression).c_str(); - } - const char* Evaluate(const std::string& expression) - { - return this->Evaluate(expression.c_str()); - } - const char* Evaluate(const char* expression, const std::string& property); - const char* Evaluate(const std::string& expression, - const std::string& property) + const std::string& Evaluate(const char* expression, + const std::string& property); + const std::string& Evaluate(const std::string& expression, + const std::string& property) { return this->Evaluate(expression.c_str(), property); } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1548374..eb1852d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3018,6 +3018,47 @@ void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result, } namespace { +void processStaticLibraryLinkOptions( + cmGeneratorTarget const* tgt, + const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, + std::vector<std::string>& options, + std::unordered_set<std::string>& uniqueOptions, + cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config, + std::string const& language) +{ + processOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, + config, false, "static library link options", + language, OptionsParse::Shell); +} +} + +void cmGeneratorTarget::GetStaticLibraryLinkOptions( + std::vector<std::string>& result, const std::string& config, + const std::string& language) const +{ + std::vector<cmGeneratorTarget::TargetPropertyEntry*> entries; + std::unordered_set<std::string> uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), "STATIC_LIBRARY_OPTIONS", nullptr, nullptr); + + if (const char* linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) { + std::vector<std::string> options; + cmGeneratorExpression ge; + cmSystemTools::ExpandListArgument(linkOptions, options); + for (const auto& option : options) { + std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(option); + entries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(std::move(cge))); + } + } + processStaticLibraryLinkOptions(this, entries, result, uniqueOptions, + &dagChecker, config, language); + + cmDeleteAll(entries); +} + +namespace { void processLinkDepends( cmGeneratorTarget const* tgt, const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries, @@ -3565,8 +3606,9 @@ bool cmGeneratorTarget::StrictTargetComparison::operator()( { int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str()); if (nameResult == 0) { - return strcmp(t1->GetLocalGenerator()->GetCurrentBinaryDirectory(), - t2->GetLocalGenerator()->GetCurrentBinaryDirectory()) < 0; + return strcmp( + t1->GetLocalGenerator()->GetCurrentBinaryDirectory().c_str(), + t2->GetLocalGenerator()->GetCurrentBinaryDirectory().c_str()) < 0; } return nameResult < 0; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6c1f931..1030d91 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -424,6 +424,9 @@ public: void GetLinkOptions(std::vector<std::string>& result, const std::string& config, const std::string& language) const; + void GetStaticLibraryLinkOptions(std::vector<std::string>& result, + const std::string& config, + const std::string& language) const; void GetLinkDepends(std::vector<std::string>& result, const std::string& config, diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4060269..bbebb90 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -64,8 +64,8 @@ bool cmTarget::StrictTargetComparison::operator()(cmTarget const* t1, { int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str()); if (nameResult == 0) { - return strcmp(t1->GetMakefile()->GetCurrentBinaryDirectory(), - t2->GetMakefile()->GetCurrentBinaryDirectory()) < 0; + return strcmp(t1->GetMakefile()->GetCurrentBinaryDirectory().c_str(), + t2->GetMakefile()->GetCurrentBinaryDirectory().c_str()) < 0; } return nameResult < 0; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 8ba38df..0c80910 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1011,8 +1011,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( std::set<std::string> const& utils = target->GetUtilities(); for (std::string const& util : utils) { std::string d = - target->GetLocalGenerator()->GetCurrentBinaryDirectory() + - std::string("/") + util; + target->GetLocalGenerator()->GetCurrentBinaryDirectory() + "/" + util; outputs.push_back(this->ConvertToNinjaPath(d)); } } else { @@ -1111,6 +1110,12 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) continue; } + // Don't write alias if there is a already a custom command with + // matching output + if (this->HasCustomCommandOutput(ta.first)) { + continue; + } + cmNinjaDeps deps; this->AppendTargetOutputs(ta.second, deps); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a5709d5..5ea323a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1014,7 +1014,7 @@ void cmGlobalVisualStudio10Generator::PathTooLong(cmGeneratorTarget* target, std::string const& sfRel) { size_t len = - (strlen(target->GetLocalGenerator()->GetCurrentBinaryDirectory()) + 1 + + (target->GetLocalGenerator()->GetCurrentBinaryDirectory().length() + 1 + sfRel.length()); if (len > this->LongestSource.Length) { this->LongestSource.Length = len; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 042ce41..7456d3c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -762,9 +762,10 @@ public: using cmGeneratorExpressionInterpreter::Evaluate; - const char* Evaluate(const char* expression, const std::string& property) + const std::string& Evaluate(const char* expression, + const std::string& property) { - const char* processed = + const std::string& processed = this->cmGeneratorExpressionInterpreter::Evaluate(expression, property); if (this->GetCompiledGeneratorExpression() .GetHadContextSensitiveCondition()) { @@ -821,7 +822,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); if (const char* compile_defs = sf->GetProperty(COMPILE_DEFINITIONS)) { this->AppendDefines( - flagsBuild, genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS), + flagsBuild, + genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS).c_str(), true); } if (!flagsBuild.IsEmpty()) { @@ -1844,7 +1846,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY || gtgt->GetType() == cmStateEnums::STATIC_LIBRARY) { this->CurrentLocalGenerator->GetStaticLibraryFlags( - extraLinkOptions, cmSystemTools::UpperCase(configName), gtgt); + extraLinkOptions, cmSystemTools::UpperCase(configName), llang, gtgt); } else { const char* targetLinkFlags = gtgt->GetProperty("LINK_FLAGS"); if (targetLinkFlags) { @@ -3040,7 +3042,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( // Point Xcode at the top of the source tree. { std::string pdir = - this->RelativeToBinary(root->GetCurrentSourceDirectory()); + this->RelativeToBinary(root->GetCurrentSourceDirectory().c_str()); this->RootObject->AddAttribute("projectDirPath", this->CreateString(pdir)); this->RootObject->AddAttribute("projectRoot", this->CreateString("")); } diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index b569b73..c9b50a3 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig( cmMakefile const& mf = *this->LocalGenerator->GetMakefile(); for (std::string& d : dirs) { if (!cmSystemTools::FileIsFullPath(d)) { - d = std::string(mf.GetCurrentSourceDirectory()) + "/" + d; + d = mf.GetCurrentSourceDirectory() + "/" + d; } } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5e6ce1a..532f9a9 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -979,6 +979,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, std::string const& config, + std::string const& linkLanguage, cmGeneratorTarget* target) { this->AppendFlags( @@ -992,6 +993,11 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, std::string name = "STATIC_LIBRARY_FLAGS_" + config; this->AppendFlags(flags, target->GetProperty(name)); } + + std::vector<std::string> options; + target->GetStaticLibraryLinkOptions(options, config, linkLanguage); + // STATIC_LIBRARY_OPTIONS are escaped. + this->AppendCompileOptions(flags, options); } void cmLocalGenerator::GetTargetFlags( @@ -1009,7 +1015,7 @@ void cmLocalGenerator::GetTargetFlags( switch (target->GetType()) { case cmStateEnums::STATIC_LIBRARY: - this->GetStaticLibraryFlags(linkFlags, buildType, target); + this->GetStaticLibraryFlags(linkFlags, buildType, linkLanguage, target); break; case cmStateEnums::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; @@ -2522,14 +2528,14 @@ std::string const& cmLocalGenerator::GetBinaryDirectory() const return this->GetCMakeInstance()->GetHomeOutputDirectory(); } -const char* cmLocalGenerator::GetCurrentBinaryDirectory() const +std::string const& cmLocalGenerator::GetCurrentBinaryDirectory() const { - return this->StateSnapshot.GetDirectory().GetCurrentBinary().c_str(); + return this->StateSnapshot.GetDirectory().GetCurrentBinary(); } -const char* cmLocalGenerator::GetCurrentSourceDirectory() const +std::string const& cmLocalGenerator::GetCurrentSourceDirectory() const { - return this->StateSnapshot.GetDirectory().GetCurrentSource().c_str(); + return this->StateSnapshot.GetDirectory().GetCurrentSource(); } std::string cmLocalGenerator::GetTargetDirectory( diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 52f0396..27a42b3 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -296,8 +296,8 @@ public: std::string const& GetSourceDirectory() const; std::string const& GetBinaryDirectory() const; - const char* GetCurrentBinaryDirectory() const; - const char* GetCurrentSourceDirectory() const; + std::string const& GetCurrentBinaryDirectory() const; + std::string const& GetCurrentSourceDirectory() const; /** * Generate a Mac OS X application bundle Info.plist file. @@ -323,6 +323,7 @@ public: /** Fill out the static linker flags for the given target. */ void GetStaticLibraryFlags(std::string& flags, std::string const& config, + std::string const& linkLanguage, cmGeneratorTarget* target); /** Fill out these strings for the given target. Libraries to link, diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index b35b116..80f2803 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -118,7 +118,7 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() if (this->GetCurrentBinaryDirectory() != this->GetSourceDirectory()) { if (!cmSystemTools::MakeDirectory(this->GetCurrentBinaryDirectory())) { cmSystemTools::Error("Error creating directory ", - this->GetCurrentBinaryDirectory()); + this->GetCurrentBinaryDirectory().c_str()); } } @@ -1038,7 +1038,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( } } std::string libflags; - this->GetStaticLibraryFlags(libflags, configTypeUpper, target); + this->GetStaticLibraryFlags(libflags, configTypeUpper, + target->GetLinkerLanguage(configName), + target); if (!libflags.empty()) { fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n"; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9e14917..6127b57 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1635,14 +1635,14 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, } } -const char* cmMakefile::GetCurrentSourceDirectory() const +const std::string& cmMakefile::GetCurrentSourceDirectory() const { - return this->StateSnapshot.GetDirectory().GetCurrentSource().c_str(); + return this->StateSnapshot.GetDirectory().GetCurrentSource(); } -const char* cmMakefile::GetCurrentBinaryDirectory() const +const std::string& cmMakefile::GetCurrentBinaryDirectory() const { - return this->StateSnapshot.GetDirectory().GetCurrentBinary().c_str(); + return this->StateSnapshot.GetDirectory().GetCurrentBinary(); } std::vector<cmTarget*> cmMakefile::GetImportedTargets() const diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 616a37f..4085e99 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -327,8 +327,8 @@ public: */ void SetArgcArgv(const std::vector<std::string>& args); - const char* GetCurrentSourceDirectory() const; - const char* GetCurrentBinaryDirectory() const; + std::string const& GetCurrentSourceDirectory() const; + std::string const& GetCurrentBinaryDirectory() const; //@} diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index b9845ba..08bb2ce 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -456,7 +456,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // clean set just in case. exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), - (targetFullPath + ".manifest").c_str())); + targetFullPath + ".manifest")); #endif if (targetNameReal != targetName) { exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 571e74b..2d2915c 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -148,7 +148,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() std::string extraFlags; this->LocalGenerator->GetStaticLibraryFlags( - extraFlags, cmSystemTools::UpperCase(this->ConfigName), + extraFlags, cmSystemTools::UpperCase(this->ConfigName), linkLanguage, this->GeneratorTarget); this->WriteLibraryRules(linkRuleVar, extraFlags, false); } @@ -635,7 +635,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) { libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), - (targetFullPath + ".manifest").c_str())); + targetFullPath + ".manifest")); } #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 79baca6..e8cf255 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -445,7 +445,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( // Add flags from source file properties. const std::string COMPILE_FLAGS("COMPILE_FLAGS"); if (const char* cflags = source.GetProperty(COMPILE_FLAGS)) { - const char* evaluatedFlags = + const std::string& evaluatedFlags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS); this->LocalGenerator->AppendFlags(flags, evaluatedFlags); *this->FlagFileStream << "# Custom flags: " << relativeObj @@ -455,7 +455,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); if (const char* coptions = source.GetProperty(COMPILE_OPTIONS)) { - const char* evaluatedOptions = + const std::string& evaluatedOptions = genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS); this->LocalGenerator->AppendCompileOptions(flags, evaluatedOptions); *this->FlagFileStream << "# Custom options: " << relativeObj @@ -468,7 +468,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); if (const char* cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) { - const char* evaluatedIncludes = + const std::string& evaluatedIncludes = genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES); this->LocalGenerator->AppendIncludeDirectories(includes, evaluatedIncludes, source); @@ -484,7 +484,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( // Add source-specific preprocessor definitions. const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); if (const char* compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) { - const char* evaluatedDefs = + const std::string& evaluatedDefs = genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS); this->LocalGenerator->AppendDefines(defines, evaluatedDefs); *this->FlagFileStream << "# Custom defines: " << relativeObj @@ -494,7 +494,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += configUpper; if (const char* config_compile_defs = source.GetProperty(defPropName)) { - const char* evaluatedDefs = + const std::string& evaluatedDefs = genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS); this->LocalGenerator->AppendDefines(defines, evaluatedDefs); *this->FlagFileStream << "# Custom defines: " << relativeObj << "_DEFINES_" diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index ee44007..305c7a6 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -35,19 +35,19 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, srcdir += "_SOURCE_DIR"; this->Makefile->AddCacheDefinition( - bindir, this->Makefile->GetCurrentBinaryDirectory(), + bindir, this->Makefile->GetCurrentBinaryDirectory().c_str(), "Value Computed by CMake", cmStateEnums::STATIC); this->Makefile->AddCacheDefinition( - srcdir, this->Makefile->GetCurrentSourceDirectory(), + srcdir, this->Makefile->GetCurrentSourceDirectory().c_str(), "Value Computed by CMake", cmStateEnums::STATIC); bindir = "PROJECT_BINARY_DIR"; srcdir = "PROJECT_SOURCE_DIR"; - this->Makefile->AddDefinition(bindir, - this->Makefile->GetCurrentBinaryDirectory()); - this->Makefile->AddDefinition(srcdir, - this->Makefile->GetCurrentSourceDirectory()); + this->Makefile->AddDefinition( + bindir, this->Makefile->GetCurrentBinaryDirectory().c_str()); + this->Makefile->AddDefinition( + srcdir, this->Makefile->GetCurrentSourceDirectory().c_str()); this->Makefile->AddDefinition("PROJECT_NAME", projectName.c_str()); diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index db7fde6..5dd3c8b 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -231,7 +231,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() { // Collapsed current binary directory std::string const cbd = cmSystemTools::CollapseFullPath( - "", makefile->GetCurrentBinaryDirectory()); + std::string(), makefile->GetCurrentBinaryDirectory()); // Info directory this->Dir.Info = cbd; @@ -452,7 +452,7 @@ bool cmQtAutoGenInitializer::InitUic() this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS"); if (!usp.empty()) { cmSystemTools::ExpandListArgument(usp, this->Uic.SearchPaths); - std::string const srcDir = makefile->GetCurrentSourceDirectory(); + std::string const& srcDir = makefile->GetCurrentSourceDirectory(); for (std::string& path : this->Uic.SearchPaths) { path = cmSystemTools::CollapseFullPath(path, srcDir); } diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 5b29868..5dd4413 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -69,7 +69,8 @@ void cmSearchPath::AddUserPath(const std::string& path) // Process them all from the current directory for (std::string const& p : outPaths) { - this->AddPathInternal(p, this->FC->Makefile->GetCurrentSourceDirectory()); + this->AddPathInternal( + p, this->FC->Makefile->GetCurrentSourceDirectory().c_str()); } } @@ -83,8 +84,8 @@ void cmSearchPath::AddCMakePath(const std::string& variable) cmSystemTools::ExpandListArgument(value, expanded); for (std::string const& p : expanded) { - this->AddPathInternal(p, - this->FC->Makefile->GetCurrentSourceDirectory()); + this->AddPathInternal( + p, this->FC->Makefile->GetCurrentSourceDirectory().c_str()); } } } @@ -107,8 +108,8 @@ void cmSearchPath::AddCMakePrefixPath(const std::string& variable) std::vector<std::string> expanded; cmSystemTools::ExpandListArgument(value, expanded); - this->AddPrefixPaths(expanded, - this->FC->Makefile->GetCurrentSourceDirectory()); + this->AddPrefixPaths( + expanded, this->FC->Makefile->GetCurrentSourceDirectory().c_str()); } } diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index f0a5e26..31101e4 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -728,7 +728,7 @@ static Json::Value DumpSourceFilesList( const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); if (const char* cincludes = file->GetProperty(INCLUDE_DIRECTORIES)) { - const char* evaluatedIncludes = + const std::string& evaluatedIncludes = genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES); lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file); @@ -769,7 +769,7 @@ static Json::Value DumpSourceFilesList( groupFileList.push_back(file->GetFullPath()); } - const std::string baseDir = target->Makefile->GetCurrentSourceDirectory(); + const std::string& baseDir = target->Makefile->GetCurrentSourceDirectory(); Json::Value result = Json::arrayValue; for (auto const& it : fileGroups) { Json::Value group = DumpSourceFileGroup(it.first, it.second, baseDir); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 05e26ea..5d1f3f0 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -132,8 +132,8 @@ bool cmSourceFile::FindFullPath(std::string* error) cmMakefile const* mf = this->Location.GetMakefile(); const char* tryDirs[3] = { nullptr, nullptr, nullptr }; if (this->Location.DirectoryIsAmbiguous()) { - tryDirs[0] = mf->GetCurrentSourceDirectory(); - tryDirs[1] = mf->GetCurrentBinaryDirectory(); + tryDirs[0] = mf->GetCurrentSourceDirectory().c_str(); + tryDirs[1] = mf->GetCurrentBinaryDirectory().c_str(); } else { tryDirs[0] = ""; } diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index bd8d318..15433f9 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -205,18 +205,18 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc) } } else if (this->AmbiguousDirectory) { // Compare possible directory combinations. - std::string const& srcDir = cmSystemTools::CollapseFullPath( + std::string const srcDir = cmSystemTools::CollapseFullPath( this->Directory, this->Makefile->GetCurrentSourceDirectory()); - std::string const& binDir = cmSystemTools::CollapseFullPath( + std::string const binDir = cmSystemTools::CollapseFullPath( this->Directory, this->Makefile->GetCurrentBinaryDirectory()); if (srcDir != loc.Directory && binDir != loc.Directory) { return false; } } else if (loc.AmbiguousDirectory) { // Compare possible directory combinations. - std::string const& srcDir = cmSystemTools::CollapseFullPath( + std::string const srcDir = cmSystemTools::CollapseFullPath( loc.Directory, loc.Makefile->GetCurrentSourceDirectory()); - std::string const& binDir = cmSystemTools::CollapseFullPath( + std::string const binDir = cmSystemTools::CollapseFullPath( loc.Directory, loc.Makefile->GetCurrentBinaryDirectory()); if (srcDir != this->Directory && binDir != this->Directory) { return false; diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index c74ca59..9d36228 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -30,18 +30,17 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args, // if they specified a relative path then compute the full std::string srcPath = - std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" + i; + this->Makefile->GetCurrentSourceDirectory() + "/" + i; if (cmSystemTools::FileIsDirectory(srcPath)) { std::string binPath = - std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + i; + this->Makefile->GetCurrentBinaryDirectory() + "/" + i; this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false); } // otherwise it is a full path else if (cmSystemTools::FileIsDirectory(i)) { // we must compute the binPath from the srcPath, we just take the last // element from the source path and use that - std::string binPath = - std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + + std::string binPath = this->Makefile->GetCurrentBinaryDirectory() + "/" + cmSystemTools::GetFilenameName(i); this->Makefile->AddSubDirectory(i, binPath, excludeFromAll, false); } else { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cc5a176..cfcb31a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1127,10 +1127,11 @@ void cmTarget::AppendBuildInterfaceIncludes() this->BuildInterfaceIncludesAppended = true; if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) { - const char* binDir = this->Makefile->GetCurrentBinaryDirectory(); - const char* srcDir = this->Makefile->GetCurrentSourceDirectory(); - const std::string dirs = std::string(binDir ? binDir : "") + - std::string(binDir ? ";" : "") + std::string(srcDir ? srcDir : ""); + std::string dirs = this->Makefile->GetCurrentBinaryDirectory(); + if (!dirs.empty()) { + dirs += ';'; + } + dirs += this->Makefile->GetCurrentSourceDirectory(); if (!dirs.empty()) { this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", ("$<BUILD_INTERFACE:" + dirs + ">").c_str()); diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index fc546cc..af142aa 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -35,8 +35,7 @@ std::string cmTargetIncludeDirectoriesCommand::Join( { std::string dirs; std::string sep; - std::string prefix = - this->Makefile->GetCurrentSourceDirectory() + std::string("/"); + std::string prefix = this->Makefile->GetCurrentSourceDirectory() + "/"; for (std::string const& it : content) { if (cmSystemTools::FileIsFullPath(it) || cmGeneratorExpression::Find(it) == 0) { @@ -56,8 +55,7 @@ bool cmTargetIncludeDirectoriesCommand::HandleDirectContent( cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); tgt->InsertInclude(this->Join(content), lfbt, prepend); if (system) { - std::string prefix = - this->Makefile->GetCurrentSourceDirectory() + std::string("/"); + std::string prefix = this->Makefile->GetCurrentSourceDirectory() + "/"; std::set<std::string> sdirs; for (std::string const& it : content) { if (cmSystemTools::FileIsFullPath(it) || diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx index 62e323c..7429053 100644 --- a/Source/cmTargetSourcesCommand.cxx +++ b/Source/cmTargetSourcesCommand.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetSourcesCommand.h" -#include <cstring> #include <sstream> #include "cmAlgorithms.h" @@ -57,7 +56,7 @@ std::vector<std::string> cmTargetSourcesCommand::ConvertToAbsoluteContent( cmTarget* tgt, const std::vector<std::string>& content, bool isInterfaceContent) { - // Skip conversion in case old behavior has been explictly requested + // Skip conversion in case old behavior has been explicitly requested if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0076) == cmPolicies::OLD) { return content; @@ -71,8 +70,8 @@ std::vector<std::string> cmTargetSourcesCommand::ConvertToAbsoluteContent( if (cmSystemTools::FileIsFullPath(src) || cmGeneratorExpression::Find(src) == 0 || (!isInterfaceContent && - strcmp(this->Makefile->GetCurrentSourceDirectory(), - tgt->GetMakefile()->GetCurrentSourceDirectory()) == 0)) { + (this->Makefile->GetCurrentSourceDirectory() == + tgt->GetMakefile()->GetCurrentSourceDirectory()))) { absoluteSrc = src; } else { changedPath = true; diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index fbe0d78..8237878 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -16,7 +16,7 @@ class cmExecutionStatus; /** \class cmTryCompileCommand * \brief Specifies where to install some files * - * cmTryCompileCommand is used to test if soucre code can be compiled + * cmTryCompileCommand is used to test if source code can be compiled */ class cmTryCompileCommand : public cmCoreTryCompile { diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index b632ef5..c54622c 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -16,7 +16,7 @@ class cmExecutionStatus; /** \class cmTryRunCommand * \brief Specifies where to install some files * - * cmTryRunCommand is used to test if soucre code can be compiled + * cmTryRunCommand is used to test if source code can be compiled */ class cmTryRunCommand : public cmCoreTryCompile { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 56d7243..d9f1942 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -250,11 +250,10 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( this->TargetCompileAsWinRT = false; this->IsMissingFiles = false; this->DefaultArtifactDir = - this->LocalGenerator->GetCurrentBinaryDirectory() + std::string("/") + + this->LocalGenerator->GetCurrentBinaryDirectory() + "/" + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); - this->InSourceBuild = - (strcmp(this->Makefile->GetCurrentSourceDirectory(), - this->Makefile->GetCurrentBinaryDirectory()) == 0); + this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() == + this->Makefile->GetCurrentBinaryDirectory()); } cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() @@ -370,7 +369,7 @@ void cmVisualStudio10TargetGenerator::Generate() path += "/"; path += this->Name; path += ProjectFileExtension; - cmGeneratedFileStream BuildFileStream(path.c_str()); + cmGeneratedFileStream BuildFileStream(path); const std::string PathToProjectFile = path; BuildFileStream.SetCopyIfDifferent(true); @@ -722,8 +721,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) if (!name.empty()) { std::string path = i.second.GetValue(); if (!cmsys::SystemTools::FileIsFullPath(path)) { - path = std::string(this->Makefile->GetCurrentSourceDirectory()) + - "/" + path; + path = this->Makefile->GetCurrentSourceDirectory() + "/" + path; } ConvertToWindowsSlash(path); this->DotNetHintReferences[""].push_back( @@ -929,8 +927,10 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup(Elem& e0) e2.SetHasElements(); if (this->ProjectType == csproj && !this->InSourceBuild) { // add <Link> tag to written XAML source if necessary - const std::string srcDir = this->Makefile->GetCurrentSourceDirectory(); - const std::string binDir = this->Makefile->GetCurrentBinaryDirectory(); + const std::string& srcDir = + this->Makefile->GetCurrentSourceDirectory(); + const std::string& binDir = + this->Makefile->GetCurrentBinaryDirectory(); std::string link; if (obj.find(srcDir) == 0) { link = obj.substr(srcDir.length() + 1); @@ -1398,7 +1398,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() path += computeProjectFileExtension(this->GeneratorTarget, *this->Configurations.begin()); path += ".filters"; - cmGeneratedFileStream fout(path.c_str()); + cmGeneratedFileStream fout(path); fout.SetCopyIfDifferent(true); char magic[] = { char(0xEF), char(0xBB), char(0xBF) }; fout.write(magic, 3); @@ -1877,7 +1877,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2, std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true); size_t const maxLen = 250; if (sf->GetCustomCommand() || - ((strlen(this->LocalGenerator->GetCurrentBinaryDirectory()) + 1 + + ((this->LocalGenerator->GetCurrentBinaryDirectory().length() + 1 + sourceRel.length()) <= maxLen)) { forceRelative = true; sourceFile = sourceRel; @@ -1886,7 +1886,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2, } } ConvertToWindowsSlash(sourceFile); - e2.StartElement(tool.c_str()); + e2.StartElement(tool); e2.Attribute("Include", sourceFile); ToolSource toolSource = { sf, forceRelative }; @@ -2490,6 +2490,16 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( if (this->MSTools) { if (this->ProjectType == vcxproj) { clOptions.FixExceptionHandlingDefault(); + if (this->GlobalGenerator->GetVersion() >= + cmGlobalVisualStudioGenerator::VS15) { + // Toolsets that come with VS 2017 may now enable UseFullPaths + // by default and there is no negative /FC option that projects + // can use to switch it back. Older toolsets disable this by + // default anyway so this will not hurt them. If the project + // is using an explicit /FC option then parsing flags will + // replace this setting with "true" below. + clOptions.AddFlag("UseFullPaths", "false"); + } clOptions.AddFlag("PrecompiledHeader", "NotUsing"); std::string asmLocation = configName + "/"; clOptions.AddFlag("AssemblerListingLocation", asmLocation); @@ -3055,9 +3065,14 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions( this->GeneratorTarget->GetType() != cmStateEnums::OBJECT_LIBRARY) { return; } + + const std::string& linkLanguage = + this->GeneratorTarget->GetLinkClosure(config)->LinkerLanguage; + std::string libflags; this->LocalGenerator->GetStaticLibraryFlags( - libflags, cmSystemTools::UpperCase(config), this->GeneratorTarget); + libflags, cmSystemTools::UpperCase(config), linkLanguage, + this->GeneratorTarget); if (!libflags.empty()) { Elem e2(e1, "Lib"); cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; @@ -3777,31 +3792,29 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) e2.Element("Project", "{" + this->GlobalGenerator->GetGUID(name) + "}"); e2.Element("Name", name); this->WriteDotNetReferenceCustomTags(e2, name); - if (this->Managed) { - // If the dependency target is not managed (compiled with /clr or - // C# target) we cannot reference it and have to set - // 'ReferenceOutputAssembly' to false. - auto referenceNotManaged = - dt->GetManagedType("") < cmGeneratorTarget::ManagedType::Mixed; - // Workaround to check for manually set /clr flags. - if (referenceNotManaged) { - if (const auto* flags = dt->GetProperty("COMPILE_OPTIONS")) { - std::string flagsStr = flags; - if (flagsStr.find("clr") != std::string::npos) { - // There is a warning already issued when building the flags. - referenceNotManaged = false; - } + + // If the dependency target is not managed (compiled with /clr or + // C# target) we cannot reference it and have to set + // 'ReferenceOutputAssembly' to false. + auto referenceNotManaged = + dt->GetManagedType("") < cmGeneratorTarget::ManagedType::Mixed; + // Workaround to check for manually set /clr flags. + if (referenceNotManaged) { + if (const auto* flags = dt->GetProperty("COMPILE_OPTIONS")) { + std::string flagsStr = flags; + if (flagsStr.find("clr") != std::string::npos) { + // There is a warning already issued when building the flags. + referenceNotManaged = false; } } - // Workaround for static library C# targets - if (referenceNotManaged && - dt->GetType() == cmStateEnums::STATIC_LIBRARY) { - referenceNotManaged = !dt->HasLanguage("CSharp", ""); - } - if (referenceNotManaged) { - e2.Element("ReferenceOutputAssembly", "false"); - e2.Element("CopyToOutputDirectory", "Never"); - } + } + // Workaround for static library C# targets + if (referenceNotManaged && dt->GetType() == cmStateEnums::STATIC_LIBRARY) { + referenceNotManaged = !dt->HasLanguage("CSharp", ""); + } + if (referenceNotManaged) { + e2.Element("ReferenceOutputAssembly", "false"); + e2.Element("CopyToOutputDirectory", "Never"); } } } @@ -4131,8 +4144,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) // this can cause an overwrite problem if projects aren't organized in // folders std::string manifestFile = - this->LocalGenerator->GetCurrentBinaryDirectory() + - std::string("/WMAppManifest.xml"); + this->LocalGenerator->GetCurrentBinaryDirectory() + "/WMAppManifest.xml"; std::string artifactDir = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); @@ -4140,7 +4152,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); - cmGeneratedFileStream fout(manifestFile.c_str()); + cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); /* clang-format off */ @@ -4223,7 +4235,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81(Elem& e1) std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); - cmGeneratedFileStream fout(manifestFile.c_str()); + cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); /* clang-format off */ @@ -4286,7 +4298,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80(Elem& e1) std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); - cmGeneratedFileStream fout(manifestFile.c_str()); + cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); /* clang-format off */ @@ -4341,7 +4353,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81(Elem& e1) std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); - cmGeneratedFileStream fout(manifestFile.c_str()); + cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); /* clang-format off */ @@ -4401,7 +4413,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0(Elem& e1) std::string targetNameXML = cmVS10EscapeXML(this->GeneratorTarget->GetName()); - cmGeneratedFileStream fout(manifestFile.c_str()); + cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); /* clang-format off */ @@ -4568,7 +4580,7 @@ void cmVisualStudio10TargetGenerator::GetCSharpSourceLink( std::string const& binaryDir = LocalGenerator->GetCurrentBinaryDirectory(); if (!cmSystemTools::IsSubDirectory(sourceFilePath, binaryDir)) { - const std::string stripFromPath = + const std::string& stripFromPath = this->Makefile->GetCurrentSourceDirectory(); if (sourceFilePath.find(stripFromPath) == 0) { if (const char* l = sf->GetProperty("VS_CSHARP_Link")) { diff --git a/Tests/RunCMake/Android/RunCMakeTest.cmake b/Tests/RunCMake/Android/RunCMakeTest.cmake index 2027c4f..45798ce 100644 --- a/Tests/RunCMake/Android/RunCMakeTest.cmake +++ b/Tests/RunCMake/Android/RunCMakeTest.cmake @@ -61,8 +61,12 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) list(APPEND _abis_${_version} ${_abis}) endif() endforeach() - set(_abis_ ${_abis_${_latest_gcc}}) set(_abis_clang ${_abis_${_latest_clang}}) + if(_latest_gcc) + set(_abis_ ${_abis_${_latest_gcc}}) + else() + set(_abis_ ${_abis_clang}) + endif() if(_versions MATCHES "clang") set(_versions "clang" ${_versions}) endif() @@ -132,10 +136,11 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) set(stl_types none system - gnustl_static - gnustl_shared ) + if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gnu-libstdc++") + list(APPEND stl_types gnustl_static gnustl_shared) + endif() if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gabi++/libs") list(APPEND stl_types gabi++_static gabi++_shared) endif() diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index f931be1..aaa7c89 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -8,7 +8,6 @@ endif() foreach(f "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}g++${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" - "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}cpp${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ar${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ld${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" ) @@ -61,10 +60,12 @@ execute_process( if(NOT _res EQUAL 0) message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}") endif() -if(NOT _out STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}") +string(REPLACE "--" "-" _out_check "${_out}") +if(NOT _out_check STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}" + AND NOT (_out STREQUAL "arm--linux-android" AND CMAKE_C_ANDROID_TOOLCHAIN_MACHINE STREQUAL "arm-linux-androideabi")) message(SEND_ERROR "'gcc -dumpmachine' produced:\n" " ${_out}\n" - "which is not equal to CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n" + "which does not match CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n" " ${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}" ) endif() diff --git a/Tests/RunCMake/LinkStatic/LinkOptionsLib.c b/Tests/RunCMake/LinkStatic/LinkOptionsLib.c new file mode 100644 index 0000000..9bbd24c --- /dev/null +++ b/Tests/RunCMake/LinkStatic/LinkOptionsLib.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) +__declspec(dllexport) +#endif + int flags_lib(void) +{ + return 0; +} diff --git a/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake b/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake index 0d29492..d3a8afb 100644 --- a/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake +++ b/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake @@ -1,3 +1,30 @@ include(RunCMake) run_cmake(LINK_SEARCH_STATIC) + + +macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + +if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + # Intel compiler does not reject bad flags or objects! + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(STATIC_LIBRARY_OPTIONS) + + run_cmake_target(STATIC_LIBRARY_OPTIONS basic StaticLinkOptions) + run_cmake_target(STATIC_LIBRARY_OPTIONS genex StaticLinkOptions_genex --config Release) + run_cmake_target(STATIC_LIBRARY_OPTIONS shared SharedLinkOptions) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) +endif() diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-check.cmake b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-check.cmake new file mode 100644 index 0000000..858ce06 --- /dev/null +++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "BADFLAG") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG'.") +endif() diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-result.txt b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-check.cmake b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-check.cmake new file mode 100644 index 0000000..a686de9 --- /dev/null +++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-check.cmake @@ -0,0 +1,7 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_RELEASE") + set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_RELEASE'.") +endif() +if (actual_stdout MATCHES "SHELL:") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.") +endif() diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-result.txt b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-check.cmake b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-check.cmake new file mode 100644 index 0000000..8c1e96e --- /dev/null +++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-check.cmake @@ -0,0 +1,4 @@ + +if (actual_stdout MATCHES "BADFLAG") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected flag 'BADFLAG'.") +endif() diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-result.txt b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS.cmake b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS.cmake new file mode 100644 index 0000000..587af1d --- /dev/null +++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS.cmake @@ -0,0 +1,21 @@ + +enable_language(C) + +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") +if(BORLAND) + set(pre -) +endif() + +add_library(StaticLinkOptions STATIC LinkOptionsLib.c) +set_property(TARGET StaticLinkOptions PROPERTY STATIC_LIBRARY_OPTIONS ${pre}BADFLAG${obj}) + +# static library with generator expression +add_library(StaticLinkOptions_genex STATIC LinkOptionsLib.c) +set_property(TARGET StaticLinkOptions_genex PROPERTY STATIC_LIBRARY_OPTIONS + $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}> + "SHELL:" # produces no options + ) + +# shared library do not use property STATIC_LIBRARY_OPTIONS +add_library(SharedLinkOptions SHARED LinkOptionsLib.c) +set_property(TARGET SharedLinkOptions PROPERTY STATIC_LIBRARY_OPTIONS ${pre}BADFLAG${obj}) diff --git a/Tests/RunCMake/Ninja/PreventTargetAliasesDupBuildRule.cmake b/Tests/RunCMake/Ninja/PreventTargetAliasesDupBuildRule.cmake new file mode 100644 index 0000000..da6f86a --- /dev/null +++ b/Tests/RunCMake/Ninja/PreventTargetAliasesDupBuildRule.cmake @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.12) +project(Test LANGUAGES C) + +# fake launcher executable +set(input_launcher_executable ${CMAKE_CURRENT_BINARY_DIR}/fake_launcher_executable) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fake_launcher_executable "") + +# application and executable name +set(application_target "HelloApp") +set(application_name "Hello") +set(executable_name "Hello") + +# target built in "<root>/bin" +add_executable(${application_target} hello.c) +set_target_properties(${application_target} PROPERTIES + OUTPUT_NAME ${executable_name} + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin + ) + +# configured launcher in "<root>" +set(configured_launcher_executable "${CMAKE_CURRENT_BINARY_DIR}/${application_name}") + +# create command to copy the launcher +add_custom_command( + DEPENDS + ${input_launcher_executable} + OUTPUT + ${configured_launcher_executable} + COMMAND + ${CMAKE_COMMAND} -E copy ${input_launcher_executable} ${configured_launcher_executable} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT + "Configuring application launcher: ${application_name}" + ) + +add_custom_target(Configure${application_name}Launcher ALL + DEPENDS + ${application_target} + ${input_launcher_executable} + ${configured_launcher_executable} + ) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index b6e6cd4..e0ddc9c 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -278,3 +278,10 @@ foreach(ninja_output_path_prefix "sub space" "sub") run_sub_cmake(SubDirPrefix "${ninja_output_path_prefix}") run_sub_cmake(CustomCommandWorkingDirectory "${ninja_output_path_prefix}") endforeach(ninja_output_path_prefix) + +function (run_PreventTargetAliasesDupBuildRule) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PreventTargetAliasesDupBuildRule-build) + run_cmake(PreventTargetAliasesDupBuildRule) + run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err) +endfunction () +run_PreventTargetAliasesDupBuildRule() diff --git a/Utilities/Release/CMakeLogo.ico b/Utilities/Release/CMakeLogo.ico Binary files differindex e13bb15..c100612 100644 --- a/Utilities/Release/CMakeLogo.ico +++ b/Utilities/Release/CMakeLogo.ico diff --git a/Utilities/Sphinx/static/cmake-favicon.ico b/Utilities/Sphinx/static/cmake-favicon.ico Binary files differindex fce8f92..ae529f5 100644 --- a/Utilities/Sphinx/static/cmake-favicon.ico +++ b/Utilities/Sphinx/static/cmake-favicon.ico diff --git a/Utilities/Sphinx/static/cmake-logo-16.png b/Utilities/Sphinx/static/cmake-logo-16.png Binary files differindex 2039c25..9c95b75 100644 --- a/Utilities/Sphinx/static/cmake-logo-16.png +++ b/Utilities/Sphinx/static/cmake-logo-16.png |