Closed fluca1978 closed 8 months ago
This doesn't sound like a json-c problem. Do you have an add_library
or add_executable
line in your project's CMakeLists.txt?
Good guess @hawicz ! It turned out that CMakeList.txt was calling a subdirectory CMakeList.txt, and is the latter one that requires the
find_package(json-c CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE json-c::json-c)
addition. Now I'm an happy json-c user!
I'm trying to use
json-c
in a project that usescmake
, the project is https://github.com/agroal/pgagroal and I've installedjson-c
as follows:Then I've added into
CMakeList.txt
:however when I try to build, I got:
The cmake log has nothing related to
json-c
. I then noted that:$ echo $PKG_CONFIG_PATH /usr/local/lib64/pkgconfig/ $ export PKG_CONFIG_PATH $ pkg-config --libs json-c -L/usr/local/lib64 -ljson-c
$ cmake .. -DCMAKE_PREFIX_PATH=/usr/local/lib64/cmake/json-c && make clean && cmake .. && make && sudo make install -- pgagroal 1.6.0 -- Build type is Release -- System is Linux -- libev found -- OpenSSL found -- rst2man found -- libatomic found -- systemd found CMake Error at CMakeLists.txt:98 (target_link_libraries): Cannot specify link libraries for target "pgagroal" which is not built by this project.
-- Configuring incomplete, errors occurred!