-
-
Notifications
You must be signed in to change notification settings - Fork 169
Add depended on libraries and C++ runtime to link to in pkg-config file #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,6 +181,28 @@ else() | |
| endif() | ||
|
|
||
| if(NOT BUILD_FRAMEWORK) | ||
| foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}) | ||
| if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB}) | ||
| list(APPEND PKG_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_LIBS "-l${DIRECT_LIB}") | ||
| elseif(LIB MATCHES "-l.*") | ||
| list(APPEND PKG_LIBS "${LIB}") | ||
| else() | ||
| list(APPEND PKG_LIBS "-l${LIB}") | ||
| endif() | ||
| endforeach() | ||
| if(PKG_LIBS) | ||
| # Blacklist for MinGW-w64 | ||
| list(REMOVE_DUPLICATES PKG_LIBS) | ||
| list(REMOVE_ITEM PKG_LIBS | ||
| "-lmingw32" "-lgcc_s" "-lgcc" "-lmoldname" "-lmingwex" "-lmingwthrd" | ||
| "-lmsvcrt" "-lpthread" "-ladvapi32" "-lshell32" "-luser32" "-lkernel32") | ||
| endif() | ||
| string(REPLACE ";" " " CHROMAPRINT_ADDITIONAL_LIBS "${PKG_LIBS}") | ||
|
Comment on lines
183
to
+205
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider initializing CHROMAPRINT_ADDITIONAL_LIBS explicitly. If if(NOT BUILD_FRAMEWORK)
set(CHROMAPRINT_ADDITIONAL_LIBS "")
foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})
# ... existing logic ...This documents that an empty value is expected when no implicit libs are found. 🤖 Prompt for AI Agents |
||
| configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libchromaprint.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libchromaprint.pc @ONLY) | ||
| install( | ||
| FILES ${CMAKE_CURRENT_BINARY_DIR}/libchromaprint.pc | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
-l:lib.a pattern handling is correct but lacks defensive check.*
The regex ensures at least one character exists between
liband.a, soDIRECT_LIBwon't be empty in practice. However, adding an explicit guard would make the code more robust against unexpected input formats:This prevents silent failures if the input format changes in future CMake versions.
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
CMAKE_CXX_IMPLICIT_LINK_LIBRARIESis poisoned we would be screwed no matter what.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robUx4 Fair point—if
CMAKE_CXX_IMPLICIT_LINK_LIBRARIEScontains garbage, the issue would surface elsewhere in the build. The regex already filters for the expected pattern, so an extra check here would be redundant. I'll drop the suggestion.