-
Notifications
You must be signed in to change notification settings - Fork 151
/
CMakeLists.txt
112 lines (91 loc) · 3.25 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
cmake_minimum_required(VERSION 3.4)
project(face_segmentation)
# Set version
set(FACE_SEG_MAJOR_VERSION 0)
set(FACE_SEG_MINOR_VERSION 9)
set(FACE_SEG_PATCH_VERSION 0)
set(FACE_SEG_VERSION ${FACE_SEG_MAJOR_VERSION}.${FACE_SEG_MINOR_VERSION}.${FACE_SEG_PATCH_VERSION})
# Global configurations
# ===================================================
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX")
set(DEF_INSTALL_CMAKE_DIR cmake)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC")
set(DEF_INSTALL_CMAKE_DIR lib/cmake/face_seg)
endif()
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
"Installation directory for CMake files")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_DEBUG_POSTFIX "_d")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Optional 3rd party components
# ===================================================
option(WITH_BOOST_STATIC "Boost static libraries" ON)
option(WITH_FIND_FACE_LANDMARKS "Find Face Landmarks library" ON)
# Build components
# ===================================================
option(BUILD_DOCS "Build documentation using Doxygen" ON)
option(BUILD_INTERFACE_PYTHON "Build interface for Python" ON)
# Find dependencies
# ===================================================
# Boost
set(Boost_USE_STATIC_LIBS ${WITH_BOOST_STATIC})
set(BOOST_ALL_DYN_LINK NOT ${WITH_BOOST_STATIC})
if(WIN32)
if(${WITH_BOOST_STATIC})
add_definitions(-DBOOST_ALL_NO_LIB)
else()
add_definitions(-DBOOST_ALL_DYN_LINK)
endif()
endif()
find_package(Boost COMPONENTS filesystem program_options regex timer)
# OpenCV
find_package(OpenCV REQUIRED highgui imgproc imgcodecs calib3d photo)
# Caffe
find_package(Caffe REQUIRED)
# sfl
if(WITH_FIND_FACE_LANDMARKS)
find_package(find_face_landmarks)
find_package(dlib)
endif()
# Doxygen
find_package(Doxygen)
# Interfaces
# Add sub-directories
# ===================================================
add_subdirectory(face_seg)
add_subdirectory(face_seg_image)
add_subdirectory(face_seg_batch)
# Interfaces
if(BUILD_INTERFACE_PYTHON)
add_subdirectory(interfaces/python)
endif()
# Documentation
if(BUILD_DOCS)
add_subdirectory(doc)
endif()
# Export configuration
# ===================================================
# Add all targets to the build-tree export set
set(FACE_SEG_TARGETS face_seg face_seg_image face_seg_batch)
export(TARGETS ${FACE_SEG_TARGETS}
FILE "${PROJECT_BINARY_DIR}/face_seg-targets.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE face_seg)
# Create config files
configure_file(cmake/face_segmentation-config.cmake.in
"${PROJECT_BINARY_DIR}/face_segmentation-config.cmake" @ONLY)
configure_file(cmake/face_segmentation-config-version.cmake.in
"${PROJECT_BINARY_DIR}/face_segmentation-config-version.cmake" @ONLY)
# Install config files
install(FILES
"${PROJECT_BINARY_DIR}/face_segmentation-config.cmake"
"${PROJECT_BINARY_DIR}/face_segmentation-config-version.cmake"
DESTINATION "cmake" COMPONENT dev)
# Install the export set for use with the install-tree
install(EXPORT face_seg-targets DESTINATION cmake COMPONENT dev)
# Install sample data
file(GLOB SAMPLE_IMAGES "data/images/*.jpg")
install(FILES ${SAMPLE_IMAGES} DESTINATION data/images)