From 20138c186ce0ef0ba4ad663d9db8a151d6aca0e0 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher
Date: Wed, 3 Feb 2021 11:38:03 +0100 Subject: [PATCH] find_path does not work when cross-compiling --- CMakeLists.txt | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2a77e7..7a83594 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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