mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-11 21:31:18 +00:00
Fixed OpenMP detection and building, better PkgConfigHelpers.cmake
This commit is contained in:
parent
054685fa67
commit
6a0d838f33
4 changed files with 72 additions and 48 deletions
|
@ -191,6 +191,7 @@ if ( NOT HAVE_LONG_LONG AND NOT MSVC)
|
|||
message ( FATAL_ERROR "Your compiler does not support intrinsic type 'long long'. Unable to compile fluidsynth." )
|
||||
endif ()
|
||||
|
||||
include ( CMakePrintHelpers ) # for cmake_print_properties() and cmake_print_variables()
|
||||
include ( TestInline )
|
||||
include ( TestVLA )
|
||||
include ( TestBigEndian )
|
||||
|
@ -525,8 +526,7 @@ else(NOT enable-pkgconfig)
|
|||
message ( WARNING "Your version of glib is very old. This may cause problems with fluidsynth's sample cache on Windows. Consider updating to glib 2.26 or newer!" )
|
||||
endif ( GLIB_glib-2.0_VERSION AND GLIB_glib-2.0_VERSION VERSION_LESS "2.26.0" )
|
||||
|
||||
include ( UnsetPkgConfig )
|
||||
include ( PkgConfigHelpers )
|
||||
include ( PkgConfigHelpers ) # has unset_pkg_config()
|
||||
|
||||
# Optional features
|
||||
unset ( LIBSNDFILE_SUPPORT CACHE )
|
||||
|
@ -535,10 +535,11 @@ else(NOT enable-pkgconfig)
|
|||
pkg_check_modules ( LIBSNDFILE sndfile>=1.0.0 IMPORTED_TARGET )
|
||||
set ( LIBSNDFILE_SUPPORT ${LIBSNDFILE_FOUND} )
|
||||
if ( LIBSNDFILE_SUPPORT )
|
||||
message (DEBUG "LIBSNDFILE_STATIC_LIBRARIES: ${LIBSNDFILE_STATIC_LIBRARIES}")
|
||||
message (DEBUG "LIBSNDFILE_STATIC_LINK_LIBRARIES: ${LIBSNDFILE_STATIC_LINK_LIBRARIES}")
|
||||
message (DEBUG "LIBSNDFILE_STATIC_LDFLAGS: ${LIBSNDFILE_STATIC_LDFLAGS}")
|
||||
message (DEBUG "LIBSNDFILE_STATIC_LDFLAGS_OTHER: ${LIBSNDFILE_STATIC_LDFLAGS_OTHER}")
|
||||
#[[ cmake_print_variables (
|
||||
LIBSNDFILE_STATIC_LIBRARIES
|
||||
LIBSNDFILE_STATIC_LINK_LIBRARIES
|
||||
LIBSNDFILE_STATIC_LDFLAGS
|
||||
LIBSNDFILE_STATIC_LDFLAGS_OTHER ) ]]
|
||||
if ( LIBSNDFILE_STATIC_LIBRARIES MATCHES "vorbis" OR
|
||||
LIBSNDFILE_STATIC_LDFLAGS MATCHES "vorbis" OR
|
||||
LIBSNDFILE_STATIC_LDFLAGS_OTHER MATCHES "vorbis" )
|
||||
|
@ -546,6 +547,12 @@ else(NOT enable-pkgconfig)
|
|||
else ()
|
||||
message ( NOTICE "Seems like libsndfile was compiled without OGG/Vorbis support." )
|
||||
endif ()
|
||||
#[[ cmake_print_properties( TARGETS PkgConfig::LIBSNDFILE
|
||||
PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
INTERFACE_LINK_OPTIONS
|
||||
INTERFACE_LINK_LIBRARIES ) ]]
|
||||
sanitize_target_dirs(PkgConfig::LIBSNDFILE)
|
||||
endif ( LIBSNDFILE_SUPPORT )
|
||||
else ( enable-libsndfile )
|
||||
|
@ -634,6 +641,13 @@ else(NOT enable-pkgconfig)
|
|||
pkg_check_modules ( LIBINSTPATCH libinstpatch-1.0>=1.1.0 IMPORTED_TARGET )
|
||||
set ( LIBINSTPATCH_SUPPORT ${LIBINSTPATCH_FOUND} )
|
||||
if (LIBINSTPATCH_SUPPORT)
|
||||
#[[ cmake_print_properties( TARGETS PkgConfig::LIBINSTPATCH
|
||||
PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
INTERFACE_LINK_DIRECTORIES
|
||||
INTERFACE_LINK_OPTIONS
|
||||
INTERFACE_LINK_LIBRARIES ) ]]
|
||||
sanitize_target_dirs(PkgConfig::LIBINSTPATCH)
|
||||
endif()
|
||||
endif ( enable-libinstpatch )
|
||||
|
@ -716,10 +730,20 @@ if ( enable-threads )
|
|||
endif ( enable-threads )
|
||||
|
||||
unset ( HAVE_OPENMP CACHE )
|
||||
find_package ( OpenMP 4.0 QUIET )
|
||||
find_package ( OpenMP QUIET )
|
||||
if ( OpenMP_FOUND OR OpenMP_C_FOUND )
|
||||
message(STATUS "Found OpenMP ${OpenMP_C_VERSION} ${OpenMP_C_SPEC_DATE}")
|
||||
set ( HAVE_OPENMP 1 )
|
||||
message(STATUS "Found OpenMP version: ${OpenMP_C_VERSION} date: ${OpenMP_C_SPEC_DATE}")
|
||||
if ( TARGET OpenMP::OpenMP_C AND (( NOT OpenMP_C_SPEC_DATE LESS "201307" ) OR NOT ( OpenMP_C_VERSION VERSION_LESS "4.0" )) )
|
||||
#[[ cmake_print_properties( TARGETS OpenMP::OpenMP_C
|
||||
PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
INTERFACE_LINK_OPTIONS
|
||||
INTERFACE_LINK_LIBRARIES ) ]]
|
||||
set ( HAVE_OPENMP 1 )
|
||||
else()
|
||||
message(STATUS " OpenMP version is not supported. Feature disabled.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# manipulate some variables to setup a proper test env
|
||||
|
|
|
@ -1,41 +1,37 @@
|
|||
macro(sanitize_target_dirs target)
|
||||
if (TARGET ${target})
|
||||
#message(DEBUG "sanitize_target(${target})")
|
||||
macro ( sanitize_property_dirs target property )
|
||||
set(_cleandirs)
|
||||
get_target_property(_dirs ${target} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(_dirs ${target} ${property})
|
||||
if(_dirs)
|
||||
foreach(_d ${_dirs})
|
||||
foreach(_d IN LISTS _dirs)
|
||||
if(EXISTS ${_d})
|
||||
list(APPEND _cleandirs ${_d})
|
||||
else()
|
||||
message(DEBUG "removing spurious directory ${_d} from property ${property} of target ${target}")
|
||||
endif()
|
||||
endforeach()
|
||||
set_property(TARGET ${target}
|
||||
PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_cleandirs})
|
||||
set_property(TARGET ${target} PROPERTY ${property} ${_cleandirs})
|
||||
endif()
|
||||
set(_cleandirs)
|
||||
get_target_property(_dirs ${target} INTERFACE_LINK_DIRECTORIES)
|
||||
if(_dirs)
|
||||
foreach(_d ${_dirs})
|
||||
if(EXISTS ${_d})
|
||||
list(APPEND _cleandirs ${_d})
|
||||
endif()
|
||||
endforeach()
|
||||
set_property(TARGET ${target}
|
||||
PROPERTY INTERFACE_LINK_DIRECTORIES ${_cleandirs})
|
||||
endif()
|
||||
endif()
|
||||
endmacro(sanitize_target_dirs)
|
||||
endmacro ( sanitize_property_dirs )
|
||||
|
||||
macro(generate_pkgconfig_spec template outfile target)
|
||||
macro ( sanitize_target_dirs target )
|
||||
if (TARGET ${target})
|
||||
message(DEBUG "performing sanitize_target_dirs(${target})")
|
||||
sanitize_property_dirs( ${target} INTERFACE_INCLUDE_DIRECTORIES )
|
||||
sanitize_property_dirs( ${target} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES )
|
||||
sanitize_property_dirs( ${target} INTERFACE_LINK_DIRECTORIES )
|
||||
endif()
|
||||
endmacro ( sanitize_target_dirs )
|
||||
|
||||
macro ( generate_pkgconfig_spec template outfile target )
|
||||
#message(DEBUG "generate_pkgconfig_spec: ${outfile} from template: ${template}")
|
||||
if (TARGET ${target})
|
||||
# retrieve all the private libs we depend on
|
||||
get_target_property (_libs ${target} INTERFACE_LINK_LIBRARIES)
|
||||
set(_cleanlibs)
|
||||
foreach(_lib ${_libs})
|
||||
foreach(_lib IN LISTS _libs)
|
||||
if (TARGET ${_lib})
|
||||
get_target_property(_tlibs ${_lib} INTERFACE_LINK_LIBRARIES)
|
||||
foreach(_clib ${_tlibs})
|
||||
foreach(_clib IN LISTS _tlibs)
|
||||
get_filename_component(_name "${_clib}" NAME)
|
||||
string(REGEX REPLACE "^lib" "" _clib ${_name})
|
||||
string(REGEX REPLACE ".so$" "" _clib ${_clib})
|
||||
|
@ -64,5 +60,19 @@ macro(generate_pkgconfig_spec template outfile target)
|
|||
|
||||
configure_file ( ${template} ${outfile} IMMEDIATE @ONLY)
|
||||
endif()
|
||||
endmacro ( generate_pkgconfig_spec )
|
||||
|
||||
endmacro(generate_pkgconfig_spec)
|
||||
macro ( unset_pkg_config _prefix )
|
||||
unset ( ${_prefix}_VERSION CACHE )
|
||||
unset ( ${_prefix}_PREFIX CACHE )
|
||||
unset ( ${_prefix}_CFLAGS CACHE )
|
||||
unset ( ${_prefix}_CFLAGS_OTHER CACHE )
|
||||
unset ( ${_prefix}_LDFLAGS CACHE )
|
||||
unset ( ${_prefix}_LDFLAGS_OTHER CACHE )
|
||||
unset ( ${_prefix}_LIBRARIES CACHE )
|
||||
unset ( ${_prefix}_INCLUDEDIR CACHE )
|
||||
unset ( ${_prefix}_INCLUDE_DIRS CACHE )
|
||||
unset ( ${_prefix}_LIBDIR CACHE )
|
||||
unset ( ${_prefix}_LIBRARY_DIRS CACHE )
|
||||
unset ( __pkg_config_checked_${_prefix} CACHE )
|
||||
endmacro ( unset_pkg_config )
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
macro ( unset_pkg_config _prefix )
|
||||
unset ( ${_prefix}_VERSION CACHE )
|
||||
unset ( ${_prefix}_PREFIX CACHE )
|
||||
unset ( ${_prefix}_CFLAGS CACHE )
|
||||
unset ( ${_prefix}_CFLAGS_OTHER CACHE )
|
||||
unset ( ${_prefix}_LDFLAGS CACHE )
|
||||
unset ( ${_prefix}_LDFLAGS_OTHER CACHE )
|
||||
unset ( ${_prefix}_LIBRARIES CACHE )
|
||||
unset ( ${_prefix}_INCLUDEDIR CACHE )
|
||||
unset ( ${_prefix}_INCLUDE_DIRS CACHE )
|
||||
unset ( ${_prefix}_LIBDIR CACHE )
|
||||
unset ( ${_prefix}_LIBRARY_DIRS CACHE )
|
||||
unset ( __pkg_config_checked_${_prefix} CACHE )
|
||||
endmacro ( unset_pkg_config )
|
|
@ -331,7 +331,7 @@ target_link_libraries ( libfluidsynth-OBJ PUBLIC
|
|||
${LIBFLUID_LIBS}
|
||||
)
|
||||
|
||||
if ( TARGET OpenMP::OpenMP_C )
|
||||
if ( TARGET OpenMP::OpenMP_C AND HAVE_OPENMP )
|
||||
target_link_libraries ( libfluidsynth-OBJ PUBLIC OpenMP::OpenMP_C )
|
||||
endif()
|
||||
|
||||
|
@ -458,6 +458,10 @@ target_link_libraries ( fluidsynth PRIVATE
|
|||
${FLUID_LIBS}
|
||||
)
|
||||
|
||||
if ( TARGET OpenMP::OpenMP_C AND HAVE_OPENMP )
|
||||
target_link_libraries ( fluidsynth PRIVATE OpenMP::OpenMP_C )
|
||||
endif()
|
||||
|
||||
if ( TARGET PkgConfig::SYSTEMD AND SYSTEMD_SUPPORT )
|
||||
target_link_libraries ( fluidsynth PRIVATE PkgConfig::SYSTEMD )
|
||||
endif()
|
||||
|
|
Loading…
Reference in a new issue