I have a cmake c++ project that uses libCrypto++. I have FindCryptoPP.cmake module hosted here. Important parts are:
find_library(CryptoPP_LIBRARY
NAMES cryptopp
DOC "CryptoPP library"
NO_PACKAGE_ROOT_PATH
PATHS "/usr/lib/x86_64-linux-gnu/"
)
...
add_library(CryptoPP::CryptoPP UNKNOWN IMPORTED)
set_target_properties(CryptoPP::CryptoPP PROPERTIES
IMPORTED_LOCATION "${CryptoPP_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CryptoPP_INCLUDE_DIR}")
And this works fine, finds static library file (*.a). Now I would like to create separate targets CryptoPP::CryptoPP-static and CryptoPP::CryptoPP-shared. Necessary files are installed (default ubuntu install):
- /usr/lib/x86_64-linux-gnu/libcryptopp.a
- /usr/lib/x86_64-linux-gnu/libcryptopp.so
I want to know how to tell find_library to search either static or shared version (preferably in portable way - I need all of Linux, Windows, MacOS) and specify the type created target.