mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
CMake: Set default visibility to hidden and dllexport on windows
This commit is contained in:
parent
b44c917be9
commit
6405fd15e3
@ -61,6 +61,16 @@ if (ENABLE_SANITIZERS)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(ENABLE_PUBLIC_SYMBOLS "Export library symbols." On)
|
||||||
|
if (ENABLE_PUBLIC_SYMBOLS)
|
||||||
|
list(APPEND custom_compiler_flags -fvisibility=hidden)
|
||||||
|
add_definitions(-DCJSON_EXPORT_SYMBOLS -DCJSON_API_VISIBILITY)
|
||||||
|
endif()
|
||||||
|
option(ENABLE_HIDDEN_SYMBOLS "Hide library symbols." Off)
|
||||||
|
if (ENABLE_HIDDEN_SYMBOLS)
|
||||||
|
add_definitions(-DCJSON_HIDE_SYMBOLS -UCJSON_API_VISIBILITY)
|
||||||
|
endif()
|
||||||
|
|
||||||
# apply custom compiler flags
|
# apply custom compiler flags
|
||||||
foreach(compiler_flag ${custom_compiler_flags})
|
foreach(compiler_flag ${custom_compiler_flags})
|
||||||
#remove problematic characters
|
#remove problematic characters
|
||||||
|
3
cJSON.c
3
cJSON.c
@ -23,6 +23,7 @@
|
|||||||
/* cJSON */
|
/* cJSON */
|
||||||
/* JSON parser in C. */
|
/* JSON parser in C. */
|
||||||
|
|
||||||
|
#pragma GCC visibility push(default)
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -30,6 +31,8 @@
|
|||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
|
|
||||||
/* define our own boolean type */
|
/* define our own boolean type */
|
||||||
|
@ -7,6 +7,11 @@ if(ENABLE_CJSON_TEST)
|
|||||||
if (werror_found)
|
if (werror_found)
|
||||||
target_compile_options(unity PRIVATE "-Wno-error")
|
target_compile_options(unity PRIVATE "-Wno-error")
|
||||||
endif()
|
endif()
|
||||||
|
# Disable -fvisibility=hidden for Unity
|
||||||
|
list(FIND custom_compiler_flags "-fvisibility=hidden" visibility_found)
|
||||||
|
if (visibility_found)
|
||||||
|
target_compile_options(unity PRIVATE "-fvisibility=default")
|
||||||
|
endif()
|
||||||
|
|
||||||
#copy test files
|
#copy test files
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/inputs")
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/inputs")
|
||||||
|
Loading…
Reference in New Issue
Block a user