forked from datamicroscopes/lda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
88 lines (72 loc) · 3.64 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
cmake_minimum_required(VERSION 2.6)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
project(microscopes_lda)
# default mode is Release
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -MD -std=c++0x")
# since we use distributions headers, we need to inherit their
# no-strict-aliasing warnings rule otherwise deal with compiler noise
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing")
# this warning is annoying; who cares about unused parameters
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
# for anaconda builds
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7")
# clang complains about register
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif()
# taken from distributions
#set(CMAKE_CXX_FLAGS_MATHOPT "-mfpmath=sse -msse4.1 -ffast-math -funsafe-math-optimizations")
set(CMAKE_CXX_FLAGS_MATHOPT "-mfpmath=sse -msse4.1")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${CMAKE_CXX_FLAGS_MATHOPT}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG_MODE -fno-omit-frame-pointer")
# give our include dirs the most precedent
include_directories(include)
# followed by the EXTRA_* ones
if(DEFINED EXTRA_INCLUDE_PATH)
include_directories(${EXTRA_INCLUDE_PATH})
endif()
if(DEFINED EXTRA_LIBRARY_PATH)
link_directories(${EXTRA_LIBRARY_PATH})
endif()
find_package(Protobuf REQUIRED)
message(STATUS "found protobuf INC=${PROTOBUF_INCLUDE_DIRS}, LIB=${PROTOBUF_LIBRARIES}")
include_directories(${PROTOBUF_INCLUDE_DIRS})
find_package(Distributions)
if(DISTRIBUTIONS_FOUND)
message(STATUS "found distributions INC=${DISTRIBUTIONS_INCLUDE_DIRS}, LIB=${DISTRIBUTIONS_LIBRARY_DIRS}")
include_directories(${DISTRIBUTIONS_INCLUDE_DIRS})
link_directories(${DISTRIBUTIONS_LIBRARY_DIRS})
else()
message(FATAL_ERROR "Could not find distributions")
endif()
find_package(MicroscopesCommon)
if(MICROSCOPES_COMMON_FOUND)
message(STATUS "found microscopes_common INC=${MICROSCOPES_COMMON_INCLUDE_DIRS}, LIB=${MICROSCOPES_COMMON_LIBRARY_DIRS}")
include_directories(${MICROSCOPES_COMMON_INCLUDE_DIRS})
link_directories(${MICROSCOPES_COMMON_LIBRARY_DIRS})
else()
message(FATAL_ERROR "Could not find microscopes_common")
endif()
install(DIRECTORY include/ DESTINATION include FILES_MATCHING PATTERN "*.h*")
install(DIRECTORY microscopes DESTINATION cython FILES_MATCHING PATTERN "*.pxd" PATTERN "__init__.py")
set(MICROSCOPES_LDA_SOURCE_FILES src/lda/model.cpp src/lda/kernels.cpp)
add_library(microscopes_lda SHARED ${MICROSCOPES_LDA_SOURCE_FILES})
target_link_libraries(microscopes_lda ${PROTOBUF_LIBRARIES} distributions_shared microscopes_common)
install(TARGETS microscopes_lda LIBRARY DESTINATION lib)
# test executables
enable_testing()
add_executable(test_small test/cxx/test_small.cpp)
add_executable(test_state test/cxx/test_state.cpp)
add_executable(test_random test/cxx/test_random.cpp)
add_executable(test_permutations test/cxx/test_permutations.cpp)
add_test(test_state test_state)
add_test(test_random test_random)
target_link_libraries(test_random ${PROTOBUF_LIBRARIES} distributions_shared microscopes_common microscopes_lda)
target_link_libraries(test_state ${PROTOBUF_LIBRARIES} distributions_shared microscopes_common microscopes_lda)
target_link_libraries(test_permutations ${PROTOBUF_LIBRARIES} distributions_shared microscopes_common microscopes_lda)
target_link_libraries(test_small ${PROTOBUF_LIBRARIES} distributions_shared microscopes_common microscopes_lda)