In cmake to find a library we use find_library(MyLibrary_LIBRARY NAMES mylibrary mylibrary10 mylibrary11 HINTS /path/to/library)
. This command tells cmake to find a file named mylibrary.so
or mylibrary10.so
or mylibrary11.so
(or files with .lib
suffix in windows) per path of HINTS
. If any of the above files were found, the path to the file would be written to the MyLibrary_LIBRARY
variable. However, as one of the libraries I am using is frequently being updated - so that the library would soon be renamed to mylibrary20.so
or mylibrary21.so
- I need to update the cmake script frequently to reflect the changes. I wonder if there is a way that I can use wildcard here, so that cmake would automatically find mylibraryXX.so
here, where XX
means two digits.
According to documentation (https://cmake.org/cmake/help/latest/command/find_library.html), it seems this is not supported. If that's the case, will there be any other workarounds? (Creating a link from mylibraryXX.so
to mylibrary.so
doesn't quite work for me, as I don't have control of the library.)