@@ -278,34 +278,28 @@ if((NOT WITH_API_ONLY)
278278 OR WITH_ETW)
279279 # nlohmann_json package is required for most SDK build configurations
280280 find_package (nlohmann_json QUIET )
281- if (NOT nlohmann_json_FOUND)
282- if (EXISTS ${PROJECT_SOURCE_DIR} /.git)
283- message ("Trying to use local nlohmann::json from submodule" )
284- set (JSON_BuildTests
285- OFF
286- CACHE INTERNAL "" )
287- set (JSON_Install
288- ON
289- CACHE INTERNAL "" )
290- if (EXISTS ${PROJECT_SOURCE_DIR} /third_party/nlohmann-json/CMakeLists.txt)
291- # This option allows to link nlohmann_json::nlohmann_json target
292- add_subdirectory (${PROJECT_SOURCE_DIR} /third_party/nlohmann-json)
293- # This option allows to add header to include directories
294- include_directories (
295- ${PROJECT_SOURCE_DIR} /third_party/nlohmann-json/single_include)
296- else ()
297- message (
298- FATAL_ERROR
299- "\n nlohmann_json package was not found. Please either provide it manually or clone with submodules. "
300- "To initialize, fetch and checkout any nested submodules, you can use the following command:\n "
301- "git submodule update --init --recursive" )
302- endif ()
303- else ()
304- # Let's fail with default find_package error
305- find_package (nlohmann_json REQUIRED)
306- endif ()
307- else ()
281+ set (nlohmann_json_clone FALSE )
282+ if (nlohmann_json_FOUND)
308283 message ("Using external nlohmann::json" )
284+ elseif (EXISTS ${PROJECT_SOURCE_DIR} /.git
285+ AND EXISTS
286+ ${PROJECT_SOURCE_DIR} /third_party/nlohmann-json/CMakeLists.txt)
287+ message ("Trying to use local nlohmann::json from submodule" )
288+ set (JSON_BuildTests
289+ OFF
290+ CACHE INTERNAL "" )
291+ set (JSON_Install
292+ ON
293+ CACHE INTERNAL "" )
294+ # This option allows to link nlohmann_json::nlohmann_json target
295+ add_subdirectory (${PROJECT_SOURCE_DIR} /third_party/nlohmann-json)
296+ # This option allows to add header to include directories
297+ include_directories (
298+ ${PROJECT_SOURCE_DIR} /third_party/nlohmann-json/single_include)
299+ else ()
300+ set (nlohmann_json_clone TRUE )
301+ include (cmake/nlohmann-json.cmake)
302+ message ("\n nlohmann_json package was not found. Cloning from github" )
309303 endif ()
310304endif ()
311305
0 commit comments