diff options
| -rw-r--r-- | CMakeLists.txt | 63 | ||||
| -rw-r--r-- | ConfigureChecks.cmake | 86 |
2 files changed, 89 insertions, 60 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b90b14..1f1d005 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,7 @@ tde_setup_paths( ) ##### optional stuff ############################ +option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ON ) option( WITH_BACKEND_LIBBFD "Build with libbfd backend" ON ) option( WITH_BACKEND_LIBELF "Build with libelf backend" OFF ) option( WITH_BACKEND_READONLY "Build with read-only backend" OFF ) @@ -57,68 +58,10 @@ option( WITH_GTK "Build support for GTK" OFF ) # It uses weak linkage, so gtk will be required during build # only and not strictly necessary during runtime. + #### configure checks ########################### -if( WITH_BACKEND_LIBBFD ) - 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" ) - set( BACKEND_NAME "libbfd" ) - - check_include_file( libiberty.h HAVE_LIBIBERTY_H ) - if( HAVE_LIBIBERTY_H ) - list( APPEND BACKEND_LIBRARIES "-liberty" ) - endif( HAVE_LIBIBERTY_H ) - -elseif( WITH_BACKEND_LIBELF ) - # Is libelf 0.8.2 safe enough? testing is currently on 0.8.6 - pkg_search_module( BACKEND libelf>=0.8.2 ) - if( NOT BACKEND_FOUND ) - tde_message_fatal( "libelf >= 0.8.2 are required, but not found on your system" ) - endif( NOT BACKEND_FOUND ) - set( LIBR_BACKEND "elf" ) - set( BACKEND_NAME "libelf" ) - -elseif( WITH_BACKEND_READONLY ) - set( BACKEND_NAME "readonly" ) - set( LIBR_BACKEND "ro" ) - -else( ) - tde_message_fatal( "Backend is not selected, cannot build." ) -endif( ) - - -find_package( ZLIB ) -if( NOT ZLIB_FOUND ) - tde_message_fatal( "zlib are required, but not found on your system" ) -endif( NOT ZLIB_FOUND ) - -if( WITH_GTK ) - pkg_search_module( GTK gtk+-2.0 ) - if( NOT GTK_FOUND ) - tde_message_fatal( "gtk2 is required but was not found on your system" ) - endif( ) -endif( WITH_GTK ) - -if( UNIX ) - set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden" ) -endif( UNIX ) - -message( STATUS "Ready to build with backend ${BACKEND_NAME}" ) +include( ConfigureChecks.cmake ) #### pkg-config ################################# diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake new file mode 100644 index 0000000..3590495 --- /dev/null +++ b/ConfigureChecks.cmake @@ -0,0 +1,86 @@ +################################################# +# +# (C) 2014 Slávek Banko +# slavek (DOT) banko (AT) axis.cz +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + + +# required stuff + +tde_setup_compiler_flags( ) + +include(TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) + +tde_setup_largefiles( ) + +if( WITH_GCC_VISIBILITY ) + tde_setup_gcc_visibility( ) +endif( ) + + +# check backend + +if( WITH_BACKEND_LIBBFD ) + 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" ) + set( BACKEND_NAME "libbfd" ) + + check_include_file( libiberty.h HAVE_LIBIBERTY_H ) + if( HAVE_LIBIBERTY_H ) + list( APPEND BACKEND_LIBRARIES "-liberty" ) + endif( HAVE_LIBIBERTY_H ) + +elseif( WITH_BACKEND_LIBELF ) + # Is libelf 0.8.2 safe enough? testing is currently on 0.8.6 + pkg_search_module( BACKEND libelf>=0.8.2 ) + if( NOT BACKEND_FOUND ) + tde_message_fatal( "libelf >= 0.8.2 are required, but not found on your system" ) + endif( NOT BACKEND_FOUND ) + set( LIBR_BACKEND "elf" ) + set( BACKEND_NAME "libelf" ) + +elseif( WITH_BACKEND_READONLY ) + set( BACKEND_NAME "readonly" ) + set( LIBR_BACKEND "ro" ) + +else( ) + tde_message_fatal( "Backend is not selected, cannot build." ) +endif( ) + + +# check other libraries + +find_package( ZLIB ) +if( NOT ZLIB_FOUND ) + tde_message_fatal( "zlib are required, but not found on your system" ) +endif( NOT ZLIB_FOUND ) + +if( WITH_GTK ) + pkg_search_module( GTK gtk+-2.0 ) + if( NOT GTK_FOUND ) + tde_message_fatal( "gtk2 is required but was not found on your system" ) + endif( ) +endif( WITH_GTK ) + +message( STATUS "Ready to build with backend ${BACKEND_NAME}" ) |
