summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/prop_tgt/BUILD_RPATH.rst10
-rw-r--r--Help/release/3.7.rst9
-rw-r--r--Help/release/dev/0-sample-topic.rst7
-rw-r--r--Help/release/dev/add-BUILD_RPATH.rst6
-rw-r--r--Help/release/index.rst2
-rw-r--r--Help/variable/CMAKE_BUILD_RPATH.rst10
-rw-r--r--Modules/CPackRPM.cmake68
-rw-r--r--Modules/FindMatlab.cmake16
-rw-r--r--Source/CMakeVersion.cmake4
-rw-r--r--Source/CPack/cmCPackGenerator.h10
-rw-r--r--Source/CPack/cmCPackLog.cxx2
-rw-r--r--Source/CPack/cmCPackLog.h10
-rw-r--r--Source/CPack/cpack.cxx2
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx4
-rw-r--r--Source/QtIFW/cmake.org.html2
-rw-r--r--Source/cmCTest.cxx7
-rw-r--r--Source/cmComputeLinkInformation.cxx6
-rw-r--r--Source/cmELF.cxx224
-rw-r--r--Source/cmELF.h23
-rw-r--r--Source/cmFileMonitor.cxx8
-rw-r--r--Source/cmGeneratorTarget.cxx3
-rw-r--r--Source/cmServerConnection.cxx162
-rw-r--r--Source/cmServerConnection.h15
-rw-r--r--Source/cmSystemTools.cxx72
-rw-r--r--Source/cmTarget.cxx1
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx6
-rw-r--r--Source/ctest.cxx4
-rw-r--r--Tests/MacRuntimePath/A/CMakeLists.txt15
-rw-r--r--Utilities/GitSetup/config2
-rw-r--r--Utilities/Release/README2
-rw-r--r--Utilities/Release/linux64_release.cmake1
-rw-r--r--Utilities/Release/osx_release.cmake2
35 files changed, 399 insertions, 326 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 309e224..b4a577c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,10 @@ if(POLICY CMP0053)
endif()
project(CMake)
+# Make sure we can find internal find_package modules only used for
+# building CMake and not for shipping externally
+list(INSERT CMAKE_MODULE_PATH 0 ${CMake_SOURCE_DIR}/Source/Modules)
+
if(CMAKE_BOOTSTRAP)
# Running from bootstrap script. Set local variable and remove from cache.
set(CMAKE_BOOTSTRAP 1)
@@ -441,7 +445,7 @@ macro (CMAKE_BUILD_UTILITIES)
# Build jsoncpp library.
if(CMAKE_USE_SYSTEM_JSONCPP)
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
- include(${CMake_SOURCE_DIR}/Source/Modules/FindJsonCpp.cmake)
+ find_package(JsonCpp)
else()
message(FATAL_ERROR "CMAKE_USE_SYSTEM_JSONCPP requires CMake >= 3.0")
endif()
@@ -487,7 +491,7 @@ int main(void) { return 0; }
if(CMAKE_USE_LIBUV)
if(CMAKE_USE_SYSTEM_LIBUV)
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
- include(${CMake_SOURCE_DIR}/Source/Modules/FindLibUV.cmake)
+ find_package(LibUV 1.0.0)
else()
message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBUV requires CMake >= 3.0")
endif()
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 271f497..fa21a1f 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -121,6 +121,7 @@ Properties on Targets
/prop_tgt/AUTORCC
/prop_tgt/AUTORCC_OPTIONS
/prop_tgt/BINARY_DIR
+ /prop_tgt/BUILD_RPATH
/prop_tgt/BUILD_WITH_INSTALL_RPATH
/prop_tgt/BUNDLE_EXTENSION
/prop_tgt/BUNDLE
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index b74f867..f76c467 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -257,6 +257,7 @@ Variables that Control the Build
/variable/CMAKE_AUTORCC_OPTIONS
/variable/CMAKE_AUTOUIC
/variable/CMAKE_AUTOUIC_OPTIONS
+ /variable/CMAKE_BUILD_RPATH
/variable/CMAKE_BUILD_WITH_INSTALL_RPATH
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
diff --git a/Help/prop_tgt/BUILD_RPATH.rst b/Help/prop_tgt/BUILD_RPATH.rst
new file mode 100644
index 0000000..27393f5
--- /dev/null
+++ b/Help/prop_tgt/BUILD_RPATH.rst
@@ -0,0 +1,10 @@
+BUILD_RPATH
+-----------
+
+A :ref:`;-list <CMake Language Lists>` specifying runtime path (``RPATH``)
+entries to add to binaries linked in the build tree (for platforms that
+support it). The entries will *not* be used for binaries in the install
+tree. See also the :prop_tgt:`INSTALL_RPATH` target property.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_BUILD_RPATH` if it is set when a target is created.
diff --git a/Help/release/3.7.rst b/Help/release/3.7.rst
index d8141ca..3b8ade6 100644
--- a/Help/release/3.7.rst
+++ b/Help/release/3.7.rst
@@ -176,7 +176,14 @@ Modules
* A :module:`FindICU` module was introduced to find the International
Components for Unicode (ICU) libraries and programs.
-* The :module:`FindMatlab` module learned to find a SIMULINK component.
+* The :module:`FindMatlab` module learned to find the SIMULINK and MAT
+ components.
+
+* The :module:`FindMatlab` module :command:`matlab_add_mex` command learned
+ to add executables and modules.
+
+* The :module:`FindMatlab` module :command:`matlab_add_unit_test` command
+ learned to support inline Matlab test code.
* The :module:`FindOpenCL` module now provides imported targets.
diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst
new file mode 100644
index 0000000..e4cc01e
--- /dev/null
+++ b/Help/release/dev/0-sample-topic.rst
@@ -0,0 +1,7 @@
+0-sample-topic
+--------------
+
+* This is a sample release note for the change in a topic.
+ Developers should add similar notes for each topic branch
+ making a noteworthy change. Each document should be named
+ and titled to match the topic name to avoid merge conflicts.
diff --git a/Help/release/dev/add-BUILD_RPATH.rst b/Help/release/dev/add-BUILD_RPATH.rst
new file mode 100644
index 0000000..0d69e45
--- /dev/null
+++ b/Help/release/dev/add-BUILD_RPATH.rst
@@ -0,0 +1,6 @@
+add-BUILD_RPATH
+---------------
+
+* A :variable:`CMAKE_BUILD_RPATH` variable and corresponding
+ :prop_tgt:`BUILD_RPATH` target property were added to support custom
+ ``RPATH`` locations to be added to binaries in the build tree.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 25c6c3e..30decd5 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -5,6 +5,8 @@ CMake Release Notes
This file should include the adjacent "dev.txt" file
in development versions but not in release versions.
+.. include:: dev.txt
+
Releases
========
diff --git a/Help/variable/CMAKE_BUILD_RPATH.rst b/Help/variable/CMAKE_BUILD_RPATH.rst
new file mode 100644
index 0000000..f20eb41
--- /dev/null
+++ b/Help/variable/CMAKE_BUILD_RPATH.rst
@@ -0,0 +1,10 @@
+CMAKE_BUILD_RPATH
+-----------------
+
+A :ref:`;-list <CMake Language Lists>` specifying runtime path (``RPATH``)
+entries to add to binaries linked in the build tree (for platforms that
+support it). The entries will *not* be used for binaries in the install
+tree. See also the :variable:`CMAKE_INSTALL_RPATH` variable.
+
+This is used to initialize the :prop_tgt:`BUILD_RPATH` target property
+for all targets.
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 3bbaae9..15b62c7 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -1427,7 +1427,8 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR)
execute_process(COMMAND "${OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F}
WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}"
RESULT_VARIABLE OBJDUMP_EXEC_RESULT
- OUTPUT_VARIABLE OBJDUMP_OUT)
+ OUTPUT_VARIABLE OBJDUMP_OUT
+ ERROR_QUIET)
# Check that if the given file was executable or not
if(NOT OBJDUMP_EXEC_RESULT)
string(FIND "${OBJDUMP_OUT}" "debug" FIND_RESULT)
@@ -1476,16 +1477,22 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR)
endif()
endforeach()
- list(REMOVE_DUPLICATES mkdir_list_)
- unset(TMP_RPM_DEBUGINFO_INSTALL)
- foreach(part_ IN LISTS mkdir_list_)
- string(APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \"${part_}\"\n")
- endforeach()
+ list(LENGTH mkdir_list_ len_)
+ if(len_)
+ list(REMOVE_DUPLICATES mkdir_list_)
+ unset(TMP_RPM_DEBUGINFO_INSTALL)
+ foreach(part_ IN LISTS mkdir_list_)
+ string(APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \"${part_}\"\n")
+ endforeach()
+ endif()
- list(REMOVE_DUPLICATES cp_list_)
- foreach(part_ IN LISTS cp_list_)
- string(APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n")
- endforeach()
+ list(LENGTH cp_list_ len_)
+ if(len_)
+ list(REMOVE_DUPLICATES cp_list_)
+ foreach(part_ IN LISTS cp_list_)
+ string(APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n")
+ endforeach()
+ endif()
if(NOT DEFINED CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS)
set(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS /usr /usr/src /usr/src/debug)
@@ -1500,29 +1507,34 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR)
message("CPackRPM:Debug: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS= ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}")
endif()
- list(REMOVE_DUPLICATES additional_sources_)
- unset(additional_sources_all_)
- foreach(source_ IN LISTS additional_sources_)
- string(REPLACE "/" ";" split_source_ " ${source_}")
- list(REMOVE_AT split_source_ 0)
- unset(tmp_path_)
- # Now generate all segments of the path
- foreach(segment_ IN LISTS split_source_)
- string(APPEND tmp_path_ "/${segment_}")
- list(APPEND additional_sources_all_ "${tmp_path_}")
+ list(LENGTH additional_sources_ len_)
+ if(len_)
+ list(REMOVE_DUPLICATES additional_sources_)
+ unset(additional_sources_all_)
+ foreach(source_ IN LISTS additional_sources_)
+ string(REPLACE "/" ";" split_source_ " ${source_}")
+ list(REMOVE_AT split_source_ 0)
+ unset(tmp_path_)
+ # Now generate all segments of the path
+ foreach(segment_ IN LISTS split_source_)
+ string(APPEND tmp_path_ "/${segment_}")
+ list(APPEND additional_sources_all_ "${tmp_path_}")
+ endforeach()
endforeach()
- endforeach()
- list(REMOVE_DUPLICATES additional_sources_all_)
- list(REMOVE_ITEM additional_sources_all_ ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS})
+ list(REMOVE_DUPLICATES additional_sources_all_)
+ list(REMOVE_ITEM additional_sources_all_
+ ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS})
- unset(TMP_DEBUGINFO_ADDITIONAL_SOURCES)
- foreach(source_ IN LISTS additional_sources_all_)
- string(APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n")
- endforeach()
+ unset(TMP_DEBUGINFO_ADDITIONAL_SOURCES)
+ foreach(source_ IN LISTS additional_sources_all_)
+ string(APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n")
+ endforeach()
+ endif()
set(TMP_RPM_DEBUGINFO_INSTALL "${TMP_RPM_DEBUGINFO_INSTALL}" PARENT_SCOPE)
- set(TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}" PARENT_SCOPE)
+ set(TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}"
+ PARENT_SCOPE)
endfunction()
function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME)
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 6beacce..b7f2db5 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -737,9 +737,9 @@ endfunction()
# added to the Matlab path.
# ``CUSTOM_MATLAB_COMMAND``
# Matlab script command to run as the test.
-# IIf this is not set, then the following is run:
-# "runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))
-# matlab_file_name comes from UNITTEST_FILE without the .m.
+# If this is not set, then the following is run:
+# ``runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))``
+# where ``matlab_file_name`` is the ``UNITTEST_FILE`` without the extension.
# ``UNITTEST_PRECOMMAND``
# Matlab script command to be ran before the file
# containing the test (eg. GPU device initialisation based on CMake
@@ -753,7 +753,7 @@ endfunction()
# ``MATLAB_ADDITIONAL_STARTUP_OPTIONS``
# a list of additional option in order
# to run Matlab from the command line.
-# -nosplash -nodesktop -nodisplay are always added.
+# ``-nosplash -nodesktop -nodisplay`` are always added.
# ``TEST_ARGS``
# Additional options provided to the add_test command. These
# options are added to the default options (eg. "CONFIGURATIONS Release")
@@ -763,7 +763,7 @@ endfunction()
# ``WORKING_DIRECTORY``
# This will be the working directory for the test. If specified it will
# also be the output directory used for the log file of the test run.
-# If not specifed the temporary directory ${CMAKE_BINARY_DIR}/Matlab will
+# If not specifed the temporary directory ``${CMAKE_BINARY_DIR}/Matlab`` will
# be used as the working directory and the log location.
#
function(matlab_add_unit_test)
@@ -844,7 +844,6 @@ endfunction()
# the same folder without any processing, with the same name as the final
# mex file, and with extension `.m`. In that case, typing ``help <name>``
# in Matlab prints the documentation contained in this file.
-#
# ``MODULE`` or ``SHARED`` may be given to specify the type of library to be
# created. ``EXECUTABLE`` may be given to create an executable instead of
# a library. If no type is given explicitly, the type is ``SHARED``.
@@ -1246,8 +1245,8 @@ if(_numbers_of_matlab_roots GREATER 0)
endif()
-# check if the root changed against the previous defined one, if so
-# clear all the cached variables
+# check if the root changed wrt. the previous defined one, if so
+# clear all the cached variables for being able to reconfigure properly
if(DEFINED Matlab_ROOT_DIR_LAST_CACHED)
if(NOT Matlab_ROOT_DIR_LAST_CACHED STREQUAL Matlab_ROOT_DIR)
@@ -1260,6 +1259,7 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED)
Matlab_ENG_LIBRARY
Matlab_MAT_LIBRARY
Matlab_MEX_EXTENSION
+ Matlab_SIMULINK_INCLUDE_DIR
# internal
Matlab_MEXEXTENSIONS_PROG
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 6cb0fea..ee2f4af 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 7)
-set(CMake_VERSION_PATCH 0)
-set(CMake_VERSION_RC 1)
+set(CMake_VERSION_PATCH 20161007)
+#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index 9232ffc..db20998 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -32,16 +32,6 @@ class cmMakefile;
cmCPackLog_msg.str().c_str()); \
} while (0)
-#ifdef cerr
-#undef cerr
-#endif
-#define cerr no_cerr_use_cmCPack_Log
-
-#ifdef cout
-#undef cout
-#endif
-#define cout no_cout_use_cmCPack_Log
-
/** \class cmCPackGenerator
* \brief A superclass of all CPack Generators
*
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx
index be429fe..317f613 100644
--- a/Source/CPack/cmCPackLog.cxx
+++ b/Source/CPack/cmCPackLog.cxx
@@ -15,8 +15,6 @@ cmCPackLog::cmCPackLog()
this->NewLine = true;
this->LastTag = cmCPackLog::NOTAG;
-#undef cerr
-#undef cout
this->DefaultOutput = &std::cout;
this->DefaultError = &std::cerr;
diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h
index 0831843..370879d 100644
--- a/Source/CPack/cmCPackLog.h
+++ b/Source/CPack/cmCPackLog.h
@@ -19,16 +19,6 @@
(ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str()); \
} while (0)
-#ifdef cerr
-#undef cerr
-#endif
-#define cerr no_cerr_use_cmCPack_Log
-
-#ifdef cout
-#undef cout
-#endif
-#define cout no_cout_use_cmCPack_Log
-
/** \class cmCPackLog
* \brief A container for CPack generators
*
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 5c45b14..a3281ab 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -415,9 +415,7 @@ int main(int argc, char const* const* argv)
}
doc.SetSection("Generators", v);
-#undef cout
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
-#define cout no_cout_use_cmCPack_Log
}
if (cmSystemTools::GetErrorOccuredFlag()) {
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index b37db30..0052a16 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -375,11 +375,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.StartElement("DefectList");
for (cc = 0; cc < this->GlobalResults.size(); cc++) {
if (this->GlobalResults[cc]) {
-#ifdef cerr
-#undef cerr
-#endif
std::cerr.width(35);
-#define cerr no_cerr
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
this->ResultStringsLong[cc]
<< " - " << this->GlobalResults[cc] << std::endl,
diff --git a/Source/QtIFW/cmake.org.html b/Source/QtIFW/cmake.org.html
index cf5649d..001d634 100644
--- a/Source/QtIFW/cmake.org.html
+++ b/Source/QtIFW/cmake.org.html
@@ -1,6 +1,6 @@
<html>
<head>
-<meta http-equiv="Refresh" content="0; url=http://cmake.org/" />
+<meta http-equiv="Refresh" content="0; url=https://cmake.org/" />
</head>
<body>
</body>
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 1824d94..7dc9e33 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2651,13 +2651,6 @@ static const char* cmCTestStringLogType[] = { "DEBUG",
"ERROR_MESSAGE",
CM_NULLPTR };
-#ifdef cerr
-#undef cerr
-#endif
-#ifdef cout
-#undef cout
-#endif
-
#define cmCTestLogOutputFileLine(stream) \
if (this->ShowLineNumbers) { \
(stream) << std::endl << file << ":" << line << " "; \
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index dc8236d..0807ef8 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -1710,6 +1710,12 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH");
cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted);
}
+ if (use_build_rpath) {
+ // Add directories explicitly specified by user
+ if (const char* build_rpath = this->Target->GetProperty("BUILD_RPATH")) {
+ cmCLI_ExpandListUnique(build_rpath, runtimeDirs, emitted);
+ }
+ }
if (use_build_rpath || use_link_rpath) {
std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
const char* stagePath =
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index 2d86674..0655da9 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -132,18 +132,13 @@ public:
// Forward to the per-class implementation.
virtual unsigned int GetNumberOfSections() const = 0;
- virtual unsigned int GetDynamicEntryCount() = 0;
virtual unsigned long GetDynamicEntryPosition(int j) = 0;
+ virtual cmELF::DynamicEntryList GetDynamicEntries() = 0;
+ virtual std::vector<char> EncodeDynamicEntries(
+ const cmELF::DynamicEntryList&) = 0;
virtual StringEntry const* GetDynamicSectionString(unsigned int tag) = 0;
virtual void PrintInfo(std::ostream& os) const = 0;
- bool ReadBytes(unsigned long pos, unsigned long size, char* buf)
- {
- this->Stream.seekg(pos);
- this->Stream.read(buf, size);
- return !this->Stream.fail();
- }
-
// Lookup the SONAME in the DYNAMIC section.
StringEntry const* GetSOName()
{
@@ -246,10 +241,13 @@ public:
return static_cast<unsigned int>(this->ELFHeader.e_shnum);
}
- // Get the file position and size of a dynamic section entry.
- unsigned int GetDynamicEntryCount() CM_OVERRIDE;
+ // Get the file position of a dynamic section entry.
unsigned long GetDynamicEntryPosition(int j) CM_OVERRIDE;
+ cmELF::DynamicEntryList GetDynamicEntries() CM_OVERRIDE;
+ std::vector<char> EncodeDynamicEntries(const cmELF::DynamicEntryList&)
+ CM_OVERRIDE;
+
// Lookup a string from the dynamic section with the given tag.
StringEntry const* GetDynamicSectionString(unsigned int tag) CM_OVERRIDE;
@@ -289,6 +287,10 @@ public:
}
private:
+ // ByteSwap(ELF_Dyn) assumes d_val and d_ptr are the same size
+ typedef char dyn_size_assert
+ [sizeof(ELF_Dyn().d_un.d_val) == sizeof(ELF_Dyn().d_un.d_ptr) ? 1 : -1];
+
void ByteSwap(ELF_Ehdr& elf_header)
{
cmELFByteSwap(elf_header.e_type);
@@ -323,121 +325,7 @@ private:
void ByteSwap(ELF_Dyn& dyn)
{
cmELFByteSwap(dyn.d_tag);
- switch (dyn.d_tag) {
- case DT_NULL: /* dyn.d_un ignored */
- break;
- case DT_NEEDED:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_PLTRELSZ:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_PLTGOT:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_HASH:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_STRTAB:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_SYMTAB:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_RELA:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_RELASZ:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_RELAENT:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_STRSZ:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_SYMENT:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_INIT:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_FINI:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_SONAME:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_RPATH:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_SYMBOLIC: /* dyn.d_un ignored */
- break;
- case DT_REL:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_RELSZ:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_RELENT:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_PLTREL:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
- case DT_DEBUG:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
- case DT_TEXTREL: /* dyn.d_un ignored */
- break;
- case DT_JMPREL:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
-#ifdef T_BIND_NOW
- case T_BIND_NOW: /* dyn.d_un ignored */
- break;
-#endif
-#ifdef DT_INIT_ARRAY
- case DT_INIT_ARRAY:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
-#endif
-#ifdef DT_FINI_ARRAY
- case DT_FINI_ARRAY:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
-#endif
-#ifdef DT_INIT_ARRAYSZ
- case DT_INIT_ARRAYSZ:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
-#endif
-#ifdef DT_FINI_ARRAYSZ
- case DT_FINI_ARRAYSZ:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
-#endif
-#ifdef DT_RUNPATH
- case DT_RUNPATH:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
-#endif
-#ifdef DT_FLAGS
- case DT_FLAGS:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
-#endif
-#ifdef DT_PREINIT_ARRAY
- case DT_PREINIT_ARRAY:
- cmELFByteSwap(dyn.d_un.d_ptr);
- break;
-#endif
-#ifdef DT_PREINIT_ARRAYSZ
- case DT_PREINIT_ARRAYSZ:
- cmELFByteSwap(dyn.d_un.d_val);
- break;
-#endif
- }
+ cmELFByteSwap(dyn.d_un.d_val);
}
bool FileTypeValid(ELF_Half et)
@@ -636,30 +524,64 @@ bool cmELFInternalImpl<Types>::LoadDynamicSection()
}
template <class Types>
-unsigned int cmELFInternalImpl<Types>::GetDynamicEntryCount()
+unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j)
{
if (!this->LoadDynamicSection()) {
return 0;
}
- for (unsigned int i = 0; i < this->DynamicSectionEntries.size(); ++i) {
- if (this->DynamicSectionEntries[i].d_tag == DT_NULL) {
- return i;
- }
+ if (j < 0 || j >= static_cast<int>(this->DynamicSectionEntries.size())) {
+ return 0;
}
- return static_cast<unsigned int>(this->DynamicSectionEntries.size());
+ ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
+ return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize * j);
}
template <class Types>
-unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j)
+cmELF::DynamicEntryList cmELFInternalImpl<Types>::GetDynamicEntries()
{
+ cmELF::DynamicEntryList result;
+
+ // Ensure entries have been read from file
if (!this->LoadDynamicSection()) {
- return 0;
+ return result;
}
- if (j < 0 || j >= static_cast<int>(this->DynamicSectionEntries.size())) {
- return 0;
+
+ // Copy into public array
+ result.reserve(this->DynamicSectionEntries.size());
+ for (typename std::vector<ELF_Dyn>::iterator di =
+ this->DynamicSectionEntries.begin();
+ di != this->DynamicSectionEntries.end(); ++di) {
+ ELF_Dyn& dyn = *di;
+ result.push_back(
+ std::pair<unsigned long, unsigned long>(dyn.d_tag, dyn.d_un.d_val));
}
- ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
- return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize * j);
+
+ return result;
+}
+
+template <class Types>
+std::vector<char> cmELFInternalImpl<Types>::EncodeDynamicEntries(
+ const cmELF::DynamicEntryList& entries)
+{
+ std::vector<char> result;
+ result.reserve(sizeof(ELF_Dyn) * entries.size());
+
+ for (cmELF::DynamicEntryList::const_iterator it = entries.begin();
+ it != entries.end(); it++) {
+ // Store the entry in an ELF_Dyn, byteswap it, then serialize to chars
+ ELF_Dyn dyn;
+ dyn.d_tag = static_cast<tagtype>(it->first);
+ dyn.d_un.d_val = static_cast<tagtype>(it->second);
+
+ if (this->NeedSwap) {
+ ByteSwap(dyn);
+ }
+
+ char* pdyn = reinterpret_cast<char*>(&dyn);
+ result.insert(result.end(), pdyn, pdyn + sizeof(ELF_Dyn));
+ }
+
+ return result;
}
template <class Types>
@@ -752,6 +674,15 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
//============================================================================
// External class implementation.
+const long cmELF::TagRPath = DT_RPATH;
+const long cmELF::TagRunPath = DT_RUNPATH;
+
+#ifdef DT_MIPS_RLD_MAP_REL
+const long cmELF::TagMipsRldMapRel = DT_MIPS_RLD_MAP_REL;
+#else
+const long cmELF::TagMipsRldMapRel = 0;
+#endif
+
cmELF::cmELF(const char* fname)
: Internal(CM_NULLPTR)
{
@@ -839,28 +770,31 @@ unsigned int cmELF::GetNumberOfSections() const
return 0;
}
-unsigned int cmELF::GetDynamicEntryCount() const
+unsigned long cmELF::GetDynamicEntryPosition(int index) const
{
if (this->Valid()) {
- return this->Internal->GetDynamicEntryCount();
+ return this->Internal->GetDynamicEntryPosition(index);
}
return 0;
}
-unsigned long cmELF::GetDynamicEntryPosition(int index) const
+cmELF::DynamicEntryList cmELF::GetDynamicEntries() const
{
if (this->Valid()) {
- return this->Internal->GetDynamicEntryPosition(index);
+ return this->Internal->GetDynamicEntries();
}
- return 0;
+
+ return cmELF::DynamicEntryList();
}
-bool cmELF::ReadBytes(unsigned long pos, unsigned long size, char* buf) const
+std::vector<char> cmELF::EncodeDynamicEntries(
+ const cmELF::DynamicEntryList& dentries) const
{
if (this->Valid()) {
- return this->Internal->ReadBytes(pos, size, buf);
+ return this->Internal->EncodeDynamicEntries(dentries);
}
- return false;
+
+ return std::vector<char>();
}
bool cmELF::GetSOName(std::string& soname)
diff --git a/Source/cmELF.h b/Source/cmELF.h
index 7e7c1d6..763a240 100644
--- a/Source/cmELF.h
+++ b/Source/cmELF.h
@@ -7,6 +7,8 @@
#include <iosfwd>
#include <string>
+#include <utility>
+#include <vector>
#if !defined(CMAKE_USE_ELF_PARSER)
#error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
@@ -61,22 +63,27 @@ public:
int IndexInSection;
};
+ /** Represent entire dynamic section header */
+ typedef std::vector<std::pair<long, unsigned long> > DynamicEntryList;
+
/** Get the type of the file opened. */
FileType GetFileType() const;
/** Get the number of ELF sections present. */
unsigned int GetNumberOfSections() const;
- /** Get the number of DYNAMIC section entries before the first
- DT_NULL. Returns zero on error. */
- unsigned int GetDynamicEntryCount() const;
-
/** Get the position of a DYNAMIC section header entry. Returns
zero on error. */
unsigned long GetDynamicEntryPosition(int index) const;
- /** Read bytes from the file. */
- bool ReadBytes(unsigned long pos, unsigned long size, char* buf) const;
+ /** Get a copy of all the DYNAMIC section header entries.
+ Returns an empty vector on error */
+ DynamicEntryList GetDynamicEntries() const;
+
+ /** Encodes a DYNAMIC section header entry list into a char vector according
+ to the type of ELF file this is */
+ std::vector<char> EncodeDynamicEntries(
+ const DynamicEntryList& entries) const;
/** Get the SONAME field if any. */
bool GetSOName(std::string& soname);
@@ -91,6 +98,10 @@ public:
/** Print human-readable information about the ELF file. */
void PrintInfo(std::ostream& os) const;
+ /** Interesting dynamic tags.
+ If the tag is 0, it does not exist in the host ELF implementation */
+ static const long TagRPath, TagRunPath, TagMipsRldMapRel;
+
private:
friend class cmELFInternal;
bool Valid() const;
diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx
index b97590b..41ec8b4 100644
--- a/Source/cmFileMonitor.cxx
+++ b/Source/cmFileMonitor.cxx
@@ -12,7 +12,7 @@
namespace {
void on_directory_change(uv_fs_event_t* handle, const char* filename,
int events, int status);
-void on_handle_close(uv_handle_t* handle);
+void on_fs_close(uv_handle_t* handle);
} // namespace
class cmIBaseWatcher
@@ -177,7 +177,7 @@ public:
{
if (this->Handle) {
uv_fs_event_stop(this->Handle);
- uv_close(reinterpret_cast<uv_handle_t*>(this->Handle), &on_handle_close);
+ uv_close(reinterpret_cast<uv_handle_t*>(this->Handle), &on_fs_close);
this->Handle = nullptr;
}
cmVirtualDirectoryWatcher::StopWatching();
@@ -292,9 +292,9 @@ void on_directory_change(uv_fs_event_t* handle, const char* filename,
watcher->Trigger(pathSegment, events, status);
}
-void on_handle_close(uv_handle_t* handle)
+void on_fs_close(uv_handle_t* handle)
{
- delete (reinterpret_cast<uv_fs_event_t*>(handle));
+ delete reinterpret_cast<uv_fs_event_t*>(handle);
}
} // namespace
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index e8d66a2..7eb0ebf 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -4965,6 +4965,9 @@ bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const
if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
return false;
}
+ if (this->GetProperty("BUILD_RPATH")) {
+ return true;
+ }
if (cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config)) {
return !impl->Libraries.empty();
diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx
index c9822d3..a814d16 100644
--- a/Source/cmServerConnection.cxx
+++ b/Source/cmServerConnection.cxx
@@ -30,7 +30,7 @@ void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf)
if (nread >= 0) {
conn->ReadData(std::string(buf->base, buf->base + nread));
} else {
- conn->HandleEof();
+ conn->TriggerShutdown();
}
delete[](buf->base);
@@ -56,6 +56,28 @@ void on_new_connection(uv_stream_t* stream, int status)
conn->Connect(stream);
}
+void on_signal(uv_signal_t* signal, int signum)
+{
+ auto conn = reinterpret_cast<cmServerConnection*>(signal->data);
+ (void)(signum);
+ conn->TriggerShutdown();
+}
+
+void on_signal_close(uv_handle_t* handle)
+{
+ delete reinterpret_cast<uv_signal_t*>(handle);
+}
+
+void on_pipe_close(uv_handle_t* handle)
+{
+ delete reinterpret_cast<uv_pipe_t*>(handle);
+}
+
+void on_tty_close(uv_handle_t* handle)
+{
+ delete reinterpret_cast<uv_tty_t*>(handle);
+}
+
} // namespace
class LoopGuard
@@ -64,19 +86,25 @@ public:
LoopGuard(cmServerConnection* connection)
: Connection(connection)
{
- Connection->mLoop = uv_default_loop();
- if (Connection->mLoop) {
- Connection->mFileMonitor = new cmFileMonitor(Connection->mLoop);
+ this->Connection->mLoop = uv_default_loop();
+ if (!this->Connection->mLoop) {
+ return;
}
+ this->Connection->mFileMonitor =
+ new cmFileMonitor(this->Connection->mLoop);
}
~LoopGuard()
{
- if (Connection->mFileMonitor) {
- delete Connection->mFileMonitor;
+ if (!this->Connection->mLoop) {
+ return;
}
- uv_loop_close(Connection->mLoop);
- Connection->mLoop = nullptr;
+
+ if (this->Connection->mFileMonitor) {
+ delete this->Connection->mFileMonitor;
+ }
+ uv_loop_close(this->Connection->mLoop);
+ this->Connection->mLoop = nullptr;
}
private:
@@ -111,6 +139,16 @@ bool cmServerConnection::ProcessEvents(std::string* errorMessage)
return false;
}
+ this->SIGINTHandler = new uv_signal_t;
+ uv_signal_init(this->mLoop, this->SIGINTHandler);
+ this->SIGINTHandler->data = static_cast<void*>(this);
+ uv_signal_start(this->SIGINTHandler, &on_signal, SIGINT);
+
+ this->SIGHUPHandler = new uv_signal_t;
+ uv_signal_init(this->mLoop, this->SIGHUPHandler);
+ this->SIGHUPHandler->data = static_cast<void*>(this);
+ uv_signal_start(this->SIGHUPHandler, &on_signal, SIGHUP);
+
if (!DoSetup(errorMessage)) {
return false;
}
@@ -162,9 +200,21 @@ void cmServerConnection::ReadData(const std::string& data)
}
}
-void cmServerConnection::HandleEof()
+void cmServerConnection::TriggerShutdown()
{
this->FileMonitor()->StopMonitoring();
+
+ uv_signal_stop(this->SIGINTHandler);
+ uv_signal_stop(this->SIGHUPHandler);
+
+ uv_close(reinterpret_cast<uv_handle_t*>(this->SIGINTHandler),
+ &on_signal_close); // delete handle
+ uv_close(reinterpret_cast<uv_handle_t*>(this->SIGHUPHandler),
+ &on_signal_close); // delete handle
+
+ this->SIGINTHandler = nullptr;
+ this->SIGHUPHandler = nullptr;
+
this->TearDown();
}
@@ -194,30 +244,42 @@ void cmServerConnection::SendGreetings()
Server->PrintHello();
}
+cmServerStdIoConnection::cmServerStdIoConnection()
+{
+ this->Input.tty = nullptr;
+ this->Output.tty = nullptr;
+}
+
bool cmServerStdIoConnection::DoSetup(std::string* errorMessage)
{
(void)(errorMessage);
if (uv_guess_handle(1) == UV_TTY) {
- uv_tty_init(this->Loop(), &this->Input.tty, 0, 1);
- uv_tty_set_mode(&this->Input.tty, UV_TTY_MODE_NORMAL);
- Input.tty.data = this;
- this->ReadStream = reinterpret_cast<uv_stream_t*>(&this->Input.tty);
-
- uv_tty_init(this->Loop(), &this->Output.tty, 1, 0);
- uv_tty_set_mode(&this->Output.tty, UV_TTY_MODE_NORMAL);
- Output.tty.data = this;
- this->WriteStream = reinterpret_cast<uv_stream_t*>(&this->Output.tty);
+ usesTty = true;
+ this->Input.tty = new uv_tty_t;
+ uv_tty_init(this->Loop(), this->Input.tty, 0, 1);
+ uv_tty_set_mode(this->Input.tty, UV_TTY_MODE_NORMAL);
+ Input.tty->data = this;
+ this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.tty);
+
+ this->Output.tty = new uv_tty_t;
+ uv_tty_init(this->Loop(), this->Output.tty, 1, 0);
+ uv_tty_set_mode(this->Output.tty, UV_TTY_MODE_NORMAL);
+ Output.tty->data = this;
+ this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.tty);
} else {
- uv_pipe_init(this->Loop(), &this->Input.pipe, 0);
- uv_pipe_open(&this->Input.pipe, 0);
- Input.pipe.data = this;
- this->ReadStream = reinterpret_cast<uv_stream_t*>(&this->Input.pipe);
-
- uv_pipe_init(this->Loop(), &this->Output.pipe, 0);
- uv_pipe_open(&this->Output.pipe, 1);
- Output.pipe.data = this;
- this->WriteStream = reinterpret_cast<uv_stream_t*>(&this->Output.pipe);
+ usesTty = false;
+ this->Input.pipe = new uv_pipe_t;
+ uv_pipe_init(this->Loop(), this->Input.pipe, 0);
+ uv_pipe_open(this->Input.pipe, 0);
+ Input.pipe->data = this;
+ this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.pipe);
+
+ this->Output.pipe = new uv_pipe_t;
+ uv_pipe_init(this->Loop(), this->Output.pipe, 0);
+ uv_pipe_open(this->Output.pipe, 1);
+ Output.pipe->data = this;
+ this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.pipe);
}
SendGreetings();
@@ -228,26 +290,35 @@ bool cmServerStdIoConnection::DoSetup(std::string* errorMessage)
void cmServerStdIoConnection::TearDown()
{
- uv_close(reinterpret_cast<uv_handle_t*>(this->ReadStream), nullptr);
+ if (usesTty) {
+ uv_close(reinterpret_cast<uv_handle_t*>(this->Input.tty), &on_tty_close);
+ uv_close(reinterpret_cast<uv_handle_t*>(this->Output.tty), &on_tty_close);
+ this->Input.tty = nullptr;
+ this->Output.tty = nullptr;
+ } else {
+ uv_close(reinterpret_cast<uv_handle_t*>(this->Input.pipe), &on_pipe_close);
+ uv_close(reinterpret_cast<uv_handle_t*>(this->Output.pipe),
+ &on_pipe_close);
+ this->Input.pipe = nullptr;
+ this->Input.pipe = nullptr;
+ }
this->ReadStream = nullptr;
- uv_close(reinterpret_cast<uv_handle_t*>(this->WriteStream), nullptr);
this->WriteStream = nullptr;
}
cmServerPipeConnection::cmServerPipeConnection(const std::string& name)
: PipeName(name)
{
- this->ServerPipe.data = nullptr;
- this->ClientPipe.data = nullptr;
}
bool cmServerPipeConnection::DoSetup(std::string* errorMessage)
{
- uv_pipe_init(this->Loop(), &this->ServerPipe, 0);
- this->ServerPipe.data = this;
+ this->ServerPipe = new uv_pipe_t;
+ uv_pipe_init(this->Loop(), this->ServerPipe, 0);
+ this->ServerPipe->data = this;
int r;
- if ((r = uv_pipe_bind(&this->ServerPipe, this->PipeName.c_str())) != 0) {
+ if ((r = uv_pipe_bind(this->ServerPipe, this->PipeName.c_str())) != 0) {
*errorMessage = std::string("Internal Error with ") + this->PipeName +
": " + uv_err_name(r);
return false;
@@ -265,31 +336,34 @@ bool cmServerPipeConnection::DoSetup(std::string* errorMessage)
void cmServerPipeConnection::TearDown()
{
- if (this->WriteStream->data) {
- uv_close(reinterpret_cast<uv_handle_t*>(this->WriteStream), nullptr);
+ if (this->ClientPipe) {
+ uv_close(reinterpret_cast<uv_handle_t*>(this->ClientPipe), &on_pipe_close);
this->WriteStream->data = nullptr;
}
- uv_close(reinterpret_cast<uv_handle_t*>(&this->ServerPipe), nullptr);
+ uv_close(reinterpret_cast<uv_handle_t*>(&this->ServerPipe), &on_pipe_close);
+ this->ClientPipe = nullptr;
+ this->ServerPipe = nullptr;
this->WriteStream = nullptr;
this->ReadStream = nullptr;
}
void cmServerPipeConnection::Connect(uv_stream_t* server)
{
- if (this->ClientPipe.data == this) {
+ if (this->ClientPipe) {
// Accept and close all pipes but the first:
- uv_pipe_t rejectPipe;
+ uv_pipe_t* rejectPipe = new uv_pipe_t;
- uv_pipe_init(this->Loop(), &rejectPipe, 0);
- auto rejecter = reinterpret_cast<uv_stream_t*>(&rejectPipe);
+ uv_pipe_init(this->Loop(), rejectPipe, 0);
+ auto rejecter = reinterpret_cast<uv_stream_t*>(rejectPipe);
uv_accept(server, rejecter);
- uv_close(reinterpret_cast<uv_handle_t*>(rejecter), nullptr);
+ uv_close(reinterpret_cast<uv_handle_t*>(rejecter), &on_pipe_close);
return;
}
- uv_pipe_init(this->Loop(), &this->ClientPipe, 0);
- this->ClientPipe.data = this;
+ this->ClientPipe = new uv_pipe_t;
+ uv_pipe_init(this->Loop(), this->ClientPipe, 0);
+ this->ClientPipe->data = this;
auto client = reinterpret_cast<uv_stream_t*>(&this->ClientPipe);
if (uv_accept(server, client) != 0) {
uv_close(reinterpret_cast<uv_handle_t*>(client), nullptr);
diff --git a/Source/cmServerConnection.h b/Source/cmServerConnection.h
index 78842e7..3efe28d 100644
--- a/Source/cmServerConnection.h
+++ b/Source/cmServerConnection.h
@@ -24,7 +24,7 @@ public:
bool ProcessEvents(std::string* errorMessage);
void ReadData(const std::string& data);
- void HandleEof();
+ void TriggerShutdown();
void WriteData(const std::string& data);
void ProcessNextRequest();
@@ -51,6 +51,8 @@ private:
uv_loop_t* mLoop = nullptr;
cmFileMonitor* mFileMonitor = nullptr;
cmServer* Server = nullptr;
+ uv_signal_t* SIGINTHandler = nullptr;
+ uv_signal_t* SIGHUPHandler = nullptr;
friend class LoopGuard;
};
@@ -58,6 +60,7 @@ private:
class cmServerStdIoConnection : public cmServerConnection
{
public:
+ cmServerStdIoConnection();
bool DoSetup(std::string* errorMessage) override;
void TearDown() override;
@@ -65,10 +68,12 @@ public:
private:
typedef union
{
- uv_tty_t tty;
- uv_pipe_t pipe;
+ uv_tty_t* tty;
+ uv_pipe_t* pipe;
} InOutUnion;
+ bool usesTty = false;
+
InOutUnion Input;
InOutUnion Output;
};
@@ -85,6 +90,6 @@ public:
private:
const std::string PipeName;
- uv_pipe_t ServerPipe;
- uv_pipe_t ClientPipe;
+ uv_pipe_t* ServerPipe = nullptr;
+ uv_pipe_t* ClientPipe = nullptr;
};
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 3d8fdf5..d800ef8 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2518,9 +2518,9 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
std::swap(se[0], se[1]);
}
- // Get the size of the dynamic section header.
- unsigned int count = elf.GetDynamicEntryCount();
- if (count == 0) {
+ // Obtain a copy of the dynamic entries
+ cmELF::DynamicEntryList dentries = elf.GetDynamicEntries();
+ if (dentries.empty()) {
// This should happen only for invalid ELF files where a DT_NULL
// appears before the end of the table.
if (emsg) {
@@ -2536,40 +2536,46 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
zeroSize[i] = se[i]->Size;
}
- // Get the range of file positions corresponding to each entry and
- // the rest of the table after them.
- unsigned long entryBegin[3] = { 0, 0, 0 };
- unsigned long entryEnd[2] = { 0, 0 };
- for (int i = 0; i < se_count; ++i) {
- entryBegin[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection);
- entryEnd[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection + 1);
- }
- entryBegin[se_count] = elf.GetDynamicEntryPosition(count);
-
- // The data are to be written over the old table entries starting at
- // the first one being removed.
- bytesBegin = entryBegin[0];
- unsigned long bytesEnd = entryBegin[se_count];
+ // Get size of one DYNAMIC entry
+ unsigned long const sizeof_dentry =
+ elf.GetDynamicEntryPosition(1) - elf.GetDynamicEntryPosition(0);
- // Allocate a buffer to hold the part of the file to be written.
- // Initialize it with zeros.
- bytes.resize(bytesEnd - bytesBegin, 0);
-
- // Read the part of the DYNAMIC section header that will move.
- // The remainder of the buffer will be left with zeros which
- // represent a DT_NULL entry.
- char* data = &bytes[0];
- for (int i = 0; i < se_count; ++i) {
- // Read data between the entries being removed.
- unsigned long sz = entryBegin[i + 1] - entryEnd[i];
- if (sz > 0 && !elf.ReadBytes(entryEnd[i], sz, data)) {
- if (emsg) {
- *emsg = "Failed to read DYNAMIC section header.";
+ // Adjust the entry list as necessary to remove the run path
+ unsigned long entriesErased = 0;
+ for (cmELF::DynamicEntryList::iterator it = dentries.begin();
+ it != dentries.end();) {
+ if (it->first == cmELF::TagRPath || it->first == cmELF::TagRunPath) {
+ it = dentries.erase(it);
+ entriesErased++;
+ continue;
+ } else {
+ if (cmELF::TagMipsRldMapRel != 0 &&
+ it->first == cmELF::TagMipsRldMapRel) {
+ // Background: debuggers need to know the "linker map" which contains
+ // the addresses each dynamic object is loaded at. Most arches use
+ // the DT_DEBUG tag which the dynamic linker writes to (directly) and
+ // contain the location of the linker map, however on MIPS the
+ // .dynamic section is always read-only so this is not possible. MIPS
+ // objects instead contain a DT_MIPS_RLD_MAP tag which contains the
+ // address where the dyanmic linker will write to (an indirect
+ // version of DT_DEBUG). Since this doesn't work when using PIE, a
+ // relative equivalent was created - DT_MIPS_RLD_MAP_REL. Since this
+ // version contains a relative offset, moving it changes the
+ // calculated address. This may cause the dyanmic linker to write
+ // into memory it should not be changing.
+ //
+ // To fix this, we adjust the value of DT_MIPS_RLD_MAP_REL here. If
+ // we move it up by n bytes, we add n bytes to the value of this tag.
+ it->second += entriesErased * sizeof_dentry;
}
- return false;
+
+ it++;
}
- data += sz;
}
+
+ // Encode new entries list
+ bytes = elf.EncodeDynamicEntries(dentries);
+ bytesBegin = elf.GetDynamicEntryPosition(0);
}
// Open the file for update.
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 54e0bea..13a4744 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -102,6 +102,7 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type,
this->SetPropertyDefault("ANDROID_JAR_DEPENDENCIES", CM_NULLPTR);
this->SetPropertyDefault("ANDROID_ASSETS_DIRECTORIES", CM_NULLPTR);
this->SetPropertyDefault("ANDROID_ANT_ADDITIONAL_OPTIONS", CM_NULLPTR);
+ this->SetPropertyDefault("BUILD_RPATH", CM_NULLPTR);
this->SetPropertyDefault("INSTALL_NAME_DIR", CM_NULLPTR);
this->SetPropertyDefault("INSTALL_RPATH", "");
this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF");
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index d81f59d..6690bfa 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2736,8 +2736,10 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
(*this->BuildFileStream) << cmVS10EscapeXML(artifactDir)
<< "\\</AppxPackageArtifactsDir>\n";
this->WriteString("<ProjectPriFullPath>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir)
- << "\\resources.pri</ProjectPriFullPath>\n";
+ std::string resourcePriFile =
+ this->DefaultArtifactDir + "/resources.pri";
+ this->ConvertToWindowsSlash(resourcePriFile);
+ (*this->BuildFileStream) << resourcePriFile << "</ProjectPriFullPath>\n";
// If we are missing files and we don't have a certificate and
// aren't targeting WP8.0, add a default certificate
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 1fb39ff..8ab17b9 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -163,11 +163,7 @@ int main(int argc, char const* const* argv)
doc.SetSection("Name", cmDocumentationName);
doc.SetSection("Usage", cmDocumentationUsage);
doc.PrependSection("Options", cmDocumentationOptions);
-#ifdef cout
-#undef cout
-#endif
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
-#define cout no_cout_use_cmCTestLog
}
}
diff --git a/Tests/MacRuntimePath/A/CMakeLists.txt b/Tests/MacRuntimePath/A/CMakeLists.txt
index ade0a3c..bf937e6 100644
--- a/Tests/MacRuntimePath/A/CMakeLists.txt
+++ b/Tests/MacRuntimePath/A/CMakeLists.txt
@@ -40,21 +40,30 @@ target_link_libraries(test3 framework)
add_executable(test4 test1.cpp)
target_link_libraries(test4 shared2)
+# executable to test a shared library dependency with build rpath
+add_executable(test5 test1.cpp)
+
+# avoid linking by 'target_link_libraries' so CMake
+# will not be able to set correct RPATH automatically
+add_dependencies(test5 shared)
+target_link_libraries(test5 "$<TARGET_FILE:shared>")
+set_target_properties(test5 PROPERTIES BUILD_RPATH "@loader_path/../lib")
+
set_target_properties(shared shared2 framework PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
-set_target_properties(test1 test2 test3 test4 PROPERTIES
+set_target_properties(test1 test2 test3 test4 test5 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} CONFIG)
set_target_properties(shared shared2 framework PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${CONFIG}
"${CMAKE_CURRENT_BINARY_DIR}/${config}/lib")
- set_target_properties(test1 test2 test3 test4 PROPERTIES
+ set_target_properties(test1 test2 test3 test4 test5 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${CONFIG}
"${CMAKE_CURRENT_BINARY_DIR}/${config}/bin")
endforeach()
-foreach(test test1 test2 test3 test4)
+foreach(test test1 test2 test3 test4 test5)
add_custom_target(${test}_run ALL
COMMAND ${test}
DEPENDS ${test}
diff --git a/Utilities/GitSetup/config b/Utilities/GitSetup/config
index b7d5423..d69a679 100644
--- a/Utilities/GitSetup/config
+++ b/Utilities/GitSetup/config
@@ -1,5 +1,5 @@
[hooks]
- url = http://cmake.org/cmake.git
+ url = https://cmake.org/cmake.git
[ssh]
host = cmake.org
key = id_git_cmake
diff --git a/Utilities/Release/README b/Utilities/Release/README
index ed1d52e..11de1c3 100644
--- a/Utilities/Release/README
+++ b/Utilities/Release/README
@@ -1,7 +1,7 @@
To create a cmake release, make sure the "release" tag is pointing to the
expected git commit:
-http://cmake.org/gitweb?p=cmake.git;a=shortlog;h=refs/heads/release
+https://cmake.org/gitweb?p=cmake.git;a=shortlog;h=refs/heads/release
Then as kitware@hythloth, using an up-to-date CMake:
diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake
index b72fc12..b9447ca 100644
--- a/Utilities/Release/linux64_release.cmake
+++ b/Utilities/Release/linux64_release.cmake
@@ -2,6 +2,7 @@ set(PROCESSORS 4)
set(BOOTSTRAP_ARGS "--docdir=doc/cmake")
set(HOST linux64)
set(MAKE_PROGRAM "make")
+set(CPACK_BINARY_GENERATORS "STGZ TGZ")
set(CC /opt/gcc-6.1.0/bin/gcc)
set(CXX /opt/gcc-6.1.0/bin/g++)
set(CFLAGS "")
diff --git a/Utilities/Release/osx_release.cmake b/Utilities/Release/osx_release.cmake
index 27c820f..88ea39b 100644
--- a/Utilities/Release/osx_release.cmake
+++ b/Utilities/Release/osx_release.cmake
@@ -4,7 +4,7 @@ set(BOOTSTRAP_ARGS "--prefix=/ --docdir=doc/cmake")
set(HOST dragnipur)
set(MAKE_PROGRAM "make")
set(MAKE "${MAKE_PROGRAM} -j5")
-set(CPACK_BINARY_GENERATORS "DragNDrop TGZ TZ")
+set(CPACK_BINARY_GENERATORS "DragNDrop TGZ")
set(CPACK_SOURCE_GENERATORS "TGZ TZ")
set(CPACK_DMG_FORMAT "UDBZ") #build using bzip2 for smaller package size
set(CC clang)