-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
62 lines (49 loc) · 1.6 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
cmake_minimum_required(VERSION 3.12)
project(centroids VERSION 0.1.9)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 14)
include(PreventInSourceBuilds)
option(PEDANTIC "Compile with pedantic warnings" ON)
option(WERROR "Treat warnings as errors" OFF)
option(DEBUG_OUTPUT "Print debug outout to stderr" OFF)
option(BUILD_DOCS "Build documentation" ON)
option(CPPLINT_CHECK "Check CXX Source for Formatting" ON)
option(BUILD_PYTHON "Build Python Bindings using pybind11" ON)
option(BUILD_LIB "Build Library" ON)
option(BUILD_WITH_OPENMP "Build With OpenMP" ON)
if(CPPLINT_CHECK)
include(cpplint)
cpplint_add_subdirectory(lib)
cpplint_add_subdirectory(python)
endif()
if(PEDANTIC)
add_compile_options(-pedantic -Wall -Wextra)
endif()
if(WERROR)
add_compile_options(-Werror)
endif()
if(DEBUG_OUTPUT)
add_compile_options(-DDEBUG_OUTPUT)
endif()
# Add __FILENAME__ with short path
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
# Add a custom command that produces version.cpp, plus
# a dummy output that's not actually produced, in order
# to force version.cmake to always be re-run before the build
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/version.cpp
${CMAKE_BINARY_DIR}/_version.cpp
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_SOURCE_DIR}/cmake/version.cmake
)
add_custom_target(version_info DEPENDS ${CMAKE_BINARY_DIR}/version.cpp)
if(BUILD_PYTHON)
add_subdirectory(python)
endif()
if(BUILD_DOCS)
add_subdirectory(docs/sphinx)
add_subdirectory(docs/doxygen)
endif()
if(BUILD_LIB)
add_subdirectory(lib)
endif()