install(TARGETS): Clarify error on imported targets
I tried to use install()
/--install
commands to find and install OpenSSL shared dynamic DLLs alongside my application, with this CMake code:
set(OPENSSL_ROOT_DIR "C:/Qt/Tools/OpenSSL/Win_x86"
CACHE STRING "Path to OpenSSL installed by Qt Maintenance tool" FORCE)
set(OPENSSL_USE_STATIC_LIBS FALSE)
find_package(OpenSSL COMPONENTS Crypto SSL REQUIRED)
...
install(TARGETS ${PROJECT_NAME}
DESTINATION .
)
install(TARGETS
# OpenSSL::Crypto
OpenSSL::SSL
LIBRARY
DESTINATION .
)
But it explodes with this error message:
CMake Error at CMakeLists.txt:56 (install):
install TARGETS given target "OpenSSL::SSL" which does not exist.
Then, I tried to debug FindOpenSSL module with this code:
message("OpenSSL found? ${OPENSSL_FOUND}")
if (TARGET OpenSSL::SSL)
message("Is it a target? YES")
else ()
message("Is it a target? NO")
endif ()
message("Where: ${OPENSSL_LIBRARIES}")
And it turned out, error message does not make any sense:
OpenSSL found? TRUE
Is it a target? YES
Where: C:/Qt/Tools/OpenSSL/Win_x86/lib/libssl.lib;C:/Qt/Tools/OpenSSL/Win_x86/lib/libcrypto.lib
For a side note, I'd like to copy libcrypto-1_1.dll
and libssl-1_1.dll
, not their *.lib
(static?) counterparts. But even setting set(OPENSSL_USE_STATIC_LIBS FALSE)
does not help.
Any ideas?
Edited by Brad King