This repository has been archived by the owner on Sep 22, 2021. It is now read-only.
generated from arrufat/cpp-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
69 lines (57 loc) · 2.09 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
cmake_minimum_required(VERSION 3.14)
project("yolo-dlib" LANGUAGES CXX)
set(CPACK_PACKAGE_NAME "yolo-dlib")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
# Use C++ 17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# Colored warnings
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." ON)
if(${FORCE_COLORED_OUTPUT})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif()
endif()
# Enable ccache if it exists
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif (CCACHE_FOUND)
# Optimization flags
include(CheckCXXCompilerFlag)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
endif()
# OpenCV dependency
find_package(OpenCV REQUIRED)
# Dependency management
include(FetchContent)
# dlib
set(DLIB_TAG master)
FetchContent_Declare(
dlib
GIT_REPOSITORY https://github.com/davisking/dlib.git
GIT_TAG ${DLIB_TAG}
SOURCE_DIR ${PROJECT_SOURCE_DIR}/external/dlib
)
set(RESNET_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/external/dlib/examples)
message("-- Fetching dlib ${DLIB_TAG}")
FetchContent_MakeAvailable(dlib)
macro(add_dlib_executable name)
add_executable(${name} src/${name}.cpp)
target_link_libraries(${name} PRIVATE dlib::dlib)
target_include_directories(${name} PRIVATE src ${RESNET_INCLUDE_DIR})
target_compile_options(${name} PRIVATE -Wall -Wextra -pedantic -Wno-deprecated-copy)
install(TARGETS ${name} DESTINATION bin)
endmacro()
add_dlib_executable(main)