From 4970f42c48a93e3045413431a756e0c643eff857 Mon Sep 17 00:00:00 2001 From: bikz05 Date: Sat, 7 Oct 2017 18:23:49 -0400 Subject: [PATCH] CMake generates libopenpose.so/.a --- .travis.yml | 2 +- cmake/OpenPoseConfig.cmake.in | 29 +++++++++++++++++++++--- examples/openpose/CMakeLists.txt | 2 +- examples/tests/CMakeLists.txt | 2 +- examples/tutorial_pose/CMakeLists.txt | 2 +- examples/tutorial_thread/CMakeLists.txt | 2 +- examples/tutorial_wrapper/CMakeLists.txt | 2 +- src/openpose/CMakeLists.txt | 21 +++++++++++++++++ 8 files changed, 53 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2dec08e4..9d5bf776 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ script: - pip install --upgrade numpy - mkdir build - cd build - - cmake -DBUILD_CAFFE=ON .. + - cmake -DBUILD_CAFFE=ON -DDOWNLOAD_COCO_MODEL=OFF -DDOWNLOAD_FACE_MODEL=OFF -DDOWNLOAD_HAND_MODEL=OFF -DDOWNLOAD_MPI_MODEL=OFF .. - no_cores=`cat /proc/cpuinfo | grep processor | wc -l` - make -j${no_cores} diff --git a/cmake/OpenPoseConfig.cmake.in b/cmake/OpenPoseConfig.cmake.in index 13f249af..82395e75 100644 --- a/cmake/OpenPoseConfig.cmake.in +++ b/cmake/OpenPoseConfig.cmake.in @@ -11,6 +11,29 @@ 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") +set(OpenPose_VERSION_MAJOR @OpenPose_VERSION_MAJOR@) +set(OpenPose_VERSION_MINOR @OpenPose_VERSION_MINOR@) +set(OpenPose_VERSION_PATCH @OpenPose_VERSION_PATCH@) +set(OpenPose_VERSION @OpenPose_VERSION@) + +# Check that the user requested components +# are actually targets that are part of this build +if (OpenPose_FIND_COMPONENTS) + foreach (comp ${OpenPose_FIND_COMPONENTS}) + if (NOT TARGET ${comp}) + set (OpenPose_${comp}_FOUND 0) + if (OpenPose_FIND_REQUIRED_${comp}) + message(FATAL_ERROR "OpenPose ${comp} not available.") + endif (OpenPose_FIND_REQUIRED_${comp}) + else (NOT TARGET ${comp}) + set(OpenPose_${comp}_FOUND 1) + set(OpenPose_LIBS "${comp};${OpenPose_LIBS}") + endif (NOT TARGET ${comp}) + endforeach () +else (OpenPose_FIND_COMPONENTS) + set(OpenPose_LIBS "openpose") +endif (OpenPose_FIND_COMPONENTS) + +if (OpenPose_INCLUDE_DIRS AND OpenPose_LIBS) + set(OpenPose_FOUND 1) +endif (OpenPose_INCLUDE_DIRS AND OpenPose_LIBS) diff --git a/examples/openpose/CMakeLists.txt b/examples/openpose/CMakeLists.txt index a65cde24..f4e9e9cb 100644 --- a/examples/openpose/CMakeLists.txt +++ b/examples/openpose/CMakeLists.txt @@ -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 - openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} + openpose ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} ) endforeach() diff --git a/examples/tests/CMakeLists.txt b/examples/tests/CMakeLists.txt index 326ffca7..c6c9a6d6 100644 --- a/examples/tests/CMakeLists.txt +++ b/examples/tests/CMakeLists.txt @@ -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 - openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} + openpose ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} ) endforeach() diff --git a/examples/tutorial_pose/CMakeLists.txt b/examples/tutorial_pose/CMakeLists.txt index c49fa6fa..04eed0bb 100644 --- a/examples/tutorial_pose/CMakeLists.txt +++ b/examples/tutorial_pose/CMakeLists.txt @@ -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 - openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} + openpose ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} ) endforeach() diff --git a/examples/tutorial_thread/CMakeLists.txt b/examples/tutorial_thread/CMakeLists.txt index 3daf9fbb..b2a7009e 100644 --- a/examples/tutorial_thread/CMakeLists.txt +++ b/examples/tutorial_thread/CMakeLists.txt @@ -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 - openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} + openpose ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} ) endforeach() diff --git a/examples/tutorial_wrapper/CMakeLists.txt b/examples/tutorial_wrapper/CMakeLists.txt index 98d6f39d..f147847b 100644 --- a/examples/tutorial_wrapper/CMakeLists.txt +++ b/examples/tutorial_wrapper/CMakeLists.txt @@ -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 - openpose_wrapper ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} + openpose ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} ${Caffe_LIBS} ) endforeach() diff --git a/src/openpose/CMakeLists.txt b/src/openpose/CMakeLists.txt index f791bc73..70403472 100644 --- a/src/openpose/CMakeLists.txt +++ b/src/openpose/CMakeLists.txt @@ -12,3 +12,24 @@ set_target_properties(openpose_core openpose_filestream openpose_gui openpose_po openpose_utilities openpose_producer openpose_thread openpose_face openpose_hand openpose_wrapper PROPERTIES COMPILE_FLAGS ${OP_CXX_FLAGS}) + +# make the openpose.so + +add_library(caffe SHARED IMPORTED) +set_property(TARGET caffe PROPERTY IMPORTED_LOCATION ${Caffe_LIBS}) + +file(GLOB_RECURSE SOURCES "*.cu" "*.cpp") # It's better not to hardcode here. + +cuda_add_library(openpose ${SOURCES}) +target_link_libraries(openpose ${OpenCV_LIBS} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} caffe) +if (BUILD_CAFFE) + add_dependencies(openpose openpose_caffe) +endif (BUILD_CAFFE) + +set_property(TARGET openpose PROPERTY VERSION ${OpenPose_VERSION}) + +install(TARGETS openpose + EXPORT OpenPose + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/openpose) -- GitLab