summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2021-11-27 19:26:58 +0300
committerIvan Maidanski <ivmai@mail.ru>2021-11-27 19:28:37 +0300
commit8aac0b5e6a8db6c340b09c3533ac4c4cde8aac24 (patch)
treee7f17c8b11a3e5903ff1285abb69c2919f830c18 /CMakeLists.txt
parent8199a20978e5a3f637ca61975d6e81632b0113cb (diff)
downloadbdwgc-8aac0b5e6a8db6c340b09c3533ac4c4cde8aac24.tar.gz
Add CMake option to force libatomic_ops headers usage
If -Dwithout_libatomic_ops=ON is passed to cmake or MS VC (or similar) compiler is used, then libatomic_ops/src is set as an additional include directory. Otherwise, GC_BUILTIN_ATOMIC macro is defined. * CMakeLists.txt (without_libatomic_ops): New option. * CMakeLists.txt [enable_threads] (libatomic_ops/src): Include only if without_libatomic_ops or BORLAND or MSVC or WATCOM; add comment. * CMakeLists.txt [enable_threads && !without_libatomic_ops && !BORLAND && !MSVC && !WATCOM] (GC_BUILTIN_ATOMIC): Define C macro only. * CMakeLists.txt [CMAKE_USE_PTHREADS_INIT] (GC_BUILTIN_ATOMIC): Remove C macro definition.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt11
1 files changed, 8 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 82f3ec1d..0af5d207 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,6 +80,7 @@ option(enable_single_obj_compilation "Compile all libgc source files into single
option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON)
option(disable_handle_fork "Prohibit installation of pthread_atfork() handlers" OFF)
option(install_headers "Install header and pkg-config metadata files" ON)
+option(without_libatomic_ops "Use atomic_ops.h in libatomic_ops/src" OFF)
# Convert VER_INFO values to [SO]VERSION ones.
if (BUILD_SHARED_LIBS)
@@ -148,7 +149,13 @@ message(STATUS "TARGET = ${HOST}")
if (enable_threads)
find_package(Threads REQUIRED)
message(STATUS "Thread library: ${CMAKE_THREAD_LIBS_INIT}")
- include_directories(libatomic_ops/src)
+ if (without_libatomic_ops OR BORLAND OR MSVC OR WATCOM)
+ include_directories(libatomic_ops/src)
+ # Note: alternatively, use CFLAGS_EXTRA to pass -I<...>/libatomic_ops/src.
+ else()
+ # Assume the compiler supports GCC atomic intrinsics.
+ add_definitions("-DGC_BUILTIN_ATOMIC")
+ endif()
include_directories(${Threads_INCLUDE_DIR})
set(THREADDLLIBS_LIST ${CMAKE_THREAD_LIBS_INIT})
if (${CMAKE_DL_LIBS} MATCHES ^[^-].*)
@@ -173,8 +180,6 @@ if (CMAKE_USE_PTHREADS_INIT)
if (HOST MATCHES .*-.*-hpux10.*)
message(FATAL_ERROR "HP/UX 10 POSIX threads are not supported.")
endif()
- # Assume the compiler supports GCC atomic intrinsics.
- add_definitions("-DGC_BUILTIN_ATOMIC")
# Common defines for POSIX platforms.
add_definitions("-DGC_THREADS -D_REENTRANT")
if (enable_parallel_mark)