2015-07-15 11:01:46 +03:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
2016-11-04 16:31:56 +03:00
|
|
|
set(CJSON_VERSION_MAJOR 1)
|
|
|
|
set(CJSON_VERSION_MINOR 0)
|
|
|
|
set(CJSON_VERSION_PATCH 0)
|
|
|
|
set(CJSON_VERSION_SO 1)
|
2016-11-04 21:30:31 +03:00
|
|
|
set(CJSON_UTILS_VERSION_SO 1)
|
2016-11-04 16:31:56 +03:00
|
|
|
set(CJSON_VERSION "${CJSON_VERSION_MAJOR}.${CJSON_VERSION_MINOR}.${CJSON_VERSION_PATCH}")
|
2015-07-15 11:01:46 +03:00
|
|
|
|
2016-11-04 20:51:31 +03:00
|
|
|
add_compile_options(-ansi -pedantic -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings)
|
|
|
|
|
2016-10-18 03:12:12 +03:00
|
|
|
#variables for pkg-config
|
|
|
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
|
2016-11-05 11:50:01 +03:00
|
|
|
set(version ${CJSON_VERSION})
|
2016-10-18 03:12:12 +03:00
|
|
|
|
2016-11-04 20:38:30 +03:00
|
|
|
#cJSON
|
|
|
|
set(PROJ_CJSON cJSON)
|
2016-11-04 20:46:41 +03:00
|
|
|
set(CJSON_LIB cjson)
|
2016-11-04 20:38:30 +03:00
|
|
|
project(${PROJ_CJSON} C)
|
|
|
|
|
2015-07-15 11:01:46 +03:00
|
|
|
file(GLOB HEADERS cJSON.h)
|
|
|
|
set(SOURCES cJSON.c)
|
|
|
|
|
2016-11-04 20:46:41 +03:00
|
|
|
add_library(${CJSON_LIB} ${HEADERS} ${SOURCES})
|
2015-08-20 06:03:08 +03:00
|
|
|
if (NOT WIN32)
|
2016-11-04 20:46:41 +03:00
|
|
|
target_link_libraries(${CJSON_LIB} m)
|
2015-08-20 06:03:08 +03:00
|
|
|
endif()
|
2015-07-15 11:01:46 +03:00
|
|
|
|
2016-10-18 03:12:12 +03:00
|
|
|
configure_file("${cJSON_SOURCE_DIR}/libcjson.pc.in"
|
|
|
|
"${cJSON_BINARY_DIR}/libcjson.pc" @ONLY)
|
|
|
|
|
2016-11-04 20:46:41 +03:00
|
|
|
install(TARGETS ${CJSON_LIB} DESTINATION lib${LIB_SUFFIX})
|
|
|
|
install(FILES cJSON.h DESTINATION include/cjson)
|
2016-10-18 03:12:12 +03:00
|
|
|
install (FILES ${cJSON_BINARY_DIR}/libcjson.pc DESTINATION lib/pkgconfig)
|
2015-07-28 00:33:17 +03:00
|
|
|
|
2016-11-04 20:50:51 +03:00
|
|
|
set_target_properties(${CJSON_LIB}
|
|
|
|
PROPERTIES
|
|
|
|
SOVERSION ${CJSON_VERSION_SO}
|
|
|
|
VERSION ${CJSON_VERSION})
|
|
|
|
|
2016-11-04 20:38:30 +03:00
|
|
|
#cJSON_Utils
|
|
|
|
set(PROJ_CJSON_UTILS cJSON_utils)
|
2016-11-04 20:46:41 +03:00
|
|
|
set(CJSON_UTILS_LIB cjson_utils)
|
2015-07-28 00:33:17 +03:00
|
|
|
project(${PROJ_CJSON_UTILS} C)
|
|
|
|
|
|
|
|
file(GLOB HEADERS_UTILS cJSON_Utils.h)
|
|
|
|
set(SOURCES_UTILS cJSON_Utils.c)
|
|
|
|
|
2016-11-04 20:46:41 +03:00
|
|
|
add_library(${CJSON_UTILS_LIB} ${HEADERS_UTILS} ${SOURCES_UTILS})
|
|
|
|
target_link_libraries(${CJSON_UTILS_LIB} ${CJSON_LIB})
|
2015-07-28 00:33:17 +03:00
|
|
|
|
2016-11-05 11:57:14 +03:00
|
|
|
configure_file("${cJSON_utils_SOURCE_DIR}/libcjson_utils.pc.in"
|
|
|
|
"${cJSON_utils_BINARY_DIR}/libcjson_utils.pc" @ONLY)
|
|
|
|
|
2016-11-04 20:46:41 +03:00
|
|
|
install(TARGETS ${CJSON_UTILS_LIB} DESTINATION lib${LIB_SUFFIX})
|
2016-11-04 20:48:35 +03:00
|
|
|
install(FILES cJSON_Utils.h DESTINATION include/cjson)
|
2016-11-05 11:57:14 +03:00
|
|
|
install (FILES ${cJSON_utils_BINARY_DIR}/libcjson.pc DESTINATION lib/pkgconfig)
|
2015-07-15 11:01:46 +03:00
|
|
|
|
2016-11-04 20:50:51 +03:00
|
|
|
set_target_properties(${CJSON_UTILS_LIB}
|
|
|
|
PROPERTIES
|
2016-11-04 21:30:31 +03:00
|
|
|
SOVERSION ${CJSON_UTILS_VERSION_SO}
|
2016-11-04 20:50:51 +03:00
|
|
|
VERSION ${CJSON_VERSION})
|
|
|
|
|
2015-07-15 11:01:46 +03:00
|
|
|
option(ENABLE_CJSON_TEST "Enable building cJSON test" OFF)
|
|
|
|
if(ENABLE_CJSON_TEST)
|
2016-11-04 20:40:23 +03:00
|
|
|
set(TEST_CJSON cJSON_test)
|
|
|
|
add_executable(${TEST_CJSON} test.c)
|
2016-11-04 20:46:41 +03:00
|
|
|
target_link_libraries(${TEST_CJSON} ${CJSON_LIB})
|
2015-07-28 00:33:17 +03:00
|
|
|
|
2016-11-04 20:40:23 +03:00
|
|
|
set(TEST_CJSON_UTILS cJSON_test_utils)
|
|
|
|
add_executable(${TEST_CJSON_UTILS} test_utils.c)
|
2016-11-04 20:46:41 +03:00
|
|
|
target_link_libraries(${TEST_CJSON_UTILS} ${CJSON_UTILS_LIB})
|
2015-07-15 11:01:46 +03:00
|
|
|
endif()
|