@@ -8,6 +8,8 @@ project (lpac
88set (CMAKE_C_STANDARD 99)
99set (CMAKE_C_STANDARD_REQUIRED ON )
1010
11+ option (USE_SYSTEM_DEPS "Use system-wide installed dependencies" OFF )
12+
1113set (LPAC_CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake" )
1214list (APPEND CMAKE_MODULE_PATH ${LPAC_CMAKE_MODULE_PATH} )
1315
@@ -65,51 +67,33 @@ if(CPACK_GENERATOR)
6567 include (CPack )
6668endif ()
6769
68- include (FetchContent )
69- FetchContent_Declare (
70- cjson
71- # FIXME: change back to DaveGamble/cJSON if upstream fix it
72- # https://github.com/DaveGamble/cJSON/pull/949
73- # https://github.com/DaveGamble/cJSON/pull/955
74- GIT_REPOSITORY https://github.com/CoelacanthusHex/cJSON
75- GIT_TAG 4818f043bda624b5738384eae3a0189b2bd1f5e1
76- GIT_PROGRESS ON
77- SOURCE_DIR cjson
78- )
79- if (NOT DEFINED USE_SYSTEM_DEPS)
80- find_package (cJSON )
81- if (NOT cJSON_FOUND)
82- if (NOT NO_NETWORK)
83- set (CJSON_OVERRIDE_BUILD_SHARED_LIBS ON )
84- set (CJSON_BUILD_SHARED_LIBS OFF )
85- set (ENABLE_CJSON_TEST OFF )
86- set (ENABLE_CUSTOM_COMPILER_FLAGS OFF )
87- FetchContent_MakeAvailable (cjson)
88- set (CJSON_LIBRARY cjson)
89- # Force cJSON dynamically link CRT although it's statuc library.
90- set_property (TARGET cjson PROPERTY
91- MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG :Debug >:Debug >DLL" )
92- else ()
93- message (FATAL_ERROR "System cJSON is not found and network access is not permitted!" )
94- endif ()
95- endif ()
96- else ()
97- if (USE_SYSTEM_DEPS)
98- find_package (cJSON REQUIRED )
99- elseif (NOT NO_NETWORK)
100- set (CJSON_OVERRIDE_BUILD_SHARED_LIBS ON )
101- set (CJSON_BUILD_SHARED_LIBS OFF )
102- set (ENABLE_CJSON_TEST OFF )
103- set (ENABLE_CUSTOM_COMPILER_FLAGS OFF )
104- FetchContent_MakeAvailable (cjson)
105- set (CJSON_LIBRARY cjson)
106- # Force cJSON dynamically link CRT although it's statuc library.
107- set_property (TARGET cjson PROPERTY
70+ if (USE_SYSTEM_DEPS)
71+ find_package (cJSON REQUIRED )
72+ elseif (NOT NO_NETWORK)
73+ set (CJSON_OVERRIDE_BUILD_SHARED_LIBS ON )
74+ set (CJSON_BUILD_SHARED_LIBS OFF )
75+ set (ENABLE_CJSON_TEST OFF )
76+ set (ENABLE_CUSTOM_COMPILER_FLAGS OFF )
77+ include (FetchContent )
78+ FetchContent_Declare (
79+ cjson
80+ # FIXME: change back to DaveGamble/cJSON if upstream fix it
81+ # https://github.com/DaveGamble/cJSON/pull/949
82+ # https://github.com/DaveGamble/cJSON/pull/955
83+ GIT_REPOSITORY https://github.com/CoelacanthusHex/cJSON
84+ GIT_TAG 4818f043bda624b5738384eae3a0189b2bd1f5e1
85+ GIT_PROGRESS ON
86+ SOURCE_DIR cjson
87+ )
88+ FetchContent_MakeAvailable (cjson)
89+ set (CJSON_LIBRARY cjson)
90+ # Force cJSON dynamically link CRT although it's statuc librgary.
91+ set_property (TARGET cjson PROPERTY
10892 MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG :Debug >:Debug >DLL" )
109- else ()
110- message (FATAL_ERROR "System cJSON is not found and network access is not permitted! " )
111- endif ()
112- endif ()
93+ else ()
94+ message (FATAL_ERROR "cJSON is required. Either set USE_SYSTEM_DEPS to ON or enable network to download it. " )
95+ endif ()
96+
11397add_subdirectory (cjson-ext )
11498add_subdirectory (euicc )
11599add_subdirectory (utils )
0 commit comments