Skip to content

Commit

Permalink
Fix Fluidsynth.pc doesn't include static libraries (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
derselbst authored Jul 11, 2021
1 parent a0ec2c5 commit fc21d28
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
28 changes: 26 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ if ( enable-profiling )

set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPT_FLAGS}" )

if ( CMAKE_VERSION VERSION_GREATER "3.6.0" )
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.6.0" )
find_program( CLANG_TIDY
NAMES "clang-tidy"
DOC "Path to clang-tidy executable" )
Expand All @@ -422,7 +422,7 @@ if ( enable-profiling )
execute_process ( COMMAND ${CLANG_TIDY} "--version" )
set ( CMAKE_C_CLANG_TIDY ${CLANG_TIDY} )
endif ( CLANG_TIDY )
endif ( CMAKE_VERSION VERSION_GREATER "3.6.0" )
endif ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.6.0" )

endif ( enable-profiling )

Expand Down Expand Up @@ -815,6 +815,30 @@ if ( IS_ABSOLUTE "${INCLUDE_INSTALL_DIR}" )
else ()
set ( includedir "\${prefix}/${INCLUDE_INSTALL_DIR}" )
endif ()

if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.12.0" )
# retrieve all the private libs we depend on
get_target_property ( LIBS_PRIVATE libfluidsynth INTERFACE_LINK_LIBRARIES)
# make a copy
set ( LIBS_PRIVATE_WITH_PATH ${LIBS_PRIVATE} )

# this matches any path and any flag entries (starting with '-')
set ( LIB_LIST_REGEX "(^(.+)\/([^\/]+)$)|(^\-.*$)" )
# remove all entries from the list which are specified by path and which already have -l
list ( FILTER LIBS_PRIVATE EXCLUDE REGEX ${LIB_LIST_REGEX} )
# include only entries specifed by path
list ( FILTER LIBS_PRIVATE_WITH_PATH INCLUDE REGEX ${LIB_LIST_REGEX} )

# prepend the linker flag to all entries except the ones that already have it
list ( TRANSFORM LIBS_PRIVATE PREPEND "-l")
list ( JOIN LIBS_PRIVATE " " LIBS_PRIVATE_JOINED )
list ( JOIN LIBS_PRIVATE_WITH_PATH " " LIBS_PRIVATE_WITH_PATH_JOINED )
else ()
set ( LIBS_PRIVATE "" )
set ( LIBS_PRIVATE_WITH_PATH "" )
message ( DEPRECATION "Your version of CMake is old. A complete pkg-config file can not created. Get cmake 3.13.3 or newer." )
endif ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.12.0" )

configure_file ( fluidsynth.pc.in
${CMAKE_BINARY_DIR}/fluidsynth.pc IMMEDIATE @ONLY )
install ( FILES ${CMAKE_BINARY_DIR}/fluidsynth.pc
Expand Down
1 change: 1 addition & 0 deletions fluidsynth.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Name: FluidSynth
Description: Software SoundFont synth
Version: @VERSION@
Libs: -L${libdir} -lfluidsynth
Libs.private: @LIBS_PRIVATE_JOINED@ @LIBS_PRIVATE_WITH_PATH_JOINED@
Cflags: -I${includedir}

0 comments on commit fc21d28

Please sign in to comment.