From b4075d5b76b3efc717de27db5c093eed1be7a985 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Mon, 5 Sep 2022 16:13:05 +0200 Subject: [PATCH 2/2] add the C++ runtime to the packages to link to gcc needs libstdc++ and clang needs libc++. --- CMakeLists.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c14e32b..b2545b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,6 +205,28 @@ else() endif() if(NOT BUILD_FRAMEWORK) + foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}) + if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB}) + list(APPEND PKG_CXX_LIBS "${LIB}") + elseif(LIB MATCHES "-l:lib.*.a") + string(LENGTH ${LIB} LIBLEN) + math(EXPR LIBLEN "${LIBLEN}-8") + string(SUBSTRING ${LIB} 6 ${LIBLEN} DIRECT_LIB) + list(APPEND PKG_CXX_LIBS "-l${DIRECT_LIB}") + elseif(LIB MATCHES "-l.*") + list(APPEND PKG_CXX_LIBS "${LIB}") + else() + list(APPEND PKG_CXX_LIBS "-l${LIB}") + endif() + endforeach() + if(PKG_CXX_LIBS) + # Blacklist for MinGW-w64 + list(REMOVE_ITEM PKG_CXX_LIBS + "-lmingw32" "-lgcc_s" "-lgcc" "-lmoldname" "-lmingwex" "-lmingwthrd" + "-lmsvcrt" "-lpthread" "-ladvapi32" "-lshell32" "-luser32" "-lkernel32") + string(REPLACE ";" " " PKG_LIBS "${PKG_CXX_LIBS}") + set(CHROMAPRINT_ADDITIONAL_LIBS "${CHROMAPRINT_ADDITIONAL_LIBS} ${PKG_LIBS}") + endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libchromaprint.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libchromaprint.pc) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libchromaprint.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) endif() -- 2.45.0.windows.1