Findcjson.cmake 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. # Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update
  4. # our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt
  5. # from 3rd parties that we should not alter. Therefore, in addition to
  6. # changing the `cmake_minimum_required()`, we should also add a configuration
  7. # here that is compatible with earlier versions.
  8. set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
  9. include(FetchContent)
  10. set(CJSON_SOURCE_DIR "${WAMR_ROOT_DIR}/core/deps/cjson")
  11. if(EXISTS ${CJSON_SOURCE_DIR})
  12. message("Use existed source code under ${CJSON_SOURCE_DIR}")
  13. FetchContent_Declare(
  14. cjson
  15. SOURCE_DIR ${CJSON_SOURCE_DIR}
  16. )
  17. else()
  18. message("download source code and store it at ${CJSON_SOURCE_DIR}")
  19. FetchContent_Declare(
  20. cjson
  21. GIT_REPOSITORY https://github.com/DaveGamble/cJSON.git
  22. GIT_TAG v1.7.18
  23. SOURCE_DIR ${CJSON_SOURCE_DIR}
  24. )
  25. endif()
  26. set(ENABLE_CJSON_TEST OFF CACHE INTERNAL "Turn off tests")
  27. set(ENABLE_CJSON_UNINSTALL OFF CACHE INTERNAL "Turn off uninstall to avoid targets conflict")
  28. FetchContent_MakeAvailable(cjson)