提交 3b2fb88a 编写于 作者: B bikz05

Support for sudo make install

上级 8b84069e
project(openpose)
cmake_minimum_required(VERSION 2.8.7 FATAL_ERROR) # min. cmake version recommmended by Caffe
cmake_minimum_required(VERSION 2.8.7 FATAL_ERROR) # min. cmake version recommended by Caffe
### FIND THE OS
......@@ -150,22 +150,21 @@ if (${DL_FRAMEWORK} MATCHES "CAFFE")
# Build Caffe
include(ExternalProject)
set(BUILD_CAFFE ON)
set(CAFFE_PREFIX caffe)
set(CAFFE_URL ${CMAKE_SOURCE_DIR}/3rdparty/caffe)
ExternalProject_Add(${CAFFE_PREFIX}
ExternalProject_Add(openpose_caffe
SOURCE_DIR ${CAFFE_URL}
PREFIX ${CAFFE_PREFIX}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DUSE_CUDNN=${USE_CUDNN}
-DOpenCV_DIR=${OpenCV_DIR})
ExternalProject_Get_Property(caffe install_dir)
ExternalProject_Get_Property(openpose_caffe install_dir)
set(Caffe_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/build/caffe/include)
set(Caffe_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/caffe/include)
# TODO -- Find a better soln.
set(Caffe_LIBS ${CMAKE_SOURCE_DIR}/build/caffe/lib/libcaffe.so)
set(Caffe_LIBS ${CMAKE_BINARY_DIR}/caffe/lib/libcaffe.so)
endif (BUILD_CAFFE)
......@@ -248,3 +247,30 @@ if (DOWNLOAD_HAND_MODEL)
endif (DOWNLOAD_HAND_MODEL)
message(STATUS "Models Downloaded.")
### INSTALL
# 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)
# Compute installation prefix relative to this file
configure_file(
${CMAKE_SOURCE_DIR}/cmake/OpenPoseConfig.cmake.in
${CMAKE_BINARY_DIR}/cmake/OpenPoseConfig.cmake @ONLY)
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)
......@@ -18,6 +18,6 @@ find_library(Caffe_LIBS NAMES caffe
HINTS
/usr/local/lib)
if(CAFFE_LIBS AND Caffe_INCLUDE_DIRS)
if (Caffe_LIBS AND Caffe_INCLUDE_DIRS)
set(Caffe_FOUND 1)
endif(CAFFE_LIBS AND Caffe_INCLUDE_DIRS)
endif (Caffe_LIBS AND Caffe_INCLUDE_DIRS)
# Compute and install package configuration and version files
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_prefix "${_dir}/../.." ABSOLUTE)
# Import the targets
include("${_prefix}/lib/OpenPose/OpenPose.cmake")
if (@BUILD_CAFFE@)
set(Caffe_INCLUDE_DIRS "${_prefix}/include/caffe")
# set(Caffe_LIBS "${_prefix}/lib/libcaffe.so")
endif (@BUILD_CAFFE@)
# Report other information
set(OpenPose_INCLUDE_DIRS "${_prefix}/include/openpose")
set(OpenPose_LIBS "openpose_core;openpose_filestream;openpose_gui;openpose_pose;"
"openpose_utilities;openpose_producer;openpose_thread;openpose_face;openpose_hand;"
"openpose_wrapper")
# Reference -- https://cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
......@@ -7,11 +7,13 @@ OpenPose - Installation using CMake
3. [Clone and Update the Repository](#clone-and-update-the-repository)
4. [Installation](#installation)
1. [Caffe Prerequisites (Ubuntu Only)](#caffe-prerequisites-ubuntu-only)
2. [OpenPose Configuration](#openpose-configuration)
3. [OpenPose Building](#openpose-building)
4. [Run OpenPose](#run-openpose)
2. [Configuration](#openpose-configuration)
3. [Building](#openpose-building)
4. [OpenPose from other Projects](#openpose-from-other-projects)
5. [Run OpenPose](#run-openpose)
5. [Reinstallation](#reinstallation)
6. [Optional Settings](#optional-settings)
6. [Uninstallation](#uninstallation)
7. [Optional Settings](#optional-settings)
1. [Doxygen Documentation Autogeneration](#doxygen-documentation-autogeneration)
2. [Custom Caffe](#custom-caffe)
3. [Custom OpenCV](#custom-opencv)
......@@ -53,7 +55,7 @@ bash ./ubuntu/install_cmake.sh
### OpenPose Configuration
Note: If you prefer to use CMake though the command line, see [Cmake Command Line Build](#cmake-command-line-build).
Note: If you prefer to use CMake through the command line, see [Cmake Command Line Build](#cmake-command-line-build).
1. Install CMake GUI.
1. Ubuntu: run `sudo apt-get install cmake-qt-gui`.
......@@ -90,11 +92,42 @@ Note: If you prefer to use your own custom Caffe or OpenCV versions, see [Custom
Finally, build the project by running the following commands.
```
cd build/
no_cores=`cat /proc/cpuinfo | grep processor | wc -l`
make -j${no_cores}
make -j`nproc`
```
### OpenPose from other Projects
If you only intend to use the OpenPose demo, you might skip this step. This step is only recommended if you plan to use the OpenPose API from other projects.
To install the OpenPose headers and libraries into the system environment path (e.g. `/usr/local/` or `/usr/`), run the following command.
```
cd build/
sudo make install
```
Once the installation is completed, you can use OpenPose in your other project using the `find_package` cmake command. Below, is a small example `CMakeLists.txt`.
```
cmake_minimum_required(VERSION 2.8.7)
add_definitions(-std=c++11)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
find_package(GFlags)
find_package(Glog)
find_package(OpenCV)
find_package(OpenPose REQUIRED)
include_directories(${OpenPose_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIR} ${GLOG_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS})
add_executable(example.bin example.cpp)
target_link_libraries(example.bin ${OpenPose_LIBS} ${GFLAGS_LIBRARY} ${GLOG_LIBRARY} ${OpenCV_LIBS})
```
If Caffe was built with OpenPose, it will automatically find it. Otherwise, you will need to link Caffe again as shown below (otherwise, you might get an error like `/usr/bin/ld: cannot find -lcaffe`).
```
link_directories(<path_to_caffe_installation>/caffe/build/install/lib)
```
### Run OpenPose
Check OpenPose was properly installed by running it on the default images, video or webcam: [doc/quick_start.md#quick-start](./quick_start.md#quick-start).
......@@ -103,9 +136,20 @@ Check OpenPose was properly installed by running it on the default images, video
## Reinstallation
In order to re-install OpenPose:
1. Delete the `build/` folder.
2. In CMake GUI, click on `File` --> `Delete Cache`.
3. Follow the [Installation](#installation) steps again.
1. If you ran `sudo make install`, then run `sudo make uninstall` in `build/`.
2. Delete the `build/` folder.
3. In CMake GUI, click on `File` --> `Delete Cache`.
4. Follow the [Installation](#installation) steps again.
## Uninstallation
If you used `sudo make install`, simply use the command below in the `build` directory and later remove the OpenPose folder.
```
cd build/
sudo make uninstall
```
If you did not use `sudo make install`, simply remove the OpenPose folder.
......
......@@ -7,7 +7,7 @@ foreach(EXAMPLE_FILE ${EXAMPLE_FILES})
message(STATUS "Adding Example ${SOURCE_NAME}")
add_executable(${SOURCE_NAME}.bin ${EXAMPLE_FILE})
target_link_libraries( ${SOURCE_NAME}.bin
wrapper utilities ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
)
endforeach()
\ No newline at end of file
endforeach()
......@@ -7,7 +7,7 @@ foreach(EXAMPLE_FILE ${EXAMPLE_FILES})
message(STATUS "Adding Example ${SOURCE_NAME}")
add_executable(${SOURCE_NAME}.bin ${EXAMPLE_FILE})
target_link_libraries( ${SOURCE_NAME}.bin
wrapper utilities ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
)
endforeach()
......
......@@ -8,7 +8,7 @@ foreach(EXAMPLE_FILE ${EXAMPLE_FILES})
message(STATUS "Adding Example ${SOURCE_NAME}")
add_executable(${SOURCE_NAME}.bin ${EXAMPLE_FILE})
target_link_libraries( ${SOURCE_NAME}.bin
wrapper utilities ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
)
endforeach()
......@@ -10,7 +10,7 @@ foreach(EXAMPLE_FILE ${EXAMPLE_FILES})
message(STATUS "Adding Example ${SOURCE_NAME}")
add_executable(${SOURCE_NAME}.bin ${EXAMPLE_FILE})
target_link_libraries( ${SOURCE_NAME}.bin
wrapper utilities ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
)
endforeach()
......@@ -9,7 +9,7 @@ foreach(EXAMPLE_FILE ${EXAMPLE_FILES})
message(STATUS "Adding Example ${SOURCE_NAME}")
add_executable(${SOURCE_NAME}.bin ${EXAMPLE_FILE})
target_link_libraries( ${SOURCE_NAME}.bin
wrapper utilities ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS}
)
endforeach()
......@@ -8,6 +8,7 @@ add_subdirectory(thread)
add_subdirectory(face)
add_subdirectory(hand)
add_subdirectory(wrapper)
set_target_properties(core filestream gui pose utilities producer thread face hand wrapper
set_target_properties(openpose_core openpose_filestream openpose_gui openpose_pose
openpose_utilities openpose_producer openpose_thread openpose_face openpose_hand
openpose_wrapper
PROPERTIES COMPILE_FLAGS ${OP_CXX_FLAGS})
cuda_add_library(core
cuda_add_library(openpose_core
array.cpp
cvMatToOpInput.cpp
cvMatToOpOutput.cpp
......@@ -22,7 +22,17 @@ cuda_add_library(core
resizeAndMergeCaffe.cpp
scaleAndSizeExtractor)
target_link_libraries(core ${Caffe_LIBS})
add_library(caffe SHARED IMPORTED)
set_property(TARGET caffe PROPERTY IMPORTED_LOCATION ${Caffe_LIBS})
target_link_libraries(openpose_core caffe)
if (BUILD_CAFFE)
add_dependencies(core caffe)
add_dependencies(openpose_core openpose_caffe)
endif (BUILD_CAFFE)
install(TARGETS openpose_core
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
......@@ -10,7 +10,13 @@ set(SOURCES
renderFace.cu
)
cuda_add_library(face ${SOURCES})
cuda_add_library(openpose_face ${SOURCES})
if (BUILD_CAFFE)
add_dependencies(face caffe)
add_dependencies(openpose_face openpose_caffe)
endif (BUILD_CAFFE)
install(TARGETS openpose_face
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
......@@ -9,4 +9,10 @@ set(SOURCES cocoJsonSaver.cpp
keypointSaver.cpp
videoSaver.cpp)
add_library(filestream ${SOURCES})
add_library(openpose_filestream ${SOURCES})
install(TARGETS openpose_filestream
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
\ No newline at end of file
......@@ -6,5 +6,12 @@ set(SOURCES
guiInfoAdder.cpp
)
add_library(gui ${SOURCES})
target_link_libraries(gui pose ${OpenCV_LIBS})
add_library(openpose_gui ${SOURCES})
target_link_libraries(openpose_gui openpose_pose ${OpenCV_LIBS})
install(TARGETS openpose_gui
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
......@@ -9,7 +9,13 @@ set(SOURCES
renderHand.cpp
renderHand.cu)
cuda_add_library(hand ${SOURCES})
cuda_add_library(openpose_hand ${SOURCES})
if (BUILD_CAFFE)
add_dependencies(hand caffe)
add_dependencies(openpose_hand openpose_caffe)
endif (BUILD_CAFFE)
install(TARGETS openpose_hand
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
......@@ -12,7 +12,14 @@ set(SOURCES
renderPose.cpp
renderPose.cu)
cuda_add_library(pose ${SOURCES})
cuda_add_library(openpose_pose ${SOURCES})
if (BUILD_CAFFE)
add_dependencies(pose caffe)
add_dependencies(openpose_pose openpose_caffe)
endif (BUILD_CAFFE)
install(TARGETS openpose_pose
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
......@@ -7,5 +7,12 @@ set(SOURCES
videoReader.cpp
webcamReader.cpp)
add_library(producer ${SOURCES})
target_link_libraries(producer ${OpenCV_LIBS} core thread filestream)
add_library(openpose_producer ${SOURCES})
target_link_libraries(openpose_producer ${OpenCV_LIBS} openpose_core
openpose_thread openpose_filestream)
install(TARGETS openpose_producer
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
set(SOURCES
defineTemplates.cpp)
add_library(thread ${SOURCES})
add_library(openpose_thread ${SOURCES})
install(TARGETS openpose_thread
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
......@@ -10,6 +10,12 @@ set(SOURCES
find_package(Boost COMPONENTS system filesystem REQUIRED)
cuda_add_library(utilities ${SOURCES})
target_link_libraries(utilities producer filestream
cuda_add_library(openpose_utilities ${SOURCES})
target_link_libraries(openpose_utilities openpose_producer openpose_filestream
${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
install(TARGETS openpose_utilities
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
......@@ -6,5 +6,13 @@ set(SOURCES
wrapperStructOutput.cpp
wrapperStructPose.cpp)
add_library(wrapper ${SOURCES})
target_link_libraries(wrapper thread pose hand core face filestream gui producer utilities)
add_library(openpose_wrapper ${SOURCES})
target_link_libraries(openpose_wrapper openpose_thread openpose_pose openpose_hand
openpose_core openpose_face openpose_filestream openpose_gui openpose_producer
openpose_utilities)
install(TARGETS openpose_wrapper
EXPORT OpenPose
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/openpose)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册