Merge branch 'develop' into feature/json-patch
This commit is contained in:
commit
7dc07b75de
2 changed files with 57 additions and 19 deletions
|
@ -1,25 +1,57 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
project(json CXX)
|
# define the project
|
||||||
|
project(json VERSION 2.0.0 LANGUAGES CXX)
|
||||||
|
|
||||||
add_executable(json_unit
|
# define project variables
|
||||||
src/json.hpp test/catch.hpp test/unit.cpp
|
set(JSON_TARGET_NAME ${PROJECT_NAME})
|
||||||
)
|
set(JSON_UNITTEST_TARGET_NAME "json_unit")
|
||||||
|
set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME})
|
||||||
|
set(JSON_TARGETS_FILENAME "${JSON_PACKAGE_NAME}Targets.cmake")
|
||||||
|
set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake")
|
||||||
|
set(JSON_CONFIGVERSION_FILENAME "${JSON_PACKAGE_NAME}ConfigVersion.cmake")
|
||||||
|
set(JSON_CONFIG_DESTINATION "cmake")
|
||||||
|
set(JSON_INCLUDE_DESTINATION "include/nlohmann")
|
||||||
|
|
||||||
if(MSVC)
|
# create and configure the library target
|
||||||
set(CMAKE_CXX_FLAGS
|
add_library(${JSON_TARGET_NAME} INTERFACE)
|
||||||
"/EHsc"
|
target_include_directories(${JSON_TARGET_NAME} INTERFACE
|
||||||
)
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||||
|
$<INSTALL_INTERFACE:${JSON_INCLUDE_DESTINATION}>)
|
||||||
|
|
||||||
STRING(REPLACE "/O2" "/Od" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
# create and configure the unit test target
|
||||||
|
add_executable(${JSON_UNITTEST_TARGET_NAME}
|
||||||
|
"test/catch.hpp" "test/unit.cpp")
|
||||||
|
set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES
|
||||||
|
CXX_STANDARD 11
|
||||||
|
CXX_STANDARD_REQUIRED ON
|
||||||
|
COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
|
||||||
|
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>")
|
||||||
|
target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "test")
|
||||||
|
target_link_libraries(${JSON_UNITTEST_TARGET_NAME} ${JSON_TARGET_NAME})
|
||||||
|
|
||||||
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
|
# generate a config and config version file for the package
|
||||||
else(MSVC)
|
include(CMakePackageConfigHelpers)
|
||||||
set(CMAKE_CXX_FLAGS
|
configure_package_config_file("cmake/config.cmake.in"
|
||||||
"-std=c++11"
|
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
|
||||||
)
|
INSTALL_DESTINATION ${JSON_CONFIG_DESTINATION})
|
||||||
endif(MSVC)
|
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
include_directories(
|
# export the library target and store build directory in package registry
|
||||||
src test
|
export(TARGETS ${JSON_TARGET_NAME}
|
||||||
)
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/${JSON_TARGETS_FILENAME}")
|
||||||
|
export(PACKAGE ${JSON_PACKAGE_NAME})
|
||||||
|
|
||||||
|
# install library target and config files
|
||||||
|
install(TARGETS ${JSON_TARGET_NAME}
|
||||||
|
EXPORT ${JSON_PACKAGE_NAME})
|
||||||
|
install(FILES "src/json.hpp"
|
||||||
|
DESTINATION ${JSON_INCLUDE_DESTINATION})
|
||||||
|
install(EXPORT ${JSON_PACKAGE_NAME}
|
||||||
|
FILE ${JSON_TARGETS_FILENAME}
|
||||||
|
DESTINATION ${JSON_CONFIG_DESTINATION})
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
|
||||||
|
DESTINATION ${JSON_CONFIG_DESTINATION})
|
||||||
|
|
6
cmake/config.cmake.in
Normal file
6
cmake/config.cmake.in
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
cmake_policy(PUSH)
|
||||||
|
cmake_policy(SET CMP0024 OLD)
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/@JSON_TARGETS_FILENAME@)
|
||||||
|
cmake_policy(POP)
|
Loading…
Reference in a new issue