-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
121 lines (91 loc) · 3.32 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
120
121
cmake_minimum_required(VERSION 2.8)
project(GKMeans)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMake")
## Compiler settings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-sign-compare")
#----------------------
# Dependencies
#----------------------
# pthread for cxx11 thread support
FIND_PACKAGE(Threads )
list(APPEND LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
# Glog for logging
FIND_PACKAGE(Glog REQUIRED)
include_directories(SYSTEM ${GLOG_INCLUDE_DIRS})
list(APPEND LIBRARIES ${GLOG_LIBRARIES})
# HDF5 for data access
FIND_PACKAGE(HDF5 REQUIRED COMPONENTS CXX)
include_directories(SYSTEM ${HDF5_INLCUDE_DIRS})
list(APPEND LIBRARIES ${HDF5_LIBRARIES})
# CUDA
FIND_PACKAGE(CUDA REQUIRED)
if (CUDA_FOUND)
message(STATUS "CUDA Version: " ${CUDA_VERSION_STRINGS})
message(STATUS "CUDA Libararies: " ${CUDA_LIBRARIES})
include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
list(APPEND LIBRARIES ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY} ${CUDA_cusparse_LIBRARY})
list(APPEND CUDA_NVCC_FLAGS "-arch=sm_35;-std=c++11;-O2;-Xcompiler \"-fPIC\"")
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
endif()
#----------------------
# Directory settings
#----------------------
include_directories(include)
cuda_include_directories(include)
set(SRC_DIR src/gkmeans)
set(TEST_SRC_DIR src/tests)
set(INIH_DIR inih)
# inih library
include_directories(SYSTEM ${INIH_DIR}/cpp)
#----------------------
# Library
#----------------------
FILE(GLOB SRC_FILES ${SRC_DIR}/*.cpp
${SRC_DIR}/utils/*.cpp
${SRC_DIR}/functions/*.cpp
${SRC_DIR}/data_providers/*.cpp
${INIH_DIR}/cpp/*.cpp
${INIH_DIR}/*.c)
FILE(GLOB CU_SRC_FILES ${SRC_DIR}/*.cu
${SRC_DIR}/utils/*.cu)
#CUDA_COMPILE(CU_OBJECT ${CU_SRC_FILES})
cuda_add_library(gkl SHARED ${SRC_FILES} ${CU_SRC_FILES})
target_link_libraries(gkl ${LIBRARIES})
#----------------------
# EXE
#----------------------
add_executable(gkmeans tools/gkmeans.cpp)
target_link_libraries(gkmeans ${LIBRARIES} gkl)
#----------------------
# TEST
#----------------------
# We use GTest as the testing framework
FIND_PACKAGE(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
FILE(GLOB TEST_SRC_FILES ${TEST_SRC_DIR}/*.cpp)
add_executable(testAll ${TEST_SRC_FILES})
target_link_libraries(testAll ${LIBRARIES} gkl ${GTEST_LIBRARIES})
enable_testing()
add_test(NAME runtest COMMAND testAll)
#----------------------
# DOC
#----------------------
#Find doxygen for generating API docs
find_package(Doxygen)
option(BUILD_DOC "Build documentation with doxygen")
if (BUILD_DOC)
if (DOXYGEN_FOUND)
message(STATUS "Found Doxygen version " ${DOXYGEN_VERSION})
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generate API docs"
VERBATIM)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/doc)
else()
message(FATAL_ERROR "Doxygen not found, documentation will not be built.")
endif()
endif()