forked from dsteinberg/libcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (92 loc) · 3.46 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
project(cluster)
cmake_minimum_required(VERSION 2.6)
#--------------------------------#
# Includes #
#--------------------------------#
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
include(${PROJECT_SOURCE_DIR}/FindEigen3.cmake REQUIRED)
include_directories(${EIGEN_INCLUDE_DIRS})
include(FindOpenMP)
#--------------------------------#
# Enforce an out-of-source build #
#--------------------------------#
string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" INSOURCE)
if(INSOURCE)
message(FATAL_ERROR "This project requires an out of source build.")
endif(INSOURCE)
#--------------------------------#
# Compiler environment Setup #
#--------------------------------#
# Some compilation options (changeable from ccmake)
option(BUILD_EXHAUST_SPLIT "Use the exhaustive cluster split heuristic?" off)
option(BUILD_PYTHON_INTERFACE "Build the python interface?" off)
option(BUILD_USE_PYTHON3 "Use python3 instead of python 2?" on)
# Locations for source code
set(LIB_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src)
set(LIB_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(TEST_SOURCE_DIR ${PROJECT_SOURCE_DIR}/test)
set(PYTHON_SOURCE_DIR ${PROJECT_SOURCE_DIR}/python)
# Locations for binary files
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)
# Automatically or from command line set build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Build type options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
endif(NOT CMAKE_BUILD_TYPE)
# If we want to use the greedy splitting heuristic, define it here
if(BUILD_EXHAUST_SPLIT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEXHAUST_SPLIT")
endif(BUILD_EXHAUST_SPLIT)
# Python needs row major matrices (for convenience)
if(BUILD_PYTHON_INTERFACE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_DEFAULT_TO_ROW_MAJOR")
endif(BUILD_PYTHON_INTERFACE)
# Search for OpenMP support for multi-threading
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}"
)
# Disable Eigen's parallelisation (this will get in the way of mine)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_DONT_PARALLELIZE")
endif(OPENMP_FOUND)
#--------------------------------#
# Library Build Instructions #
#--------------------------------#
# Make sure we include library headers in compile
include_directories(${LIB_INCLUDE_DIR})
# Library build instructions
add_library(${PROJECT_NAME} SHARED
${LIB_INCLUDE_DIR}/libcluster.h
${LIB_INCLUDE_DIR}/probutils.h
${LIB_INCLUDE_DIR}/distributions.h
${LIB_SOURCE_DIR}/distributions.cpp
${LIB_SOURCE_DIR}/comutils.h
${LIB_SOURCE_DIR}/comutils.cpp
${LIB_SOURCE_DIR}/cluster.cpp
${LIB_SOURCE_DIR}/scluster.cpp
${LIB_SOURCE_DIR}/mcluster.cpp
${LIB_SOURCE_DIR}/probutils.cpp
)
add_definitions("-Wall")
#--------------------------------#
# Library Install Instructions #
#--------------------------------#
if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local" )
endif(NOT CMAKE_INSTALL_PREFIX)
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(FILES
${LIB_INCLUDE_DIR}/libcluster.h
${LIB_INCLUDE_DIR}/probutils.h
${LIB_INCLUDE_DIR}/distributions.h
DESTINATION include/libcluster
)
#--------------------------------#
# Subdirectories to recurse to #
#--------------------------------#
subdirs(test python)