Skip to content

Commit

Permalink
Merge pull request #242 from PunishedSnakePr/CMake-Extension
Browse files Browse the repository at this point in the history
Added CMake compile definitions
  • Loading branch information
vstakhov committed Sep 23, 2020
2 parents b14e498 + f25a74a commit 21ef6eb
Showing 1 changed file with 38 additions and 0 deletions.
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

0 comments on commit 21ef6eb

Please sign in to comment.