-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
157 lines (120 loc) · 4.96 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# ----------------------------------------------------------------------------
# EOgmaNeo
# Copyright(c) 2017-2018 Ogma Intelligent Systems Corp. All rights reserved.
#
# This copy of EOgmaNeo is licensed to you under the terms described
# in the EOGMANEO_LICENSE.md file included in this distribution.
# ----------------------------------------------------------------------------
# CMake version 3.1+ is required to enable C++14 features cleanly
cmake_minimum_required(VERSION 3.1)
project(EOgmaNeo)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(EOGMANEO_MAJOR_VERSION 1)
set(EOGMANEO_MINOR_VERSION 3)
set(EOGMANEO_PATCH_VERSION 0)
set(EOGMANEO_VERSION ${EOGMANEO_MAJOR_VERSION}.${EOGMANEO_MINOR_VERSION}.${EOGMANEO_PATCH_VERSION})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITNESS 64)
else()
set(BITNESS 32)
endif()
message(STATUS "Bitness: ${BITNESS}")
if(NOT CMAKE_BUILD_TYPE)
message("CMAKE_BUILD_TYPE not set, setting it to Release")
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
option(BUILD_PREENCODERS ON)
message(STATUS "Build pre-encoders: ${BUILD_PREENCODERS}")
############################################################################
# Add the EOgmaNeo library
set(EOGMANEO_INCLUDE_DIR "source/eogmaneo;source/optional")
include_directories(${EOGMANEO_INCLUDE_DIR})
file(GLOB_RECURSE EOGMANEO_SRC
"source/eogmaneo/*.h"
"source/eogmaneo/*.cpp"
)
if (BUILD_PREENCODERS)
file(GLOB_RECURSE EOGMANEO_IMAGEENCODER_SRC "source/optional/ImageEncoder.*")
list(APPEND EOGMANEO_SRC ${EOGMANEO_IMAGEENCODER_SRC})
file(GLOB_RECURSE EOGMANEO_KMEANSENCODER_SRC "source/optional/KMeansEncoder.*")
list(APPEND EOGMANEO_SRC ${EOGMANEO_KMEANSENCODER_SRC})
file(GLOB_RECURSE EOGMANEO_GABORENCODER_SRC "source/optional/GaborEncoder.*")
list(APPEND EOGMANEO_SRC ${EOGMANEO_GABORENCODER_SRC})
endif()
add_library(EOgmaNeo ${EOGMANEO_SRC})
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
set_property(TARGET EOgmaNeo PROPERTY CXX_STANDARD 14)
set_property(TARGET EOgmaNeo PROPERTY CXX_STANDARD_REQUIRED ON)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(BITNESS EQUAL 64)
set_target_properties(EOgmaNeo PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
# Offer the user the choice of overriding the installation directories
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_INCLUDE_DIR include/oegmaneo CACHE PATH "Installation directory for header files")
message(STATUS "CMake install prefix = ${CMAKE_INSTALL_PREFIX}")
if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR CMake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/CMake/EOgmaNeo)
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()
# Add all targets to the build-tree export set
export(TARGETS EOgmaNeo
FILE "${PROJECT_BINARY_DIR}/EOgmaNeoTargets.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE EOgmaNeo)
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
"${INSTALL_INCLUDE_DIR}")
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
configure_file(EOgmaNeoConfig.cmake.in
"${PROJECT_BINARY_DIR}/EOgmaNeoConfig.cmake" @ONLY)
set(CONF_INCLUDE_DIRS "\${EOGMANEO_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(EOgmaNeoConfig.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/EOgmaNeoConfig.cmake" @ONLY)
configure_file(EOgmaNeoConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/EOgmaNeoConfigVersion.cmake" @ONLY)
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/EOgmaNeoConfig.cmake"
"${PROJECT_BINARY_DIR}/EOgmaNeoConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}")
# Library install target
install(TARGETS EOgmaNeo
EXPORT EOgmaNeoTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
# Headers, incl. schema headers, install targets
install(DIRECTORY "${PROJECT_SOURCE_DIR}/source/"
EXPORT EOgmaNeoTargets
DESTINATION include/eogmaneo
FILES_MATCHING PATTERN "*.h*")
# 3rd party headers install targets
install(DIRECTORY "${3RDPARTY_PATH}/include/"
EXPORT EOgmaNeoTargets
DESTINATION include/eogmaneo
FILES_MATCHING PATTERN "*.h*")
install(EXPORT EOgmaNeoTargets
DESTINATION "${INSTALL_CMAKE_DIR}")
# Uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)