[CMake] install(EXPORT "XXXTargets" ...) includes target "XXX" which requires target "caffe2_library"...
Mario Emmenlauer
mario at emmenlauer.de
Sun Mar 3 05:28:43 EST 2019
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
More information about the CMake
mailing list