Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CMake compile definitions #242

Merged
merged 1 commit into from
Sep 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SET(LIBUCL_VERSION
"${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}")

INCLUDE(CheckCCompilerFlag)
INCLUDE(CheckCSourceCompiles)
INCLUDE(FindOpenSSL)
INCLUDE(GNUInstallDirs)

Expand Down Expand Up @@ -159,6 +160,25 @@ IF(ENABLE_URL_INCLUDE MATCHES "ON")
ENDIF(LIBFETCH_LIBRARY)
ENDIF(ENABLE_URL_INCLUDE MATCHES "ON")

set(SYNC_BUILTINS_TEST_SOURCE [====[
int main()
{
unsigned long val;

__sync_bool_compare_and_swap(&val, 0, 1);
__sync_add_and_fetch(&val, 1);
__sync_fetch_and_add(&val, 0);
__sync_sub_and_fetch(&val, 1);

return 0;
}
]====])

CHECK_C_SOURCE_COMPILES("${SYNC_BUILTINS_TEST_SOURCE}" HAVE_ATOMIC_BUILTINS)
IF(NOT HAVE_ATOMIC_BUILTINS)
MESSAGE(WARNING "Libucl references could be thread-unsafe because atomic builtins are missing")
ENDIF(NOT HAVE_ATOMIC_BUILTINS)

SET(CMAKE_C_WARN_FLAGS "")
CHECK_C_COMPILER_FLAG(-W SUPPORT_W)
CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN)
Expand All @@ -182,6 +202,20 @@ IF(ENABLE_URL_SIGN MATCHES "ON")
ENDIF(OPENSSL_FOUND)
ENDIF(ENABLE_URL_SIGN MATCHES "ON")

SET(UCL_COMPILE_DEFS)
IF(HAVE_FETCH_H)
LIST(APPEND UCL_COMPILE_DEFS -DHAVE_FETCH_H=1)
ENDIF(HAVE_FETCH_H)
IF(CURL_FOUND)
LIST(APPEND UCL_COMPILE_DEFS -DCURL_FOUND=1)
ENDIF(CURL_FOUND)
IF(HAVE_OPENSSL)
LIST(APPEND UCL_COMPILE_DEFS -DHAVE_OPENSSL=1)
ENDIF(HAVE_OPENSSL)
IF(HAVE_ATOMIC_BUILTINS)
LIST(APPEND UCL_COMPILE_DEFS -DHAVE_ATOMIC_BUILTINS=1)
ENDIF(HAVE_ATOMIC_BUILTINS)

SET(UCLSRC src/ucl_util.c
src/ucl_parser.c
src/ucl_emitter.c
Expand Down Expand Up @@ -209,6 +243,10 @@ TARGET_INCLUDE_DIRECTORIES(ucl
src
uthash
klib)
TARGET_COMPILE_DEFINITIONS(ucl
PRIVATE
${UCL_COMPILE_DEFS}
)

IF(ENABLE_LUA MATCHES "ON")
IF(ENABLE_LUAJIT MATCHES "ON")
Expand Down