Skip to content
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

Incorrect reference to boost thread library in pkg-config file on macOS #2790

Open
scpeters opened this issue Jul 16, 2020 · 0 comments
Open

Comments

@scpeters
Copy link
Member

Copied from #2751 (review):

I've noticed for a while that the pkg-config files have incorrect references to the boost libraries on homebrew, passing cmake target names to the linking args like -lBoost::thread instead of -lboost_thread. #2751 does some string manipulation to fix this, but it doesn't fix the issue on homebrew because those libraries have an extra -mt (for multithreaded I believe).

$ ls /usr/local/opt/boost/lib | grep thread
libboost_thread-mt.a
libboost_thread-mt.dylib

This causes CI error messages like the following when trying to compile example code based on pkg-config flags:

399: ld: library not found for -lboost_thread

In my previous debugging, I tried to use a generator expression to extract the boost library names from cmake targets. For example, the following patch is able to write the absolute path of the library for each target:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8659ff1707..e90e868a23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -383,6 +383,7 @@ else (build_errors)
   string (REPLACE ";" " -L" Boost_PKGCONFIG_LIBS "${Boost_PKGCONFIG_LIBS}")
 
   foreach (b ${Boost_LIBRARIES})
+    file(GENERATE OUTPUT generated_${b}.txt CONTENT $<TARGET_LINKER_FILE:${b}>\n)
     get_filename_component(bname ${b} NAME_WE)
     # Prefix -l if not already prefixed
     string(FIND ${bname} "-l" lprefix)
$ cat generated_Boost\:\:thread.txt 
/usr/local/lib/libboost_thread-mt.dylib

cmake has a different generator expression that seems like it would be perfect for this case: TARGET_LINKER_FILE_BASE_NAME, but it doesn't work for boost and has been reported upstream (boostorg/boost_install#41, and cmake issue 20611).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant