aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-10-01 19:56:39 -0700
committerChris Robinson <[email protected]>2019-10-01 19:56:39 -0700
commite2c1602ede1b17a4499cb4fa737eae04dc529ce0 (patch)
tree7998980b97d9562614e11e6c6658cfcc495920a7
parent0063f4bfac96f35899d9dec4e273f5ed642b4358 (diff)
Link the examples with librt if it exists
-rw-r--r--CMakeLists.txt14
1 files changed, 12 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f833e41..9bf09a3f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1423,12 +1423,22 @@ IF(ALSOFT_UTILS)
ENDIF()
+# Some systems need to link with -lrt for clock_gettime as used by the common
+# eaxmple functions.
+SET(RT_LIB )
+CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
+IF(HAVE_LIBRT)
+ SET(RT_LIB rt)
+ENDIF()
+
# Add a static library with common functions used by multiple example targets
-ADD_LIBRARY(ex-common STATIC EXCLUDE_FROM_ALL examples/common/alhelpers.c)
+ADD_LIBRARY(ex-common STATIC EXCLUDE_FROM_ALL
+ examples/common/alhelpers.c
+ examples/common/alhelpers.h)
TARGET_COMPILE_DEFINITIONS(ex-common PUBLIC ${CPP_DEFS})
TARGET_INCLUDE_DIRECTORIES(ex-common PUBLIC ${OpenAL_SOURCE_DIR}/common)
TARGET_COMPILE_OPTIONS(ex-common PUBLIC ${C_FLAGS})
-TARGET_LINK_LIBRARIES(ex-common PUBLIC OpenAL)
+TARGET_LINK_LIBRARIES(ex-common PUBLIC OpenAL PRIVATE ${RT_LIB})
IF(ALSOFT_TESTS)
ADD_EXECUTABLE(altonegen examples/altonegen.c)