From d99c7b9593e5f0c4a408302b82e7bfeaeee665bc Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Wed, 4 Mar 2015 22:46:33 -0500 Subject: deal with libdl --- decoder/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'decoder/CMakeLists.txt') diff --git a/decoder/CMakeLists.txt b/decoder/CMakeLists.txt index 591ab7b3..f7683887 100644 --- a/decoder/CMakeLists.txt +++ b/decoder/CMakeLists.txt @@ -3,6 +3,8 @@ 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) find_package(FLEX REQUIRED) @@ -145,7 +147,7 @@ add_library(libcdec STATIC ${libcdec_SRCS}) set(cdec_SRCS cdec.cc) add_executable(cdec ${cdec_SRCS}) -target_link_libraries(cdec libcdec mteval utils ksearch klm klm_util klm_util_double ${Boost_LIBRARIES} ${ZLIB_LIBRARIES}) +target_link_libraries(cdec libcdec mteval utils ksearch klm klm_util klm_util_double ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBDL_LIBRARIES}) set(TEST_SRCS grammar_test.cc -- cgit v1.2.3 From 55b75d9f94a36de2d3f7eb9eb132b8286ddd2723 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 (limited to 'decoder/CMakeLists.txt') 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