2023-02-23 01:01:14 +00:00
|
|
|
# CMake 3.9 was released in 2017/07
|
|
|
|
|
# As of 2023, many versions of Linux, NetBSD and FreeBSD provide,
|
|
|
|
|
# and many OpenWRT packages require, much newer CMake packages.
|
|
|
|
|
# We're stopping before 3.10 because that version starts requiring
|
|
|
|
|
# c++11, which isn't available on e.g HPUX.
|
2023-09-05 14:31:24 +02:00
|
|
|
cmake_minimum_required(VERSION 3.9...3.12)
|
2016-08-24 00:16:13 -07:00
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
# JSON-C library is C only project.
|
2023-02-23 01:01:14 +00:00
|
|
|
# PROJECT_VERSION{,_MAJOR,_MINOR,_PATCH} set by project():
|
2023-08-12 19:08:59 +00:00
|
|
|
project(json-c LANGUAGES C VERSION 0.17.99)
|
2017-10-09 13:16:00 -04:00
|
|
|
|
2020-02-29 15:32:42 +08:00
|
|
|
# set default build type if not specified by user
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
set(CMAKE_BUILD_TYPE debug)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-03-03 14:16:13 +08:00
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
|
2020-03-02 20:19:35 +08:00
|
|
|
|
2019-11-23 15:15:48 -05:00
|
|
|
include(CTest)
|
|
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
# Set some packaging variables.
|
|
|
|
|
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
|
2019-11-23 15:34:23 -05:00
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
2018-07-24 08:06:13 +10:00
|
|
|
set(JSON_C_BUGREPORT "json-c@googlegroups.com")
|
2020-02-21 12:16:51 +08:00
|
|
|
set(CPACK_SOURCE_IGNORE_FILES
|
|
|
|
|
${PROJECT_SOURCE_DIR}/build
|
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake-build-debug
|
|
|
|
|
${PROJECT_SOURCE_DIR}/pack
|
|
|
|
|
${PROJECT_SOURCE_DIR}/.idea
|
|
|
|
|
${PROJECT_SOURCE_DIR}/.DS_Store
|
|
|
|
|
${PROJECT_SOURCE_DIR}/.git
|
|
|
|
|
${PROJECT_SOURCE_DIR}/.vscode)
|
2016-08-24 00:16:13 -07:00
|
|
|
|
2017-10-03 22:50:29 -04:00
|
|
|
include(CheckSymbolExists)
|
2018-07-24 08:06:13 +10:00
|
|
|
include(CheckIncludeFile)
|
|
|
|
|
include(CheckIncludeFiles)
|
|
|
|
|
include(CheckCSourceCompiles)
|
|
|
|
|
include(CheckTypeSize)
|
|
|
|
|
include(CPack)
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
2018-12-11 20:59:08 -05:00
|
|
|
option(BUILD_SHARED_LIBS "Default to building shared libraries" ON)
|
2020-05-07 14:50:43 +08:00
|
|
|
option(BUILD_STATIC_LIBS "Default to building static libraries" ON)
|
2018-12-11 20:59:08 -05:00
|
|
|
|
2021-03-02 14:27:40 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
|
add_definitions(-D JSON_C_DLL)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-02-21 12:16:51 +08:00
|
|
|
# Generate a release merge and test it to verify the correctness of republishing the package.
|
|
|
|
|
ADD_CUSTOM_TARGET(distcheck
|
|
|
|
|
COMMAND make package_source
|
|
|
|
|
COMMAND tar -xvf "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source.tar.gz"
|
|
|
|
|
COMMAND mkdir "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/build"
|
|
|
|
|
COMMAND cmake "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/" -B"./${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/build/"
|
|
|
|
|
COMMAND make -C "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/build"
|
|
|
|
|
COMMAND make test -C "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source/build"
|
|
|
|
|
COMMAND rm -rf "${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-Source"
|
|
|
|
|
)
|
|
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
# Enable or disable features. By default, all features are turned off.
|
2020-05-18 12:26:47 +02:00
|
|
|
option(DISABLE_BSYMBOLIC "Avoid linking with -Bsymbolic-function." OFF)
|
|
|
|
|
option(DISABLE_THREAD_LOCAL_STORAGE "Disable using Thread-Local Storage (HAVE___THREAD)." OFF)
|
|
|
|
|
option(DISABLE_WERROR "Avoid treating compiler warnings as fatal errors." OFF)
|
|
|
|
|
option(ENABLE_RDRAND "Enable RDRAND Hardware RNG Hash Seed." OFF)
|
|
|
|
|
option(ENABLE_THREADING "Enable partial threading support." OFF)
|
2020-07-22 02:25:03 +00:00
|
|
|
option(OVERRIDE_GET_RANDOM_SEED "Override json_c_get_random_seed() with custom code." OFF)
|
2021-02-15 20:19:56 +00:00
|
|
|
option(DISABLE_EXTRA_LIBS "Avoid linking against extra libraries, such as libbsd." OFF)
|
2021-04-24 17:00:13 +03:00
|
|
|
option(DISABLE_JSON_POINTER "Disable JSON pointer (RFC6901) and JSON patch support." OFF)
|
|
|
|
|
option(DISABLE_JSON_PATCH "Disable JSON patch (RFC6902) support." OFF)
|
2023-07-30 13:38:15 -04:00
|
|
|
option(NEWLOCALE_NEEDS_FREELOCALE "Work around newlocale bugs in old FreeBSD by calling freelocale" OFF)
|
2023-08-04 19:46:50 +05:00
|
|
|
option(BUILD_APPS "Default to building apps" ON)
|
2020-07-22 02:25:03 +00:00
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
|
|
|
|
|
if (UNIX OR MINGW OR CYGWIN)
|
|
|
|
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (UNIX)
|
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS /D_CRT_SECURE_NO_DEPRECATE)
|
|
|
|
|
list(APPEND CMAKE_REQUIRED_FLAGS /wd4996)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-06-14 12:01:48 -04:00
|
|
|
if (NOT DISABLE_STATIC_FPIC)
|
|
|
|
|
# Use '-fPIC'/'-fPIE' option.
|
|
|
|
|
# This will allow other libraries to statically link in libjson-c.a
|
|
|
|
|
# which in turn prevents crashes in downstream apps that may use
|
|
|
|
|
# a different JSON library with identical symbol names.
|
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
check_include_file("fcntl.h" HAVE_FCNTL_H)
|
|
|
|
|
check_include_file("inttypes.h" HAVE_INTTYPES_H)
|
|
|
|
|
check_include_file(stdarg.h HAVE_STDARG_H)
|
|
|
|
|
check_include_file(strings.h HAVE_STRINGS_H)
|
|
|
|
|
check_include_file(string.h HAVE_STRING_H)
|
|
|
|
|
check_include_file(syslog.h HAVE_SYSLOG_H)
|
|
|
|
|
|
2019-11-26 23:01:27 -05:00
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
|
|
|
|
|
|
|
|
|
|
check_include_file(unistd.h HAVE_UNISTD_H)
|
|
|
|
|
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
2020-04-21 03:51:16 +00:00
|
|
|
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H) # for getrusage
|
2018-07-24 08:06:13 +10:00
|
|
|
|
|
|
|
|
check_include_file("dlfcn.h" HAVE_DLFCN_H)
|
|
|
|
|
check_include_file("endian.h" HAVE_ENDIAN_H)
|
|
|
|
|
check_include_file("limits.h" HAVE_LIMITS_H)
|
|
|
|
|
check_include_file("locale.h" HAVE_LOCALE_H)
|
|
|
|
|
check_include_file("memory.h" HAVE_MEMORY_H)
|
|
|
|
|
|
|
|
|
|
check_include_file(stdint.h HAVE_STDINT_H)
|
|
|
|
|
check_include_file(stdlib.h HAVE_STDLIB_H)
|
|
|
|
|
check_include_file(sys/cdefs.h HAVE_SYS_CDEFS_H)
|
|
|
|
|
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
|
2020-07-30 16:13:04 -07:00
|
|
|
check_include_file(sys/random.h HAVE_SYS_RANDOM_H)
|
2018-07-24 08:06:13 +10:00
|
|
|
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
|
|
|
|
|
check_include_file(xlocale.h HAVE_XLOCALE_H)
|
|
|
|
|
|
2023-08-05 22:11:30 -04:00
|
|
|
# Set json-c specific vars to stamp into json_config.h
|
|
|
|
|
# in a way that hopefully won't conflict with other
|
|
|
|
|
# projects that use json-c.
|
2021-06-13 21:12:22 +00:00
|
|
|
if (HAVE_INTTYPES_H)
|
2023-08-05 22:11:30 -04:00
|
|
|
set(JSON_C_HAVE_INTTYPES_H 1)
|
|
|
|
|
endif()
|
|
|
|
|
if (HAVE_STDINT_H)
|
|
|
|
|
set(JSON_C_HAVE_STDINT_H 1)
|
2018-07-24 08:06:13 +10:00
|
|
|
endif()
|
2017-10-03 22:50:29 -04:00
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
check_symbol_exists(_isnan "float.h" HAVE_DECL__ISNAN)
|
|
|
|
|
check_symbol_exists(_finite "float.h" HAVE_DECL__FINITE)
|
|
|
|
|
|
|
|
|
|
if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX)
|
|
|
|
|
check_symbol_exists(INFINITY "math.h" HAVE_DECL_INFINITY)
|
|
|
|
|
check_symbol_exists(isinf "math.h" HAVE_DECL_ISINF)
|
|
|
|
|
check_symbol_exists(isnan "math.h" HAVE_DECL_ISNAN)
|
|
|
|
|
check_symbol_exists(nan "math.h" HAVE_DECL_NAN)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
check_symbol_exists(_doprnt "stdio.h" HAVE_DOPRNT)
|
|
|
|
|
if (UNIX OR MINGW OR CYGWIN)
|
|
|
|
|
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
|
|
|
|
|
endif()
|
|
|
|
|
check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF)
|
|
|
|
|
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
|
|
|
|
|
check_symbol_exists(vprintf "stdio.h" HAVE_VPRINTF)
|
|
|
|
|
|
2021-01-13 01:57:25 +00:00
|
|
|
check_symbol_exists(arc4random "stdlib.h" HAVE_ARC4RANDOM)
|
2021-02-15 20:19:56 +00:00
|
|
|
if (NOT HAVE_ARC4RANDOM AND DISABLE_EXTRA_LIBS STREQUAL "OFF")
|
2021-01-13 01:57:25 +00:00
|
|
|
check_include_file(bsd/stdlib.h HAVE_BSD_STDLIB_H)
|
|
|
|
|
if (HAVE_BSD_STDLIB_H)
|
2022-05-30 15:30:11 +00:00
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "bsd")
|
2021-01-13 01:57:25 +00:00
|
|
|
unset(HAVE_ARC4RANDOM CACHE)
|
|
|
|
|
check_symbol_exists(arc4random "bsd/stdlib.h" HAVE_ARC4RANDOM)
|
2022-05-30 15:30:11 +00:00
|
|
|
if (NOT HAVE_ARC4RANDOM)
|
|
|
|
|
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "bsd")
|
|
|
|
|
endif()
|
2021-01-13 01:57:25 +00:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
if (HAVE_FCNTL_H)
|
|
|
|
|
check_symbol_exists(open "fcntl.h" HAVE_OPEN)
|
|
|
|
|
endif()
|
|
|
|
|
if (HAVE_STDLIB_H)
|
|
|
|
|
check_symbol_exists(realloc "stdlib.h" HAVE_REALLOC)
|
|
|
|
|
endif()
|
|
|
|
|
if (HAVE_LOCALE_H)
|
|
|
|
|
check_symbol_exists(setlocale "locale.h" HAVE_SETLOCALE)
|
|
|
|
|
check_symbol_exists(uselocale "locale.h" HAVE_USELOCALE)
|
|
|
|
|
endif()
|
2022-07-30 20:27:35 +00:00
|
|
|
|
|
|
|
|
# uClibc *intentionally* crashes in duplocale(), at least as of:
|
|
|
|
|
# https://github.com/ffainelli/uClibc/blob/266bdc1/libc/misc/locale/locale.c#L1322
|
2023-12-12 16:28:41 +03:00
|
|
|
# So, if it looks like we're compiling for a system like that just disable
|
2022-07-30 20:27:35 +00:00
|
|
|
# locale handling entirely.
|
2023-12-17 11:19:20 +03:00
|
|
|
execute_process (COMMAND ${CMAKE_C_COMPILER} -dumpmachine ERROR_QUIET OUTPUT_VARIABLE CMAKE_GNU_C_MACHINE)
|
|
|
|
|
|
2022-07-30 20:27:35 +00:00
|
|
|
if (CMAKE_GNU_C_MACHINE MATCHES "uclibc")
|
|
|
|
|
message(STATUS "Detected uClibc compiler, disabling locale handling")
|
|
|
|
|
set(HAVE_SETLOCALE 0)
|
|
|
|
|
set(HAVE_USELOCALE 0)
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
if (HAVE_STRINGS_H)
|
|
|
|
|
check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP)
|
|
|
|
|
check_symbol_exists(strncasecmp "strings.h" HAVE_STRNCASECMP)
|
|
|
|
|
endif()
|
|
|
|
|
if (HAVE_STRING_H)
|
|
|
|
|
check_symbol_exists(strdup "string.h" HAVE_STRDUP)
|
|
|
|
|
check_symbol_exists(strerror "string.h" HAVE_STRERROR)
|
|
|
|
|
endif()
|
|
|
|
|
if (HAVE_SYSLOG_H)
|
|
|
|
|
check_symbol_exists(vsyslog "syslog.h" HAVE_VSYSLOG)
|
|
|
|
|
endif()
|
2020-07-30 16:13:04 -07:00
|
|
|
if (HAVE_SYS_RANDOM_H)
|
|
|
|
|
check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
|
|
|
|
|
endif()
|
2020-04-21 03:51:16 +00:00
|
|
|
if (HAVE_SYS_RESOURCE_H)
|
|
|
|
|
check_symbol_exists(getrusage "sys/resource.h" HAVE_GETRUSAGE)
|
|
|
|
|
endif()
|
2018-07-24 08:06:13 +10:00
|
|
|
|
2020-04-09 20:58:28 +00:00
|
|
|
check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL)
|
|
|
|
|
check_symbol_exists(strtoull "stdlib.h" HAVE_STRTOULL)
|
|
|
|
|
|
|
|
|
|
set(json_c_strtoll "strtoll")
|
|
|
|
|
if (NOT HAVE_STRTOLL)
|
|
|
|
|
# Use _strtoi64 if strtoll is not available.
|
|
|
|
|
check_symbol_exists(_strtoi64 "stdlib.h" __have_strtoi64)
|
|
|
|
|
if (__have_strtoi64)
|
|
|
|
|
#set(HAVE_STRTOLL 1)
|
|
|
|
|
set(json_c_strtoll "_strtoi64")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(json_c_strtoull "strtoull")
|
|
|
|
|
if (NOT HAVE_STRTOULL)
|
|
|
|
|
# Use _strtoui64 if strtoull is not available.
|
|
|
|
|
check_symbol_exists(_strtoui64 "stdlib.h" __have_strtoui64)
|
|
|
|
|
if (__have_strtoui64)
|
|
|
|
|
#set(HAVE_STRTOULL 1)
|
|
|
|
|
set(json_c_strtoull "_strtoui64")
|
|
|
|
|
endif()
|
2018-07-24 08:06:13 +10:00
|
|
|
endif()
|
|
|
|
|
|
2019-11-26 23:01:27 -05:00
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
check_type_size(int SIZEOF_INT)
|
|
|
|
|
check_type_size(int64_t SIZEOF_INT64_T)
|
|
|
|
|
check_type_size(long SIZEOF_LONG)
|
|
|
|
|
check_type_size("long long" SIZEOF_LONG_LONG)
|
|
|
|
|
check_type_size("size_t" SIZEOF_SIZE_T)
|
2020-06-07 15:19:29 +00:00
|
|
|
if (MSVC)
|
2020-06-07 03:36:59 +00:00
|
|
|
list(APPEND CMAKE_EXTRA_INCLUDE_FILES BaseTsd.h)
|
2020-06-07 15:19:29 +00:00
|
|
|
check_type_size("SSIZE_T" SIZEOF_SSIZE_T)
|
2020-06-07 03:36:59 +00:00
|
|
|
else()
|
2020-06-07 02:42:58 +00:00
|
|
|
check_type_size("ssize_t" SIZEOF_SSIZE_T)
|
2020-06-07 03:36:59 +00:00
|
|
|
endif()
|
2018-07-24 08:06:13 +10:00
|
|
|
|
2019-11-26 23:01:27 -05:00
|
|
|
check_c_source_compiles(
|
2020-05-30 19:36:54 +00:00
|
|
|
"
|
2019-11-26 23:01:27 -05:00
|
|
|
extern void json_object_get();
|
2020-05-30 19:36:54 +00:00
|
|
|
__asm__(\".section .gnu.json_object_get\\n\\t.ascii \\\"Please link against libjson-c instead of libjson\\\"\\n\\t.text\");
|
2019-11-26 23:01:27 -05:00
|
|
|
int main(int c, char *v) { return 0;}
|
2020-05-30 19:36:54 +00:00
|
|
|
"
|
2019-11-26 23:01:27 -05:00
|
|
|
HAS_GNU_WARNING_LONG)
|
|
|
|
|
|
2018-07-24 08:06:13 +10:00
|
|
|
check_c_source_compiles(
|
|
|
|
|
"int main() { int i, x = 0; i = __sync_add_and_fetch(&x,1); return x; }"
|
|
|
|
|
HAVE_ATOMIC_BUILTINS)
|
|
|
|
|
|
2020-05-18 11:38:58 +02:00
|
|
|
if (NOT DISABLE_THREAD_LOCAL_STORAGE)
|
|
|
|
|
check_c_source_compiles(
|
|
|
|
|
"__thread int x = 0; int main() { return 0; }"
|
|
|
|
|
HAVE___THREAD)
|
2018-07-24 08:06:13 +10:00
|
|
|
|
2020-05-18 11:38:58 +02:00
|
|
|
if (HAVE___THREAD)
|
|
|
|
|
set(SPEC___THREAD __thread)
|
|
|
|
|
elseif (MSVC)
|
|
|
|
|
set(SPEC___THREAD __declspec(thread))
|
|
|
|
|
endif()
|
2018-07-24 08:06:13 +10:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Hardware random number is not available on Windows? Says, config.h.win32. Best to preserve compatibility.
|
|
|
|
|
if (WIN32)
|
|
|
|
|
set(ENABLE_RDRAND 0)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Once we've done basic symbol/header searches let's add them in.
|
2018-10-20 10:50:15 +05:00
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/config.h.in ${PROJECT_BINARY_DIR}/config.h)
|
2020-05-18 20:36:05 +02:00
|
|
|
message(STATUS "Wrote ${PROJECT_BINARY_DIR}/config.h")
|
2018-10-20 10:50:15 +05:00
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/json_config.h.in ${PROJECT_BINARY_DIR}/json_config.h)
|
2020-05-18 20:36:05 +02:00
|
|
|
message(STATUS "Wrote ${PROJECT_BINARY_DIR}/json_config.h")
|
2018-07-24 08:06:13 +10:00
|
|
|
|
2020-12-17 19:59:37 -08:00
|
|
|
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
2018-07-24 08:06:13 +10:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
|
2019-11-26 23:01:27 -05:00
|
|
|
if ("${DISABLE_WERROR}" STREQUAL "OFF")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
|
|
|
|
endif()
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wwrite-strings")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter")
|
2020-04-15 13:01:09 +02:00
|
|
|
if (NOT WIN32)
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
|
|
|
|
|
endif()
|
2018-07-24 08:06:13 +10:00
|
|
|
|
|
|
|
|
add_definitions(-D_GNU_SOURCE)
|
2023-07-30 11:38:01 -04:00
|
|
|
|
|
|
|
|
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
|
# Remove this for 1.0 when we can bump the ABI and actually fix these warnings.
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shorten-64-to-32")
|
|
|
|
|
endif()
|
2018-07-24 08:06:13 +10:00
|
|
|
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DEBUG")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4100")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4706")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4702")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4701")
|
|
|
|
|
endif()
|
2016-08-24 00:16:13 -07:00
|
|
|
|
2019-11-26 23:01:27 -05:00
|
|
|
if (NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC"))
|
|
|
|
|
check_c_source_compiles(
|
2020-05-30 19:36:54 +00:00
|
|
|
"
|
2019-11-26 23:01:27 -05:00
|
|
|
/* uClibc toolchains without threading barf when _REENTRANT is defined */
|
|
|
|
|
#define _REENTRANT 1
|
|
|
|
|
#include <sys/types.h>
|
2020-04-14 20:42:32 +02:00
|
|
|
int main (void)
|
2019-11-26 23:01:27 -05:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2020-05-30 19:36:54 +00:00
|
|
|
"
|
2019-11-26 23:01:27 -05:00
|
|
|
REENTRANT_WORKS
|
|
|
|
|
)
|
|
|
|
|
if (REENTRANT_WORKS)
|
|
|
|
|
add_compile_options("-D_REENTRANT")
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-04-10 14:42:03 +02:00
|
|
|
# OSX Mach-O doesn't support linking with '-Bsymbolic-functions'.
|
|
|
|
|
# Others may not support it, too.
|
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "-Wl,-Bsymbolic-functions")
|
|
|
|
|
check_c_source_compiles(
|
2020-05-30 19:36:54 +00:00
|
|
|
"
|
2020-04-14 20:42:32 +02:00
|
|
|
int main (void)
|
2020-04-10 14:42:03 +02:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2020-05-30 19:36:54 +00:00
|
|
|
"
|
2020-04-10 14:42:03 +02:00
|
|
|
BSYMBOLIC_WORKS
|
|
|
|
|
)
|
|
|
|
|
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "-Wl,-Bsymbolic-functions")
|
|
|
|
|
if (DISABLE_BSYMBOLIC STREQUAL "OFF" AND BSYMBOLIC_WORKS)
|
2020-04-10 14:15:52 +02:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
|
2019-11-26 23:01:27 -05:00
|
|
|
# XXX need cmake>=3.13 for this:
|
|
|
|
|
#add_link_options("-Wl,-Bsymbolic-functions")
|
|
|
|
|
endif()
|
build: Add symbol versions to all exported symbols
With this version script, newly-linked binaries that depend on the
json-c shared library will refer to its symbols in a versioned form,
preventing their references from being resolved to a symbol of the same
name exported by json-glib or libjansson if those libraries appear in
dependency search order before json-c, which will usually result in
a crash. This is necessary because ELF symbol resolution normally uses
a single flat namespace, not a tree like Windows symbol resolution.
At least one symbol (json_object_iter_next()) is exported by all three
JSON libraries.
Linking with -Bsymbolic is not enough to have this effect in all cases,
because -Bsymbolic only affects symbol lookup within a shared object,
for example when json_object_set_serializer() calls
json_object_set_userdata(). It does not affect calls from external
code into json-c, unless json-c was statically linked into the
external caller.
This change will also not prevent code that depends on json-glib or
libjansson from finding json-c's symbols and crashing; to prevent
that, a corresponding change in json-glib or libjansson would be needed.
Adding a symbol-version is a backwards-compatible change, but once
added, removing or changing the symbol-version on a symbol would be an
incompatible change that requires a SONAME bump.
Resolves: https://github.com/json-c/json-c/issues/621
(when combined with an equivalent change to libjansson).
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-29 18:16:34 +01:00
|
|
|
|
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/check-version-script.sym" "TEST { global: *; };")
|
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/check-version-script.sym")
|
|
|
|
|
check_c_source_compiles(
|
|
|
|
|
"
|
|
|
|
|
int main (void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
VERSION_SCRIPT_WORKS
|
|
|
|
|
)
|
|
|
|
|
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/check-version-script.sym")
|
|
|
|
|
if (VERSION_SCRIPT_WORKS)
|
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/json-c.sym")
|
|
|
|
|
endif()
|
2019-11-26 23:01:27 -05:00
|
|
|
endif()
|
|
|
|
|
|
2019-11-23 15:15:48 -05:00
|
|
|
if ($ENV{VALGRIND})
|
|
|
|
|
# Build so that valgrind doesn't complain about linkhash.c
|
|
|
|
|
add_definitions(-DVALGRIND=1)
|
|
|
|
|
endif()
|
|
|
|
|
|
2017-09-17 21:27:07 -04:00
|
|
|
set(JSON_C_PUBLIC_HEADERS
|
2020-04-21 01:13:21 +00:00
|
|
|
# Note: config.h is _not_ included here
|
2018-10-20 10:50:15 +05:00
|
|
|
${PROJECT_BINARY_DIR}/json_config.h
|
|
|
|
|
|
2021-04-16 09:42:07 +03:00
|
|
|
${PROJECT_BINARY_DIR}/json.h
|
2018-10-20 10:50:15 +05:00
|
|
|
${PROJECT_SOURCE_DIR}/arraylist.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/debug.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_c_version.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_inttypes.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_object.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_object_iterator.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_tokener.h
|
2020-04-06 13:55:27 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/json_types.h
|
2018-10-20 10:50:15 +05:00
|
|
|
${PROJECT_SOURCE_DIR}/json_util.h
|
2019-11-23 15:34:23 -05:00
|
|
|
${PROJECT_SOURCE_DIR}/json_visit.h
|
2018-10-20 10:50:15 +05:00
|
|
|
${PROJECT_SOURCE_DIR}/linkhash.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/printbuf.h
|
2017-09-17 21:27:07 -04:00
|
|
|
)
|
2018-07-24 08:06:13 +10:00
|
|
|
|
2017-09-17 21:27:07 -04:00
|
|
|
set(JSON_C_HEADERS
|
|
|
|
|
${JSON_C_PUBLIC_HEADERS}
|
2018-10-20 10:50:15 +05:00
|
|
|
${PROJECT_SOURCE_DIR}/json_object_private.h
|
2023-07-16 10:48:20 -04:00
|
|
|
${PROJECT_SOURCE_DIR}/json_pointer_private.h
|
2018-10-20 10:50:15 +05:00
|
|
|
${PROJECT_SOURCE_DIR}/random_seed.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/strerror_override.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/math_compat.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/snprintf_compat.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/strdup_compat.h
|
|
|
|
|
${PROJECT_SOURCE_DIR}/vasprintf_compat.h
|
2016-08-24 00:16:13 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(JSON_C_SOURCES
|
2018-10-20 10:50:15 +05:00
|
|
|
${PROJECT_SOURCE_DIR}/arraylist.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/debug.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_c_version.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_object.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_object_iterator.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_tokener.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_util.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/json_visit.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/linkhash.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/printbuf.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/random_seed.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/strerror_override.c
|
2016-08-24 00:16:13 -07:00
|
|
|
)
|
|
|
|
|
|
2021-04-16 09:42:07 +03:00
|
|
|
if (NOT DISABLE_JSON_POINTER)
|
|
|
|
|
set(JSON_C_PUBLIC_HEADERS ${JSON_C_PUBLIC_HEADERS} ${PROJECT_SOURCE_DIR}/json_pointer.h)
|
|
|
|
|
set(JSON_C_SOURCES ${JSON_C_SOURCES} ${PROJECT_SOURCE_DIR}/json_pointer.c)
|
|
|
|
|
set(JSON_H_JSON_POINTER "#include \"json_pointer.h\"")
|
2021-04-24 17:00:13 +03:00
|
|
|
|
|
|
|
|
if (NOT DISABLE_JSON_PATCH)
|
|
|
|
|
set(JSON_C_PUBLIC_HEADERS ${JSON_C_PUBLIC_HEADERS} ${PROJECT_SOURCE_DIR}/json_patch.h)
|
|
|
|
|
set(JSON_C_SOURCES ${JSON_C_SOURCES} ${PROJECT_SOURCE_DIR}/json_patch.c)
|
|
|
|
|
set(JSON_H_JSON_PATCH "#include \"json_patch.h\"")
|
|
|
|
|
endif()
|
2021-04-16 09:42:07 +03:00
|
|
|
else()
|
|
|
|
|
set(JSON_H_JSON_POINTER "")
|
2021-04-24 17:00:13 +03:00
|
|
|
set(JSON_H_JSON_PATCH "")
|
2021-04-16 09:42:07 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
configure_file(json.h.cmakein ${PROJECT_BINARY_DIR}/json.h @ONLY)
|
|
|
|
|
|
2018-10-20 10:50:15 +05:00
|
|
|
include_directories(${PROJECT_SOURCE_DIR})
|
|
|
|
|
include_directories(${PROJECT_BINARY_DIR})
|
2017-05-03 11:59:31 +03:00
|
|
|
|
2020-05-18 20:32:35 +02:00
|
|
|
add_subdirectory(doc)
|
2020-02-26 15:39:27 +08:00
|
|
|
|
2021-07-26 18:52:29 +03:00
|
|
|
# "uninstall" custom target for make generators in unix like operating systems
|
|
|
|
|
# and if that target is not present
|
|
|
|
|
if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
|
|
|
|
if(NOT TARGET uninstall)
|
|
|
|
|
add_custom_target(uninstall
|
|
|
|
|
COMMAND cat ${PROJECT_BINARY_DIR}/install_manifest.txt | xargs rm
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2021-07-25 15:11:11 +00:00
|
|
|
endif()
|
2020-02-27 16:00:09 +08:00
|
|
|
|
2019-11-23 15:15:48 -05:00
|
|
|
# XXX for a normal full distribution we'll need to figure out
|
|
|
|
|
# XXX how to build both shared and static libraries.
|
|
|
|
|
# Probably leverage that to build a local VALGRIND=1 library for testing too.
|
2018-07-24 08:06:13 +10:00
|
|
|
add_library(${PROJECT_NAME}
|
2016-08-24 00:16:13 -07:00
|
|
|
${JSON_C_SOURCES}
|
|
|
|
|
${JSON_C_HEADERS}
|
2016-09-25 22:03:56 -04:00
|
|
|
)
|
2019-11-25 23:26:48 -05:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
2023-08-12 19:08:59 +00:00
|
|
|
VERSION 5.3.0
|
2020-04-19 03:57:08 +00:00
|
|
|
SOVERSION 5)
|
2020-05-08 02:16:52 +03:00
|
|
|
list(APPEND CMAKE_TARGETS ${PROJECT_NAME})
|
2018-10-20 10:50:15 +05:00
|
|
|
# If json-c is used as subroject it set to target correct interface -I flags and allow
|
|
|
|
|
# to build external target without extra include_directories(...)
|
2019-05-18 19:44:29 +08:00
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
|
|
|
PUBLIC
|
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
|
2018-10-20 10:50:15 +05:00
|
|
|
)
|
|
|
|
|
|
2022-05-30 15:30:11 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_REQUIRED_LIBRARIES})
|
|
|
|
|
|
2020-05-06 10:48:53 +08:00
|
|
|
# Allow to build static and shared libraries at the same time
|
2020-05-10 03:48:45 +00:00
|
|
|
if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
|
2020-05-08 02:19:38 +03:00
|
|
|
set(STATIC_LIB ${PROJECT_NAME}-static)
|
|
|
|
|
add_library(${STATIC_LIB} STATIC
|
2020-05-06 10:48:53 +08:00
|
|
|
${JSON_C_SOURCES}
|
|
|
|
|
${JSON_C_HEADERS}
|
|
|
|
|
)
|
2021-11-10 16:04:01 +01:00
|
|
|
target_include_directories(${PROJECT_NAME}-static
|
|
|
|
|
PUBLIC
|
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
|
|
|
|
|
)
|
2020-05-06 10:48:53 +08:00
|
|
|
|
2022-05-30 15:30:11 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME}-static PUBLIC ${CMAKE_REQUIRED_LIBRARIES})
|
|
|
|
|
|
2020-05-06 10:48:53 +08:00
|
|
|
# rename the static library
|
2020-05-10 03:58:51 +00:00
|
|
|
if (NOT MSVC)
|
2020-05-08 02:19:38 +03:00
|
|
|
set_target_properties(${STATIC_LIB} PROPERTIES
|
2020-05-06 10:48:53 +08:00
|
|
|
OUTPUT_NAME ${PROJECT_NAME}
|
|
|
|
|
)
|
2020-05-10 03:58:51 +00:00
|
|
|
endif()
|
2020-05-08 02:16:52 +03:00
|
|
|
list(APPEND CMAKE_TARGETS ${STATIC_LIB})
|
2020-05-06 10:48:53 +08:00
|
|
|
endif ()
|
|
|
|
|
|
2020-04-21 03:19:17 +00:00
|
|
|
# Always create new install dirs with 0755 permissions, regardless of umask
|
|
|
|
|
set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
|
|
|
|
|
OWNER_READ
|
|
|
|
|
OWNER_WRITE
|
|
|
|
|
OWNER_EXECUTE
|
|
|
|
|
GROUP_READ
|
|
|
|
|
GROUP_EXECUTE
|
|
|
|
|
WORLD_READ
|
|
|
|
|
WORLD_EXECUTE
|
|
|
|
|
)
|
|
|
|
|
|
2020-05-08 02:16:52 +03:00
|
|
|
install(TARGETS ${CMAKE_TARGETS}
|
2019-05-18 19:44:29 +08:00
|
|
|
EXPORT ${PROJECT_NAME}-targets
|
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2021-12-22 02:52:37 +00:00
|
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/json-c
|
2019-05-18 19:44:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
install(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
|
FILE ${PROJECT_NAME}-targets.cmake
|
|
|
|
|
NAMESPACE ${PROJECT_NAME}::
|
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
configure_package_config_file(
|
|
|
|
|
"cmake/Config.cmake.in"
|
|
|
|
|
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
|
|
|
|
|
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
install(
|
|
|
|
|
FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
|
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
2016-09-25 22:03:56 -04:00
|
|
|
)
|
2016-09-25 14:42:14 -04:00
|
|
|
|
2018-09-01 15:06:14 -04:00
|
|
|
if (UNIX OR MINGW OR CYGWIN)
|
2019-01-26 12:30:40 +01:00
|
|
|
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
|
# exec_prefix is prefix by default and CMake does not have the
|
|
|
|
|
# concept.
|
|
|
|
|
SET(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
|
SET(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
|
|
|
|
|
SET(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
2019-11-23 15:34:23 -05:00
|
|
|
SET(VERSION ${PROJECT_VERSION})
|
2022-05-30 15:30:11 +00:00
|
|
|
|
|
|
|
|
# Linking against the static json-c requires
|
|
|
|
|
# dependent packages to include additional libs:
|
|
|
|
|
SET(LIBS_LIST ${CMAKE_REQUIRED_LIBRARIES})
|
2022-06-27 02:15:24 +00:00
|
|
|
|
|
|
|
|
# Note: We would need cmake >= 3.12 in order to use list(TRANSFORM ...)
|
|
|
|
|
function(list_transform_prepend var prefix)
|
|
|
|
|
set(temp "")
|
|
|
|
|
foreach(f ${${var}})
|
|
|
|
|
list(APPEND temp "${prefix}${f}")
|
|
|
|
|
endforeach()
|
|
|
|
|
set(${var} "${temp}" PARENT_SCOPE)
|
|
|
|
|
endfunction()
|
|
|
|
|
list_transform_prepend(LIBS_LIST "-l")
|
|
|
|
|
|
2022-05-30 15:30:11 +00:00
|
|
|
string(REPLACE ";" " " LIBS "${LIBS_LIST}")
|
|
|
|
|
|
2018-10-20 10:50:15 +05:00
|
|
|
configure_file(json-c.pc.in json-c.pc @ONLY)
|
2020-04-12 19:21:54 +02:00
|
|
|
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
|
2018-10-20 10:50:15 +05:00
|
|
|
install(FILES ${PROJECT_BINARY_DIR}/json-c.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}")
|
2018-09-01 15:06:14 -04:00
|
|
|
endif ()
|
|
|
|
|
|
2021-10-15 11:12:39 +02:00
|
|
|
install(FILES ${JSON_C_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/json-c)
|
|
|
|
|
|
2022-05-30 14:33:16 +00:00
|
|
|
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING AND
|
|
|
|
|
(NOT MSVC OR NOT (MSVC_VERSION LESS 1800)) # Tests need at least VS2013
|
|
|
|
|
)
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-08-04 19:46:50 +05:00
|
|
|
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_APPS)
|
2023-07-06 20:56:49 -04:00
|
|
|
# skip apps when we're included in someone else's build
|
2022-05-30 14:33:16 +00:00
|
|
|
if (NOT MSVC) # cmd line apps don't built on Windows currently.
|
|
|
|
|
add_subdirectory(apps)
|
|
|
|
|
endif()
|
2023-07-06 20:56:49 -04:00
|
|
|
endif()
|