At A Aaaaaaaaaaaa
At A Aaaaaaaaaaaa
At A Aaaaaaaaaaaa
set(OpenPose_VERSION_MAJOR 1)
set(OpenPose_VERSION_MINOR 3)
set(OpenPose_VERSION_PATCH 0)
set(OpenPose_VERSION ${OpenPose_VERSION_MAJOR}.${OpenPose_VERSION_MINOR}.$
{OpenPose_VERSION_PATCH})
### FLAGS
if (WIN32)
# TODO -- Makeshift solution -- This prevents rerunning build again
# https://gitlab.kitware.com/cmake/cmake/issues/16783
set(CMAKE_SUPPRESS_REGENERATION ON)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}
/LTCG:incremental /OPT:REF /OPT:ICF")
if (WIN32)
# Select the Enhanced Instruction Set
set(INSTRUCTION_SET NONE CACHE STRING "Enable Enhanced Instruction Set")
set_property(CACHE INSTRUCTION_SET PROPERTY STRINGS NONE SSE SSE2 AVX AVX2 IA32)
if (${USE_MKL})
# OpenPose flags
add_definitions(-DUSE_MKL)
message(STATUS "Building with MKL support.")
endif (${USE_MKL})
# Set/disable profiler
if (PROFILER_ENABLED)
add_definitions(-DPROFILER_ENABLED)
endif (PROFILER_ENABLED)
# More options
option(BUILD_EXAMPLES "Build OpenPose examples." ON)
option(BUILD_DOCS "Build OpenPose documentation." OFF)
# Speed profiler
option(PROFILER_ENABLED "If enabled, OpenPose will be able to print out speed
information at runtime." OFF)
# Threads - Pthread
if (${GPU_MODE} MATCHES "OPENCL" OR (UNIX AND NOT APPLE))
unset(CMAKE_THREAD_LIBS_INIT CACHE)
find_package(Threads)
endif (${GPU_MODE} MATCHES "OPENCL" OR (UNIX AND NOT APPLE))
# Adding 3D
if (WITH_3D_RENDERER)
# OpenPose flags
add_definitions(-DWITH_3D_RENDERER)
endif (WITH_3D_RENDERER)
if (WITH_CERES)
add_definitions(-DWITH_CERES)
endif (WITH_CERES)
if (WITH_FLIR_CAMERA)
# OpenPose flags
add_definitions(-DWITH_FLIR_CAMERA)
endif (WITH_FLIR_CAMERA)
# Adding tracking
if (WITH_TRACKING)
# OpenPose flags
add_definitions(-DWITH_TRACKING)
endif (WITH_TRACKING)
# Calibration
# No Eigen
if (${WITH_EIGEN} MATCHES "NONE")
if (WITH_CERES)
message(FATAL_ERROR "Eigen is required (enable `WITH_EIGEN`) if CERES is
enabled.")
endif (WITH_CERES)
# If Eigen used
else (${WITH_EIGEN} MATCHES "NONE")
# OpenPose flags
add_definitions(-DWITH_EIGEN)
# OpenPose download/builds Eigen
if (${WITH_EIGEN} MATCHES "BUILD")
# Download it
set(OP_URL "http://posefs1.perception.cs.cmu.edu/OpenPose/3rdparty/")
set(FIND_LIB_PREFIX ${CMAKE_SOURCE_DIR}/3rdparty/)
download_zip("eigen_2018_05_23.zip" ${OP_URL} ${FIND_LIB_PREFIX}
29B9B2FD4679D587BB67467F09EE8365)
# Set path
set(EIGEN3_INCLUDE_DIRS "3rdparty/eigen/include/")
# Alread installed with apt-get
elseif (${WITH_EIGEN} MATCHES "APT_GET")
# Eigen
find_package(PkgConfig)
pkg_check_modules(EIGEN3 REQUIRED eigen3)
endif (${WITH_EIGEN} MATCHES "BUILD")
endif (${WITH_EIGEN} MATCHES "NONE")
# 3D
if (WITH_3D_RENDERER)
# GLUT
find_package(GLUT REQUIRED)
endif (WITH_3D_RENDERER)
if (WITH_CERES)
# Eigen + Ceres
find_package(Ceres REQUIRED COMPONENTS SuiteSparse)
endif (WITH_CERES)
if (WITH_FLIR_CAMERA)
# Spinnaker
find_package(Spinnaker)
if (NOT SPINNAKER_FOUND)
message(FATAL_ERROR "Spinnaker not found. Either turn off the
`WITH_FLIR_CAMERA` option or specify the path to
the Spinnaker includes and libs.")
endif (NOT SPINNAKER_FOUND)
endif (WITH_FLIR_CAMERA)
# OpenMP
if (${GPU_MODE} MATCHES "CPU_ONLY")
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} $
{OpenMP_EXE_LINKER_FLAGS}")
endif (OPENMP_FOUND)
endif (${GPU_MODE} MATCHES "CPU_ONLY")
if (NOT GLOG_FOUND)
message(FATAL_ERROR "Glog not found. Install Glog from the command line using
the command(s) -\
sudo apt-get install libgoogle-glog-dev")
endif (NOT GLOG_FOUND)
if (NOT GFLAGS_FOUND)
message(FATAL_ERROR "GFlags not found. Install GFlags from the command line
using the command(s) --\
sudo apt-get install libgflags-dev")
endif (NOT GFLAGS_FOUND)
if (NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV not found. Install OpenCV from the command line
using the command(s) --\
sudo apt-get install libopencv-dev")
endif (NOT OpenCV_FOUND)
if (WIN32)
# If OpenPose builds it
if (BUILD_CAFFE)
unset(Caffe_INCLUDE_DIRS CACHE)
unset(Caffe_LIB CACHE)
unset(Caffe_Proto_LIB CACHE)
endif (BUILD_CAFFE)
# OpenCL
if (${GPU_MODE} MATCHES "OPENCL")
set(VCXPROJ_FILE_GPU_MODE "_CL")
find_library(Caffe_LIB caffe HINTS ${FIND_LIB_PREFIX}/caffe_opencl/lib)
find_library(Caffe_Proto_LIB caffeproto HINTS $
{FIND_LIB_PREFIX}/caffe_opencl/lib)
# CPU & CUDA
else (${GPU_MODE} MATCHES "OPENCL")
# CPU
if (${GPU_MODE} MATCHES "CPU_ONLY")
set(VCXPROJ_FILE_GPU_MODE "_CPU")
find_library(Caffe_LIB caffe HINTS ${FIND_LIB_PREFIX}/caffe_cpu/lib)
find_library(Caffe_Proto_LIB caffeproto HINTS $
{FIND_LIB_PREFIX}/caffe_cpu/lib)
# CUDA
else (${GPU_MODE} MATCHES "CPU_ONLY")
set(VCXPROJ_FILE_GPU_MODE "")
find_library(Caffe_LIB caffe HINTS ${FIND_LIB_PREFIX}/caffe/lib)
find_library(Caffe_Proto_LIB caffeproto HINTS ${FIND_LIB_PREFIX}/caffe/lib)
endif (${GPU_MODE} MATCHES "CPU_ONLY")
endif (${GPU_MODE} MATCHES "OPENCL")
if (WITH_3D_RENDERER)
find_library(GLUT_LIBRARY freeglut HINTS ${FIND_LIB_PREFIX}/freeglut/lib)
message(STATUS "\${GLUT_LIBRARY} = ${GLUT_LIBRARY}")
endif (WITH_3D_RENDERER)
if (WITH_FLIR_CAMERA)
find_library(SPINNAKER_LIB spinnaker_v140 HINTS $
{FIND_LIB_PREFIX}/spinnaker/lib)
endif (WITH_FLIR_CAMERA)
set(Caffe_LIBS ${Caffe_LIB};${Caffe_Proto_LIB})
set(OpenCV_INCLUDE_DIRS "3rdparty/windows/opencv/include")
# OpenCL
if (${GPU_MODE} MATCHES "OPENCL")
unset(Caffe_INCLUDE_DIRS CACHE)
set(Caffe_INCLUDE_DIRS
"3rdparty/windows/caffe_opencl/include;3rdparty/windows/caffe_opencl/include2"
CACHE FILEPATH "Caffe_INCLUDE_DIRS")
# CUDA and CPU
else (${GPU_MODE} MATCHES "OPENCL")
# CPU
if (${GPU_MODE} MATCHES "CPU_ONLY")
set(Caffe_INCLUDE_DIRS
"3rdparty/windows/caffe_cpu/include;3rdparty/windows/caffe_cpu/include2" CACHE
FILEPATH "Caffe_INCLUDE_DIRS")
# CUDA
else (${GPU_MODE} MATCHES "CPU_ONLY")
set(Caffe_INCLUDE_DIRS
"3rdparty/windows/caffe/include;3rdparty/windows/caffe/include2" CACHE FILEPATH
"Caffe_INCLUDE_DIRS")
endif (${GPU_MODE} MATCHES "CPU_ONLY")
endif (${GPU_MODE} MATCHES "OPENCL")
set(Boost_INCLUDE_DIRS "3rdparty/windows/caffe3rdparty/include/boost-1_61")
set(WINDOWS_INCLUDE_DIRS "3rdparty/windows/caffe3rdparty/include")
if (WITH_3D_RENDERER)
set(GLUT_INCLUDE_DIRS "3rdparty/windows/freeglut/include")
endif (WITH_3D_RENDERER)
if (WITH_FLIR_CAMERA)
set(SPINNAKER_INCLUDE_DIRS "3rdparty/windows/spinnaker/include")
endif (WITH_FLIR_CAMERA)
set(Caffe_FOUND 1)
endif (WIN32)
### CAFFE
if (UNIX AND NOT APPLE)
# Download Caffe
message(STATUS "Caffe will be downloaded from source now. NOTE: This process
might take several minutes depending
on your internet connection.")
# Check if pulled
file(GLOB CAFFE_DIR_VALID ${CMAKE_SOURCE_DIR}/3rdparty/caffe/*)
list(LENGTH CAFFE_DIR_VALID CAFFE_DIR_VALID_LENGTH)
if (CAFFE_DIR_VALID_LENGTH EQUAL 0)
execute_process(COMMAND git submodule update --init --recursive)
else (CAFFE_DIR_VALID_LENGTH EQUAL 0)
message(STATUS "Caffe has already been downloaded.")
endif (CAFFE_DIR_VALID_LENGTH EQUAL 0)
# Build Process
set(CAFFE_CPU_ONLY OFF)
if (${GPU_MODE} MATCHES "CUDA")
execute_process(COMMAND git checkout master WORKING_DIRECTORY $
{CMAKE_SOURCE_DIR}/3rdparty/caffe)
elseif (${GPU_MODE} MATCHES "CPU_ONLY")
if (USE_MKL)
#execute_process(COMMAND git checkout intel WORKING_DIRECTORY $
{CMAKE_SOURCE_DIR}/3rdparty/caffe)
execute_process(COMMAND git checkout b6712ce WORKING_DIRECTORY $
{CMAKE_SOURCE_DIR}/3rdparty/caffe)
execute_process(COMMAND sh prepare_mkl.sh WORKING_DIRECTORY $
{CMAKE_SOURCE_DIR}/3rdparty/caffe/external/mkl
OUTPUT_VARIABLE rv)
set( MLIST ${rv} )
separate_arguments(MLIST)
list(GET MLIST 0 MKL_PATH)
message(STATUS ${MKL_PATH})
file(GLOB MKL_SO
"${MKL_PATH}lib/*"
)
file(COPY ${MKL_SO} DESTINATION ${CMAKE_BINARY_DIR}/caffe)
set(MKL_LIBS
#"${CMAKE_BINARY_DIR}/caffe/libmlsl.so"
"${CMAKE_BINARY_DIR}/caffe/libiomp5.so"
"${CMAKE_BINARY_DIR}/caffe/libmklml_intel.so"
"${CMAKE_BINARY_DIR}/caffe/lib/libmkldnn.so"
)
else (USE_MKL)
execute_process(COMMAND git checkout master WORKING_DIRECTORY $
{CMAKE_SOURCE_DIR}/3rdparty/caffe)
endif (USE_MKL)
set(CAFFE_CPU_ONLY ON)
set(USE_CUDNN OFF)
elseif (${GPU_MODE} MATCHES "OPENCL")
execute_process(COMMAND git checkout opencl WORKING_DIRECTORY $
{CMAKE_SOURCE_DIR}/3rdparty/caffe)
set(USE_CUDNN OFF)
endif (${GPU_MODE} MATCHES "CUDA")
# Build Caffe
message(STATUS "Caffe will be built from source now.")
find_package(Caffe)
include(ExternalProject)
set(CAFFE_PREFIX caffe)
set(CAFFE_URL ${CMAKE_SOURCE_DIR}/3rdparty/caffe)
ExternalProject_Get_Property(openpose_caffe install_dir)
if (NOT Caffe_FOUND)
add_custom_command(TARGET openpose_caffe
POST_BUILD
COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}
COMMAND $(MAKE)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Rerunning cmake after building Caffe submodule")
endif (NOT Caffe_FOUND)
endif (BUILD_CAFFE)
# Calibration
if (NOT ${WITH_EIGEN} MATCHES "NONE")
include_directories(
${EIGEN3_INCLUDE_DIRS})
endif (NOT ${WITH_EIGEN} MATCHES "NONE")
if (USE_MKL)
include_directories(
"${MKL_PATH}/include/")
endif (USE_MKL)
if (Caffe_FOUND)
include_directories(
${Caffe_INCLUDE_DIRS})
endif (Caffe_FOUND)
if (BUILD_DOCS)
find_package(Doxygen)
if (DOXYGEN_FOUND)
# Set input and output files
set(DOXYGEN_FILE ${CMAKE_SOURCE_DIR}/doc/doc_autogeneration.doxygen)
### INSTALL
if (UNIX AND NOT APPLE)
if (Caffe_FOUND)
# Install the headers
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/openpose DESTINATION include)
install(EXPORT OpenPose DESTINATION lib/OpenPose)
if (BUILD_CAFFE)
install(DIRECTORY ${CMAKE_BINARY_DIR}/caffe/include/caffe DESTINATION
include)
install(DIRECTORY ${CMAKE_BINARY_DIR}/caffe/lib/ DESTINATION lib)
endif (BUILD_CAFFE)
install(FILES ${CMAKE_BINARY_DIR}/cmake/OpenPoseConfig.cmake
DESTINATION lib/OpenPose)
# Uninstall target
configure_file(
"${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P $
{CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif (Caffe_FOUND)
endif (UNIX AND NOT APPLE)