diff options
-rw-r--r-- | Help/command/add_dependencies.rst | 3 | ||||
-rw-r--r-- | Help/manual/cmake-compile-features.7.rst | 2 | ||||
-rw-r--r-- | Modules/FindMatlab.cmake | 7 | ||||
-rw-r--r-- | Modules/MatlabTestsRedirect.cmake | 1 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 51 | ||||
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 44 | ||||
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 18 | ||||
-rw-r--r-- | Tests/RunCMake/FindMatlab/MatlabTest2-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FindMatlab/MatlabTest2-stderr.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FindMatlab/MatlabTest2.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/FindMatlab/RunCMakeTest.cmake | 48 |
13 files changed, 149 insertions, 41 deletions
diff --git a/Help/command/add_dependencies.rst b/Help/command/add_dependencies.rst index c3583cf..7a66143 100644 --- a/Help/command/add_dependencies.rst +++ b/Help/command/add_dependencies.rst @@ -10,7 +10,8 @@ Add a dependency between top-level targets. Make a top-level ``<target>`` depend on other top-level targets to ensure that they build before ``<target>`` does. A top-level target is one created by one of the :command:`add_executable`, -:command:`add_library`, or :command:`add_custom_target` commands. +:command:`add_library`, or :command:`add_custom_target` commands +(but not targets generated by CMake like ``install``). Dependencies added to an :ref:`imported target <Imported Targets>` or an :ref:`interface library <Interface Libraries>` are followed diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index 46a5afb..caf5bac 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -278,7 +278,7 @@ properties: add_library(foo INTERFACE) set(with_variadics ${CMAKE_CURRENT_SOURCE_DIR}/with_variadics) set(no_variadics ${CMAKE_CURRENT_SOURCE_DIR}/no_variadics) - target_link_libraries(foo + target_include_directories(foo INTERFACE "$<$<COMPILE_FEATURES:cxx_variadic_templates>:${with_variadics}>" "$<$<NOT:$<COMPILE_FEATURES:cxx_variadic_templates>>:${no_variadics}>" diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index b4beec3..028bf5a 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -134,7 +134,8 @@ # returns the suffix to be used for the mex files # (platform/architecture dependant) # :command:`matlab_get_version_from_matlab_run` -# returns the version of Matlab, given the full directory of the Matlab program. +# returns the version of Matlab, given the full directory of the Matlab +# program. # # # Known issues @@ -918,7 +919,7 @@ function(matlab_add_mex ) PROPERTIES CXX_VISIBILITY_PRESET "hidden" C_VISIBILITY_PRESET "hidden" - VISIBILITY_INLINES_HIDDEN "hidden" + VISIBILITY_INLINES_HIDDEN ON ) # get_target_property( @@ -1064,7 +1065,7 @@ if(Matlab_ROOT_DIR) endif() else() # NOTFOUND indicates the code below to search for the version automatically - if(NOT DEFINED Matlab_VERSION_STRING_INTERNAL) + if("${Matlab_VERSION_STRING_INTERNAL}" STREQUAL "") list(APPEND _matlab_possible_roots "NOTFOUND" ${Matlab_ROOT_DIR}) # empty version else() list(APPEND _matlab_possible_roots ${Matlab_VERSION_STRING_INTERNAL} ${Matlab_ROOT_DIR}) # cached version diff --git a/Modules/MatlabTestsRedirect.cmake b/Modules/MatlabTestsRedirect.cmake index ebccbf6..77b7afe 100644 --- a/Modules/MatlabTestsRedirect.cmake +++ b/Modules/MatlabTestsRedirect.cmake @@ -17,7 +17,6 @@ # Usage: cmake # -Dtest_timeout=180 -# -Dworking_directory="." # -Doutput_directory= # -Dadditional_paths="" # -Dno_unittest_framework="" diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 56fed5d..26c9e44 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 2) -set(CMake_VERSION_PATCH 20150528) +set(CMake_VERSION_PATCH 20150601) #set(CMake_VERSION_RC 1) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 0af4688..4698468 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2798,13 +2798,36 @@ namespace { static size_t - cmFileCommandCurlDebugCallback(CURL *, curl_infotype, char *chPtr, + cmFileCommandCurlDebugCallback(CURL *, curl_infotype type, char *chPtr, size_t size, void *data) { cmFileCommandVectorOfChar *vec = static_cast<cmFileCommandVectorOfChar*>(data); - vec->insert(vec->end(), chPtr, chPtr + size); - return size; + switch(type) + { + case CURLINFO_TEXT: + case CURLINFO_HEADER_IN: + case CURLINFO_HEADER_OUT: + vec->insert(vec->end(), chPtr, chPtr + size); + break; + case CURLINFO_DATA_IN: + case CURLINFO_DATA_OUT: + case CURLINFO_SSL_DATA_IN: + case CURLINFO_SSL_DATA_OUT: + { + char buf[128]; + int n = sprintf(buf, "[%" cmIML_INT_PRIu64 " bytes data]\n", + static_cast<cmIML_INT_uint64_t>(size)); + if (n > 0) + { + vec->insert(vec->end(), buf, buf + n); + } + } + break; + default: + break; + } + return 0; } @@ -2963,7 +2986,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) long timeout = 0; long inactivity_timeout = 0; - std::string verboseLog; + std::string logVar; std::string statusVar; bool tls_verify = this->Makefile->IsOn("CMAKE_TLS_VERIFY"); const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO"); @@ -3008,7 +3031,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) this->SetError("DOWNLOAD missing VAR for LOG."); return false; } - verboseLog = *i; + logVar = *i; } else if(*i == "STATUS") { @@ -3200,7 +3223,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); check_curl_result(res, "DOWNLOAD cannot set follow-redirect option: "); - if(!verboseLog.empty()) + if(!logVar.empty()) { res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); check_curl_result(res, "DOWNLOAD cannot set verbose: "); @@ -3287,22 +3310,10 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) } } - if(!chunkDebug.empty()) + if (!logVar.empty()) { chunkDebug.push_back(0); - if(CURLE_OPERATION_TIMEOUTED == res) - { - std::string output = &*chunkDebug.begin(); - - if(!verboseLog.empty()) - { - this->Makefile->AddDefinition(verboseLog, - &*chunkDebug.begin()); - } - } - - this->Makefile->AddDefinition(verboseLog, - &*chunkDebug.begin()); + this->Makefile->AddDefinition(logVar, &*chunkDebug.begin()); } return true; diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 8069ee2..c88e888 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -88,6 +88,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) IF(POLICY CMP0025) CMAKE_POLICY(SET CMP0025 NEW) ENDIF() +IF(POLICY CMP0056) + CMAKE_POLICY(SET CMP0056 NEW) +ENDIF() #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 6c4a7a6..c834e34 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2674,27 +2674,43 @@ kwsys_stl::string SystemTools::GetLastSystemError() bool SystemTools::RemoveFile(const kwsys_stl::string& source) { #ifdef _WIN32 + kwsys_stl::wstring const& ws = + SystemTools::ConvertToWindowsExtendedPath(source); + if (DeleteFileW(ws.c_str())) + { + return true; + } + DWORD err = GetLastError(); + if (err == ERROR_FILE_NOT_FOUND || + err == ERROR_PATH_NOT_FOUND) + { + return true; + } + if (err != ERROR_ACCESS_DENIED) + { + return false; + } + /* The file may be read-only. Try adding write permission. */ mode_t mode; - if ( !SystemTools::GetPermissions(source, mode) ) + if (!SystemTools::GetPermissions(source, mode) || + !SystemTools::SetPermissions(source, S_IWRITE)) { + SetLastError(err); return false; } - /* Win32 unlink is stupid --- it fails if the file is read-only */ - SystemTools::SetPermissions(source, S_IWRITE); -#endif -#ifdef _WIN32 - bool res = - _wunlink(SystemTools::ConvertToWindowsExtendedPath(source).c_str()) == 0; -#else - bool res = unlink(source.c_str()) != 0 ? false : true; -#endif -#ifdef _WIN32 - if ( !res ) + if (DeleteFileW(ws.c_str()) || + GetLastError() == ERROR_FILE_NOT_FOUND || + GetLastError() == ERROR_PATH_NOT_FOUND) { - SystemTools::SetPermissions(source, mode); + return true; } + /* Try to restore the original permissions. */ + SystemTools::SetPermissions(source, mode); + SetLastError(err); + return false; +#else + return unlink(source.c_str()) == 0 || errno == ENOENT; #endif - return res; } bool SystemTools::RemoveADirectory(const kwsys_stl::string& source) diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 42b6249..15d8eab 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -156,6 +156,24 @@ static bool CheckFileOperations() res = false; } + kwsys_stl::string const testFileMissing(testNewDir + "/testMissingFile.txt"); + if (!kwsys::SystemTools::RemoveFile(testFileMissing)) + { + std::string const& msg = kwsys::SystemTools::GetLastSystemError(); + kwsys_ios::cerr << + "RemoveFile(\"" << testFileMissing << "\") failed: " << msg << "\n"; + res = false; + } + + kwsys_stl::string const testFileMissingDir(testNewDir + "/missing/file.txt"); + if (!kwsys::SystemTools::RemoveFile(testFileMissingDir)) + { + std::string const& msg = kwsys::SystemTools::GetLastSystemError(); + kwsys_ios::cerr << + "RemoveFile(\"" << testFileMissingDir << "\") failed: " << msg << "\n"; + res = false; + } + kwsys::SystemTools::Touch(testNewFile.c_str(), true); if (!kwsys::SystemTools::RemoveADirectory(testNewDir)) { diff --git a/Tests/RunCMake/FindMatlab/MatlabTest2-result.txt b/Tests/RunCMake/FindMatlab/MatlabTest2-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/FindMatlab/MatlabTest2-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/FindMatlab/MatlabTest2-stderr.txt b/Tests/RunCMake/FindMatlab/MatlabTest2-stderr.txt new file mode 100644 index 0000000..9abb766 --- /dev/null +++ b/Tests/RunCMake/FindMatlab/MatlabTest2-stderr.txt @@ -0,0 +1 @@ +.*
\ No newline at end of file diff --git a/Tests/RunCMake/FindMatlab/MatlabTest2.cmake b/Tests/RunCMake/FindMatlab/MatlabTest2.cmake new file mode 100644 index 0000000..d5b0e6d --- /dev/null +++ b/Tests/RunCMake/FindMatlab/MatlabTest2.cmake @@ -0,0 +1,9 @@ +cmake_minimum_required (VERSION 2.8.12) +enable_testing() +project(findmatlab_runcmake_test2) + +if(NOT DEFINED matlab_required) + set(matlab_required REQUIRED) +endif() + +find_package(Matlab ${matlab_required} COMPONENTS MX_LIBRARY) diff --git a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake index 33dbb77..f0eb6b4 100644 --- a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake @@ -1,3 +1,51 @@ include(RunCMake) run_cmake(MatlabTest1) + +if(RunCMake_GENERATOR MATCHES "Make" AND UNIX) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunFindMatlab-build-init) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + message(STATUS "RerunFindMatlab: first configuration to extract real Matlab_ROOT_DIR") + set(RunCMake_TEST_OPTIONS "-Dmatlab_required=REQUIRED") + run_cmake(MatlabTest2) + + message(STATUS "RerunFindMatlab: flushing the variables") + execute_process(COMMAND + ${CMAKE_COMMAND} -L ${RunCMake_TEST_BINARY_DIR} + RESULT_VARIABLE _MatlabTest2_error + OUTPUT_VARIABLE _MatlabTest2_output) + if(NOT _MatlabTest2_error EQUAL 0) + message(FATAL_ERROR "RerunFindMatlab: cannot list the variables ...") + endif() + + string(REGEX MATCH "Matlab_ROOT_DIR.+=([^\r\n]+)" _matched ${_MatlabTest2_output}) + + set(Matlab_ROOT_DIR_correct "${CMAKE_MATCH_1}") + if(Matlab_ROOT_DIR_correct STREQUAL "") + message(FATAL_ERROR "RerunFindMatlab: cannot extract Matlab_ROOT_DIR") + endif() + message(STATUS "RerunFindMatlab: detected correct Matlab_ROOT_DIR=${Matlab_ROOT_DIR_correct}") + + message(STATUS "RerunFindMatlab: change configuration, incorrect Matlab_ROOT_DIR setting") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunFindMatlab-build-second) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + set(RunCMake_TEST_OPTIONS "-DMatlab_ROOT_DIR=/" "-Dmatlab_required=") + run_cmake(MatlabTest2) + + message(STATUS "RerunFindMatlab: fixing configuration with correct Matlab_ROOT_DIR setting") + set(RunCMake_TEST_OPTIONS "-DMatlab_ROOT_DIR=${Matlab_ROOT_DIR_correct}") # required this time? + run_cmake(MatlabTest2) + + # no target on this test + run_cmake_command(MatlabTest2 ${CMAKE_COMMAND} --build .) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endif() |