diff options
-rw-r--r-- | Help/manual/cmake.1.rst | 12 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 35 | ||||
-rw-r--r-- | Source/kwsys/CommandLineArguments.cxx | 1 | ||||
-rw-r--r-- | Source/kwsys/ProcessUNIX.c | 2 | ||||
-rw-r--r-- | Source/kwsys/ProcessWin32.c | 4 | ||||
-rw-r--r-- | Source/kwsys/SystemInformation.cxx | 40 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 107 | ||||
-rw-r--r-- | Source/kwsys/testHashSTL.cxx | 1 | ||||
-rw-r--r-- | Source/kwsys/testIOS.cxx | 6 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/FindPackageModeMakefileTest/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/QtAutogen/Adir/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/QtAutogen/Adir/bar/foo.cpp | 4 | ||||
-rw-r--r-- | Tests/QtAutogen/Adir/bar/foo.h | 10 | ||||
-rw-r--r-- | Tests/QtAutogen/Adir/foo.cpp | 4 | ||||
-rw-r--r-- | Tests/QtAutogen/Adir/foo.h | 8 |
17 files changed, 160 insertions, 83 deletions
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 959148e..5295a48c 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -200,16 +200,19 @@ Available commands are: ``make_directory <dir>...`` Create ``<dir>`` directories. If necessary, create parent - directories too. + directories too. If a directory already exists it will be + silently ignored. ``md5sum <file>...`` Compute md5sum of files. ``remove [-f] <file>...`` - Remove the file(s), use ``-f`` to force it. + Remove the file(s), use ``-f`` to force it. If a file does + not exist it will be silently ignored. ``remove_directory <dir>`` - Remove a directory and its contents. + Remove a directory and its contents. If a directory does + not exist it will be silently ignored. ``rename <oldname> <newname>`` Rename a file or directory (on one volume). @@ -242,7 +245,8 @@ Available commands are: Touch a file. ``touch_nocreate <file>`` - Touch a file if it exists but do not create it. + Touch a file if it exists but do not create it. If a file does + not exist it will be silently ignored. UNIX-specific Command-Line Tools -------------------------------- diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4628127..b983213 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 5) -set(CMake_VERSION_PATCH 20160221) +set(CMake_VERSION_PATCH 20160224) #set(CMake_VERSION_RC 1) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 226ab43..b16eccd 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1104,39 +1104,10 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders, std::cout << "AUTOGEN: Checking " << headerName << std::endl; } - std::string headerDirectory; - if (cmsys::SystemTools::IsSubDirectory(headerName, - this->ProjectSourceDir)) - { - headerDirectory = this->ProjectSourceDir; - } - else if (cmsys::SystemTools::IsSubDirectory(headerName, - this->ProjectBinaryDir)) - { - headerDirectory = this->ProjectBinaryDir; - } - else - { - cmsys::SystemTools::SplitPathRootComponent(headerName, - &headerDirectory); - } - - std::string baseHeaderName = - cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName); - - headerDirectory = cmsys::SystemTools::RelativePath( - headerDirectory, cmsys::SystemTools::GetParentDirectory(headerName)); - - if (!headerDirectory.empty()) - { - headerDirectory += "/"; - } - - std::string mocName = headerDirectory + baseHeaderName; - - cmSystemTools::ReplaceString(mocName, "/", "_"); + const std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(headerName); - const std::string currentMoc = "moc_" + mocName + ".cpp"; + const std::string currentMoc = "moc_" + basename + ".cpp"; std::string macroName; if (requiresMocing(contents, macroName)) { diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx index 3636836..f713294 100644 --- a/Source/kwsys/CommandLineArguments.cxx +++ b/Source/kwsys/CommandLineArguments.cxx @@ -20,6 +20,7 @@ #if 0 # include "CommandLineArguments.hxx.in" # include "Configure.hxx.in" +# include "String.hxx.in" #endif #include <vector> diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 07c644b..7402955 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -505,6 +505,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout) { cp->Timeout = 0; } + // Force recomputation of TimeoutTime. + cp->TimeoutTime.tv_sec = -1; } /*--------------------------------------------------------------------------*/ diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index 1f8749f..a18ea27 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -17,7 +17,7 @@ duplicate the above list of headers. */ #if 0 # include "Process.h.in" -# include "Encoding_c.h.in" +# include "Encoding.h.in" #endif /* @@ -698,6 +698,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout) { cp->Timeout = 0; } + // Force recomputation of TimeoutTime. + cp->TimeoutTime.QuadPart = -1; } /*--------------------------------------------------------------------------*/ diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index cddcc8d..127a048 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -43,7 +43,6 @@ #if 0 # include "SystemInformation.hxx.in" # include "Process.h.in" -# include "Configure.hxx.in" #endif #include <iostream> @@ -3570,33 +3569,44 @@ SystemInformationImplementation::GetHostMemoryUsed() return (statex.ullTotalPhys - statex.ullAvailPhys)/1024; # endif #elif defined(__linux) - const char *names[3]={"MemTotal:","MemFree:",NULL}; - SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)}; - int ierr=GetFieldsFromFile("/proc/meminfo",names,values); + // First try to use MemAvailable, but it only works on newer kernels + const char *names2[3]={"MemTotal:","MemAvailable:",NULL}; + SystemInformation::LongLong values2[2]={SystemInformation::LongLong(0)}; + int ierr=GetFieldsFromFile("/proc/meminfo",names2,values2); if (ierr) { - return ierr; - } - SystemInformation::LongLong &memTotal=values[0]; - SystemInformation::LongLong &memFree=values[1]; - return memTotal - memFree; + const char *names4[5]={"MemTotal:","MemFree:","Buffers:","Cached:",NULL}; + SystemInformation::LongLong values4[4]={SystemInformation::LongLong(0)}; + ierr=GetFieldsFromFile("/proc/meminfo",names4,values4); + if(ierr) + { + return ierr; + } + SystemInformation::LongLong &memTotal=values4[0]; + SystemInformation::LongLong &memFree=values4[1]; + SystemInformation::LongLong &memBuffers=values4[2]; + SystemInformation::LongLong &memCached=values4[3]; + return memTotal - memFree - memBuffers - memCached; + } + SystemInformation::LongLong &memTotal=values2[0]; + SystemInformation::LongLong &memAvail=values2[1]; + return memTotal - memAvail; #elif defined(__APPLE__) SystemInformation::LongLong psz=getpagesize(); if (psz<1) { return -1; } - const char *names[4]={"Pages active:","Pages inactive:","Pages wired down:",NULL}; - SystemInformation::LongLong values[3]={SystemInformation::LongLong(0)}; + const char *names[3]={"Pages wired down:","Pages active:",NULL}; + SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)}; int ierr=GetFieldsFromCommand("vm_stat", names, values); if (ierr) { return -1; } - SystemInformation::LongLong &vmActive=values[0]; - SystemInformation::LongLong &vmInactive=values[1]; - SystemInformation::LongLong &vmWired=values[2]; - return ((vmActive+vmInactive+vmWired)*psz)/1024; + SystemInformation::LongLong &vmWired=values[0]; + SystemInformation::LongLong &vmActive=values[1]; + return ((vmActive+vmWired)*psz)/1024; #else return 0; #endif diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index e3428f8..544a638 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -35,10 +35,12 @@ #include <fstream> #include <sstream> #include <set> +#include <vector> // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 +# include "RegularExpression.hxx.in" # include "SystemTools.hxx.in" # include "Directory.hxx.in" # include "FStream.hxx.in" @@ -87,6 +89,7 @@ // Windows API. #if defined(_WIN32) # include <windows.h> +# include <winioctl.h> # ifndef INVALID_FILE_ATTRIBUTES # define INVALID_FILE_ATTRIBUTES ((DWORD)-1) # endif @@ -2754,6 +2757,106 @@ std::string SystemTools::GetLastSystemError() return strerror(e); } +#ifdef _WIN32 + +static bool IsJunction(const std::wstring& source) +{ +#ifdef FSCTL_GET_REPARSE_POINT + const DWORD JUNCTION_ATTRS = FILE_ATTRIBUTE_DIRECTORY | + FILE_ATTRIBUTE_REPARSE_POINT; + DWORD attrs = GetFileAttributesW(source.c_str()); + if (attrs == INVALID_FILE_ATTRIBUTES) + { + return false; + } + if ((attrs & JUNCTION_ATTRS) != JUNCTION_ATTRS) + { + return false; + } + + // Adjust privileges so that we can succefully open junction points. + HANDLE token; + TOKEN_PRIVILEGES privs; + OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token); + LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &privs.Privileges[0].Luid); + privs.PrivilegeCount = 1; + privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL); + CloseHandle(token); + + HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ, + 0, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (dir == INVALID_HANDLE_VALUE) + { + return false; + } + + // Query whether this is a reparse point or not. + BYTE buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; + REPARSE_GUID_DATA_BUFFER *reparse_buffer = + (REPARSE_GUID_DATA_BUFFER*) buffer; + DWORD sentinel; + + BOOL success = DeviceIoControl( + dir, FSCTL_GET_REPARSE_POINT, + NULL, 0, + reparse_buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, + &sentinel, NULL); + + CloseHandle(dir); + + return (success && (reparse_buffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT)); +#else + return false; +#endif +} + +static bool DeleteJunction(const std::wstring& source) +{ +#ifdef FSCTL_DELETE_REPARSE_POINT + // Adjust privileges so that we can succefully open junction points as + // read/write. + HANDLE token; + TOKEN_PRIVILEGES privs; + OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token); + LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &privs.Privileges[0].Luid); + privs.PrivilegeCount = 1; + privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL); + CloseHandle(token); + + HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (dir == INVALID_HANDLE_VALUE) + { + return false; + } + + // Set up the structure so that we can delete the junction. + std::vector<BYTE> buffer(REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, 0); + REPARSE_GUID_DATA_BUFFER *reparse_buffer = + (REPARSE_GUID_DATA_BUFFER*) &buffer[0]; + DWORD sentinel; + + reparse_buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; + + BOOL success = DeviceIoControl( + dir, FSCTL_DELETE_REPARSE_POINT, + reparse_buffer, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, + NULL, 0, + &sentinel, NULL); + + CloseHandle(dir); + + return !!success; +#else + return false; +#endif +} +#endif + bool SystemTools::RemoveFile(const std::string& source) { #ifdef _WIN32 @@ -2781,6 +2884,10 @@ bool SystemTools::RemoveFile(const std::string& source) SetLastError(err); return false; } + if (IsJunction(ws) && !DeleteJunction(ws)) + { + return false; + } if (DeleteFileW(ws.c_str()) || GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND) diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx index ab1f83e..ae66ceb 100644 --- a/Source/kwsys/testHashSTL.cxx +++ b/Source/kwsys/testHashSTL.cxx @@ -18,7 +18,6 @@ #if 0 # include "hash_map.hxx.in" # include "hash_set.hxx.in" -# include "hashtable.hxx.in" #endif #include <iostream> diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx index 396a09d..5ff7955 100644 --- a/Source/kwsys/testIOS.cxx +++ b/Source/kwsys/testIOS.cxx @@ -18,6 +18,12 @@ #include <vector> #include <string.h> /* strlen */ +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Configure.hxx.in" +#endif + int testIOS(int, char*[]) { std::ostringstream ostr; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 7bb0721..b43275a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1644,7 +1644,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5 AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)") - set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1}) + set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1} -DCMAKE_OSX_SYSROOT=macosx) ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> -V) endif() diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 8e21c32..56fcc5d 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -1,6 +1,7 @@ -if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND + NOT CMake_TEST_NO_FindPackageModeMakefileTest) # Test whether the make is GNU make, and only add the test in this case, # since the configured makefile in this test uses $(shell ...), which diff --git a/Tests/QtAutogen/Adir/CMakeLists.txt b/Tests/QtAutogen/Adir/CMakeLists.txt index 0c7848d..a1c36ff 100644 --- a/Tests/QtAutogen/Adir/CMakeLists.txt +++ b/Tests/QtAutogen/Adir/CMakeLists.txt @@ -3,6 +3,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) -add_library(libA SHARED libA.cpp foo.cpp bar/foo.cpp) +add_library(libA SHARED libA.cpp) target_link_libraries(libA LINK_PUBLIC ${QT_QTCORE_TARGET}) generate_export_header(libA) diff --git a/Tests/QtAutogen/Adir/bar/foo.cpp b/Tests/QtAutogen/Adir/bar/foo.cpp deleted file mode 100644 index 3f5e0a9..0000000 --- a/Tests/QtAutogen/Adir/bar/foo.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "foo.h" - -bar::foo::foo() {} -bar::foo::~foo() {} diff --git a/Tests/QtAutogen/Adir/bar/foo.h b/Tests/QtAutogen/Adir/bar/foo.h deleted file mode 100644 index daf2367..0000000 --- a/Tests/QtAutogen/Adir/bar/foo.h +++ /dev/null @@ -1,10 +0,0 @@ -#include <QObject> - -namespace bar { - class foo: public QObject { - Q_OBJECT - public: - foo(); - ~foo(); - }; -} diff --git a/Tests/QtAutogen/Adir/foo.cpp b/Tests/QtAutogen/Adir/foo.cpp deleted file mode 100644 index 86e4d8e..0000000 --- a/Tests/QtAutogen/Adir/foo.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "foo.h" - -foo::foo() {} -foo::~foo() {} diff --git a/Tests/QtAutogen/Adir/foo.h b/Tests/QtAutogen/Adir/foo.h deleted file mode 100644 index a51960c..0000000 --- a/Tests/QtAutogen/Adir/foo.h +++ /dev/null @@ -1,8 +0,0 @@ -#include <QObject> - -class foo: public QObject { - Q_OBJECT -public: - foo(); - ~foo(); -}; |