summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <redpony@gmail.com>2015-03-05 15:15:38 -0500
committerChris Dyer <redpony@gmail.com>2015-03-05 15:15:38 -0500
commit154b799d148276b09aa740a67e0afdf94281c452 (patch)
tree92141cb1bf7d9ccf644e1bcb9d25c6e8c97c88a6
parent91434e55cd1d1a8b810c0b84d684c42706564043 (diff)
parent55b75d9f94a36de2d3f7eb9eb132b8286ddd2723 (diff)
Merge branch 'cmake' of https://github.com/redpony/cdec into cmake
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt1
-rw-r--r--cmake/FindLibDL.cmake30
-rw-r--r--cmake/FindRT.cmake55
-rw-r--r--decoder/CMakeLists.txt4
-rw-r--r--extractor/CMakeLists.txt10
-rw-r--r--klm/lm/CMakeLists.txt6
-rw-r--r--training/crf/CMakeLists.txt22
-rw-r--r--training/dtrain/CMakeLists.txt2
-rw-r--r--training/latent_svm/CMakeLists.txt2
-rw-r--r--training/mira/CMakeLists.txt7
-rw-r--r--training/utils/CMakeLists.txt6
-rw-r--r--utils/CMakeLists.txt2
13 files changed, 118 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore
index 81ede92e..07145db9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+example_extff/libff_example.so*
Testing/
*/Testing/
training/Testing/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 21c2a230..934c69e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
#### packages
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)
+find_package(LibDL REQUIRED)
# for pycdec
find_package(PythonInterp 2.7 REQUIRED)
diff --git a/cmake/FindLibDL.cmake b/cmake/FindLibDL.cmake
new file mode 100644
index 00000000..1689e4c7
--- /dev/null
+++ b/cmake/FindLibDL.cmake
@@ -0,0 +1,30 @@
+# - Find libdl
+# Find the native LIBDL includes and library
+#
+# LIBDL_INCLUDE_DIR - where to find dlfcn.h, etc.
+# LIBDL_LIBRARIES - List of libraries when using libdl.
+# LIBDL_FOUND - True if libdl found.
+
+
+IF (LIBDL_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(LIBDL_FIND_QUIETLY TRUE)
+ENDIF (LIBDL_INCLUDE_DIR)
+
+FIND_PATH(LIBDL_INCLUDE_DIR dlfcn.h)
+
+SET(LIBDL_NAMES dl libdl ltdl libltdl)
+FIND_LIBRARY(LIBDL_LIBRARY NAMES ${LIBDL_NAMES} )
+
+# handle the QUIETLY and REQUIRED arguments and set LIBDL_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDL DEFAULT_MSG LIBDL_LIBRARY LIBDL_INCLUDE_DIR)
+
+IF(LIBDL_FOUND)
+ SET( LIBDL_LIBRARIES ${LIBDL_LIBRARY} )
+ELSE(LIBDL_FOUND)
+ SET( LIBDL_LIBRARIES )
+ENDIF(LIBDL_FOUND)
+
+MARK_AS_ADVANCED( LIBDL_LIBRARY LIBDL_INCLUDE_DIR )
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 591ab7b3..ac07e9fe 100644
--- a/decoder/CMakeLists.txt
+++ b/decoder/CMakeLists.txt
@@ -5,6 +5,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
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)
@@ -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
diff --git a/extractor/CMakeLists.txt b/extractor/CMakeLists.txt
index 1cf8533b..93a524cc 100644
--- a/extractor/CMakeLists.txt
+++ b/extractor/CMakeLists.txt
@@ -8,9 +8,10 @@ if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
-find_package(GTest REQUIRED)
-find_package(GMock REQUIRED)
-if(GMOCK_FOUND)
+find_package(GTest)
+find_package(GMock)
+if(GTEST_FOUND)
+ if(GMOCK_FOUND)
#rule_factory_test.cc
set(TEST_SRCS alignment_test.cc
data_array_test.cc
@@ -50,7 +51,8 @@ if(GMOCK_FOUND)
add_test(NAME ${testName} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${testName}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endforeach(testSrc)
-endif(GMOCK_FOUND)
+ endif(GMOCK_FOUND)
+endif(GTEST_FOUND)
set(sacompile_SRCS sacompile.cc)
add_executable(sacompile ${sacompile_SRCS})
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
diff --git a/training/crf/CMakeLists.txt b/training/crf/CMakeLists.txt
index 4792983e..85fab7a0 100644
--- a/training/crf/CMakeLists.txt
+++ b/training/crf/CMakeLists.txt
@@ -9,7 +9,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder)
set(mpi_batch_optimize_SRCS mpi_batch_optimize.cc cllh_observer.cc cllh_observer.h)
add_executable(mpi_batch_optimize ${mpi_batch_optimize_SRCS})
-target_link_libraries(mpi_batch_optimize training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
+target_link_libraries(mpi_batch_optimize training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
########### next target ###############
@@ -17,8 +17,7 @@ set(mpi_adagrad_optimize_SRCS mpi_adagrad_optimize.cc cllh_observer.cc cllh_obse
add_executable(mpi_adagrad_optimize ${mpi_adagrad_optimize_SRCS})
-target_link_libraries(mpi_adagrad_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
-
+target_link_libraries(mpi_adagrad_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
########### next target ###############
@@ -27,8 +26,7 @@ set(mpi_compute_cllh_SRCS mpi_compute_cllh.cc cllh_observer.cc cllh_observer.h)
add_executable(mpi_compute_cllh ${mpi_compute_cllh_SRCS})
-target_link_libraries(mpi_compute_cllh ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
-
+target_link_libraries(mpi_compute_cllh ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
########### next target ###############
@@ -37,8 +35,7 @@ set(mpi_extract_features_SRCS mpi_extract_features.cc)
add_executable(mpi_extract_features ${mpi_extract_features_SRCS})
-target_link_libraries(mpi_extract_features ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
-
+target_link_libraries(mpi_extract_features ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
########### next target ###############
@@ -47,8 +44,7 @@ set(mpi_extract_reachable_SRCS mpi_extract_reachable.cc)
add_executable(mpi_extract_reachable ${mpi_extract_reachable_SRCS})
-target_link_libraries(mpi_extract_reachable ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
-
+target_link_libraries(mpi_extract_reachable ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
########### next target ###############
@@ -56,8 +52,7 @@ set(mpi_flex_optimize_SRCS mpi_flex_optimize.cc)
add_executable(mpi_flex_optimize ${mpi_flex_optimize_SRCS})
-target_link_libraries(mpi_flex_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
-
+target_link_libraries(mpi_flex_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
########### next target ###############
@@ -65,7 +60,7 @@ set(mpi_online_optimize_SRCS mpi_online_optimize.cc)
add_executable(mpi_online_optimize ${mpi_online_optimize_SRCS})
-target_link_libraries(mpi_online_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
+target_link_libraries(mpi_online_optimize ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
########### next target ###############
@@ -73,6 +68,5 @@ set(mpi_baum_welch_SRCS mpi_baum_welch.cc)
add_executable(mpi_baum_welch ${mpi_baum_welch_SRCS})
-target_link_libraries(mpi_baum_welch ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
-
+target_link_libraries(mpi_baum_welch ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
diff --git a/training/dtrain/CMakeLists.txt b/training/dtrain/CMakeLists.txt
index 653cfe2b..72e80b6b 100644
--- a/training/dtrain/CMakeLists.txt
+++ b/training/dtrain/CMakeLists.txt
@@ -12,4 +12,4 @@ set(dtrain_SRCS
pairsampling.h
score.h)
add_executable(dtrain ${dtrain_SRCS})
-target_link_libraries(dtrain libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
+target_link_libraries(dtrain libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
diff --git a/training/latent_svm/CMakeLists.txt b/training/latent_svm/CMakeLists.txt
index ec48e02f..332b8d42 100644
--- a/training/latent_svm/CMakeLists.txt
+++ b/training/latent_svm/CMakeLists.txt
@@ -5,4 +5,4 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder)
set(latent_svm_SRCS latent_svm.cc)
add_executable(latent_svm ${latent_svm_SRCS})
-target_link_libraries(latent_svm libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
+target_link_libraries(latent_svm libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
diff --git a/training/mira/CMakeLists.txt b/training/mira/CMakeLists.txt
index 3a8fa516..bba9ef5f 100644
--- a/training/mira/CMakeLists.txt
+++ b/training/mira/CMakeLists.txt
@@ -5,13 +5,12 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder)
set(kbest_mira_SRCS kbest_mira.cc)
add_executable(kbest_mira ${kbest_mira_SRCS})
-target_link_libraries(kbest_mira ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
+target_link_libraries(kbest_mira libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
set(kbest_cut_mira_SRCS kbest_cut_mira.cc)
add_executable(kbest_cut_mira ${kbest_cut_mira_SRCS})
-target_link_libraries(kbest_cut_mira ${KDE4_KDECORE_LIBS} libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
+target_link_libraries(kbest_cut_mira libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
set(ada_opt_sm_SRCS ada_opt_sm.cc)
add_executable(ada_opt_sm ${ada_opt_sm_SRCS})
-target_link_libraries(ada_opt_sm ${KDE4_KDECORE_LIBS} training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z)
-
+target_link_libraries(ada_opt_sm training_utils libcdec ksearch mteval utils klm klm_util klm_util_double ${Boost_LIBRARIES} z ${LIBDL_LIBRARIES})
diff --git a/training/utils/CMakeLists.txt b/training/utils/CMakeLists.txt
index 1734ee73..2753b9f0 100644
--- a/training/utils/CMakeLists.txt
+++ b/training/utils/CMakeLists.txt
@@ -2,6 +2,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../utils)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../mteval)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../decoder)
+find_package(Threads REQUIRED)
+
set(training_utils_STAT_SRCS
candidate_set.h
entropy.h
@@ -21,11 +23,11 @@ add_library(training_utils STATIC ${training_utils_STAT_SRCS})
set(sentserver_SRCS sentserver.cc)
add_executable(sentserver ${sentserver_SRCS})
-target_link_libraries(sentserver)
+target_link_libraries(sentserver ${CMAKE_THREAD_LIBS_INIT})
set(sentclient_SRCS sentclient.cc)
add_executable(sentclient ${sentclient_SRCS})
-target_link_libraries(sentclient)
+target_link_libraries(sentclient ${CMAKE_THREAD_LIBS_INIT})
set(grammar_convert_SRCS grammar_convert.cc)
add_executable(grammar_convert ${grammar_convert_SRCS})
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 59fb644d..58668254 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -1,4 +1,4 @@
-include_directories()
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(TEST_SRCS dict_test.cc
logval_test.cc