Fixed undefined reference to 'clock_gettime' by linking rt library (#2409)
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 03efa91..07e31e1 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -361,6 +361,14 @@
)
add_dependencies( ${SPIRV_TOOLS}-shared core_tables enum_string_mapping extinst_tables )
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ find_library(LIBRT rt)
+ if(LIBRT)
+ target_link_libraries(${SPIRV_TOOLS} ${LIBRT})
+ target_link_libraries(${SPIRV_TOOLS}-shared ${LIBRT})
+ endif()
+endif()
+
if(ENABLE_SPIRV_TOOLS_INSTALL)
install(TARGETS ${SPIRV_TOOLS} ${SPIRV_TOOLS}-shared
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}