2017-04-27 02:05:25 +08:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
if (CMAKE_VERSION VERSION_LESS "3")
|
|
|
|
project(json11 CXX)
|
|
|
|
else()
|
2017-04-29 01:46:38 +08:00
|
|
|
cmake_policy(SET CMP0048 NEW)
|
|
|
|
project(json11 VERSION 1.0.0 LANGUAGES CXX)
|
2017-04-27 02:05:25 +08:00
|
|
|
endif()
|
2015-08-20 05:53:28 +08:00
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
|
2017-02-17 01:35:24 +08:00
|
|
|
option(JSON11_BUILD_TESTS "Build unit tests" OFF)
|
2016-12-28 10:25:14 +08:00
|
|
|
option(JSON11_ENABLE_DR1467_CANARY "Enable canary test for DR 1467" OFF)
|
2016-07-05 22:37:44 +08:00
|
|
|
|
2017-04-27 02:05:25 +08:00
|
|
|
if(CMAKE_VERSION VERSION_LESS "3")
|
|
|
|
add_definitions(-std=c++11)
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
|
|
|
|
2017-01-13 02:03:09 +08:00
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
set(CMAKE_INSTALL_PREFIX /usr)
|
|
|
|
endif()
|
2016-08-11 09:16:59 +08:00
|
|
|
|
2016-04-08 01:16:21 +08:00
|
|
|
add_library(json11 json11.cpp)
|
2017-02-08 03:32:23 +08:00
|
|
|
target_include_directories(json11 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
2016-04-08 01:16:21 +08:00
|
|
|
target_compile_options(json11
|
2017-02-07 09:10:38 +08:00
|
|
|
PRIVATE -fPIC -fno-rtti -fno-exceptions -Wall)
|
|
|
|
|
|
|
|
# Set warning flags, which may vary per platform
|
2017-02-08 03:54:10 +08:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
set(_possible_warnings_flags /W4 /WX -Wextra -Werror)
|
2019-04-16 07:06:48 +08:00
|
|
|
foreach(_warning_flag ${_possible_warnings_flags})
|
|
|
|
unset(_flag_supported)
|
|
|
|
CHECK_CXX_COMPILER_FLAG(${_warning_flag} _flag_supported)
|
2017-02-08 03:54:10 +08:00
|
|
|
if(${_flag_supported})
|
|
|
|
target_compile_options(json11 PRIVATE ${_warning_flag})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2017-02-07 09:10:38 +08:00
|
|
|
|
2016-04-17 01:41:25 +08:00
|
|
|
configure_file("json11.pc.in" "json11.pc" @ONLY)
|
2015-08-20 05:53:28 +08:00
|
|
|
|
2016-07-05 22:37:44 +08:00
|
|
|
if (JSON11_BUILD_TESTS)
|
2016-08-14 07:22:49 +08:00
|
|
|
|
|
|
|
# enable test for DR1467, described here: https://llvm.org/bugs/show_bug.cgi?id=23812
|
|
|
|
if(JSON11_ENABLE_DR1467_CANARY)
|
|
|
|
add_definitions(-D JSON11_ENABLE_DR1467_CANARY=1)
|
|
|
|
else()
|
|
|
|
add_definitions(-D JSON11_ENABLE_DR1467_CANARY=0)
|
|
|
|
endif()
|
|
|
|
|
2016-07-05 22:37:44 +08:00
|
|
|
add_executable(json11_test test.cpp)
|
|
|
|
target_link_libraries(json11_test json11)
|
|
|
|
endif()
|
2016-04-17 01:41:25 +08:00
|
|
|
|
2016-09-08 08:33:00 +08:00
|
|
|
install(TARGETS json11 DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE})
|
2017-01-31 07:09:01 +08:00
|
|
|
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include/${CMAKE_LIBRARY_ARCHITECTURE})
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/json11.pc" DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig)
|