Skip to content

Commit

Permalink
Merge pull request #944 from theodelrieu/fix/cmake_install
Browse files Browse the repository at this point in the history
fix cmake install directory (for real this time)
  • Loading branch information
nlohmann committed Feb 1, 2018
2 parents 9958dde + 14cd019 commit ce7d0eb
Show file tree
Hide file tree
Showing 73 changed files with 226 additions and 224 deletions.
13 changes: 6 additions & 7 deletions CMakeLists.txt
Expand Up @@ -24,17 +24,16 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
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")

if (JSON_MultipleHeaders)
set(NLOHMANN_JSON_SOURCE_DIR "develop/")
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
else()
set(NLOHMANN_JSON_SOURCE_DIR "src/")
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/single_include/")
endif()

##
Expand All @@ -46,7 +45,7 @@ add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
target_include_directories(
${NLOHMANN_JSON_TARGET_NAME}
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/${NLOHMANN_JSON_SOURCE_DIR}>
$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:include>
)

Expand All @@ -70,7 +69,6 @@ include(CTest) #adds option BUILD_TESTING (default ON)

if(BUILD_TESTING AND JSON_BuildTests)
enable_testing()
include_directories(${NLOHMANN_JSON_SOURCE_DIR})
add_subdirectory(test)
endif()

Expand All @@ -87,9 +85,10 @@ configure_package_config_file(
${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}
DIRECTORY ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}
DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
)
install(
FILES ${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE} ${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
Expand Down
78 changes: 40 additions & 38 deletions Makefile
@@ -1,37 +1,39 @@
.PHONY: pretty clean ChangeLog.md

SRCS = develop/json.hpp \
develop/json_fwd.hpp \
develop/adl_serializer.hpp \
develop/detail/conversions/from_json.hpp \
develop/detail/conversions/to_chars.hpp \
develop/detail/conversions/to_json.hpp \
develop/detail/exceptions.hpp \
develop/detail/input/binary_reader.hpp \
develop/detail/input/input_adapters.hpp \
develop/detail/input/lexer.hpp \
develop/detail/input/parser.hpp \
develop/detail/iterators/internal_iterator.hpp \
develop/detail/iterators/iter_impl.hpp \
develop/detail/iterators/iteration_proxy.hpp \
develop/detail/iterators/json_reverse_iterator.hpp \
develop/detail/iterators/primitive_iterator.hpp \
develop/detail/json_pointer.hpp \
develop/detail/json_ref.hpp \
develop/detail/macro_scope.hpp \
develop/detail/macro_unscope.hpp \
develop/detail/meta.hpp \
develop/detail/output/binary_writer.hpp \
develop/detail/output/output_adapters.hpp \
develop/detail/output/serializer.hpp \
develop/detail/value_t.hpp
SRCS = include/nlohmann/json.hpp \
include/nlohmann/json_fwd.hpp \
include/nlohmann/adl_serializer.hpp \
include/nlohmann/detail/conversions/from_json.hpp \
include/nlohmann/detail/conversions/to_chars.hpp \
include/nlohmann/detail/conversions/to_json.hpp \
include/nlohmann/detail/exceptions.hpp \
include/nlohmann/detail/input/binary_reader.hpp \
include/nlohmann/detail/input/input_adapters.hpp \
include/nlohmann/detail/input/lexer.hpp \
include/nlohmann/detail/input/parser.hpp \
include/nlohmann/detail/iterators/internal_iterator.hpp \
include/nlohmann/detail/iterators/iter_impl.hpp \
include/nlohmann/detail/iterators/iteration_proxy.hpp \
include/nlohmann/detail/iterators/json_reverse_iterator.hpp \
include/nlohmann/detail/iterators/primitive_iterator.hpp \
include/nlohmann/detail/json_pointer.hpp \
include/nlohmann/detail/json_ref.hpp \
include/nlohmann/detail/macro_scope.hpp \
include/nlohmann/detail/macro_unscope.hpp \
include/nlohmann/detail/meta.hpp \
include/nlohmann/detail/output/binary_writer.hpp \
include/nlohmann/detail/output/output_adapters.hpp \
include/nlohmann/detail/output/serializer.hpp \
include/nlohmann/detail/value_t.hpp

UNAME = $(shell uname)
CXX=clang++

AMALGAMATED_FILE=single_include/nlohmann/json.hpp

# main target
all:
@echo "amalgamate - amalgamate file src/json.hpp from the develop sources"
@echo "amalgamate - amalgamate file single_include/nlohmann/json.hpp from the include/nlohmann sources"
@echo "ChangeLog.md - generate ChangeLog file"
@echo "check - compile and execute test suite"
@echo "check-amalgamation - check whether sources have been amalgamated"
Expand Down Expand Up @@ -243,7 +245,7 @@ fuzzing-stop:

# call cppcheck on the main header file
cppcheck:
cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1
cppcheck --enable=warning --inconclusive --force --std=c++11 $(AMALGAMATED_FILE) --error-exitcode=1


##########################################################################
Expand All @@ -257,29 +259,29 @@ pretty:
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
--align-reference=type --add-brackets --convert-tabs --close-templates \
--lineend=linux --preserve-date --suffix=none --formatted \
$(SRCS) src/json.hpp test/src/*.cpp \
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp \
benchmarks/src/benchmarks.cpp doc/examples/*.cpp

# create single header file
amalgamate: src/json.hpp
amalgamate: $(AMALGAMATED_FILE)

src/json.hpp: $(SRCS)
third_party/amalgamate/amalgamate.py -c third_party/amalgamate/config.json -s develop --verbose=yes
$(AMALGAMATED_FILE): $(SRCS)
third_party/amalgamate/amalgamate.py -c third_party/amalgamate/config.json -s . --verbose=yes
$(MAKE) pretty

# check if src/json.hpp has been amalgamated from the develop sources
# check if single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources
check-amalgamation:
@mv src/json.hpp src/json.hpp~
@mv $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~
@$(MAKE) amalgamate
@diff src/json.hpp src/json.hpp~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv src/json.hpp~ src/json.hpp ; false)
@mv src/json.hpp~ src/json.hpp
@diff $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE) ; false)
@mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE)

# check if every header in develop includes sufficient headers to be compiled
# check if every header in nlohmann includes sufficient headers to be compiled
# individually
check-single-includes:
for x in $(SRCS); do \
echo "#include \"$$x\"\nint main() {}\n" | sed 's|develop/||' > single_include_test.cpp; \
$(CXX) $(CXXFLAGS) -Idevelop -std=c++11 single_include_test.cpp -o single_include_test; \
echo "#include <$$x>\nint main() {}\n" | sed 's|include/||' > single_include_test.cpp; \
$(CXX) $(CXXFLAGS) -Iinclude -std=c++11 single_include_test.cpp -o single_include_test; \
rm single_include_test.cpp single_include_test; \
done

Expand Down
Expand Up @@ -2,8 +2,8 @@

#include <utility>

#include "detail/conversions/from_json.hpp"
#include "detail/conversions/to_json.hpp"
#include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp>

namespace nlohmann
{
Expand Down
Expand Up @@ -11,10 +11,10 @@
#include <utility> // pair, declval
#include <valarray> // valarray

#include "detail/exceptions.hpp"
#include "detail/macro_scope.hpp"
#include "detail/meta.hpp"
#include "detail/value_t.hpp"
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta.hpp>
#include <nlohmann/detail/value_t.hpp>

namespace nlohmann
{
Expand Down
File renamed without changes.
Expand Up @@ -8,8 +8,8 @@
#include <valarray> // valarray
#include <vector> // vector

#include "detail/meta.hpp"
#include "detail/value_t.hpp"
#include <nlohmann/detail/meta.hpp>
#include <nlohmann/detail/value_t.hpp>

namespace nlohmann
{
Expand Down
File renamed without changes.
Expand Up @@ -15,10 +15,10 @@
#include <string> // char_traits, string
#include <utility> // make_pair, move

#include "detail/input/input_adapters.hpp"
#include "detail/exceptions.hpp"
#include "detail/macro_scope.hpp"
#include "detail/value_t.hpp"
#include <nlohmann/detail/input/input_adapters.hpp>
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/value_t.hpp>

namespace nlohmann
{
Expand Down
Expand Up @@ -14,7 +14,7 @@
#include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
#include <utility> // pair, declval

#include "detail/macro_scope.hpp"
#include <nlohmann/detail/macro_scope.hpp>

namespace nlohmann
{
Expand Down
Expand Up @@ -10,8 +10,8 @@
#include <string> // char_traits, string
#include <vector> // vector

#include "detail/macro_scope.hpp"
#include "detail/input/input_adapters.hpp"
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/input/input_adapters.hpp>

namespace nlohmann
{
Expand Down
Expand Up @@ -7,11 +7,11 @@
#include <string> // string
#include <utility> // move

#include "detail/exceptions.hpp"
#include "detail/macro_scope.hpp"
#include "detail/input/input_adapters.hpp"
#include "detail/input/lexer.hpp"
#include "detail/value_t.hpp"
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/input/input_adapters.hpp>
#include <nlohmann/detail/input/lexer.hpp>
#include <nlohmann/detail/value_t.hpp>

namespace nlohmann
{
Expand Down
@@ -1,6 +1,6 @@
#pragma once

#include "detail/iterators/primitive_iterator.hpp"
#include <nlohmann/detail/iterators/primitive_iterator.hpp>

namespace nlohmann
{
Expand Down
Expand Up @@ -4,12 +4,12 @@
#include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
#include <type_traits> // conditional, is_const, remove_const

#include "detail/exceptions.hpp"
#include "detail/iterators/internal_iterator.hpp"
#include "detail/iterators/primitive_iterator.hpp"
#include "detail/macro_scope.hpp"
#include "detail/meta.hpp"
#include "detail/value_t.hpp"
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/iterators/internal_iterator.hpp>
#include <nlohmann/detail/iterators/primitive_iterator.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta.hpp>
#include <nlohmann/detail/value_t.hpp>

namespace nlohmann
{
Expand Down
Expand Up @@ -3,7 +3,7 @@
#include <cstddef> // size_t
#include <string> // string, to_string

#include "detail/value_t.hpp"
#include <nlohmann/detail/value_t.hpp>

namespace nlohmann
{
Expand Down
Expand Up @@ -5,9 +5,9 @@
#include <string> // string
#include <vector> // vector

#include "detail/macro_scope.hpp"
#include "detail/exceptions.hpp"
#include "detail/value_t.hpp"
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/value_t.hpp>

namespace nlohmann
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions develop/detail/meta.hpp → include/nlohmann/detail/meta.hpp
Expand Up @@ -6,8 +6,8 @@
#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
#include <utility> // declval

#include "json_fwd.hpp"
#include "detail/macro_scope.hpp"
#include <nlohmann/json_fwd.hpp>
#include <nlohmann/detail/macro_scope.hpp>

namespace nlohmann
{
Expand Down
Expand Up @@ -6,8 +6,8 @@
#include <cstring> // memcpy
#include <limits> // numeric_limits

#include "detail/input/binary_reader.hpp"
#include "detail/output/output_adapters.hpp"
#include <nlohmann/detail/input/binary_reader.hpp>
#include <nlohmann/detail/output/output_adapters.hpp>

namespace nlohmann
{
Expand Down
File renamed without changes.
Expand Up @@ -16,12 +16,12 @@
#include <sstream> // stringstream
#include <type_traits> // is_same

#include "detail/exceptions.hpp"
#include "detail/conversions/to_chars.hpp"
#include "detail/macro_scope.hpp"
#include "detail/meta.hpp"
#include "detail/output/output_adapters.hpp"
#include "detail/value_t.hpp"
#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/conversions/to_chars.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta.hpp>
#include <nlohmann/detail/output/output_adapters.hpp>
#include <nlohmann/detail/value_t.hpp>

namespace nlohmann
{
Expand Down
File renamed without changes.

0 comments on commit ce7d0eb

Please sign in to comment.