diff options
-rw-r--r-- | Modules/FindMatlab.cmake | 26 | ||||
-rw-r--r-- | Modules/UseSWIG.cmake | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 1 | ||||
-rw-r--r-- | Source/cmCommands.cxx | 4 | ||||
-rw-r--r-- | Source/cmLinkLineDeviceComputer.cxx | 35 | ||||
-rw-r--r-- | Source/cmState.cxx | 10 | ||||
-rw-r--r-- | Source/cmState.h | 1 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 44 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ScriptMode/RunCMakeTest.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/ScriptMode/set_directory_properties.cmake | 1 |
11 files changed, 94 insertions, 36 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 2d04b84..d765bdf 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -1163,21 +1163,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) @@ -1185,8 +1188,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/UseSWIG.cmake b/Modules/UseSWIG.cmake index b7b9fe1..492842b 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -479,6 +479,10 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) get_property (compile_options SOURCE "${infile}" PROPERTY GENERATED_COMPILE_OPTIONS) set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY COMPILE_OPTIONS $<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_GENERATED_COMPILE_OPTIONS>> ${compile_options}) + if (SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG MATCHES "php") + set_property (SOURCE "${swig_generated_file_fullname}" APPEND PROPERTY INCLUDE_DIRECTORIES "${outdir}") + endif() + set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files} PARENT_SCOPE) # legacy support diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 91b92a3..d005134 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 dc9318e..7c32e6d 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -148,6 +148,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); @@ -237,8 +239,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/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 557fa41..20bd537 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -23,6 +23,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) { @@ -51,16 +68,16 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( } 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")) { - fout << "-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")) { + fout << this->ConvertToOutputFormat( + this->ConvertToLinkReference(item.Value)); } - fout << this->ConvertToOutputFormat( - this->ConvertToLinkReference(item.Value)); - } else { + } else if (cmLinkItemValidForDevice(item.Value)) { fout << item.Value; } fout << " "; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index b2f6091..a32e04a 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -497,6 +497,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 38bdfec..b20e8c6 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 72fd2bb..75c8caf 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1703,6 +1703,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) { @@ -1716,24 +1742,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; } } @@ -1792,7 +1811,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/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 637c5c2..6122350 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -171,6 +171,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) |