Skip to content

Instantly share code, notes, and snippets.

@Rockncoder
Last active May 8, 2022 20:08
Show Gist options
  • Save Rockncoder/b6c0f113ea9ae16186755c58d2351fe5 to your computer and use it in GitHub Desktop.
Save Rockncoder/b6c0f113ea9ae16186755c58d2351fe5 to your computer and use it in GitHub Desktop.
CMakeLists.txt file for building an app with the JsonCpp library. This macOS specific since it assumes the use of homebrew to install the library, but gist of the idea will also work on Linux.
cmake_minimum_required(VERSION 3.22)
project(jsontest)
find_package(PkgConfig REQUIRED)
set(CMAKE_CXX_STANDARD 17)
# brew install jsoncpp
# jsoncpp library was installed via homebrew, so point to its directories
link_directories("/opt/homebrew/lib")
include_directories("/opt/homebrew/include")
pkg_check_modules(JSONCPP jsoncpp)
# access the header files with: #include <json/json.h>
add_executable(jsontest main.cpp)
# be sure link jsoncpp into your app
target_link_libraries(jsontest jsoncpp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment