diff options
| author | Alexander Golubev <fatzer2@gmail.com> | 2025-10-03 10:48:01 +0300 |
|---|---|---|
| committer | Alexander Golubev <fatzer2@gmail.com> | 2025-10-03 11:50:33 +0300 |
| commit | 47ca6398b7cfa9c8f8d41f736162cd8232853db7 (patch) | |
| tree | 7b9bdc229f46ec3d06f3b01968f469858dcf3f58 /CMakeLists.txt | |
| parent | f12839f5bbc48e51c4873478477be5b33da1e4a5 (diff) | |
| download | libr-47ca6398.tar.gz libr-47ca6398.zip | |
Use compilation config-time checks instead of linker versionr14.1.5
To rely on current linker's version to determine the libbfd version is
unreliable. In particular it's likely to yield wrong result in next
use-cases:
- cross-compilations
- build with non-GNU toolchain
- just build with another linker version
Unfortunately libbfd doesn't provide a reliable way to retrieve version
information, so we will have to check for features in specific versions
we are interested in.
Note: this essentially reverts most of the changes introduced by
c57eae31615bc70072c7e99d712c2285817bd2e5.
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit 8380fc26a471d64bcddc38a2bce9442f6386b805)
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cdc124..f7f489d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ set( PACKAGE_VERSION 0.7.0 ) include( FindPkgConfig ) include( FindThreads ) +include( CheckCSourceCompiles ) include( CheckIncludeFile ) include( CheckFunctionExists ) include( CheckLibraryExists ) @@ -59,26 +60,20 @@ option( WITH_GTK "Build support for GTK" ON ) #### configure checks ########################### if( WITH_BACKEND_LIBBFD ) - message( STATUS "Checking linker version" ) - execute_process( - COMMAND ${CMAKE_LINKER} --version - OUTPUT_VARIABLE _linker_version - ERROR_VARIABLE _linker_version - ) - string( REGEX REPLACE "^GNU [^\n]* ([^ ]*)\n.*" "\\1" LINKER_VERSION ${_linker_version} ) - string( REGEX MATCH "^([0-9]+)\\.([0-9]+)(\\.([0-9]+))?.*" LINKER_VERSION_MATCH ${LINKER_VERSION} ) - math( EXPR LINKER_VERSION_MAJOR "${CMAKE_MATCH_1}+0" ) - math( EXPR LINKER_VERSION_MINOR "${CMAKE_MATCH_2}+0" ) - math( EXPR LINKER_VERSION_PATCH "${CMAKE_MATCH_4}+0" ) - math( EXPR LINKER_VERSION_C "(${LINKER_VERSION_MAJOR}*1000000) + (${LINKER_VERSION_MINOR}*1000) + ${LINKER_VERSION_PATCH}" ) - set( LINKER_VERSION_C ${LINKER_VERSION_C} CACHE INTERNAL "Linker version as code number" ) - message( STATUS "Checking linker version - ${LINKER_VERSION}" ) - tde_save_and_set( CMAKE_REQUIRED_DEFINITIONS "-DPACKAGE" "-DPACKAGE_VERSION" ) check_include_file( bfd.h HAVE_BFD_H ) if( NOT HAVE_BFD_H ) tde_message_fatal( "Could not find libbfd header file (bfd.h)!\nThis file is usually included in the package binutils-dev." ) endif( NOT HAVE_BFD_H ) + tde_save_and_set( CMAKE_REQUIRED_LIBRARIES "bfd" ) + check_symbol_exists( bfd_asymbol_section bfd.h HAVE_BFD_2_34 ) + check_c_source_compiles( + "#include <bfd.h> + int main() { bfd *ihandle, *ohandle; asection *iscn, *oscn; + bfd_copy_private_section_data(ihandle, iscn, ohandle, oscn, NULL); + }" + HAVE_BFD_2_45) + tde_restore( CMAKE_REQUIRED_LIBRARIES ) tde_restore( CMAKE_REQUIRED_DEFINITIONS ) set( BACKEND_LIBRARIES "-lbfd" ) set( LIBR_BACKEND "bfd" ) |
