I have generated a package by myself, and the CMakeLists.txt looks like:
...
install(TARGETS pA pB
EXPORT SustaoBasic
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(DIRECTORY package/ DESTINATION include
FILES_MATCHING PATTERN "*.h"
)
install(EXPORT SustaoBasic
FILE SustaoBasic.cmake
NAMESPACE SustaoBasic::
DESTINATION lib/cmake
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
SustaoBasicConfigVersion.cmake
VERSION V1.0
COMPATIBILITY AnyNewerVersion # 表示该函数库向下兼容
)
configure_package_config_file(
SustaoBasicConfig.cmake.in ${PROJECT_BINARY_DIR}/SustaoBasicConfig.cmake
INSTALL_DESTINATION lib/cmake
)
install(FILES "${PROJECT_BINARY_DIR}/SustaoBasicConfig.cmake"
"${PROJECT_BINARY_DIR}/SustaoBasicConfigVersion.cmake"
DESTINATION lib/cmake)
I need a thirdparty Algorithm
in my SustaoBasic
package, which is a pure dll/lib
. When I import link SustaoBasic
to Pro
, it reports unresolved external symbol Algorithm
. If I link Algorithm
to Pro
, everything is OK.
But, I don’t want to link Algorithm
when I import SustaoBasic
package each time. I find that SustaoBasicConfig.cmake
can declare the dependency by:
find_dependency(VTK REQUIRED)
But, my Algorithm
is a pure dll/lib
, and it do not support find_package()
. If I declare find_dependency(Algorithm REQUIREd)
, the CMake
would repored:
By not providing "FindAlgorithm.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Algorithm", but CMake did not find one.
Could not find a package configuration file provided by "Algorithm" with any of the following names:
AlgorithmConfig.cmake
algorithm-config.cmake
...
How can I declare the dependency Algorithm
to SustaoBasic
? Or how to avoid link Algorithm
to Pro
when I import SustaoBasic
in Pro
?
Any suggestion is appreciated~~~