CMakeLists.txt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. cmake_minimum_required(VERSION 2.8)
  2. set(PROJ_CJSON cJSON)
  3. project(${PROJ_CJSON} C)
  4. set(CJSON_VERSION_MAJOR 1)
  5. set(CJSON_VERSION_MINOR 0)
  6. set(CJSON_VERSION_PATCH 0)
  7. set(CJSON_VERSION_SO 1)
  8. set(CJSON_VERSION "${CJSON_VERSION_MAJOR}.${CJSON_VERSION_MINOR}.${CJSON_VERSION_PATCH}")
  9. file(GLOB HEADERS cJSON.h)
  10. set(SOURCES cJSON.c)
  11. add_library(${PROJ_CJSON} ${HEADERS} ${SOURCES})
  12. if (NOT WIN32)
  13. target_link_libraries(${PROJ_CJSON} m)
  14. endif()
  15. set(PROJ_CJSON_UTILS cJSON_utils)
  16. project(${PROJ_CJSON_UTILS} C)
  17. file(GLOB HEADERS_UTILS cJSON_Utils.h)
  18. set(SOURCES_UTILS cJSON_Utils.c)
  19. add_library(${PROJ_CJSON_UTILS} ${HEADERS_UTILS} ${SOURCES_UTILS})
  20. target_link_libraries(${PROJ_CJSON_UTILS} ${PROJ_CJSON})
  21. install (TARGETS ${PROJ_CJSON} DESTINATION lib${LIB_SUFFIX})
  22. install (FILES cJSON.h DESTINATION include/cJSON)
  23. install (TARGETS ${PROJ_CJSON_UTILS} DESTINATION lib${LIB_SUFFIX})
  24. install (FILES cJSON_Utils.h DESTINATION include/cJSON)
  25. option(ENABLE_CJSON_TEST "Enable building cJSON test" OFF)
  26. if(ENABLE_CJSON_TEST)
  27. set(TEST_CJSON cJSON_test)
  28. add_executable(${TEST_CJSON} test.c)
  29. target_link_libraries(${TEST_CJSON} ${PROJ_CJSON})
  30. set(TEST_CJSON_UTILS cJSON_test_utils)
  31. add_executable(${TEST_CJSON_UTILS} test_utils.c)
  32. target_link_libraries(${TEST_CJSON_UTILS} ${PROJ_CJSON_UTILS})
  33. endif()