Reputation: 3161
I'm writing a c project using cmake on a mac. I use homebrew. I installed libpqxx via homebrew. I have the following CMakeLists.txt.
cmake_minimum_required(VERSION 3.11)
project(imagedb)
set(CMAKE_CXX_STANDARD 14)
add_executable(imagedb main.cpp)
target_link_libraries( imagedb /usr/local/lib/libpqxx.dylib)
While this builds I would like to avoid using an absolute path here. How can I do this using cmake given that /usr/local
is already in the path prefix?
Upvotes: 1
Views: 956
Reputation: 1821
Usually you should use find_package
to find dependencies.
Looking at libpqxx's repo, you can see that they provide a CMake config file.
So in your CMakeLists.txt
file you just have to do this:
find_package(libpqxx REQUIRED)
target_link_libraries(imagedb libpqxx::pqxx_shared)
If for some reason libpqxx-config.cmake
is not shipped with the homebrew version, you have to write a find file.
Upvotes: 1