From 5eb2eb6693340c14766876bce705e3adb8733796 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 5 Mar 2015 00:14:16 -0500 Subject: deal with possible RT lib dependency --- cmake/FindRT.cmake | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ decoder/CMakeLists.txt | 4 ++-- klm/lm/CMakeLists.txt | 6 ++++-- 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 cmake/FindRT.cmake diff --git a/cmake/FindRT.cmake b/cmake/FindRT.cmake new file mode 100644 index 00000000..55ae1a26 --- /dev/null +++ b/cmake/FindRT.cmake @@ -0,0 +1,55 @@ +# - Check for the presence of RT +# +# The following variables are set when RT is found: +# HAVE_RT = Set to true, if all components of RT +# have been found. +# RT_INCLUDES = Include path for the header files of RT +# RT_LIBRARIES = Link these to use RT + +## ----------------------------------------------------------------------------- +## Check for the header files + +find_path (RT_INCLUDES time.h + PATHS /usr/local/include /usr/include ${CMAKE_EXTRA_INCLUDES} + ) + +## ----------------------------------------------------------------------------- +## Check for the library + +find_library (RT_LIBRARIES rt + PATHS /usr/local/lib /usr/lib /lib ${CMAKE_EXTRA_LIBRARIES} + ) + +## ----------------------------------------------------------------------------- +## Actions taken when all components have been found + +if (RT_INCLUDES AND RT_LIBRARIES) + set (HAVE_RT TRUE) +else (RT_INCLUDES AND RT_LIBRARIES) + if (NOT RT_FIND_QUIETLY) + if (NOT RT_INCLUDES) + message (STATUS "Unable to find RT header files!") + endif (NOT RT_INCLUDES) + if (NOT RT_LIBRARIES) + message (STATUS "Unable to find RT library files!") + endif (NOT RT_LIBRARIES) + endif (NOT RT_FIND_QUIETLY) +endif (RT_INCLUDES AND RT_LIBRARIES) + +if (HAVE_RT) + if (NOT RT_FIND_QUIETLY) + message (STATUS "Found components for RT") + message (STATUS "RT_INCLUDES = ${RT_INCLUDES}") + message (STATUS "RT_LIBRARIES = ${RT_LIBRARIES}") + endif (NOT RT_FIND_QUIETLY) +else (HAVE_RT) + if (RT_FIND_REQUIRED) + message (FATAL_ERROR "Could not find RT!") + endif (RT_FIND_REQUIRED) +endif (HAVE_RT) + +mark_as_advanced ( + HAVE_RT + RT_LIBRARIES + RT_INCLUDES + ) diff --git a/decoder/CMakeLists.txt b/decoder/CMakeLists.txt index f7683887..ac07e9fe 100644 --- a/decoder/CMakeLists.txt +++ b/decoder/CMakeLists.txt @@ -3,10 +3,10 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../mteval) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../klm) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - PROJECT(decoder C CXX) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + find_package(FLEX REQUIRED) FLEX_TARGET(RuleLexer rule_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/rule_lexer.cc) diff --git a/klm/lm/CMakeLists.txt b/klm/lm/CMakeLists.txt index 5814b623..b95cddee 100644 --- a/klm/lm/CMakeLists.txt +++ b/klm/lm/CMakeLists.txt @@ -1,13 +1,15 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) +find_package(RT) + set(build_binary_SRCS build_binary_main.cc) add_executable(build_binary ${build_binary_SRCS}) -target_link_libraries(build_binary klm klm_util klm_util_double z) +target_link_libraries(build_binary klm klm_util klm_util_double z ${RT_LIBRARIES}) set(ngram_query_SRCS query_main.cc) add_executable(ngram_query ${ngram_query_SRCS}) -target_link_libraries(ngram_query klm klm_util klm_util_double z) +target_link_libraries(ngram_query klm klm_util klm_util_double z ${RT_LIBRARIES}) set(klm_STAT_SRCS bhiksha.hh -- cgit v1.2.3