From 422de5c0e66c236273a8ac7c7c8c6f4b72443a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bertel?= Date: Mon, 25 Feb 2019 10:25:24 -0500 Subject: [PATCH] Fixed undefined reference to 'clock_gettime' by linking rt library --- CMakeLists.txt | 9 ++++++++- Sample-Programs/Hologram/CMakeLists.txt | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e5a8d0e81..e4bab6340f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,11 +290,18 @@ if(WIN32) SPIRV-Tools-opt PROPERTIES IMPORTED_LOCATION "${SPIRV_TOOLS_OPT_LIB}" IMPORTED_LOCATION_DEBUG "${SPIRV_TOOLS_OPT_DLIB}") endif() +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + find_library(LIBRT rt) +endif() + if(WIN32) set(SPIRV_TOOLS_LIBRARIES SPIRV-Tools-opt SPIRV-Tools) set(GLSLANG_LIBRARIES glslang OGLCompiler OSDependent HLSL SPIRV SPVRemapper ${SPIRV_TOOLS_LIBRARIES}) else() - set(SPIRV_TOOLS_LIBRARIES ${SPIRV_TOOLS_OPT_LIB} ${SPIRV_TOOLS_LIB}) + set(SPIRV_TOOLS_LIBRARIES + ${SPIRV_TOOLS_OPT_LIB} + ${SPIRV_TOOLS_LIB} + ${LIBRT}) set(GLSLANG_LIBRARIES ${GLSLANG_LIB} ${OGLCompiler_LIB} diff --git a/Sample-Programs/Hologram/CMakeLists.txt b/Sample-Programs/Hologram/CMakeLists.txt index cc041a4287..dcf291b738 100644 --- a/Sample-Programs/Hologram/CMakeLists.txt +++ b/Sample-Programs/Hologram/CMakeLists.txt @@ -96,6 +96,9 @@ endif() add_executable(Hologram ${sources}) target_compile_definitions(Hologram ${definitions}) target_include_directories(Hologram ${includes}) -target_link_libraries(Hologram ${libraries}) +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + find_library(LIBRT rt) +endif() +target_link_libraries(Hologram ${libraries} ${LIBRT}) install(TARGETS Hologram RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})