CMake: Move cJSON check out of the plugin check since it is required elsewhere

Some client/app code also optionally use cJSON, however it won't be found if plugins are disabled.

Signed-off-by: Pierre Hallot <hallotpierre@gmail.com>
This commit is contained in:
Pierre Hallot 2020-12-02 11:47:08 +01:00 committed by Roger Light
parent 6293e13142
commit 2afc5783a9

View File

@ -98,6 +98,14 @@ if (WITH_DLT)
add_definitions("-DWITH_DLT") add_definitions("-DWITH_DLT")
endif (WITH_DLT) endif (WITH_DLT)
FIND_PACKAGE(cJSON)
if (CJSON_FOUND)
message(STATUS ${CJSON_FOUND})
add_definitions("-DWITH_CJSON")
else (CJSON_FOUND)
message(STATUS "Optional dependency cJSON not found. Some features will be disabled.")
endif(CJSON_FOUND)
# ======================================== # ========================================
# Include projects # Include projects
# ======================================== # ========================================
@ -122,11 +130,6 @@ if (WITH_APPS)
endif (WITH_APPS) endif (WITH_APPS)
if (WITH_PLUGINS) if (WITH_PLUGINS)
FIND_PACKAGE(cJSON)
if (CJSON_FOUND)
message(STATUS ${CJSON_FOUND})
add_definitions("-DWITH_CJSON")
endif()
add_subdirectory(plugins) add_subdirectory(plugins)
endif (WITH_PLUGINS) endif (WITH_PLUGINS)