Dear all,
I'm trying to build a C++ project based on PyTorch with cmake package
configuration files. The includes and libs generally seem to work after
doing:
find_package(Torch 1.0.0 REQUIRED)
But when I try to generate package configuration for my library, cmake
shows an error:
CMake Error: install(EXPORT "XXXTargets" ...) includes target "XXX" which
requires target "caffe2_library" that is not in the export set.
I read a number of suggestions but they refer to the case where
"caffe2_library" would be one of my generated targets. I tried to
generate a target for "caffe2_library" and failed, and now I'm a
bit at a loss. Can someone lend me a hand?
Here is a cropped version of my CMakeLists.txt:
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(XXX VERSION 1.0.0)
find_package(Torch 1.0.0 REQUIRED)
add_library(${PROJECT_NAME} include/XXX.hh src/XXX.cc)
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${TORCH_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME}
PUBLIC
${TORCH_LIBRARIES})
export(TARGETS ${PROJECT_NAME} FILE cmake/${PROJECT_NAME}Targets.cmake)
export(PACKAGE ${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
install(EXPORT ${PROJECT_NAME}Targets
DESTINATION lib/cmake/)
All the best,
Mario Emmenlauer
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake