Compare commits

...

1 Commits

Author SHA1 Message Date
Patrick Boettcher
20138c186c find_path does not work when cross-compiling 2021-02-03 11:38:03 +01:00

View File

@ -10,19 +10,12 @@ option(BUILD_EXAMPLES "Build examples" ON)
if(NOT TARGET json-hpp)
set(NLOHMANN_JSON_DIR "" CACHE STRING "path to json.hpp")
# find nlohmann's json.hpp
find_path(JSON_HPP nlohmann/json.hpp
PATHS
${NLOHMANN_JSON_DIR}
${CMAKE_BINARY_DIR}/${NLOHMANN_JSON_DIR}) # in case it is a relative path
# get the full, real path
get_filename_component(NLOHMANN_JSON_REALPATH ${JSON_HPP} REALPATH)
if(NOT EXISTS ${NLOHMANN_JSON_REALPATH}/nlohmann/json.hpp)
if(NOT EXISTS ${NLOHMANN_JSON_DIR}/nlohmann/json.hpp)
message(FATAL_ERROR "please set NLOHMANN_JSON_DIR to a path in which NLohmann's json.hpp can be found. Looking for nlohmann/json.hpp in '${NLOHMANN_JSON_REALPATH}")
endif()
get_filename_component(NLOHMANN_JSON_REALPATH ${NLOHMANN_JSON_DIR} REALPATH)
# create an interface-library for simple cmake-linking
add_library(json-hpp INTERFACE)
target_include_directories(json-hpp