find_path does not work when cross-compiling
This commit is contained in:
parent
2785ce0c64
commit
20138c186c
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user