Menu

#22 Generate jsoncpp-config.cmake.

Unstable (example)
closed-out-of-date
nobody
None
5
2015-03-06
2013-09-25
No

A CMake library jsoncpp-config.cmake file is very important for other CMake projects that use jsoncpp.

This allows other projects that use CMake to build against JsonCpp effectively
by adding

find_package( jsoncpp )
include_directories( ${jsoncpp_INCLUDE_DIRS} )
add_executable( myexe main.cpp )
target_link_libraries( myexe ${jsoncpp_LIBRARIES} )

to their CMakeLists.txt.

By only pointing their CMake build jsoncpp_DIR to their build of JsonCpp, it is
possible to easily and reliably build against an installed version of JsonCpp
or a non-installed version of JsonCpp.

This conforms to the recommended configuration as described here:

http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file

This solution is more robust and easier to use that forcing other projects to use a FindJsonCpp.cmake file.

Two patches are provided, one that changes the CMake commands to modern CMake style of lower case command names, and one that adds the jsoncpp-config.cmake file generation.

2 Attachments

Discussion

  • Christopher Dunn

    • status: open --> closed-out-of-date
     

Log in to post a comment.