From 0a2f5a792977b640e4d41f96f0523f416fac7359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Mon, 11 Jul 2022 18:16:01 +0200 Subject: Add a check for a pkg-config package named libmad next to mad, for detection of library libmad >= 0.16.x (Tenacity's fork). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split configuration tests into separate files. Fill PC_LIB_REQUIRE list during tests. Signed-off-by: Slávek Banko --- flow/gsl/CMakeLists.txt | 93 +--------------------------------- flow/gsl/ConfigureChecks.cmake | 112 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 91 deletions(-) create mode 100644 flow/gsl/ConfigureChecks.cmake (limited to 'flow') diff --git a/flow/gsl/CMakeLists.txt b/flow/gsl/CMakeLists.txt index e8e9576..b3370fd 100644 --- a/flow/gsl/CMakeLists.txt +++ b/flow/gsl/CMakeLists.txt @@ -9,97 +9,9 @@ # ################################################# -include( CheckCSourceCompiles ) +##### configure checks - -##### check for ogg/vorbis ###################### - -set( GSL_HAVE_OGGVORBIS 0 ) -if( WITH_VORBIS ) - - pkg_search_module( VORBIS vorbis ) - - if( VORBIS_FOUND ) - - pkg_search_module( VORBISFILE vorbisfile ) - - if( VORBISFILE_FOUND ) - - set( GSL_HAVE_OGGVORBIS 1 ) - - set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ) - set( CMAKE_REQUIRED_LIBRARIES ${VORBISFILE_LIBRARIES} ) - check_c_source_compiles( - "#include - int main() { ov_read_float(0,0,0); return 0; } " - GSL_HAVE_OGGVORBIS_RC3 ) - if( NOT GSL_HAVE_OGGVORBIS_RC3 ) - set( GSL_HAVE_OGGVORBIS_RC3 0 ) - endif( NOT GSL_HAVE_OGGVORBIS_RC3 ) - set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} ) - - else( VORBISFILE_FOUND ) - - message(FATAL_ERROR "\nOgg/Vorbis support are requested, but `libvorbisfile` not found" ) - - endif( VORBISFILE_FOUND ) - - else( VORBIS_FOUND ) - - message(FATAL_ERROR "\nOgg/Vorbis support are requested, but `libvorbis` but found" ) - - endif( VORBIS_FOUND ) - -endif( WITH_VORBIS ) - - -##### check for libmad MPEG decoder ############# - -set( GSL_HAVE_LIBMAD 0 ) -if( WITH_MAD ) - - pkg_search_module( MAD mad ) - - if( MAD_FOUND ) - set( GSL_HAVE_LIBMAD 1 ) - else( MAD_FOUND ) - find_library( MAD_LIBRARIES NAMES mad ) - find_path( MAD_INCLUDE_DIRS mad.h ) - if( NOT MAD_LIBRARIES ) - message(FATAL_ERROR "\nMAD support is requested, but `libmad` not found" ) - endif( NOT MAD_LIBRARIES ) - endif( MAD_FOUND ) - -endif( WITH_MAD ) - - -##### check for some type sizes ################# - -include( CheckTypeSize ) - -check_type_size( pthread_mutex_t GSL_SIZEOF_PTH_MUTEX_T ) -check_type_size( pthread_cond_t GSL_SIZEOF_PTH_COND_T ) -check_type_size( intmax_t GSL_SIZEOF_STD_INTMAX_T ) - -set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ) -set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ) -check_c_source_compiles( - "#define _XOPEN_SOURCE 500 - #include - int main() - { - int (*attr_settype) (pthread_mutexattr_t *__attr, int __kind) = pthread_mutexattr_settype; - int val = PTHREAD_MUTEX_RECURSIVE; attr_settype = 0; val = 0; - return 0; - }" - GSL_HAVE_MUTEXATTR_SETTYPE ) - if( NOT GSL_HAVE_MUTEXATTR_SETTYPE ) - set( GSL_HAVE_MUTEXATTR_SETTYPE 0 ) - endif( NOT GSL_HAVE_MUTEXATTR_SETTYPE ) -set( CMAKE_REQUIRED_LIBRARIES ${bak_CMAKE_REQUIRED_LIBRARIES} ) - -set( GSL_USE_GSL_GLIB 1 ) -set( GSL_USE_ARTS_THREADS 1 ) +include( ConfigureChecks.cmake ) ##### write configuration ####################### @@ -152,4 +64,3 @@ tde_add_library( ${target} STATIC_PIC LINK ${GLIB2_LIBRARIES} ${GTHREAD2_LIBRARIES} ${VORBISFILE_LIBRARIES} ${VORBIS_LIBRARIES} ${MAD_LIBRARIES} DESTINATION ${LIB_INSTALL_DIR} ) - diff --git a/flow/gsl/ConfigureChecks.cmake b/flow/gsl/ConfigureChecks.cmake new file mode 100644 index 0000000..f0a9dee --- /dev/null +++ b/flow/gsl/ConfigureChecks.cmake @@ -0,0 +1,112 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include( CheckCSourceCompiles ) +include( CheckTypeSize ) + + +##### check for ogg/vorbis ###################### + +set( GSL_HAVE_OGGVORBIS 0 ) +if( WITH_VORBIS ) + + pkg_search_module( VORBIS vorbis ) + + if( VORBIS_FOUND ) + + pkg_search_module( VORBISFILE vorbisfile ) + + if( VORBISFILE_FOUND ) + + set( GSL_HAVE_OGGVORBIS 1 ) + + tde_save_and_set( CMAKE_REQUIRED_LIBRARIES ${VORBISFILE_LIBRARIES} ) + check_c_source_compiles( + "#include + int main() { ov_read_float(0,0,0); return 0; } " + GSL_HAVE_OGGVORBIS_RC3 ) + if( NOT GSL_HAVE_OGGVORBIS_RC3 ) + set( GSL_HAVE_OGGVORBIS_RC3 0 ) + endif( NOT GSL_HAVE_OGGVORBIS_RC3 ) + tde_restore( CMAKE_REQUIRED_LIBRARIES ) + + list( APPEND PC_LIB_REQUIRE "vorbis" "vorbisfile" ) + + else( VORBISFILE_FOUND ) + + tde_message_fatal( "Ogg/Vorbis support are requested, but `libvorbisfile` not found" ) + + endif( VORBISFILE_FOUND ) + + else( VORBIS_FOUND ) + + tde_message_fafal( "Ogg/Vorbis support are requested, but `libvorbis` but found" ) + + endif( VORBIS_FOUND ) + +endif( WITH_VORBIS ) + + +##### check for libmad MPEG decoder ############# + +set( GSL_HAVE_LIBMAD 0 ) +if( WITH_MAD ) + + pkg_search_module( MAD libmad ) + set( MAD_MODULE_NAME "libmad" ) + if( NOT MAD_FOUND ) + pkg_search_module( MAD mad ) + set( MAD_MODULE_NAME "mad" ) + endif() + + if( MAD_FOUND ) + set( GSL_HAVE_LIBMAD 1 ) + list( APPEND PC_LIB_REQUIRE ${MAD_MODULE_NAME} ) + else( MAD_FOUND ) + find_library( MAD_LIBRARIES NAMES mad ) + find_path( MAD_INCLUDE_DIRS mad.h ) + if( NOT MAD_LIBRARIES ) + tde_message_fatal( "MAD support is requested, but `libmad` not found" ) + endif( NOT MAD_LIBRARIES ) + endif( MAD_FOUND ) + +endif( WITH_MAD ) + + +##### check for some type sizes ################# + +check_type_size( pthread_mutex_t GSL_SIZEOF_PTH_MUTEX_T ) +check_type_size( pthread_cond_t GSL_SIZEOF_PTH_COND_T ) +check_type_size( intmax_t GSL_SIZEOF_STD_INTMAX_T ) + +tde_save_and_set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ) +check_c_source_compiles( + "#define _XOPEN_SOURCE 500 + #include + int main() + { + int (*attr_settype) (pthread_mutexattr_t *__attr, int __kind) = pthread_mutexattr_settype; + int val = PTHREAD_MUTEX_RECURSIVE; attr_settype = 0; val = 0; + return 0; + }" + GSL_HAVE_MUTEXATTR_SETTYPE ) + if( NOT GSL_HAVE_MUTEXATTR_SETTYPE ) + set( GSL_HAVE_MUTEXATTR_SETTYPE 0 ) + endif( NOT GSL_HAVE_MUTEXATTR_SETTYPE ) +tde_restore( CMAKE_REQUIRED_LIBRARIES ) + +set( GSL_USE_GSL_GLIB 1 ) +set( GSL_USE_ARTS_THREADS 1 ) + + +##### save cached value of required packages #### + +set( PC_LIB_REQUIRE "${PC_LIB_REQUIRE}" CACHE INTERNAL "List of required packages" FORCE ) -- cgit v1.2.1