-
Notifications
You must be signed in to change notification settings - Fork 32
/
CMakeLists.txt
85 lines (71 loc) · 2.64 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
cmake_minimum_required(VERSION 3.6)
project(lccv)
if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
message(STATUS "No previous build - default to Release build")
endif()
endif()
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (CMAKE_CXX_STANDARD 17)
add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter -faligned-new -Werror -Wfatal-errors)
add_definitions(-D_FILE_OFFSET_BITS=64)
if (CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-Wno-psabi)
endif()
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
IF (NOT ENABLE_COMPILE_FLAGS_FOR_TARGET)
# On a Pi this will give us armhf or arm64.
execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
OUTPUT_VARIABLE ENABLE_COMPILE_FLAGS_FOR_TARGET OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
message(STATUS "Platform: ${ENABLE_COMPILE_FLAGS_FOR_TARGET}")
if ("${ENABLE_COMPILE_FLAGS_FOR_TARGET}" STREQUAL "arm64")
# 64-bit binaries can be fully optimised.
add_definitions(-ftree-vectorize)
elseif ("${ENABLE_COMPILE_FLAGS_FOR_TARGET}" STREQUAL "armv8-neon")
# Only build with 32-bit Pi 3/4 specific optimisations if requested on the command line.
add_definitions(-mfpu=neon-fp-armv8 -ftree-vectorize)
endif()
# Source package generation setup.
set(CPACK_GENERATOR "TXZ")
set(CPACK_PACKAGE_FILE_NAME "lccv-build")
set(CPACK_SOURCE_GENERATOR "TXZ")
set(CPACK_INSTALL_SCRIPTS ${CMAKE_SOURCE_DIR}/package.cmake)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "lccv-src")
set(CPACK_SOURCE_IGNORE_FILES "/\.git*;/build;")
include(CPack)
find_package(PkgConfig REQUIRED)
find_package(OpenCV REQUIRED)
pkg_check_modules(LIBCAMERA REQUIRED libcamera)
message(STATUS "libcamera library found:")
message(STATUS " version: ${LIBCAMERA_VERSION}")
message(STATUS " libraries: ${LIBCAMERA_LINK_LIBRARIES}")
message(STATUS " include path: ${LIBCAMERA_INCLUDE_DIRS}")
include(GNUInstallDirs)
set(SOURCES
src/lccv.cpp
src/libcamera_app.cpp
src/libcamera_app_options.cpp
)
set(HEADERS
include/lccv.hpp
include/libcamera_app.hpp
include/libcamera_app_options.hpp
)
add_library(liblccv ${SOURCES} ${HEADERS})
target_include_directories(liblccv
PUBLIC
include
${LIBCAMERA_INCLUDE_DIRS}
${OPENCV_INCLUDE_DIRS}
)
set_target_properties(liblccv PROPERTIES PREFIX "" IMPORT_PREFIX "")
target_link_libraries(liblccv pthread ${LIBCAMERA_LINK_LIBRARIES} ${OpenCV_LIBS})
install(TARGETS liblccv
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)