-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
73 lines (57 loc) · 2.85 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
# requires minimum cmake version
cmake_minimum_required(VERSION 3.5)
# produce the cmake var PROJECT_NAME
project(objectRecognizer)
# mandatory use of these packages
find_package(ICUBcontrib REQUIRED)
find_package(YARP 3.1.100 REQUIRED COMPONENTS OS sig math cv)
find_package(Caffe REQUIRED)
find_package(OpenCV REQUIRED)
# extend the current search path used by cmake to load helpers
list(APPEND CMAKE_MODULE_PATH ${ICUBCONTRIB_MODULE_PATH})
# helpers defining certain macros
include(ICUBcontribHelpers)
include(ICUBcontribOptions)
# specify to install in $ICUBcontrib_DIR/bin
icubcontrib_set_default_prefix()
# verify Caffe version
get_target_property(CAFFE_SONAME caffe IMPORTED_SONAME_RELEASE)
if("${CAFFE_SONAME}" MATCHES "libcaffe.so.([0-9]+).([0-9]+).([0-9]+)(-(.+))?")
set(CAFFE_MAJOR "${CMAKE_MATCH_1}")
set(CAFFE_MINOR "${CMAKE_MATCH_2}")
set(CAFFE_PATCH "${CMAKE_MATCH_3}")
set(CAFFE_PATCH2 "${CMAKE_MATCH_5}")
set(CAFFE_VERSION_STRING "${CAFFE_MAJOR}.${CAFFE_MINOR}.${CAFFE_PATCH}")
if(NOT "${CAFFE_PATCH2}" STREQUAL "")
set(CAFFE_VERSION_STRING "${CAFFE_VERSION_STRING}-${CAFFE_PATCH2}")
endif()
else()
set(CAFFE_MAJOR 0)
set(CAFFE_MINOR 0)
set(CAFFE_PATCH 0)
set(CAFFE_PATCH2 0)
set(CAFFE_VERSION_STRING unknown)
endif()
math(EXPR CAFFE_VERSION "${CAFFE_MAJOR}*10000 + ${CAFFE_MINOR}*100 + ${CAFFE_PATCH}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/caffe-version.h.in
${CMAKE_CURRENT_BINARY_DIR}/caffe-version.h
@ONLY)
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
include_directories(${Caffe_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/${PROJECT_NAME}/include)
set(folder_source ${PROJECT_NAME}/src/main.cpp)
set(folder_header ${PROJECT_NAME}/include/CaffeWrapper.hpp
${PROJECT_NAME}/include/definitions.h)
add_executable(${PROJECT_NAME} ${folder_source} ${folder_header})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${Caffe_DEFINITIONS})
target_link_libraries(${PROJECT_NAME} ${YARP_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
target_link_libraries(${PROJECT_NAME} ${Caffe_LIBRARIES})
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
file(GLOB conf ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/app/conf/*.ini ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/app/conf/*.prototxt)
file(GLOB conf ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/app/conf/*.ini.template ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/app/conf/*.prototxt.template)
file(GLOB scripts ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/app/scripts/*.xml.template ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/app/scripts/*.xml)
yarp_install(FILES ${conf} DESTINATION ${ICUBCONTRIB_CONTEXTS_INSTALL_DIR}/${PROJECT_NAME})
yarp_install(FILES ${scripts} DESTINATION ${ICUBCONTRIB_APPLICATIONS_INSTALL_DIR})
# generate ad-hoc project to perform "make uninstall"
icubcontrib_add_uninstall_target()