2017-07-29 11:59:09 +02:00
|
|
|
cmake_minimum_required(VERSION 3.0.0)
|
2015-04-26 22:47:40 +02:00
|
|
|
|
2017-07-29 11:59:09 +02:00
|
|
|
##
|
|
|
|
## PROJECT
|
|
|
|
## name and version
|
|
|
|
##
|
|
|
|
project(nlohmann_json VERSION 2.1.1)
|
2015-04-26 22:47:40 +02:00
|
|
|
|
2017-07-29 11:59:09 +02:00
|
|
|
##
|
|
|
|
## OPTIONS
|
|
|
|
##
|
2017-07-11 15:57:49 +02:00
|
|
|
option(JSON_BuildTests "Build the unit tests" ON)
|
2016-05-08 17:30:24 +02:00
|
|
|
|
2017-07-29 11:59:09 +02:00
|
|
|
##
|
|
|
|
## CONFIGURATION
|
|
|
|
##
|
|
|
|
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
|
|
|
|
set(NLOHMANN_JSON_SOURCE_DIR "src/")
|
|
|
|
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
|
|
|
|
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include")
|
|
|
|
set(NLOHMANN_JSON_HEADER_INSTALL_DIR "${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}/nlohmann")
|
|
|
|
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
|
|
|
set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in")
|
|
|
|
set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/cmake_config")
|
|
|
|
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
|
|
|
|
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
|
2015-04-26 22:47:40 +02:00
|
|
|
|
2017-07-29 11:59:09 +02:00
|
|
|
##
|
|
|
|
## TARGET
|
|
|
|
## create target and add include path
|
|
|
|
##
|
|
|
|
add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
|
2017-02-12 12:46:54 +01:00
|
|
|
|
2017-07-29 11:59:09 +02:00
|
|
|
target_include_directories(
|
|
|
|
${NLOHMANN_JSON_TARGET_NAME}
|
|
|
|
INTERFACE $<INSTALL_INTERFACE:include/>
|
|
|
|
)
|
|
|
|
|
|
|
|
##
|
|
|
|
## TESTS
|
|
|
|
## create and configure the unit test target
|
|
|
|
##
|
2017-07-11 15:57:49 +02:00
|
|
|
if(JSON_BuildTests)
|
2017-07-27 16:50:24 +02:00
|
|
|
enable_testing()
|
2017-07-29 11:59:09 +02:00
|
|
|
include_directories(${NLOHMANN_JSON_SOURCE_DIR})
|
2016-05-11 02:25:54 +02:00
|
|
|
add_subdirectory(test)
|
2016-05-08 17:30:24 +02:00
|
|
|
endif()
|
2016-04-25 09:36:05 +02:00
|
|
|
|
2017-07-29 11:59:09 +02:00
|
|
|
##
|
|
|
|
## INSTALL
|
|
|
|
## install header files, generate and install cmake config files for find_package()
|
|
|
|
##
|
2016-04-25 10:23:14 +02:00
|
|
|
include(CMakePackageConfigHelpers)
|
2017-07-29 11:59:09 +02:00
|
|
|
write_basic_package_version_file(
|
|
|
|
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE} COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
configure_package_config_file(
|
|
|
|
${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE}
|
|
|
|
${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE}
|
|
|
|
INSTALL_DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
DIRECTORY ${NLOHMANN_JSON_SOURCE_DIR}
|
|
|
|
DESTINATION ${NLOHMANN_JSON_HEADER_INSTALL_DIR}
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
FILES ${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE} ${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
|
|
|
|
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
|
|
|
|
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
|
|
|
|
INCLUDES DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
|
|
|
|
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
|
|
|
|
)
|