I have Boost and Served REST API package installed in /opt/local
.
Here's the "meaningful" part of my CmakeLists.txt
:
find_package(PkgConfig REQUIRED)
pkg_check_modules(SERVED_PKG REQUIRED IMPORTED_TARGET served)
add_executable( rest_server rest_server.cpp )
target_link_libraries(rest_server PUBLIC PkgConfig::SERVED_PKG)
It does create an executable, and links it with the needed library.
However, it somehow fails to include the path to that library:
$ otool -L cmake-build-debug/rest_server
cmake-build-debug/rest_server:
libserved.1.4.dylib (compatibility version 0.0.0, current version 1.4.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
Which, when I try to run it via the CLion IDE, results in a failure to load the libserved.1.4.dylib
library:
/Users/ur20980/src/security2/cmake-build-debug/rest_server
dyld: Library not loaded: libserved.1.4.dylib
Referenced from: /Users/ur20980/src/security2/cmake-build-debug/rest_server
Reason: image not found
Process finished with exit code 6
When I invoke the executable manually from the terminal, it seems to be OK:
$ cmake-build-debug/rest_server
Hello, World!
What is wrong???