diff options
author | ebraminio <ebrahim@gnu.org> | 2017-04-14 04:25:50 +0430 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-14 04:25:50 +0430 |
commit | a41d5ea4453995dfd7c523427c6017623164c6ff (patch) | |
tree | 14715f4290e83f8e4be07c21e23772aa92806457 | |
parent | 8568588202dd718b089e43cd6d46f689c706f665 (diff) | |
download | harfbuzz_ng-a41d5ea4453995dfd7c523427c6017623164c6ff.tar.gz |
[cmake] Add atomic ops availability detection (#464)
-rw-r--r-- | CMakeLists.txt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b374e57b1..93d30a9db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,6 +296,36 @@ endif () set(project_sources ${project_sources} ${project_headers}) ## +## Atomic ops availability detection +file(WRITE "${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c" +" void memory_barrier (void) { __sync_synchronize (); } + int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); } + int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); } + void mutex_unlock (int *m) { __sync_lock_release (m); } +") +try_compile(HB_HAVE_INTEL_ATOMIC_PRIMITIVES + ${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives + SOURCES ${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c) +if (HB_HAVE_INTEL_ATOMIC_PRIMITIVES) + add_definitions(-DHAVE_INTEL_ATOMIC_PRIMITIVES) +endif () + +file(WRITE "${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c" +" #include <atomic.h> + /* This requires Solaris Studio 12.2 or newer: */ + #include <mbarrier.h> + void memory_barrier (void) { __machine_rw_barrier (); } + int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); } + void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); } +") +try_compile(HB_HAVE_SOLARIS_ATOMIC_OPS + ${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops + SOURCES ${PROJECT_BINARY_DIR}/try_compile_solaris_atomic_ops.c) +if (HB_HB_HAVE_SOLARIS_ATOMIC_OPS) + add_definitions(-DHB_HAVE_SOLARIS_ATOMIC_OPS) +endif () +## + add_library(harfbuzz ${project_sources}) target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS}) |