forked from FORTH-ModelBasedTracker/PyOpenPose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
111 lines (86 loc) · 3.3 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
cmake_minimum_required(VERSION 3.5)
project(PyOpenPose)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 11)
include(FeatureSummary)
##### Auto configure install prefix and build mode #####
if(DEFINED ENV{PYOPENPOSE_ROOT})
message("PYOPENPOSE_ROOT is defined. Setting CMAKE_INSTALL_PREFIX to: $ENV{PYOPENPOSE_ROOT}")
set(CMAKE_INSTALL_PREFIX $ENV{PYOPENPOSE_ROOT} CACHE PATH "Install path for PyOpenpose" FORCE )
endif()
message("Install prefix is set to: ${CMAKE_INSTALL_PREFIX}")
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
message("Generating with build type: ${CMAKE_BUILD_TYPE}")
###############
# Use at every target to make it default installable
macro(make_installable project)
set_target_properties(${project} PROPERTIES DEBUG_POSTFIX "D")
install(TARGETS ${project} EXPORT ${project}
INCLUDES DESTINATION include
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin)
install(EXPORT ${project} DESTINATION cmake)
endmacro()
# Use for every python target to take care of peculiarities
macro(pythonize project)
set_target_properties(${project} PROPERTIES PREFIX "")
if(WIN32)
set_target_properties(${project} PROPERTIES SUFFIX ".pyd" FOLDER "Python")
endif()
make_installable(${project})
endmacro()
if(NOT WIN32) # compile with fPIC when building static with gcc
set(CUDA_NVCC_FLAGS "--compiler-options=-fPIC ${CUDA_NVCC_FLAGS}")
set(CMAKE_CXX_FLAGS "-fPIC ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
endif()
find_package(CUDA REQUIRED)
find_package(OpenCV 3 REQUIRED)
find_package(Doxygen)
set(WITH_PYTHON3 False CACHE BOOL "Use Python3")
### for python 3 use this:
find_package(Boost 1.63.0)
if( Boost_FOUND ) #new syntax is needed
if( WITH_PYTHON3 )
find_package(Boost COMPONENTS system python3 REQUIRED)
else()
find_package(Boost COMPONENTS system python2 REQUIRED)
endif()
else()
if( WITH_PYTHON3 )
find_package(Boost COMPONENTS system python-py35 REQUIRED)
else()
find_package(Boost COMPONENTS system python-py27 REQUIRED)
endif()
endif()
if( WITH_PYTHON3 )
find_package(PythonLibs 3 EXACT REQUIRED)
else()
find_package(PythonLibs 2.7 EXACT REQUIRED)
endif()
# USE_CAFFE define needed by openpose headers
if(DEFINED ENV{OPENPOSE_ROOT})
add_definitions("-DUSE_CAFFE")
set(OPENPOSE_INCLUDE_DIRS "$ENV{OPENPOSE_ROOT}/include")
set(OPENPOSE_LIBRARIES "$ENV{OPENPOSE_ROOT}/lib")
set(CAFFE_INCLUDE_DIRS "$ENV{OPENPOSE_ROOT}/include")
set(CAFFE_LIBRARIES "$ENV{OPENPOSE_ROOT}/lib")
else()
message(FATAL_ERROR "Environment variable OPENPOSE_ROOT is not set. Please set and point to openpose installation folder")
endif()
link_directories(${CAFFE_LIBRARIES} ${OPENPOSE_LIBRARIES})
include_directories(${OPENPOSE_INCLUDE_DIRS})
include_directories(${CAFFE_INCLUDE_DIRS})
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${CUDA_INCLUDE_DIRS})
include_directories(${PYTHON_INCLUDE_DIRS})
feature_summary(WHAT ALL)
add_subdirectory(PyOpenPoseLib)
if(DOXYGEN_FOUND)
add_subdirectory(doc)
endif()
# custom install target, needed for Clion IDE.
add_custom_target(install_${PROJECT_NAME} $(MAKE) install COMMENT "Installing ${PROJECT_NAME}")