2023-05-02 20:45:04 +02:00
# nlohmann-json is a custom addition to the emscripten SDK, so it is possible
# someone patched their SDK. Test out if the SDK supports nlohmann-json.
include ( CheckCXXSourceCompiles )
set ( CMAKE_REQUIRED_FLAGS "-sUSE_NLOHMANN_JSON=1" )
check_cxx_source_compiles ( "
#include <nlohmann/json.hpp>
i n t main ( ) { r e t u r n 0 ; } "
2023-07-06 11:49:06 +02:00
n l o h m a n n _ j s o n _ F O U N D
2023-05-02 20:45:04 +02:00
)
2023-07-06 11:49:06 +02:00
if ( nlohmann_json_FOUND )
2023-05-02 20:45:04 +02:00
add_library ( nlohmann_json INTERFACE IMPORTED )
set_target_properties ( nlohmann_json PROPERTIES
I N T E R F A C E _ C O M P I L E _ O P T I O N S " - s U S E _ N L O H M A N N _ J S O N = 1 "
I N T E R F A C E _ L I N K _ L I B R A R I E S " - s U S E _ N L O H M A N N _ J S O N = 1 "
)
2023-07-07 23:21:43 +02:00
set ( nlohmann_json_LIBRARY "nlohmann_json" )
2023-05-02 20:45:04 +02:00
else ( )
message ( WARNING "You are using an emscripten SDK without nlohmann-json support. Please apply 'emsdk-nlohmann_json.patch' to your local emsdk installation." )
endif ( )