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

cmake: fix definitions for older cmake #955

Merged
merged 2 commits into from
Sep 12, 2023
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
93 changes: 47 additions & 46 deletions cmake/re-config.cmake
Original file line number Diff line number Diff line change
@@ -26,26 +26,26 @@ endif()

check_symbol_exists("arc4random" "stdlib.h" HAVE_ARC4RANDOM)
if(HAVE_ARC4RANDOM)
list(APPEND RE_DEFINITIONS -DHAVE_ARC4RANDOM)
list(APPEND RE_DEFINITIONS HAVE_ARC4RANDOM)
endif()

if(ZLIB_FOUND)
list(APPEND RE_DEFINITIONS -DUSE_ZLIB)
list(APPEND RE_DEFINITIONS USE_ZLIB)
endif()

check_include_file(syslog.h HAVE_SYSLOG_H)
if(HAVE_SYSLOG_H)
list(APPEND RE_DEFINITIONS -DHAVE_SYSLOG)
list(APPEND RE_DEFINITIONS HAVE_SYSLOG)
endif()

check_include_file(getopt.h HAVE_GETOPT_H)
if(HAVE_GETOPT_H)
list(APPEND RE_DEFINITIONS -DHAVE_GETOPT)
list(APPEND RE_DEFINITIONS HAVE_GETOPT)
endif()

check_include_file(unistd.h HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
list(APPEND RE_DEFINITIONS -DHAVE_UNISTD_H)
list(APPEND RE_DEFINITIONS HAVE_UNISTD_H)
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
@@ -55,135 +55,136 @@ else()
endif()
if(HAVE_RESOLV)
set(RESOLV_LIBRARY resolv)
list(APPEND RE_DEFINITIONS -DHAVE_RESOLV)
list(APPEND RE_DEFINITIONS HAVE_RESOLV)
else()
set(RESOLV_LIBRARY)
endif()

if(Backtrace_FOUND)
list(APPEND RE_DEFINITIONS -DHAVE_EXECINFO)
list(APPEND RE_DEFINITIONS HAVE_EXECINFO)
else()
set(Backtrace_LIBRARIES)
endif()

check_function_exists(thrd_create HAVE_THREADS)
if(HAVE_THREADS)
list(APPEND RE_DEFINITIONS -DHAVE_THREADS)
list(APPEND RE_DEFINITIONS HAVE_THREADS)
endif()

check_function_exists(accept4 HAVE_ACCEPT4)
if(HAVE_ACCEPT4)
list(APPEND RE_DEFINITIONS -DHAVE_ACCEPT4)
list(APPEND RE_DEFINITIONS HAVE_ACCEPT4)
endif()

if(CMAKE_USE_PTHREADS_INIT)
list(APPEND RE_DEFINITIONS -DHAVE_PTHREAD)
list(APPEND RE_DEFINITIONS HAVE_PTHREAD)
set(HAVE_PTHREAD ON)
endif()

if(UNIX)
check_symbol_exists(epoll_create "sys/epoll.h" HAVE_EPOLL)
if(HAVE_EPOLL)
list(APPEND RE_DEFINITIONS -DHAVE_EPOLL)
list(APPEND RE_DEFINITIONS HAVE_EPOLL)
endif()
check_symbol_exists(kqueue "sys/types.h;sys/event.h" HAVE_KQUEUE)
if(HAVE_KQUEUE)
list(APPEND RE_DEFINITIONS -DHAVE_KQUEUE)
list(APPEND RE_DEFINITIONS HAVE_KQUEUE)
endif()
endif()

check_include_file(sys/prctl.h HAVE_PRCTL)
if(HAVE_PRCTL)
list(APPEND RE_DEFINITIONS -DHAVE_PRCTL)
list(APPEND RE_DEFINITIONS HAVE_PRCTL)
endif()


list(APPEND RE_DEFINITIONS
-DHAVE_ATOMIC
-DHAVE_INET6
-DHAVE_SELECT
HAVE_ATOMIC
HAVE_INET6
HAVE_SELECT
)

if(UNIX)
list(APPEND RE_DEFINITIONS
-DHAVE_PWD_H
-DHAVE_ROUTE_LIST
-DHAVE_SETRLIMIT
-DHAVE_STRERROR_R
-DHAVE_STRINGS_H
-DHAVE_SYS_TIME_H
-DHAVE_UNAME
-DHAVE_SELECT_H
-DHAVE_SIGNAL
-DHAVE_FORK
HAVE_PWD_H
HAVE_ROUTE_LIST
HAVE_SETRLIMIT
HAVE_STRERROR_R
HAVE_STRINGS_H
HAVE_SYS_TIME_H
HAVE_UNAME
HAVE_SELECT_H
HAVE_SIGNAL
HAVE_FORK
)
if(NOT ANDROID)
list(APPEND RE_DEFINITIONS -DHAVE_GETIFADDRS)
list(APPEND RE_DEFINITIONS HAVE_GETIFADDRS)
endif()
endif()


if(MSVC)
list(APPEND RE_DEFINITIONS
-DHAVE_IO_H
-D_CRT_SECURE_NO_WARNINGS
HAVE_IO_H
_CRT_SECURE_NO_WARNINGS
)
endif()

if(WIN32)
list(APPEND RE_DEFINITIONS
-DWIN32 -D_WIN32_WINNT=0x0600
WIN32
_WIN32_WINNT=0x0600
)
endif()

if(USE_OPENSSL)
list(APPEND RE_DEFINITIONS
-DUSE_DTLS
-DUSE_OPENSSL
-DUSE_OPENSSL_AES
-DUSE_OPENSSL_HMAC
-DUSE_OPENSSL_SRTP
-DUSE_TLS
USE_DTLS
USE_OPENSSL
USE_OPENSSL_AES
USE_OPENSSL_HMAC
USE_OPENSSL_SRTP
USE_TLS
)
endif()

if(USE_MBEDTLS)
list(APPEND RE_DEFINITIONS
-DUSE_MBEDTLS
USE_MBEDTLS
)
endif()

if(USE_UNIXSOCK)
list(APPEND RE_DEFINITIONS
-DHAVE_UNIXSOCK=1
HAVE_UNIXSOCK=1
)
else()
list(APPEND RE_DEFINITIONS
-DHAVE_UNIXSOCK=0
HAVE_UNIXSOCK=0
)
endif()

if(USE_TRACE)
list(APPEND RE_DEFINITIONS
-DRE_TRACE_ENABLED
RE_TRACE_ENABLED
)
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list(APPEND RE_DEFINITIONS -DDARWIN)
list(APPEND RE_DEFINITIONS DARWIN)
include_directories(/opt/local/include)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
list(APPEND RE_DEFINITIONS -DFREEBSD)
list(APPEND RE_DEFINITIONS FREEBSD)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
list(APPEND RE_DEFINITIONS -DOPENBSD)
list(APPEND RE_DEFINITIONS OPENBSD)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND RE_DEFINITIONS -DLINUX)
list(APPEND RE_DEFINITIONS LINUX)
endif()


list(APPEND RE_DEFINITIONS
-DARCH="${CMAKE_SYSTEM_PROCESSOR}"
-DOS="${CMAKE_SYSTEM_NAME}"
ARCH="${CMAKE_SYSTEM_PROCESSOR}"
OS="${CMAKE_SYSTEM_NAME}"
$<$<NOT:$<CONFIG:DEBUG>>:RELEASE>
)