This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathCMakeLists.txt
125 lines (107 loc) · 3.71 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
122
123
124
125
##
# Project setup.
project(hayai)
cmake_minimum_required(VERSION 2.4)
cmake_policy(SET CMP0012 NEW)
option(INSTALL_HAYAI "Install Hayai in addition of library compilation" ON)
option(BUILD_HAYAI_TESTS "Build the tests" ON)
option(BUILD_HAYAI_SAMPLES "Build the samples" ON)
# Offer the user the choice of overriding the installation directories.
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set(INSTALL_INCLUDE_DIR include CACHE PATH
"Installation directory for header files")
if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR CMake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/CMake/hayai)
endif()
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
"Installation directory for CMake files")
# Make relative paths absolute (needed later on.)
foreach(p LIB BIN INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()
# Proxy external CXXFLAGS.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{CXXFLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} $ENV{CXXFLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} $ENV{CXXFLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} $ENV{CXXFLAGS}")
# Determine system-dependant library paths.
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_RT_LIB)
if (${NEED_RT_LIB})
set(LIB_TIMING "rt")
else (${NEED_RT_LIB})
set(LIB_TIMING "")
endif (${NEED_RT_LIB})
##
# Include the individual projects.
add_subdirectory(src)
# Include the sample subdirectory if requested by user passing -BUILD_HAYAI_SAMPLES=true.
if (${BUILD_HAYAI_SAMPLES})
add_subdirectory(sample)
endif (${BUILD_HAYAI_SAMPLES})
# Include tests if requested by the user passing -DBUILD_HAYAI_TESTS=true.
if (${BUILD_HAYAI_TESTS})
enable_testing()
add_subdirectory(vendor/gtest)
add_subdirectory(tests)
endif (${BUILD_HAYAI_TESTS})
##
# Export targets and package
# Add all targets to the build-tree export set
export(
TARGETS hayai_main
FILE "${PROJECT_BINARY_DIR}/hayai-targets.cmake"
)
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry.)
export(PACKAGE hayai)
# Install targets if requested.
if (${INSTALL_HAYAI})
# Create the hayai-config.cmake.
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
"${INSTALL_INCLUDE_DIR}")
# ... for the build tree.
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}")
configure_file(hayai-config.cmake.in
"${PROJECT_BINARY_DIR}/hayai-config.cmake" @ONLY)
# ... for the install tree.
set(CONF_INCLUDE_DIRS "\${HAYAI_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(
hayai-config.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hayai-config.cmake" @ONLY
)
# Install the hayai-config.cmake
install(
FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hayai-config.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev
)
# Install the export set for use with the install-tree.
install(
EXPORT hayai-targets
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev
)
endif (${INSTALL_HAYAI})
# Print build resume.
#
# This function has been adapted from the OpenCV CMake utilities.
function(print_status txt var)
if (var)
message(STATUS ${txt} "YES")
else (var)
message(STATUS ${txt} "NO")
endif (var)
endfunction()
message(STATUS "")
message(STATUS "Hayai build resume:")
print_status(" Building tests: " ${BUILD_HAYAI_TESTS})
print_status(" Building samples: " ${BUILD_HAYAI_SAMPLES})
print_status(" Installing: " ${INSTALL_HAYAI})
message(STATUS "")