-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
94 lines (83 loc) · 3.15 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
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake/"
"${CMAKE_SOURCE_DIR}/cmake/Modules/"
)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(
FATAL_ERROR
"In-source build not supported; generation should be done in a subdir, e.g.: ${CMAKE_SOURCE_DIR}/build"
)
endif ()
include(FrameworkUtils)
include(CheckFunctionExists)
project(embedded_bgsub CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Install path prefix (optional)")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Forced project build type" FORCE)
endif (NOT CMAKE_BUILD_TYPE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "$<$<CONFIG:Debug>:DEBUG>")
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "$<$<CONFIG:Debug>:_DEBUG>")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
option(USE_LINK_TIME_OPTIM "Enable link time optimization" ON)
option(USE_INLINE_INTRINSIC_FUNCS "Enable use of built-in inline intrinsic functions" ON)
option(USE_FAST_MATH "Enable fast math optimization" OFF)
option(USE_OPENMP "Enable OpenMP in internal implementations" ON)
find_package(OpenCV 4.0 REQUIRED)
message(STATUS "Found OpenCV >=4.0 at '${OpenCV_DIR}'")
if (USE_OPENMP)
find_package(OpenMP REQUIRED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif ()
add_subdirectory(cmake/checks/simd)
# if (USE_NEON)
# add_definitions(-mfpu=neon)
# endif ()
if (USE_FAST_MATH)
add_definitions(-ffast-math)
endif ()
IF (NOT WIN32)
add_definitions(-O3)
add_definitions(-Ofast)
add_definitions(-march=native)
# add_definitions(-Wall)
# add_definitions(-Wfatal-errors)
# add_definitions(-Wextra)
# add_definitions(-Wshadow)
# add_definitions(-Werror)
# add_definitions(-pedantic-errors)
add_definitions(-Wno-missing-braces)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
find_package(TBB REQUIRED) # for <execution> stdlib
endif ()
ENDIF()
if (USE_LINK_TIME_OPTIM)
IF (NOT WIN32)
add_definitions(-flto)
ENDIF()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
find_program(GCC_AR gcc-ar)
if (GCC_AR)
set(CMAKE_AR ${GCC_AR})
endif ()
find_program(GCC_RANLIB gcc-ranlib)
if (GCC_RANLIB)
set(CMAKE_RANLIB ${GCC_RANLIB})
endif ()
endif ()
endif ()
add_subdirectory(api)
add_subdirectory(apps)