From 5a71336bd991ebf3106359a22b01ffc715fab872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Sun, 5 Sep 2021 11:30:25 +0200 Subject: [PATCH] replaced global include_directories and link_directories * by target_include_directories * by target_link_libraries, using imported targets when possible --- CMakeLists.txt | 121 +++++------- cmake_admin/FluidUnitTest.cmake | 4 +- .../fluidsynth-assetloader/CMakeLists.txt | 2 +- src/CMakeLists.txt | 179 ++++++++++++------ src/gentables/CMakeLists.txt | 4 +- 5 files changed, 172 insertions(+), 138 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b6caf41..09d32dc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -508,12 +508,18 @@ if(NOT enable-pkgconfig) message( STATUS "GLIB_INCLUDE_DIRS: " ${GLIB_INCLUDE_DIRS} ) message( STATUS "GLIB_LIBRARIES: " ${GLIB_LIBRARIES} ) + unset ( ALSA_SUPPORT CACHE ) + if ( enable-alsa ) + find_package( ALSA 0.9.1 ) # imported target ALSA::ALSA since CMake 3.12 + set ( ALSA_SUPPORT ${ALSA_FOUND} ) + endif() + else(NOT enable-pkgconfig) find_package ( PkgConfig REQUIRED ) # Mandatory libraries: glib and gthread - pkg_check_modules ( GLIB REQUIRED glib-2.0>=2.6.5 gthread-2.0>=2.6.5 ) + pkg_check_modules ( GLIB REQUIRED glib-2.0>=2.6.5 gthread-2.0>=2.6.5 IMPORTED_TARGET ) if ( GLIB_glib-2.0_VERSION AND GLIB_glib-2.0_VERSION VERSION_LESS "2.26.0" ) 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!" ) @@ -525,7 +531,7 @@ else(NOT enable-pkgconfig) unset ( LIBSNDFILE_SUPPORT CACHE ) unset ( LIBSNDFILE_HASVORBIS CACHE ) if ( enable-libsndfile ) - pkg_check_modules ( LIBSNDFILE sndfile>=1.0.0 ) + 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}") @@ -547,51 +553,51 @@ else(NOT enable-pkgconfig) unset ( PULSE_SUPPORT CACHE ) if ( enable-pulseaudio ) - pkg_check_modules ( PULSE libpulse-simple>=0.9.8 ) - set ( PULSE_SUPPORT ${PULSE_FOUND} ) + pkg_check_modules ( PULSE libpulse-simple>=0.9.8 IMPORTED_TARGET ) + set ( PULSE_SUPPORT ${PULSE_FOUND} ) else ( enable-pulseaudio ) - unset_pkg_config ( PULSE ) + unset_pkg_config ( PULSE ) endif ( enable-pulseaudio ) unset ( ALSA_SUPPORT CACHE ) if ( enable-alsa ) - pkg_check_modules ( ALSA alsa>=0.9.1 ) - set ( ALSA_SUPPORT ${ALSA_FOUND} ) + pkg_check_modules ( ALSA alsa>=0.9.1 IMPORTED_TARGET ) + set ( ALSA_SUPPORT ${ALSA_FOUND} ) else ( enable-alsa ) - unset_pkg_config ( ALSA ) + unset_pkg_config ( ALSA ) endif ( enable-alsa ) unset ( PORTAUDIO_SUPPORT CACHE ) if ( enable-portaudio ) - pkg_check_modules ( PORTAUDIO portaudio-2.0>=19 ) - set ( PORTAUDIO_SUPPORT ${PORTAUDIO_FOUND} ) + pkg_check_modules ( PORTAUDIO portaudio-2.0>=19 IMPORTED_TARGET ) + set ( PORTAUDIO_SUPPORT ${PORTAUDIO_FOUND} ) else ( enable-portaudio ) - unset_pkg_config ( PORTAUDIO ) + unset_pkg_config ( PORTAUDIO ) endif ( enable-portaudio ) unset ( JACK_SUPPORT CACHE ) if ( enable-jack ) - pkg_check_modules ( JACK jack ) - set ( JACK_SUPPORT ${JACK_FOUND} ) + pkg_check_modules ( JACK jack IMPORTED_TARGET ) + set ( JACK_SUPPORT ${JACK_FOUND} ) else ( enable-jack ) - unset_pkg_config ( JACK ) + unset_pkg_config ( JACK ) endif ( enable-jack ) unset ( LASH_SUPPORT CACHE ) if ( enable-lash ) - pkg_check_modules ( LASH lash-1.0>=0.3 ) - if ( LASH_FOUND ) - set ( LASH_SUPPORT 1 ) - add_definitions ( -DHAVE_LASH ) - endif ( LASH_FOUND ) + pkg_check_modules ( LASH lash-1.0>=0.3 IMPORTED_TARGET ) + if ( LASH_FOUND ) + set ( LASH_SUPPORT 1 ) + add_definitions ( -DHAVE_LASH ) + endif ( LASH_FOUND ) else ( enable-lash ) - unset_pkg_config ( LASH ) - remove_definitions( -DHAVE_LASH ) + unset_pkg_config ( LASH ) + remove_definitions( -DHAVE_LASH ) endif ( enable-lash ) unset ( SYSTEMD_SUPPORT CACHE ) if ( enable-systemd ) - pkg_check_modules ( SYSTEMD libsystemd ) + pkg_check_modules ( SYSTEMD libsystemd IMPORTED_TARGET ) set ( SYSTEMD_SUPPORT ${SYSTEMD_FOUND} ) else ( enable-systemd ) unset_pkg_config ( SYSTEMD ) @@ -599,30 +605,30 @@ else(NOT enable-pkgconfig) unset ( DBUS_SUPPORT CACHE ) if ( enable-dbus ) - pkg_check_modules ( DBUS dbus-1>=1.0.0 ) - set ( DBUS_SUPPORT ${DBUS_FOUND} ) + pkg_check_modules ( DBUS dbus-1>=1.0.0 IMPORTED_TARGET ) + set ( DBUS_SUPPORT ${DBUS_FOUND} ) else ( enable-dbus ) - unset_pkg_config ( DBUS ) + unset_pkg_config ( DBUS ) endif ( enable-dbus ) unset ( LADSPA_SUPPORT CACHE ) if ( enable-ladspa ) - check_include_file ( ladspa.h LADSPA_SUPPORT ) - if ( LADSPA_SUPPORT ) - pkg_check_modules ( GMODULE REQUIRED gmodule-2.0>=2.6.5 ) - set ( LADSPA 1 ) - endif ( LADSPA_SUPPORT ) + check_include_file ( ladspa.h LADSPA_SUPPORT ) + if ( LADSPA_SUPPORT ) + pkg_check_modules ( GMODULE REQUIRED gmodule-2.0>=2.6.5 IMPORTED_TARGET ) + set ( LADSPA 1 ) + endif ( LADSPA_SUPPORT ) endif ( enable-ladspa ) unset ( LIBINSTPATCH_SUPPORT CACHE ) if ( enable-libinstpatch ) - pkg_check_modules ( LIBINSTPATCH libinstpatch-1.0>=1.1.0 ) + pkg_check_modules ( LIBINSTPATCH libinstpatch-1.0>=1.1.0 IMPORTED_TARGET ) set ( LIBINSTPATCH_SUPPORT ${LIBINSTPATCH_FOUND} ) endif ( enable-libinstpatch ) unset ( SDL2_SUPPORT CACHE ) if ( enable-sdl2 ) - pkg_check_modules ( SDL2 sdl2 ) + pkg_check_modules ( SDL2 sdl2 IMPORTED_TARGET ) set ( SDL2_SUPPORT ${SDL2_FOUND} ) else ( enable-sdl2 ) unset_pkg_config ( SDL2 ) @@ -631,7 +637,7 @@ else(NOT enable-pkgconfig) unset ( OBOE_SUPPORT CACHE ) unset ( OBOE_LIBS CACHE ) if ( enable-oboe ) - pkg_check_modules ( OBOE oboe-1.0 ) + pkg_check_modules ( OBOE oboe-1.0 IMPORTED_TARGET ) if ( OBOE_FOUND ) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -643,15 +649,15 @@ else(NOT enable-pkgconfig) unset ( WITH_READLINE CACHE ) unset ( READLINE_LIBS CACHE ) if ( enable-readline ) - pkg_check_modules ( READLINE readline ) - if ( NOT READLINE_FOUND ) - find_package ( READLINE ) - set ( READLINE_FOUND ${HAVE_READLINE} ) - endif ( NOT READLINE_FOUND ) - if ( READLINE_FOUND ) - set ( WITH_READLINE 1 ) - set ( READLINE_LIBS ${READLINE_LIBRARIES} ) - endif ( READLINE_FOUND ) + pkg_check_modules ( READLINE readline QUIET IMPORTED_TARGET ) + if ( NOT READLINE_FOUND ) + find_package ( READLINE ) + set ( READLINE_FOUND ${HAVE_READLINE} ) + endif ( NOT READLINE_FOUND ) + if ( READLINE_FOUND ) + set ( WITH_READLINE 1 ) + set ( READLINE_LIBS ${READLINE_LIBRARIES} ) + endif ( READLINE_FOUND ) endif ( enable-readline ) endif(NOT enable-pkgconfig) @@ -698,20 +704,10 @@ if ( enable-threads ) endif ( enable-threads ) unset ( HAVE_OPENMP CACHE ) -find_package ( OpenMP QUIET ) +find_package ( OpenMP 4.0 QUIET ) if ( OpenMP_FOUND OR OpenMP_C_FOUND ) - message(STATUS "Found OpenMP ${OpenMP_C_SPEC_DATE}") - # require at least OMP 4.0 - if ( ( NOT OpenMP_C_SPEC_DATE LESS "201307" ) OR NOT ( OpenMP_C_VERSION VERSION_LESS "4.0" ) ) - set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" ) - set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" ) - - # include dir and library link seems to be required for Xcode 12.5 (issue #917) - include_directories ( SYSTEM ${OpenMP_C_INCLUDE_DIRS} ) - set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}" ) - set ( LIBFLUID_LIBS "${OpenMP_C_LIBRARIES};${LIBFLUID_LIBS}" ) - set ( HAVE_OPENMP 1 ) - endif() + message(STATUS "Found OpenMP ${OpenMP_C_VERSION} ${OpenMP_C_SPEC_DATE}") + set ( HAVE_OPENMP 1 ) endif() # manipulate some variables to setup a proper test env @@ -792,21 +788,6 @@ endif ( HAVE_SOCKLEN_T ) configure_file ( ${CMAKE_SOURCE_DIR}/src/config.cmake ${CMAKE_BINARY_DIR}/config.h ) -# Setup linker directories NOW, as the command will apply only to targets created after it has been called. -link_directories ( - ${GLIB_LIBRARY_DIRS} - ${LASH_LIBRARY_DIRS} - ${JACK_LIBRARY_DIRS} - ${ALSA_LIBRARY_DIRS} - ${PULSE_LIBRARY_DIRS} - ${PORTAUDIO_LIBRARY_DIRS} - ${LIBSNDFILE_LIBRARY_DIRS} - ${DBUS_LIBRARY_DIRS} - ${SDL2_LIBRARY_DIRS} - ${OBOE_LIBRARY_DIRS} - ${LIBINSTPATCH_LIBRARY_DIRS} -) - # required to allow ctest to be called from top-level build directory ENABLE_TESTING() diff --git a/cmake_admin/FluidUnitTest.cmake b/cmake_admin/FluidUnitTest.cmake index 10120116..3aa7fd07 100644 --- a/cmake_admin/FluidUnitTest.cmake +++ b/cmake_admin/FluidUnitTest.cmake @@ -16,7 +16,7 @@ macro ( ADD_FLUID_TEST _test ) $ # include auto generated headers $ # include "normal" public (sub-)headers $ # include private headers - $ # include all other header search paths needed by libfluidsynth (esp. glib) + $ # include all other header search paths needed by libfluidsynth (esp. glib) ) # add the test to ctest @@ -48,7 +48,7 @@ macro ( ADD_FLUID_TEST_UTIL _util ) $ # include auto generated headers $ # include "normal" public (sub-)headers $ # include private headers - $ # include all other header search paths needed by libfluidsynth (esp. glib) + $ # include all other header search paths needed by libfluidsynth (esp. glib) ) # append the current unit test to check-target as dependency diff --git a/doc/android/fluidsynth-assetloader/CMakeLists.txt b/doc/android/fluidsynth-assetloader/CMakeLists.txt index efe51108..92a1e803 100644 --- a/doc/android/fluidsynth-assetloader/CMakeLists.txt +++ b/doc/android/fluidsynth-assetloader/CMakeLists.txt @@ -11,7 +11,7 @@ target_compile_options ( fluidsynth-assetloader PRIVATE -Wall PRIVATE "$<$:-Werror>") # Only include -Werror when building debug config -include_directories ( ../../../include ) +target_include_directories ( fluidsynth-assetloader PRIVATE ../../../include ) set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L../../../dist/${ANDROID_ABI} -lfluidsynth" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e6d86ef..83ae27bd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,42 +19,14 @@ # CMake based build system. Pedro Lopez-Cabanillas -include_directories ( - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_SOURCE_DIR}/src/drivers - ${CMAKE_SOURCE_DIR}/src/synth - ${CMAKE_SOURCE_DIR}/src/rvoice - ${CMAKE_SOURCE_DIR}/src/midi - ${CMAKE_SOURCE_DIR}/src/utils - ${CMAKE_SOURCE_DIR}/src/sfloader - ${CMAKE_SOURCE_DIR}/src/bindings - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_BINARY_DIR}/include -) - -include_directories ( - SYSTEM - ${GLIB_INCLUDE_DIRS} - ${PTHREADS_INCLUDE_DIR} - ${SDL2_INCLUDE_DIR} - ${LIBINSTPATCH_INCLUDE_DIRS} -) - # ************ library ************ -if ( READLINE_SUPPORT ) - include_directories ( ${READLINE_INCLUDE_DIR} ) -endif ( READLINE_SUPPORT ) - if ( PULSE_SUPPORT ) set ( fluid_pulse_SOURCES drivers/fluid_pulse.c ) - include_directories ( ${PULSE_INCLUDE_DIRS} ) endif ( PULSE_SUPPORT ) if ( ALSA_SUPPORT ) set ( fluid_alsa_SOURCES drivers/fluid_alsa.c ) - include_directories ( ${ALSA_INCLUDE_DIRS} ) endif ( ALSA_SUPPORT ) if ( COREAUDIO_SUPPORT ) @@ -67,17 +39,14 @@ endif ( COREMIDI_SUPPORT ) if ( DBUS_SUPPORT ) set ( fluid_dbus_SOURCES bindings/fluid_rtkit.c bindings/fluid_rtkit.h ) - include_directories ( ${DBUS_INCLUDE_DIRS} ) endif ( DBUS_SUPPORT ) if ( JACK_SUPPORT ) set ( fluid_jack_SOURCES drivers/fluid_jack.c ) - include_directories ( ${JACK_INCLUDE_DIRS} ) endif ( JACK_SUPPORT ) if ( PORTAUDIO_SUPPORT ) set ( fluid_portaudio_SOURCES drivers/fluid_portaudio.c ) - include_directories ( ${PORTAUDIO_INCLUDE_DIRS} ) endif ( PORTAUDIO_SUPPORT ) if ( DSOUND_SUPPORT ) @@ -98,7 +67,6 @@ endif ( WINMIDI_SUPPORT ) if ( SDL2_SUPPORT ) set ( fluid_sdl2_SOURCES drivers/fluid_sdl2.c ) - include_directories ( ${SDL2_INCLUDE_DIRS} ) endif ( SDL2_SUPPORT ) if ( OSS_SUPPORT ) @@ -107,25 +75,14 @@ endif ( OSS_SUPPORT ) if ( LASH_SUPPORT ) set ( fluid_lash_SOURCES bindings/fluid_lash.c bindings/fluid_lash.h ) - include_directories ( ${LASH_INCLUDE_DIRS}) endif ( LASH_SUPPORT ) -if ( SYSTEMD_SUPPORT ) - include_directories ( ${SYSTEMD_INCLUDE_DIRS}) -endif ( SYSTEMD_SUPPORT ) - if ( DART_SUPPORT ) set ( fluid_dart_SOURCES drivers/fluid_dart.c ) - include_directories ( ${DART_INCLUDE_DIRS} ) endif ( DART_SUPPORT ) -if ( LIBSNDFILE_SUPPORT ) - include_directories ( ${LIBSNDFILE_INCLUDE_DIRS} ) -endif ( LIBSNDFILE_SUPPORT ) - if ( MIDISHARE_SUPPORT ) set ( fluid_midishare_SOURCES drivers/fluid_midishare.c ) - include_directories ( ${MidiShare_INCLUDE_DIRS} ) endif ( MIDISHARE_SUPPORT ) if ( AUFILE_SUPPORT ) @@ -138,12 +95,10 @@ endif ( LIBINSTPATCH_SUPPORT ) if ( OPENSLES_SUPPORT ) set ( fluid_opensles_SOURCES drivers/fluid_opensles.c ) - include_directories ( ${OpenSLES_INCLUDE_DIRS} ) endif ( OPENSLES_SUPPORT ) if ( OBOE_SUPPORT ) set ( fluid_oboe_SOURCES drivers/fluid_oboe.cpp ) - include_directories ( ${OBOE_INCLUDE_DIRS} ) endif ( OBOE_SUPPORT ) set ( config_SOURCES ${CMAKE_BINARY_DIR}/config.h ) @@ -296,6 +251,20 @@ add_library ( libfluidsynth-OBJ OBJECT ${VersionFilesOutputVariable} ) +target_include_directories ( libfluidsynth-OBJ PRIVATE + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/include + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/drivers + ${CMAKE_SOURCE_DIR}/src/synth + ${CMAKE_SOURCE_DIR}/src/rvoice + ${CMAKE_SOURCE_DIR}/src/midi + ${CMAKE_SOURCE_DIR}/src/utils + ${CMAKE_SOURCE_DIR}/src/sfloader + ${CMAKE_SOURCE_DIR}/src/bindings + ${CMAKE_SOURCE_DIR}/include +) + if ( LIBFLUID_CPPFLAGS ) set_target_properties ( libfluidsynth-OBJ PROPERTIES COMPILE_FLAGS ${LIBFLUID_CPPFLAGS} ) @@ -352,30 +321,97 @@ endif ( MACOSX_FRAMEWORK ) # See https://cmake.org/cmake/help/latest/command/target_link_libraries.html#linking-object-libraries # Object Libraries may "link" to other libraries to get usage requirements, # but since they do not have a link step nothing is done with their object files. -target_link_libraries ( libfluidsynth-OBJ INTERFACE - ${GLIB_LIBRARIES} - ${GMODULE_LIBRARIES} - ${LASH_LIBRARIES} - ${JACK_LIBRARIES} - ${ALSA_LIBRARIES} - ${PULSE_LIBRARIES} - ${PORTAUDIO_LIBRARIES} - ${LIBSNDFILE_LIBRARIES} - ${SDL2_LIBRARIES} - ${DBUS_LIBRARIES} - ${READLINE_LIBS} +target_link_libraries ( libfluidsynth-OBJ PUBLIC ${DART_LIBS} ${COREAUDIO_LIBS} ${COREMIDI_LIBS} ${WINDOWS_LIBS} ${MidiShare_LIBS} ${OpenSLES_LIBS} - ${OBOE_LIBS} ${LIBFLUID_LIBS} - ${LIBINSTPATCH_LIBRARIES} ) -# This doesn't install any object file at all +if ( TARGET OpenMP::OpenMP_C ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC OpenMP::OpenMP_C ) +endif() + +if ( TARGET PkgConfig::GLIB ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::GLIB ) +else() + target_include_directories ( libfluidsynth-OBJ PUBLIC ${GLIB_INCLUDE_DIRS} ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC ${GLIB_LIBRARIES} ) +endif() + +if ( TARGET PkgConfig::LIBSNDFILE AND LIBSNDFILE_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::LIBSNDFILE ) +endif() + +if ( TARGET PkgConfig::PULSE AND PULSE_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::PULSE ) +endif() + +if ( ALSA_SUPPORT ) + if ( TARGET PkgConfig::ALSA ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::ALSA ) + else() + target_link_libraries ( libfluidsynth-OBJ PUBLIC ALSA::ALSA ) + endif() +endif() + +if ( TARGET PkgConfig::PORTAUDIO AND PORTAUDIO_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::PORTAUDIO ) +endif() + +if ( TARGET PkgConfig::JACK AND JACK_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::JACK ) +endif() + +if ( TARGET PkgConfig::LASH AND LASH_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::LASH ) +endif() + +if ( TARGET PkgConfig::DBUS AND DBUS_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::DBUS ) +endif() + +if ( TARGET PkgConfig::GMODULE AND LADSPA_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::GMODULE ) +endif() + +if ( TARGET PkgConfig::LIBINSTPATCH AND LIBINSTPATCH_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::LIBINSTPATCH ) +endif() + +if ( TARGET PkgConfig::SDL2 AND SDL2_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::SDL2 ) +endif() + +if ( TARGET PkgConfig::OBOE AND OBOE_SUPPORT ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::OBOE ) +endif() + +if ( WITH_READLINE ) + if ( TARGET PkgConfig::READLINE ) + target_link_libraries ( libfluidsynth-OBJ PUBLIC PkgConfig::READLINE ) + else() + target_link_libraries ( libfluidsynth-OBJ PUBLIC ${READLINE_LIBRARIES} ) + target_include_directories ( libfluidsynth-OBJ PUBLIC ${READLINE_INCLUDE_DIR} ) + endif() +endif() + +if ( DART_SUPPORT ) + target_include_directories ( libfluidsynth-OBJ PUBLIC ${DART_INCLUDE_DIRS} ) +endif ( DART_SUPPORT ) + +if ( MIDISHARE_SUPPORT ) + target_include_directories ( libfluidsynth-OBJ PUBLIC ${MidiShare_INCLUDE_DIRS} ) +endif ( MIDISHARE_SUPPORT ) + +if ( OPENSLES_SUPPORT ) + target_include_directories ( libfluidsynth-OBJ PUBLIC ${OpenSLES_INCLUDE_DIRS} ) +endif ( OPENSLES_SUPPORT ) + +# This doesn't install any object file at all! # it is only a trick for exporting targets install( TARGETS libfluidsynth-OBJ EXPORT FluidSynthTargets @@ -404,14 +440,31 @@ if ( FLUID_CPPFLAGS ) PROPERTIES COMPILE_FLAGS ${FLUID_CPPFLAGS} ) endif ( FLUID_CPPFLAGS ) +target_include_directories ( fluidsynth PRIVATE + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/include + ${CMAKE_SOURCE_DIR}/src/utils + ${CMAKE_SOURCE_DIR}/src/bindings + ${CMAKE_SOURCE_DIR}/include +) + target_link_libraries ( fluidsynth PRIVATE libfluidsynth - ${SYSTEMD_LIBRARIES} ${FLUID_LIBS} - ${GLIB_LIBRARIES} # because g_file_test() - ${SDL2_LIBRARIES} # because SDL_Init() etc. ) +if ( TARGET PkgConfig::SYSTEMD AND SYSTEMD_SUPPORT ) + target_link_libraries ( fluidsynth PRIVATE PkgConfig::SYSTEMD ) +endif() + +if ( TARGET PkgConfig::GLIB ) # because g_file_test() + target_link_libraries ( fluidsynth PRIVATE PkgConfig::GLIB ) +endif() + +if ( TARGET PkgConfig::SDL2 AND SDL2_SUPPORT ) # because SDL_Init() etc. + target_link_libraries ( fluidsynth PRIVATE PkgConfig::SDL2 ) +endif() + if ( MACOSX_FRAMEWORK ) install ( TARGETS fluidsynth libfluidsynth EXPORT FluidSynthTargets diff --git a/src/gentables/CMakeLists.txt b/src/gentables/CMakeLists.txt index 638f299c..9cb69f2b 100644 --- a/src/gentables/CMakeLists.txt +++ b/src/gentables/CMakeLists.txt @@ -21,14 +21,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../) - # Add the executable that generates the table add_executable( make_tables make_tables.c gen_conv.c gen_rvoice_dsp.c) +target_include_directories( make_tables PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../ ) + if ( WIN32 ) add_definitions ( -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS ) else ( WIN32 )