I want to add libpqxx library to my project, but find_package doesn't seem work with it. So I decided to manually add pkg-config's output on libpqxx to compiler and linker flags. For some reason this doesn't work (I tried building with CLion and from terminal, they both failed but with different errors). But if I simply insert pkg-config's output manually, then everything works fine.
execute_process (COMMAND bash -c "pkg-config --cflags libpqxx" OUTPUT_VARIABLE libs_cflags)
execute_process (COMMAND bash -c "pkg-config --libs libpqxx" OUTPUT_VARIABLE libs_linker_flags)
# Prints 'flags ='
execute_process (COMMAND bash -c "echo flags = ${CMAKE_CXX_FLAGS}")
# Works fine
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/opt/homebrew/Cellar/libpqxx/7.7.0/include")
# Doesn't work
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${libs_cflags}")
# Prints 'flags=-I/opt/homebrew/Cellar/libpqxx/7.7.0/include'
execute_process (COMMAND bash -c "echo flags = ${CMAKE_CXX_FLAGS}")
# Works fine
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/Cellar/libpqxx/7.7.0/lib -lpqxx")
# Doesn't work
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${libs_linker_flags}")