From e3d42e65c27fb20546c704c514555433c29d3f92 Mon Sep 17 00:00:00 2001 From: Bryan Gillespie Date: Fri, 11 May 2018 11:16:27 -0400 Subject: [PATCH] Add CMake options to disable extras and support install Description: - Adds support for the following CMake options: - BUILD_TESTS (default: ON) - BUILD_EXAMPLES (default: ON) - CMAKE_INSTALL_PREFIX (both static and shared) --- CMakeLists.txt | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec9f365..b2a77e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,9 @@ project(json-schema-validator CXX) cmake_minimum_required(VERSION 3.2) +option(BUILD_TESTS "Build tests" ON) +option(BUILD_EXAMPLES "Build examples" ON) + # if used as a subdirectory just define a json-hpp-target as add_library(json-hpp INTERFACE) # and associate the path to json.hpp via target_include_directories() if(NOT TARGET json-hpp) @@ -33,6 +36,14 @@ add_library(json-schema-validator src/json-uri.cpp src/json-validator.cpp) +install(TARGETS json-schema-validator + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + +install(DIRECTORY src/ + DESTINATION include + FILES_MATCHING PATTERN "*.h*") + target_include_directories(json-schema-validator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) @@ -80,10 +91,14 @@ if(NOT TARGET json-hpp) # if used as a subdirectory do not install json-schema.h ) endif() -# simple json-schema-validator-executable -add_executable(json-schema-validate app/json-schema-validate.cpp) -target_link_libraries(json-schema-validate json-schema-validator) +if (BUILD_EXAMPLES) + # simple json-schema-validator-executable + add_executable(json-schema-validate app/json-schema-validate.cpp) + target_link_libraries(json-schema-validate json-schema-validator) +endif() -# test-zone -enable_testing() -add_subdirectory(test) +if (BUILD_TESTS) + # test-zone + enable_testing() + add_subdirectory(test) +endif()