From 8076ba74e08907b1e219f748f61f6ae6b69ca145 Mon Sep 17 00:00:00 2001 From: Nick White Date: Sat, 16 Apr 2016 18:41:25 +0100 Subject: [PATCH] Generate pkg-config File & Add Install ...to the CMake build script. The pkg-config file needs a version number (which it takes from the CMakeLists.txt variable), which I've set to 1.0.0. The cmake project declaration needs to be after the minimum-requirement declaration to avoid errors from the cmake's change in VERSION semantics. --- .gitignore | 11 +++++++++++ CMakeLists.txt | 8 ++++++-- json11.pc.in | 9 +++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 json11.pc.in diff --git a/.gitignore b/.gitignore index 9daeafb..e959b6f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,12 @@ +# generated files test +libjson11.a +json11.pc + +# Cmake +CMakeCache.txt +CTestTestfile.cmake +CMakeFiles +CMakeScripts +cmake_install.cmake +install_manifest.txt \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 397104a..9d6adf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ -project(json11 CXX) - cmake_minimum_required(VERSION 3.2) +project(json11 VERSION 1.0.0 LANGUAGES CXX) enable_testing() @@ -9,6 +8,11 @@ target_include_directories(json11 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_options(json11 PUBLIC -std=c++11 PRIVATE -fno-rtti -fno-exceptions -Wall -Wextra -Werror) +configure_file("json11.pc.in" "json11.pc" @ONLY) add_executable(json11_test test.cpp) target_link_libraries(json11_test json11) + +install(TARGETS json11 DESTINATION lib) +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include) +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.pc" DESTINATION lib/pkgconfig) diff --git a/json11.pc.in b/json11.pc.in new file mode 100644 index 0000000..de4b6dd --- /dev/null +++ b/json11.pc.in @@ -0,0 +1,9 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: @PROJECT_NAME@ +Description: json11 is a tiny JSON library for C++11, providing JSON parsing and serialization. +Version: @PROJECT_VERSION@ +Libs: -L${libdir} -ljson11 +Cflags: -I${includedir} \ No newline at end of file