forked from IBM/comanche
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (67 loc) · 2.88 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 3.5)
# force out-of-tree build
option(FORCE_OTT_BUILD "force out of tree build" ON)
option(BOOTSTRAP_DEPS "bootstrap to build deps" ON)
if(CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR AND FORCE_OTT_BUILD)
message(FATAL_ERROR "Cannot use in-source build ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}. You should delete any CMakeCache.txt and CMakeFiles and then try out-of-tree build")
endif(CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR AND FORCE_OTT_BUILD)
# used for kernel
set(ENV{COMANCHE_HOME} ${CMAKE_CURRENT_SOURCE_DIR})
include(CheckIncludeFiles)
find_package(PkgConfig)
include(${CMAKE_CURRENT_SOURCE_DIR}/mk/common.cmake)
project(comanche)
# locate FindXXX.cmake
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mk)
message("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
# make COMANCHE HOME visible in config.h
set(CONF_COMANCHE_HOME ${CMAKE_CURRENT_SOURCE_DIR})
# override this at cmake time with 'cmake -DCMAKE_INSTALL_PREFIX:PATH=/foo ..'
set(CONF_COMANCHE_INSTALL ${CMAKE_INSTALL_PREFIX})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/config_comanche.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/config_comanche.h"
@ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/config_comanche.h"
DESTINATION include)
# this flag is only for GNU compiler version number smaller than 8 and clang compilers
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
set(FLAG_DUMP_CLASS "-fdump-class-hierarchy")
endif()
# run 'make components' to trigger compoents build,
# it's requireqd to wrap compoents targets with BOOTSTRAP_DEPS in the parent projects
add_custom_target(components
${CMAKE_COMMAND} -DBOOTSTRAP_DEPS=off ${CMAKE_SOURCE_DIR}
COMMAND make all
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
# default make will only build core and dependencies
if(BOOTSTRAP_DEPS)
add_subdirectory(src/lib)
message("\n[IMPORTANT]: first run 'make' to build core and dependencies")
message(" then run 'make components' to build components")
else(BOOTSTRAP_DEPS)
set(PMDK_PREFIX ${CONF_COMANCHE_HOME}/src/lib/pmdk)
#find_package(PMDK REQUIRED)
find_package(TBB REQUIRED)
set(PMDK_INCLUDE_DIRS ${PMDK_PREFIX}/src/include)
add_subdirectory(src)
add_subdirectory(apps)
add_subdirectory(testing)
endif(BOOTSTRAP_DEPS)
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(gtags
GTAGSFORCECPP=1 gtags
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating GTAGS files" VERBATIM
)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)