-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathCMakeLists.txt
144 lines (113 loc) · 6.31 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
# ----------------------------------------------------------------------------
# Basic Configuration
# ----------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(raspicam)
set(PROJECT_VERSION "0.1.9")
string(REGEX MATCHALL "[0-9]" PROJECT_VERSION_PARTS "${PROJECT_VERSION}")
list(GET PROJECT_VERSION_PARTS 0 PROJECT_VERSION_MAJOR)
list(GET PROJECT_VERSION_PARTS 1 PROJECT_VERSION_MINOR)
list(GET PROJECT_VERSION_PARTS 2 PROJECT_VERSION_PATCH)
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
#------------------------------------------------------
# Build type
#------------------------------------------------------
IF(NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE "Release" )
ENDIF()
#------------------------------------------------------
# Lib Names and Dirs
#------------------------------------------------------
# Postfix of so's:
set(PROJECT_DLLVERSION)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_INSTALL_PREFIX}/lib/cmake/ /usr/lib/cmake)
OPTION(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
OPTION(BUILD_UTILS "Acitvates/Deactivates building utils libraries" ON)
OPTION(BUILD_TESTS "Acitvates/Deactivates building tests " OFF)
OPTION(BUILD_CV "Acitvates/Deactivates building utils libraries" ON)
#If opencv installed, creates the libraspicam_cv library module
IF(BUILD_CV)
FIND_PACKAGE(OpenCV)
IF(OpenCV_FOUND)
include_directories(${OpenCV_INCLUDE_DIRS})
SET(LIB_COMPONENTS ${LIB_COMPONENTS} ${PROJECT_NAME}_cv)
SET(PROJECT_CV_CREATED_FLAG "YES")
ENDIF()
ENDIF()
# ----------------------------------------------------------------------------
# PROJECT CONFIGURATION
# force some variables that could be defined in the command line to be written to cache
# ----------------------------------------------------------------------------
OPTION(INSTALL_DOC "Set to ON to build/install Documentation" OFF)
IF (INSTALL_DOC)
FIND_PACKAGE(Doxygen REQUIRED)
MESSAGE( STATUS "INSTALL_DOC: ${INSTALL_DOC} ")
INCLUDE("${PROJECT_SOURCE_DIR}/generateDoc.cmake")
GENERATE_DOCUMENTATION(${PROJECT_SOURCE_DIR}/dox.in)
ENDIF()
# ----------------------------------------------------------------------------
# Uninstall target, for "make uninstall"
# ----------------------------------------------------------------------------
CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# ----------------------------------------------------------------------------
# create configuration file from .in file (If you use windows take care with paths)
# ----------------------------------------------------------------------------
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/config.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
INSTALL(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" DESTINATION share/${PROJECT_NAME} )
IF(NOT TARGET_PROCESSOR )
SET(TARGET_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
ENDIF()
if(${TARGET_PROCESSOR} MATCHES armv7l) # In ARM_COrtex8 with neon, enalble vectorized operations
set(GENERAL_FLAGS "${GENERAL_FLAGS} -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=hard ")
endif()
if(${TARGET_PROCESSOR} MATCHES armv6l) # In PiZero with neon, enalble vectorized operations
set(GENERAL_FLAGS "${GENERAL_FLAGS} -mabi=aapcs-linux -marm -march=armv6 -mfloat-abi=hard -mfp16-format=none -mfpu=vfp -mlittle-endian -mpic-data-is-text-relative -mrestrict-it -msched-prolog -mstructure-size-boundary=0x20 -mtp=auto -mtls-dialect=gnu -munaligned-access -mvectorize-with-neon-quad")
endif()
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${GENERAL_FLAGS} -O3 -g0 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${GENERAL_FLAGS} -O0 -g3 -DDEBUG -D_DEBUG -DPRINT_DEBUG_MESSAGES")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} ${GENERAL_FLAGS} -O1 -g3 -D_DEBUG -DDEBUG -DPRINT_DEBUG_MESSAGES")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_EXE_LINKER_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${EXTRA_EXE_LINKER_FLAGS_RELEASE}")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${EXTRA_EXE_LINKER_FLAGS_DEBUG}")
#------------------------------------------------
# DIRS
#------------------------------------------------
SET(REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} pthread)
ADD_SUBDIRECTORY(src)
IF(BUILD_UTILS)
ADD_SUBDIRECTORY(utils)
ENDIF()
IF(BUILD_TESTS)
ADD_SUBDIRECTORY(test)
ENDIF()
# ----------------------------------------------------------------------------
# display status message for important variables
# ----------------------------------------------------------------------------
message( STATUS )
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
message( STATUS "General configuration for ${PROJECT_NAME} ${PROJECT_VERSION}")
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
message( STATUS )
message(" Built as dynamic libs?:" ${BUILD_SHARED_LIBS})
message(" Compiler:" "${CMAKE_COMPILER}" "${CMAKE_CXX_COMPILER}")
message( STATUS "C++ flags (Release): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
message( STATUS "C++ flags (Debug): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
message( STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message( STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
MESSAGE( STATUS )
MESSAGE( STATUS "TARGET_PROCESSOR = ${TARGET_PROCESSOR}" )
MESSAGE( STATUS "BUILD_SHARED_LIBS = ${BUILD_SHARED_LIBS}" )
MESSAGE( STATUS "BUILD_UTILS = ${BUILD_UTILS}" )
MESSAGE( STATUS "BUILD_TESTS = ${BUILD_TESTS}" )
MESSAGE( STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}" )
MESSAGE( STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}" )
MESSAGE( STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}" )
MESSAGE( STATUS )
MESSAGE( STATUS "CREATE OPENCV MODULE=${OpenCV_FOUND}")
MESSAGE( STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
MESSAGE( STATUS "REQUIRED_LIBRARIES=${REQUIRED_LIBRARIES}")
MESSAGE( STATUS )
MESSAGE( STATUS )
MESSAGE( STATUS "Change a value with: cmake -D<Variable>=<Value>" )
MESSAGE( STATUS )