add single_header CMake target
This commit is contained in:
parent
57d822b6e2
commit
7e4ee23f40
5 changed files with 19119 additions and 27 deletions
|
|
@ -6,6 +6,12 @@ cmake_minimum_required(VERSION 3.0.0)
|
|||
##
|
||||
project(nlohmann_json VERSION 3.0.1 LANGUAGES CXX)
|
||||
|
||||
##
|
||||
## INCLUDE
|
||||
##
|
||||
##
|
||||
include(ExternalProject)
|
||||
|
||||
##
|
||||
## OPTIONS
|
||||
##
|
||||
|
|
@ -15,7 +21,7 @@ option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
|
|||
## CONFIGURATION
|
||||
##
|
||||
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
|
||||
set(NLOHMANN_JSON_SOURCE_DIR "src/")
|
||||
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")
|
||||
|
|
@ -62,6 +68,19 @@ if(BUILD_TESTING AND JSON_BuildTests)
|
|||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(amalgamate
|
||||
GIT_REPOSITORY "https://github.com/theodelrieu/Amalgamate"
|
||||
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}"
|
||||
)
|
||||
|
||||
# There is no way to tell amalgamate to force-write the output file even if it already exists...
|
||||
add_custom_target(single_header ALL rm -f "${CMAKE_SOURCE_DIR}/single_header/json.hpp"
|
||||
COMMENT "Amalgamating json.hpp..."
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${NLOHMANN_JSON_SOURCE_DIR}
|
||||
DEPENDS amalgamate
|
||||
COMMAND "${CMAKE_BINARY_DIR}/bin/amalgamate" -w '*.hpp' -i . json.hpp "${CMAKE_SOURCE_DIR}/single_header/json.hpp"
|
||||
)
|
||||
|
||||
##
|
||||
## INSTALL
|
||||
## install header files, generate and install cmake config files for find_package()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue