Skip to content

Commit

Permalink
ports/cmake: fix up of pkg-config file template processing with Libs.…
Browse files Browse the repository at this point in the history
…private

This is based on the change that went into

	microsoft/vcpkg#42601

I added some, removed some.



git-svn-id: svn://scm.orgis.org/mpg123/trunk@5462 35dc7657-300d-0410-a2e5-dc2837fedb53
  • Loading branch information
thor committed Dec 10, 2024
1 parent eda5f60 commit 5e1e52b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- libmpg123:
-- Un-break DLL builds that need I/O functions defined in libmpg123.c
(like mpg123_open(), bug 374).
- ports/cmake: More fixup to also produce .pc files with Libs.private.

1.32.9
------
Expand Down
12 changes: 12 additions & 0 deletions ports/cmake/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ function(check_m)
check_function_exists(sin HAVE_M)
endfunction(check_m)
check_m()
# Cargo coding the check if there is a library rt, possibly providing
# a canary symbol. I am not sure if this logic really mirrors what
# autotools does.
function(check_rt)
set(CMAKE_REQUIRED_LIBRARIES rt)
check_function_exists(clock_gettime HAVE_RT)
endfunction(check_rt)
check_rt()

check_function_exists(atoll HAVE_ATOLL)
check_function_exists(getaddrinfo HAVE_IPV6)
Expand Down Expand Up @@ -450,3 +458,7 @@ if(UNIX AND NOT PORTABLE_API)
endif()

configure_file(config.cmake.h.in config.h)

set(LIBMPG123_LIBS "${LIBMPG123_LIBS}" PARENT_SCOPE)
set(LIBOUT123_LIBS "${LIBOUT123_LIBS}" PARENT_SCOPE)
set(LIBSYN123_LIBS "${LIBSYN123_LIBS}" PARENT_SCOPE)
7 changes: 7 additions & 0 deletions ports/cmake/src/libmpg123/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ else()
target_sources(${TARGET} PRIVATE ${PLATFORM_SOURCES})
endif()

if(HAVE_M)
string(APPEND LIBMPG123_LIBS " -lm")
endif()
if(WANT_WIN32_UNICODE)
string(APPEND LIBMPG123_LIBS " -lshlwapi")
endif()
set(LIBMPG123_LIBS "${LIBMPG123_LIBS}" PARENT_SCOPE)
target_link_libraries(${TARGET} PRIVATE
$<$<BOOL:${HAVE_M}>:m>
$<$<BOOL:${WANT_WIN32_UNICODE}>:shlwapi>)
Expand Down
15 changes: 15 additions & 0 deletions ports/cmake/src/libout123/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,24 @@ add_library(${TARGET}

set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME out123)

if(HAVE_UNIX_DL)
string(APPEND LIBOUT123_LIBS " -ldl")
endif()
if(HAVE_M)
string(APPEND LIBOUT123_LIBS " -lm")
endif()
if(HAVE_RT)
string(APPEND LIBOUT123_LIBS " -lrt")
endif()
if(WANT_WIN32_UNICODE)
string(APPEND LIBOUT123_LIBS " -lshlwapi")
endif()
set(LIBOUT123_LIBS "${LIBOUT123_LIBS}" PARENT_SCOPE)
target_link_libraries(${TARGET} PRIVATE
$<TARGET_NAME_IF_EXISTS:defaultmodule>
$<$<BOOL:${HAVE_UNIX_DL}>:dl>
$<$<BOOL:${HAVE_M}>:m>
$<$<BOOL:${HAVE_RT}>:rt>
$<$<BOOL:${WANT_WIN32_UNICODE}>:shlwapi>)

target_include_directories(${TARGET} INTERFACE
Expand Down
7 changes: 5 additions & 2 deletions ports/cmake/src/libsyn123/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ target_include_directories(${TARGET} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")

if(HAVE_M)
string(APPEND LIBSYN123_LIBS " -lm")
endif()
set(LIBSYN123_LIBS "${LIBSYN123_LIBS}" PARENT_SCOPE)
target_link_libraries(${TARGET} PRIVATE
$<$<BOOL:${HAVE_M}>:m>
$<$<BOOL:${WANT_WIN32_UNICODE}>:shlwapi>)
$<$<BOOL:${HAVE_M}>:m>)

install(TARGETS ${TARGET} EXPORT targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
Expand Down

0 comments on commit 5e1e52b

Please sign in to comment.