summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--Help/release/3.7.rst2
-rw-r--r--Help/variable/CMAKE_CODELITE_USE_TARGETS.rst5
-rw-r--r--Modules/CPackRPM.cmake68
-rw-r--r--Modules/Platform/Android/ndk-stl-c++.cmake8
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmELF.cxx224
-rw-r--r--Source/cmELF.h23
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx4
-rw-r--r--Source/cmGlobalGenerator.cxx19
-rw-r--r--Source/cmGlobalGenerator.h4
-rw-r--r--Source/cmGlobalVisualStudio15Generator.cxx2
-rw-r--r--Source/cmLocalGenerator.cxx105
-rw-r--r--Source/cmLocalGenerator.h3
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx5
-rw-r--r--Source/cmSystemTools.cxx72
-rw-r--r--Tests/RunCMake/Android/common.cmake4
17 files changed, 287 insertions, 271 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/release/3.7.rst b/Help/release/3.7.rst
index 9794267..3b8ade6 100644
--- a/Help/release/3.7.rst
+++ b/Help/release/3.7.rst
@@ -32,7 +32,7 @@ Generators
with :ref:`Makefile Generators`.
* The :generator:`Visual Studio 15` generator was added. This is
- experimental and based on Preview 4 because this version of VS
+ experimental and based on Preview 5 because this version of VS
has not been released.
* :ref:`Visual Studio Generators` for VS 2010 and above learned to
diff --git a/Help/variable/CMAKE_CODELITE_USE_TARGETS.rst b/Help/variable/CMAKE_CODELITE_USE_TARGETS.rst
index 4aede03..33cdf6c 100644
--- a/Help/variable/CMAKE_CODELITE_USE_TARGETS.rst
+++ b/Help/variable/CMAKE_CODELITE_USE_TARGETS.rst
@@ -3,5 +3,6 @@ CMAKE_CODELITE_USE_TARGETS
Change the way the CodeLite generator creates projectfiles.
-If this variable is set to ``ON`` the generator creates projectfiles
-based on targets rather than projects.
+If this variable evaluates to ``ON`` at the end of the top-level
+``CMakeLists.txt`` file, the generator creates projectfiles based on targets
+rather than projects.
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/Platform/Android/ndk-stl-c++.cmake b/Modules/Platform/Android/ndk-stl-c++.cmake
index 14748a1..cb9fd68 100644
--- a/Modules/Platform/Android/ndk-stl-c++.cmake
+++ b/Modules/Platform/Android/ndk-stl-c++.cmake
@@ -3,7 +3,13 @@ set(_ANDROID_STL_RTTI 1)
set(_ANDROID_STL_EXCEPTIONS 1)
macro(__android_stl_cxx lang filename)
# Add the include directory.
- __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include" 1)
+ if(EXISTS "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include/cstddef")
+ # r12 and below
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include" 1)
+ else()
+ # r13 and above
+ __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/include" 1)
+ endif()
# Add a secondary include directory if it exists.
__android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/android/support/include" 0)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 32578c2..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 20161006)
+set(CMake_VERSION_PATCH 20161007)
#set(CMake_VERSION_RC 1)
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/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index 629c5b6..360c852 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -60,7 +60,6 @@ void cmExtraCodeLiteGenerator::Generate()
// loop projects and locate the root project.
// and extract the information for creating the worspace
// root makefile
- const cmMakefile* rmf = CM_NULLPTR;
for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
it = projectMap.begin();
it != projectMap.end(); ++it) {
@@ -75,7 +74,6 @@ void cmExtraCodeLiteGenerator::Generate()
workspaceFileName = workspaceOutputDir + "/";
workspaceFileName += workspaceProjectName + ".workspace";
this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();
- rmf = it->second[0]->GetMakefile();
;
break;
}
@@ -89,7 +87,7 @@ void cmExtraCodeLiteGenerator::Generate()
xml.Attribute("Name", workspaceProjectName);
bool const targetsAreProjects =
- rmf && rmf->IsOn("CMAKE_CODELITE_USE_TARGETS");
+ this->GlobalGenerator->GlobalSettingIsOn("CMAKE_CODELITE_USE_TARGETS");
std::vector<std::string> ProjectNames;
if (targetsAreProjects) {
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index a446862..7132ade 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1007,6 +1007,25 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
}
}
+const char* cmGlobalGenerator::GetGlobalSetting(std::string const& name) const
+{
+ assert(!this->Makefiles.empty());
+ return this->Makefiles[0]->GetDefinition(name);
+}
+
+bool cmGlobalGenerator::GlobalSettingIsOn(std::string const& name) const
+{
+ assert(!this->Makefiles.empty());
+ return this->Makefiles[0]->IsOn(name);
+}
+
+const char* cmGlobalGenerator::GetSafeGlobalSetting(
+ std::string const& name) const
+{
+ assert(!this->Makefiles.empty());
+ return this->Makefiles[0]->GetSafeDefinition(name);
+}
+
bool cmGlobalGenerator::IgnoreFile(const char* ext) const
{
if (!this->GetLanguageFromExtension(ext).empty()) {
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 4120b52..add2b92 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -194,6 +194,10 @@ public:
cmExportSetMap& GetExportSets() { return this->ExportSets; }
+ const char* GetGlobalSetting(std::string const& name) const;
+ bool GlobalSettingIsOn(std::string const& name) const;
+ const char* GetSafeGlobalSetting(std::string const& name) const;
+
/** Add a file to the manifest of generated targets for a configuration. */
void AddToManifest(std::string const& f);
diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx
index 4d62f2b..a833a5f 100644
--- a/Source/cmGlobalVisualStudio15Generator.cxx
+++ b/Source/cmGlobalVisualStudio15Generator.cxx
@@ -79,7 +79,7 @@ cmGlobalVisualStudio15Generator::cmGlobalVisualStudio15Generator(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\15.0\\Setup\\VC;"
"ProductDir",
vc15Express, cmSystemTools::KeyWOW64_32);
- this->DefaultPlatformToolset = "v140";
+ this->DefaultPlatformToolset = "v141";
this->Version = VS15;
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index b2569a2..2284cf9 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1248,6 +1248,14 @@ void cmLocalGenerator::GetTargetFlags(
linkFlags += this->Makefile->GetSafeDefinition(exportFlagVar);
linkFlags += " ";
}
+
+ std::string cmp0065Flags =
+ this->GetLinkLibsCMP0065(linkLanguage, *target);
+ if (!cmp0065Flags.empty()) {
+ linkFlags += cmp0065Flags;
+ linkFlags += " ";
+ }
+
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
linkFlags += targetLinkFlags;
@@ -1424,59 +1432,15 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
}
cmComputeLinkInformation& cli = *pcli;
- // Collect library linking flags command line options.
- std::string linkLibs;
-
std::string linkLanguage = cli.GetLinkLanguage();
+ std::string linkLibs;
+
std::string libPathFlag =
this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
std::string libPathTerminator =
this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
- // Flags to link an executable to shared libraries.
- if (tgt.GetType() == cmState::EXECUTABLE &&
- this->StateSnapshot.GetState()->GetGlobalPropertyAsBool(
- "TARGET_SUPPORTS_SHARED_LIBS")) {
- bool add_shlib_flags = false;
- switch (tgt.GetPolicyStatusCMP0065()) {
- case cmPolicies::WARN:
- if (!tgt.GetPropertyAsBool("ENABLE_EXPORTS") &&
- this->Makefile->PolicyOptionalWarningEnabled(
- "CMAKE_POLICY_WARNING_CMP0065")) {
- std::ostringstream w;
- /* clang-format off */
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n"
- "For compatibility with older versions of CMake, "
- "additional flags may be added to export symbols on all "
- "executables regardless of their ENABLE_EXPORTS property.";
- /* clang-format on */
- this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
- }
- case cmPolicies::OLD:
- // OLD behavior is to always add the flags
- add_shlib_flags = true;
- break;
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- this->IssueMessage(
- cmake::FATAL_ERROR,
- cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065));
- case cmPolicies::NEW:
- // NEW behavior is to only add the flags if ENABLE_EXPORTS is on
- add_shlib_flags = tgt.GetPropertyAsBool("ENABLE_EXPORTS");
- break;
- }
-
- if (add_shlib_flags) {
- std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
- linkFlagsVar += linkLanguage;
- linkFlagsVar += "_FLAGS";
- linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar);
- linkLibs += " ";
- }
- }
-
// Append the framework search path flags.
std::string fwSearchFlagVar = "CMAKE_";
fwSearchFlagVar += linkLanguage;
@@ -1569,6 +1533,55 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
linkLibraries = fout.str();
}
+std::string cmLocalGenerator::GetLinkLibsCMP0065(
+ std::string const& linkLanguage, cmGeneratorTarget& tgt) const
+{
+ std::string linkFlags;
+
+ // Flags to link an executable to shared libraries.
+ if (tgt.GetType() == cmState::EXECUTABLE &&
+ this->StateSnapshot.GetState()->GetGlobalPropertyAsBool(
+ "TARGET_SUPPORTS_SHARED_LIBS")) {
+ bool add_shlib_flags = false;
+ switch (tgt.GetPolicyStatusCMP0065()) {
+ case cmPolicies::WARN:
+ if (!tgt.GetPropertyAsBool("ENABLE_EXPORTS") &&
+ this->Makefile->PolicyOptionalWarningEnabled(
+ "CMAKE_POLICY_WARNING_CMP0065")) {
+ std::ostringstream w;
+ /* clang-format off */
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n"
+ "For compatibility with older versions of CMake, "
+ "additional flags may be added to export symbols on all "
+ "executables regardless of their ENABLE_EXPORTS property.";
+ /* clang-format on */
+ this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ }
+ case cmPolicies::OLD:
+ // OLD behavior is to always add the flags
+ add_shlib_flags = true;
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ this->IssueMessage(
+ cmake::FATAL_ERROR,
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065));
+ case cmPolicies::NEW:
+ // NEW behavior is to only add the flags if ENABLE_EXPORTS is on
+ add_shlib_flags = tgt.GetPropertyAsBool("ENABLE_EXPORTS");
+ break;
+ }
+
+ if (add_shlib_flags) {
+ std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
+ linkFlagsVar += linkLanguage;
+ linkFlagsVar += "_FLAGS";
+ linkFlags = this->Makefile->GetSafeDefinition(linkFlagsVar);
+ }
+ }
+ return linkFlags;
+}
+
void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
cmGeneratorTarget const* target,
const std::string& lang,
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 703a507..e16ddab 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -82,6 +82,9 @@ public:
return this->GlobalGenerator;
}
+ std::string GetLinkLibsCMP0065(std::string const& linkLanguage,
+ cmGeneratorTarget& tgt) const;
+
cmState* GetState() const;
cmState::Snapshot GetStateSnapshot() const;
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index ff97696..79168d8 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -192,6 +192,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->LocalGenerator->AppendFlags(
linkFlags, this->Makefile->GetDefinition(export_flag_var));
}
+
+ this->LocalGenerator->AppendFlags(linkFlags,
+ this->LocalGenerator->GetLinkLibsCMP0065(
+ linkLanguage, *this->GeneratorTarget));
+
if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) {
this->LocalGenerator->AppendFlags(linkFlags, " -Wl,--no-as-needed");
}
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/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake
index 7eac5d6..6ea0909 100644
--- a/Tests/RunCMake/Android/common.cmake
+++ b/Tests/RunCMake/Android/common.cmake
@@ -17,8 +17,8 @@ foreach(f
endif()
endforeach()
-string(APPEND CMAKE_C_FLAGS " -Werror")
-string(APPEND CMAKE_CXX_FLAGS " -Werror")
+string(APPEND CMAKE_C_FLAGS " -Werror -Wno-attributes")
+string(APPEND CMAKE_CXX_FLAGS " -Werror -Wno-attributes")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-no-undefined")
if(CMAKE_ANDROID_NDK)