diff options
32 files changed, 267 insertions, 78 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 20ee36c..998db15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -791,9 +791,10 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() endif() -# add a test -add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" - --system-information -G "${CMAKE_GENERATOR}" ) +if(BUILD_TESTING) + add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" + --system-information -G "${CMAKE_GENERATOR}" ) +endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) # Install license file as it requires. diff --git a/Help/command/LINK_OPTIONS_LINKER.txt b/Help/command/LINK_OPTIONS_LINKER.txt index 76927be..a723375 100644 --- a/Help/command/LINK_OPTIONS_LINKER.txt +++ b/Help/command/LINK_OPTIONS_LINKER.txt @@ -8,3 +8,15 @@ driver option and the rest of the option string defines linker arguments using For example, ``"LINKER:-z,defs"`` becomes ``-Xlinker -z -Xlinker defs`` for ``Clang`` and ``-Wl,-z,defs`` for ``GNU GCC``. + +The ``LINKER:`` prefix can be specified as part of a ``SHELL:`` prefix +expression. + +The ``LINKER:`` prefix supports, as alternate syntax, specification of +arguments using ``SHELL:`` prefix and space as separator. Previous example +becomes ``"LINKER:SHELL:-z defs"``. + +.. note:: + + Specifying ``SHELL:`` prefix elsewhere than at the beginning of the + ``LINKER:`` prefix is not supported. diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst index 551d440..e5fb878 100644 --- a/Help/command/add_link_options.rst +++ b/Help/command/add_link_options.rst @@ -21,6 +21,6 @@ the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. -.. include:: LINK_OPTIONS_LINKER.txt - .. include:: OPTIONS_SHELL.txt + +.. include:: LINK_OPTIONS_LINKER.txt diff --git a/Help/command/target_link_options.rst b/Help/command/target_link_options.rst index 8f47180..0b45a8b 100644 --- a/Help/command/target_link_options.rst +++ b/Help/command/target_link_options.rst @@ -37,6 +37,6 @@ with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. -.. include:: LINK_OPTIONS_LINKER.txt - .. include:: OPTIONS_SHELL.txt + +.. include:: LINK_OPTIONS_LINKER.txt diff --git a/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst index 0e52282..321f97e 100644 --- a/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst +++ b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst @@ -17,7 +17,7 @@ For example, for ``Clang`` we have: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Xlinker" " ") -Specifying ``"LINKER:-z defs"`` will be transformed in +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Xlinker -z -Xlinker defs``. For ``GNU GCC``: @@ -27,7 +27,7 @@ For ``GNU GCC``: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,") set (CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") -Specifying ``"LINKER:-z defs"`` will be transformed in ``-Wl,-z,defs``. +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Wl,-z,defs``. And for ``SunPro``: @@ -36,4 +36,4 @@ And for ``SunPro``: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ") set (CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") -Specifying ``"LINKER:-z defs"`` will be transformed in ``-Qoption ld -z,defs``. +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Qoption ld -z,defs``. diff --git a/Modules/Compiler/Flang-Fortran.cmake b/Modules/Compiler/Flang-Fortran.cmake index a1051f4..d522739 100644 --- a/Modules/Compiler/Flang-Fortran.cmake +++ b/Modules/Compiler/Flang-Fortran.cmake @@ -2,7 +2,7 @@ include(Compiler/Clang) __compiler_clang(Fortran) set(CMAKE_Fortran_PREPROCESS_SOURCE - "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>") + "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake index 9ba9900..9df8269 100644 --- a/Modules/Compiler/QCC.cmake +++ b/Modules/Compiler/QCC.cmake @@ -11,7 +11,7 @@ macro(__compiler_qcc lang) set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,") - set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>") + set(CMAKE_DEPFILE_FLAGS_${lang} "-Wp,-MD,<DEPFILE> -Wp,-MT,<OBJECT> -Wp,-MF,<DEPFILE>") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 5090c60..e0f0517 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -823,27 +823,42 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) + elseif(NOT Boost_VERSION VERSION_LESS 106800 AND Boost_VERSION VERSION_LESS 106900) + set(_Boost_CHRONO_DEPENDENCIES system) + set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) + set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time) + set(_Boost_COROUTINE_DEPENDENCIES context system) + set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) + set(_Boost_FILESYSTEM_DEPENDENCIES system) + set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) + set(_Boost_MPI_DEPENDENCIES serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) + set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) + set(_Boost_RANDOM_DEPENDENCIES system) + set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_TIMER_DEPENDENCIES chrono system) + set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() - if(NOT Boost_VERSION VERSION_LESS 106800) - set(_Boost_CHRONO_DEPENDENCIES system) - set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) - set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time) - set(_Boost_COROUTINE_DEPENDENCIES context system) - set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) - set(_Boost_FILESYSTEM_DEPENDENCIES system) + if(NOT Boost_VERSION VERSION_LESS 106900) + set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) + set(_Boost_COROUTINE_DEPENDENCIES context) + set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) - set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) - set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) - set(_Boost_RANDOM_DEPENDENCIES system) - set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_NUMPY_DEPENDENCIES python) + set(_Boost_SYNC_DEPENDENCIES chrono atomic) + set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) - set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) endif() - if(NOT Boost_VERSION VERSION_LESS 106900) + if(NOT Boost_VERSION VERSION_LESS 107000) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() @@ -914,6 +929,12 @@ function(_Boost_COMPONENT_HEADERS component _hdrs) set(_Boost_REGEX_HEADERS "boost/regex.hpp") set(_Boost_SERIALIZATION_HEADERS "boost/serialization/serialization.hpp") set(_Boost_SIGNALS_HEADERS "boost/signals.hpp") + set(_Boost_STACKTRACE_ADDR2LINE_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_BASIC_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_NOOP_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_WINDBG_CACHED_HEADERS "boost/stacktrace.hpp") + set(_Boost_STACKTRACE_WINDBG_HEADERS "boost/stacktrace.hpp") set(_Boost_SYSTEM_HEADERS "boost/system/config.hpp") set(_Boost_TEST_EXEC_MONITOR_HEADERS "boost/test/test_exec_monitor.hpp") set(_Boost_THREAD_HEADERS "boost/thread.hpp") diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index bfcd876..b94e69e 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1131,7 +1131,12 @@ macro(_MPI_create_imported_target LANG) add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) endif() - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + # When this is consumed for compiling CUDA, use '-Xcompiler' to wrap '-pthread'. + string(REPLACE "-pthread" "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler >-pthread" + _MPI_${LANG}_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${_MPI_${LANG}_COMPILE_OPTIONS}") + unset(_MPI_${LANG}_COMPILE_OPTIONS) + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 3f6fa6c..c044ab3 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -27,7 +27,7 @@ # In Windows the default installation of PostgreSQL uses that as part of the path. # E.g C:\Program Files\PostgreSQL\8.4. # Currently, the following version numbers are known to this module: -# "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" # # To use this variable just do something like this: # set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") @@ -71,7 +71,7 @@ set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to wher set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} - "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") + "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") # Define additional search paths for root directories. set( PostgreSQL_ROOT_DIRECTORIES diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index a0148dd..75e83ea 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -208,7 +208,9 @@ if(THREADS_FOUND AND NOT TARGET Threads::Threads) add_library(Threads::Threads INTERFACE IMPORTED) if(THREADS_HAVE_PTHREAD_ARG) - set_property(TARGET Threads::Threads PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread") + set_property(TARGET Threads::Threads + PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler -pthread>" + "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-pthread>") endif() if(CMAKE_THREAD_LIBS_INIT) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index f20a53b..82fbc4b 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -122,7 +122,7 @@ ensure generated files will receive the required settings. If set to ``TRUE``, contents of target property :prop_tgt:`INCLUDE_DIRECTORIES` will be forwarded to ``SWIG`` compiler. If set to ``FALSE`` target property :prop_tgt:`INCLUDE_DIRECTORIES` will be - ignored. If not set, target property ``SWIG_USE_TARGT_INCLUDE_DIRECTORIES`` + ignored. If not set, target property ``SWIG_USE_TARGET_INCLUDE_DIRECTORIES`` will be considered. ``GENERATED_INCLUDE_DIRECTORIES``, ``GENERATED_COMPILE_DEFINITIONS`` and ``GENERATED_COMPILE_OPTIONS`` @@ -234,6 +234,8 @@ set(SWIG_PYTHON_EXTRA_FILE_EXTENSIONS ".py") set(SWIG_JAVA_EXTRA_FILE_EXTENSIONS ".java" "JNI.java") set(SWIG_CSHARP_EXTRA_FILE_EXTENSIONS ".cs" "PINVOKE.cs") +set(SWIG_MANAGE_SUPPORT_FILES_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/UseSWIG/ManageSupportFiles.cmake") + ## ## PRIVATE functions ## @@ -444,9 +446,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) if (UseSWIG_MODULE_VERSION VERSION_GREATER 1) # as part of custom command, start by removing old generated files # to ensure obsolete files do not stay - set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" -E remove_directory "${outdir}") + set (swig_file_outdir "${workingdir}/${swig_source_file_name_we}.files") + set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=CLEAN -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}") + set (swig_copy_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=COPY -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}") else() + set (swig_file_outdir "${outdir}") unset (swig_cleanup_command) + unset (swig_copy_command) endif() # IMPLICIT_DEPENDS below can not handle situations where a dependent file is @@ -476,16 +482,17 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) COMMAND "${CMAKE_COMMAND}" -E env "SWIG_LIB=${SWIG_DIR}" "${SWIG_EXECUTABLE}" "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" "${swig_source_file_flags}" - -outdir "${outdir}" + -outdir "${swig_file_outdir}" ${swig_special_flags} ${swig_extra_flags} "${swig_include_dirs}" -o "${swig_generated_file_fullname}" "${swig_source_file_fullname}" + ${swig_copy_command} MAIN_DEPENDENCY "${swig_source_file_fullname}" DEPENDS ${swig_dependencies} IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}" - COMMENT "Swig source" + COMMENT "Swig compile ${infile} for ${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" COMMAND_EXPAND_LISTS) set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files} PROPERTIES GENERATED 1) diff --git a/Modules/UseSWIG/ManageSupportFiles.cmake b/Modules/UseSWIG/ManageSupportFiles.cmake new file mode 100644 index 0000000..4a03900 --- /dev/null +++ b/Modules/UseSWIG/ManageSupportFiles.cmake @@ -0,0 +1,31 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +if (ACTION STREQUAL "CLEAN") + # Collect current list of generated files + file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + + if (files) + # clean-up the output directory + ## compute full paths + list (TRANSFORM files PREPEND "${SUPPORT_FILES_OUTPUT_DIRECTORY}/") + ## remove generated files from the output directory + file (REMOVE ${files}) + + # clean-up working directory + file (REMOVE_RECURSE "${SUPPORT_FILES_WORKING_DIRECTORY}") + endif() + + file (MAKE_DIRECTORY "${SUPPORT_FILES_WORKING_DIRECTORY}") +endif() + +if (ACTION STREQUAL "COPY") + # Collect current list of generated files + file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*") + + if (files) + # copy files to the output directory + file (COPY ${files} DESTINATION "${SUPPORT_FILES_OUTPUT_DIRECTORY}") + endif() +endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 626dbb8..bb81237 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,4 +2,4 @@ set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 13) set(CMake_VERSION_PATCH 0) -set(CMake_VERSION_RC 1) +set(CMake_VERSION_RC 2) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 7fb5e80..c936910 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1686,6 +1686,7 @@ void cmCTestTestHandler::GetListOfTests() cm.GetState()->AddBuiltinCommand("set_tests_properties", newCom4); // Add handler for SET_DIRECTORY_PROPERTIES + cm.GetState()->RemoveBuiltinCommand("set_directory_properties"); cmCTestSetDirectoryPropertiesCommand* newCom5 = new cmCTestSetDirectoryPropertiesCommand; newCom5->TestHandler = this; diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 873372f..63c5397 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -151,6 +151,8 @@ void GetScriptingCommands(cmState* state) state->AddBuiltinCommand("separate_arguments", new cmSeparateArgumentsCommand); state->AddBuiltinCommand("set", new cmSetCommand); + state->AddBuiltinCommand("set_directory_properties", + new cmSetDirectoryPropertiesCommand); state->AddBuiltinCommand("set_property", new cmSetPropertyCommand); state->AddBuiltinCommand("site_name", new cmSiteNameCommand); state->AddBuiltinCommand("string", new cmStringCommand); @@ -240,8 +242,6 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("install_targets", new cmInstallTargetsCommand); state->AddBuiltinCommand("link_directories", new cmLinkDirectoriesCommand); state->AddBuiltinCommand("project", new cmProjectCommand); - state->AddBuiltinCommand("set_directory_properties", - new cmSetDirectoryPropertiesCommand); state->AddBuiltinCommand("set_source_files_properties", new cmSetSourceFilesPropertiesCommand); state->AddBuiltinCommand("set_target_properties", diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 4aa52c3..da3daf8 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -878,12 +878,13 @@ bool cmGlobalVisualStudioGenerator::Open(const std::string& bindir, const std::string& projectName, bool dryRun) { - std::string buildDir = cmSystemTools::ConvertToOutputPath(bindir); - std::string sln = buildDir + "\\" + projectName + ".sln"; + std::string sln = bindir + "/" + projectName + ".sln"; if (dryRun) { return cmSystemTools::FileExists(sln, true); } + sln = cmSystemTools::ConvertToOutputPath(sln); + return std::async(std::launch::async, OpenSolution, sln).get(); } diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index c9bbde1..a93ec12 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -25,6 +25,23 @@ cmLinkLineDeviceComputer::~cmLinkLineDeviceComputer() { } +static bool cmLinkItemValidForDevice(std::string const& item) +{ + // Valid items are: + // * Non-flags (does not start in '-') + // * Specific flags --library, --library-path, -l, -L + // For example: + // * 'cublas_device' => pass-along + // * '--library pthread' => pass-along + // * '-lpthread' => pass-along + // * '-pthread' => drop + // * '-a' => drop + return (!cmHasLiteralPrefix(item, "-") || // + cmHasLiteralPrefix(item, "-l") || // + cmHasLiteralPrefix(item, "-L") || // + cmHasLiteralPrefix(item, "--library")); +} + std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( cmComputeLinkInformation& cli, std::string const& stdLibString) { @@ -60,16 +77,16 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( std::string out; if (item.IsPath) { - // nvcc understands absolute paths to libraries ending in '.a' should - // be passed to nvlink. Other extensions like '.so' or '.dylib' are - // rejected by the nvcc front-end even though nvlink knows to ignore - // them. Bypass the front-end via '-Xnvlink'. - if (!cmHasLiteralSuffix(item.Value, ".a")) { - out += "-Xnvlink "; + // nvcc understands absolute paths to libraries ending in '.a' or '.lib'. + // These should be passed to nvlink. Other extensions need to be left + // out because nvlink may not understand or need them. Even though it + // can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'. + if (cmHasLiteralSuffix(item.Value, ".a") || + cmHasLiteralSuffix(item.Value, ".lib")) { + out += this->ConvertToOutputFormat( + this->ConvertToLinkReference(item.Value)); } - out += - this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value)); - } else { + } else if (cmLinkItemValidForDevice(item.Value)) { out += item.Value; } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 4b65cf1..a2008a0 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -502,6 +502,16 @@ std::vector<std::string> cmState::GetCommandNames() const return commandNames; } +void cmState::RemoveBuiltinCommand(std::string const& name) +{ + assert(name == cmSystemTools::LowerCase(name)); + std::map<std::string, cmCommand*>::iterator i = + this->BuiltinCommands.find(name); + assert(i != this->BuiltinCommands.end()); + delete i->second; + this->BuiltinCommands.erase(i); +} + void cmState::RemoveUserDefinedCommands() { cmDeleteAll(this->ScriptedCommands); diff --git a/Source/cmState.h b/Source/cmState.h index ca7093a..916985d 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -135,6 +135,7 @@ public: cmPolicies::PolicyID policy, const char* message); void AddUnexpectedCommand(std::string const& name, const char* error); void AddScriptedCommand(std::string const& name, cmCommand* command); + void RemoveBuiltinCommand(std::string const& name); void RemoveUserDefinedCommands(); std::vector<std::string> GetCommandNames() const; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index d05d660..568ee82 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1733,6 +1733,32 @@ void list_item_verbose(FILE* out, struct archive_entry* entry) fflush(out); } +bool la_diagnostic(struct archive* ar, __LA_SSIZE_T r) +{ + // See archive.h definition of ARCHIVE_OK for return values. + + if (r >= ARCHIVE_OK) { + return true; + } + + if (r >= ARCHIVE_WARN) { + const char* warn = archive_error_string(ar); + if (!warn) { + warn = "unknown warning"; + } + std::cerr << "cmake -E tar: warning: " << warn << '\n'; + return true; + } + + // Error. + const char* err = archive_error_string(ar); + if (!err) { + err = "unknown error"; + } + std::cerr << "cmake -E tar: error: " << err << '\n'; + return false; +} + // Return 'true' on success bool copy_data(struct archive* ar, struct archive* aw) { @@ -1746,24 +1772,17 @@ bool copy_data(struct archive* ar, struct archive* aw) # endif for (;;) { - // Return value: - // * ARCHIVE_OK - read succeed - // * ARCHIVE_EOF - no more data to read left + // See archive.h definition of ARCHIVE_OK for return values. r = archive_read_data_block(ar, &buff, &size, &offset); if (r == ARCHIVE_EOF) { return true; } - if (r != ARCHIVE_OK) { + if (!la_diagnostic(ar, r)) { return false; } - // Return value: - // * >= ARCHIVE_OK - write succeed - // * < ARCHIVE_OK - write failed - const __LA_SSIZE_T w_size = - archive_write_data_block(aw, buff, size, offset); - if (w_size < ARCHIVE_OK) { - cmSystemTools::Message("archive_write_data_block()", - archive_error_string(aw)); + // See archive.h definition of ARCHIVE_OK for return values. + __LA_SSIZE_T const w = archive_write_data_block(aw, buff, size, offset); + if (!la_diagnostic(ar, w)) { return false; } } @@ -1822,7 +1841,6 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract) r = archive_write_header(ext, entry); if (r == ARCHIVE_OK) { if (!copy_data(a, ext)) { - cmSystemTools::Error("Problem with copy_data"); break; } r = archive_write_finish_entry(ext); diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 8a43df5..1b3daa6 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -4,5 +4,6 @@ ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures) ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary) ADD_TEST_MACRO(Cuda.MixedStandardLevels MixedStandardLevels) ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude) +ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries) ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags) ADD_TEST_MACRO(Cuda.WithC CudaWithC) diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt new file mode 100644 index 0000000..cb47b09 --- /dev/null +++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.13) +project(ProperDeviceLibraries CXX CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35") +set(CMAKE_CUDA_STANDARD 11) + +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads) + +add_executable(ProperDeviceLibraries main.cu) +set_target_properties(ProperDeviceLibraries + PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + +add_library(UseThreadsMixed SHARED use_pthreads.cxx use_pthreads.cu) +target_link_libraries(UseThreadsMixed Threads::Threads) + +add_library(UseThreadsCuda SHARED use_pthreads.cu) +target_link_libraries(UseThreadsCuda Threads::Threads) + +target_link_libraries(ProperDeviceLibraries PRIVATE UseThreadsMixed UseThreadsCuda) + +if(THREADS_HAVE_PTHREAD_ARG AND CMAKE_USE_PTHREADS_INIT) + add_library(UseExplicitPThreadsFlag SHARED use_pthreads.cu) + target_compile_options(UseExplicitPThreadsFlag PUBLIC "-Xcompiler=-pthread") + target_link_libraries(UseExplicitPThreadsFlag PUBLIC "-pthread") + + add_library(UseExplicitLThreadsFlag SHARED use_pthreads.cu) + target_compile_options(UseExplicitLThreadsFlag PUBLIC "-Xcompiler=-pthread") + target_link_libraries(UseExplicitLThreadsFlag PUBLIC "-lpthread") + + add_library(UseExplicitLongThreadsFlag SHARED use_pthreads.cu) + target_link_libraries(UseExplicitLongThreadsFlag PUBLIC "--library pthread") + + target_link_libraries(ProperDeviceLibraries PRIVATE UseExplicitPThreadsFlag UseExplicitLThreadsFlag UseExplicitLongThreadsFlag) +endif() + +if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0) + #CUDA 10 removed the cublas_device library + target_link_libraries(ProperDeviceLibraries PRIVATE cublas_device) +endif() + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET ProperDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu b/Tests/Cuda/ProperDeviceLibraries/main.cu index 2c7c388..8ceb0cc 100644 --- a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu +++ b/Tests/Cuda/ProperDeviceLibraries/main.cu @@ -3,6 +3,15 @@ #include <cuda_runtime.h> #include <iostream> +#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) + +# include <pthread.h> +static int verify_linking_to_pthread() +{ + return static_cast<int>(pthread_self()); +} +#endif + // this test only makes sense for versions of CUDA that ships // static libraries that have separable compilation device symbols #if __CUDACC_VER_MAJOR__ <= 9 diff --git a/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu new file mode 100644 index 0000000..c57b8a8 --- /dev/null +++ b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu @@ -0,0 +1,9 @@ + +#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) + +# include <pthread.h> +static int verify_linking_to_pthread_cuda() +{ + return static_cast<int>(pthread_self()); +} +#endif diff --git a/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx new file mode 100644 index 0000000..dc7c208 --- /dev/null +++ b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx @@ -0,0 +1,9 @@ + +#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) + +# include <pthread.h> +static int verify_linking_to_pthread_cxx() +{ + return static_cast<int>(pthread_self()); +} +#endif diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 5b7c0e6..9c4f86a 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -3,7 +3,6 @@ ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) -ADD_TEST_MACRO(CudaOnly.LinkSystemDeviceLibraries CudaOnlyLinkSystemDeviceLibraries) ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt b/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt deleted file mode 100644 index 7f7f606..0000000 --- a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(LinkSystemDeviceLibraries CUDA) - -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35") -set(CMAKE_CUDA_STANDARD 11) - -add_executable(CudaOnlyLinkSystemDeviceLibraries main.cu) -set_target_properties( CudaOnlyLinkSystemDeviceLibraries - PROPERTIES CUDA_SEPARABLE_COMPILATION ON) -target_link_libraries( CudaOnlyLinkSystemDeviceLibraries PRIVATE cublas_device) - -if(APPLE) - # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. - set_property(TARGET CudaOnlyLinkSystemDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) -endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 90681b9..394dd6d 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -178,6 +178,7 @@ add_RunCMake_test(ObjectLibrary) if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") add_RunCMake_test(RuntimePath) endif() +add_RunCMake_test(ScriptMode) add_RunCMake_test(Swift) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) diff --git a/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake b/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake new file mode 100644 index 0000000..4c44ffb --- /dev/null +++ b/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake_command(set_directory_properties ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/set_directory_properties.cmake) diff --git a/Tests/RunCMake/ScriptMode/set_directory_properties.cmake b/Tests/RunCMake/ScriptMode/set_directory_properties.cmake new file mode 100644 index 0000000..bf79317 --- /dev/null +++ b/Tests/RunCMake/ScriptMode/set_directory_properties.cmake @@ -0,0 +1 @@ +set_directory_properties(PROPERTIES SOME_PROPERTY FALSE) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 8e0378c..636530e 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -1289,7 +1289,7 @@ endif() add_executable(LIBCURL curltest.c) target_link_libraries(LIBCURL cmcurl) -if(CMAKE_CURL_TEST_URL) +if(BUILD_TESTING AND CMAKE_CURL_TEST_URL) add_test(curl LIBCURL ${CMAKE_CURL_TEST_URL}) endif() |