[CMake] Find a library that matches a specific pattern
Keith Gardner
kgardner at zebraimaging.com
Wed Nov 28 16:28:10 EST 2012
You can use file(GLOB variable [RELATIVE path] [globbing expression] ...)
file( GLOB result ${first_build_dir} "filea*.lib")
Result will contain a list of files that match the globbing expression.
Enjoy!
Keith
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of katie outram
Sent: Wednesday, November 28, 2012 2:37 PM
To: cmake at cmake.org
Subject: [CMake] Find a library that matches a specific pattern
I have a build that depends on the output from another build. We can't combine the code into one build due to other issues.
I need to get cmake to pass the values of the libraries I want to link against. I have worked out a find script for my second build that allows me to use the find_library command to pull the .lib file that I'm looking for. However, I must force the user to specify the specific name of the library and I need to avoid this and just be able to pick up the value if the name passes validation and the version is any number since ultimately this whole process will be automated and I don't want to have to worry about specifying version numbers.
My first build creates a directory
* build
* win64
* VC10
* bin
* Release
* filea1231.1.1.1.lib
* fileb2341.1.1.1.lib
* filec3451.1.1.1.lib
For the second build I force the user to tell me the path of the build directory (i.e. C:\build\win64\VC10\bin\Release and assign this to a value of first_build_dir)
I then have a find script where I am trying to find the library (i.e. filea1231.1.1.1)
set (file_name filea1231.1.1.1)
find_library(my_library
name ${file_name}
PATHS ${first_build_dir}
)
The problem I have is that the filea1231.1.1.1 might change for the next build (i.e filea1231.1.1.2). There is only one file named filea so I'd like to be able to search for filea*.lib no matter what the versioning information contains.
I thought I needed to go down the path of using a string(regex match([filea0-9]+\\.[0-9]\\.[0-9]\\.[0-9<file:///\\.[0-9]\.%5b0-9>] file_name) however I can't figure out how to make this work in my current situation.
I then went down the path of trying the file(strings filea*.lib file_name) option but it returned my ${first_build_dir} path
I'm looking for suggestions on how to handle pulling the changing file name within cmake for use at anytime.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121128/97f285f0/attachment-0001.htm>
More information about the CMake
mailing list