diff options
author | Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> | 2021-06-23 08:24:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-06-24 14:57:51 (GMT) |
commit | 5dfa3ddbe592add43e2985dad772f6aa44d37c0b (patch) | |
tree | 0e49df76386e2c3399e6f34ecefc8ad35dd718d5 /Source/CMakeLists.txt | |
parent | 0da1540aaa8d36145329572938aeec6c86fb1ee7 (diff) | |
download | CMake-5dfa3ddbe592add43e2985dad772f6aa44d37c0b.zip CMake-5dfa3ddbe592add43e2985dad772f6aa44d37c0b.tar.gz CMake-5dfa3ddbe592add43e2985dad772f6aa44d37c0b.tar.bz2 |
cmELF: Allow building without system ELF headers
Use ELF headers vendored in `Utilities/cmelf` to get the ELF constants
and types. Using the same ELF definition header for all compilation
targets allows removing some #ifdefs depending on the host OS since we
know all required ELF constants will always be present. To reduce the
size of this commit, the CMake_USE_ELF_PARSER definite will be removed
in a separate commit.
This allows me to use CMAKE_BUILD_WITH_INSTALL_RPATH=False and the Ninja
generator on macOS, whereas before it would always give me the following
error message (despite cross-compiling for an ELF-based platform):
```
The install of the <name> target requires changing an RPATH from
the build tree, but this is not supported with the Ninja generator unless
on an ELF-based platform. The CMAKE_BUILD_WITH_INSTALL_RPATH variable may
be set to avoid this relinking step.
```
Diffstat (limited to 'Source/CMakeLists.txt')
-rw-r--r-- | Source/CMakeLists.txt | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9a18184..39e4a9d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -10,36 +10,8 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "QNX") endif() include(CheckIncludeFile) -# Check if we can build support for ELF parsing. -if(WIN32) - set(HAVE_ELF_H 0) -elseif(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") - CHECK_INCLUDE_FILES("stdint.h;elf_abi.h" HAVE_ELF_H) -else() - CHECK_INCLUDE_FILE("elf.h" HAVE_ELF_H) -endif() -if(HAVE_ELF_H) - set(CMake_USE_ELF_PARSER 1) -elseif(HAIKU) - # On Haiku, we need to include elf32.h from the private headers - set(CMake_HAIKU_INCLUDE_DIRS - /boot/system/develop/headers/private/system - /boot/system/develop/headers/private/system/arch/x86 - ) - - set(CMAKE_REQUIRED_INCLUDES ${CMake_HAIKU_INCLUDE_DIRS}) - CHECK_INCLUDE_FILE("elf32.h" HAVE_ELF32_H) - unset(CMAKE_REQUIRED_INCLUDES) - if(HAVE_ELF32_H) - set(CMake_USE_ELF_PARSER 1) - else() - unset(CMake_HAIKU_INCLUDE_DIRS) - set(CMake_USE_ELF_PARSER) - endif() -else() - set(CMake_USE_ELF_PARSER) -endif() +set(CMake_USE_ELF_PARSER 1) if(NOT CMake_DEFAULT_RECURSION_LIMIT) if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST}) @@ -111,7 +83,7 @@ include_directories( ${CMake_HAIKU_INCLUDE_DIRS} ) -# Check if we can build the ELF parser. +# The ELF parser can be built on all platforms. if(CMake_USE_ELF_PARSER) set(ELF_SRCS cmELF.h cmELF.cxx) endif() |