Browse Source

* Initial commit

master
bergmann 4 years ago
commit
ab62f18b64
7 changed files with 21039 additions and 0 deletions
  1. +55
    -0
      CMakeLists.txt
  2. +10
    -0
      cmake/nlohmann_json-config.cmake
  3. +18
    -0
      cmake/nlohmann_json-var.cmake
  4. +4
    -0
      cmake/nlohmann_json-version.cmake
  5. +20910
    -0
      include/nlohmann/json.hpp
  6. +17
    -0
      src/CMakeLists.txt
  7. +25
    -0
      tools/update

+ 55
- 0
CMakeLists.txt View File

@@ -0,0 +1,55 @@
# Initialize CMake ################################################################################

CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR )

# Set CMAKE_BUILD_TYPE
If ( NOT CMAKE_BUILD_TYPE )
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE )
EndIf ( NOT CMAKE_BUILD_TYPE )
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel )

# Set CMAKE_MODULE_PATH
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
EndIf ( )
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
EndIf ( )

# Project #########################################################################################

Include ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/nlohmann_json-var.cmake" )
Project ( nlohmann_json
DESCRIPTION "A simple library"
VERSION "${NLOHMANN_JSON_VERSION}" )
Include ( CTest )
Include ( GNUInstallDirs )

# Subdirectories
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src )

# Install
Include ( CMakePackageConfigHelpers )
Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/nlohmann_json-config-version.cmake"
VERSION ${NLOHMANN_JSON_VERSION}
COMPATIBILITY AnyNewerVersion )
Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/nlohmann_json-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/nlohmann_json-config.cmake"
@ONLY )

Set ( ConfigPackageLocation "${NLOHMANN_JSON_INSTALL_DIR_SHARE}/cmake" )
Install ( EXPORT
nlohmann_json
NAMESPACE
nlohmann_json::
DESTINATION
${ConfigPackageLocation} )
Install ( FILES
"${CMAKE_CURRENT_BINARY_DIR}/cmake/nlohmann_json-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/nlohmann_json-config-version.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel )

+ 10
- 0
cmake/nlohmann_json-config.cmake View File

@@ -0,0 +1,10 @@
# nlohmann_json-config.cmake - package configuration file

Message ( WARNING "Please configure the dependencies of this package!" )
# Include ( CMakeFindDependencyMacro )
# Find_Dependency ( <dependency> )

Include ( FindPackageHandleStandardArgs )
Set ( ${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE} )
Find_Package_Handle_Standard_Args ( nlohmann_json CONFIG_MODE )
Include ( "${CMAKE_CURRENT_LIST_DIR}/nlohmann_json.cmake")

+ 18
- 0
cmake/nlohmann_json-var.cmake View File

@@ -0,0 +1,18 @@
# Version
Include ( ${CMAKE_CURRENT_LIST_DIR}/nlohmann_json-version.cmake )
Set ( NLOHMANN_JSON_VERSION_SHORT "${NLOHMANN_JSON_VERSION_MAJOR}.${NLOHMANN_JSON_VERSION_MINOR}" )
Set ( NLOHMANN_JSON_VERSION_MID "${NLOHMANN_JSON_VERSION_SHORT}.${NLOHMANN_JSON_VERSION_PATCH}" )
Set ( NLOHMANN_JSON_VERSION "${NLOHMANN_JSON_VERSION_MID}.${NLOHMANN_JSON_VERSION_BUILD}" )
Set ( NLOHMANN_JSON_NAME "nlohmann_json-${NLOHMANN_JSON_VERSION_MID}" )
Set ( NLOHMANN_JSON_OUTPUTNAME "nlohmann_json" )

# Install directories
Set ( NLOHMANN_JSON_INSTALL_DIR_INCLUDE "include/${NLOHMANN_JSON_NAME}" )
Set ( NLOHMANN_JSON_INSTALL_DIR_LIB "lib" )
Set ( NLOHMANN_JSON_INSTALL_DIR_SHARE "share/${NLOHMANN_JSON_NAME}" )

# C Standard
Set ( CMAKE_C_STANDARD 11 )
Set ( CMAKE_CXX_STANDARD 17 )
Set ( CMAKE_C_STANDARD_REQUIRED ON )
Set ( CMAKE_CXX_STANDARD_REQUIRED ON )

+ 4
- 0
cmake/nlohmann_json-version.cmake View File

@@ -0,0 +1,4 @@
Set ( NLOHMANN_JSON_VERSION_MAJOR 3 )
Set ( NLOHMANN_JSON_VERSION_MINOR 6 )
Set ( NLOHMANN_JSON_VERSION_PATCH 1 )
Set ( NLOHMANN_JSON_VERSION_BUILD 0 )

+ 20910
- 0
include/nlohmann/json.hpp
File diff suppressed because it is too large
View File


+ 17
- 0
src/CMakeLists.txt View File

@@ -0,0 +1,17 @@
# Interface Library ###############################################################################

Set ( NLOHMANN_JSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include )
Add_Library ( nlohmann_json INTERFACE )
Target_Include_Directories ( nlohmann_json
INTERFACE
$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${NLOHMANN_JSON_INSTALL_DIR_INCLUDE}> )

# Install #########################################################################################

# Header
Install ( DIRECTORY ${NLOHMANN_JSON_INCLUDE_DIR}/nlohman
DESTINATION ${NLOHMANN_JSON_INSTALL_DIR_INCLUDE} )
Install ( TARGETS nlohmann_json
EXPORT nlohmann_json
DESTINATION ${NLOHMANN_JSON_INSTALL_DIR_INCLUDE} )

+ 25
- 0
tools/update View File

@@ -0,0 +1,25 @@
#!/bin/bash

ScriptFile=$(readlink -f "${BASH_SOURCE[0]}")
ScriptDir=$(dirname "${ScriptFile}")

HeaderUrl="https://raw.githubusercontent.com/nlohmann/json/develop/single_include/nlohmann/json.hpp"
HeaderFile="$ScriptDir/../include/nlohman/json.hpp"
VersionFile="$ScriptDir/../cmake/nlohmann_json-version.cmake"

wget "$HeaderUrl" -O "$HeaderFile"

VERION_MAJOR=$(egrep -io 'NLOHMANN_JSON_VERSION_MAJOR\s+[0-9]+' "$HeaderFile")
VERION_MINOR=$(egrep -io 'NLOHMANN_JSON_VERSION_MINOR\s+[0-9]+' "$HeaderFile")
VERION_PATCH=$(egrep -io 'NLOHMANN_JSON_VERSION_PATCH\s+[0-9]+' "$HeaderFile")

VERION_MAJOR=$(echo "$VERION_MAJOR" | egrep -io '[0-9]+')
VERION_MINOR=$(echo "$VERION_MINOR" | egrep -io '[0-9]+')
VERION_PATCH=$(echo "$VERION_PATCH" | egrep -io '[0-9]+')

printf \
"Set ( NLOHMANN_JSON_VERSION_MAJOR $VERION_MAJOR )
Set ( NLOHMANN_JSON_VERSION_MINOR $VERION_MINOR )
Set ( NLOHMANN_JSON_VERSION_PATCH $VERION_PATCH )
Set ( NLOHMANN_JSON_VERSION_BUILD 0 )
" > "$VersionFile"

Loading…
Cancel
Save