[CMake] Best Practice to determine what type of libraries I am linking to
James Bigler
jamesbigler at gmail.com
Thu Jul 10 17:55:35 EDT 2008
You are correct that you can't simply test the HDF5_LIBRARIES
variables since in windows a .lib is used for both static and shared
linking.
Since you can get access to this information from a header file you
could do a try compile and look at the output, or you could read the
contents of the file into a variable and parse out the define with a
regular expression. See file(READ filename variable [LIMIT numBytes]
[OFFSET offset] [HEX]) and string(REGEX MATCH <regular_expression>
<output variable> <input> [<input>...]).
James
On Fri, Jun 27, 2008 at 8:16 AM, Mike Jackson <mike.jackson at imts.us> wrote:
> What are the recommended ways to determine what type of libraries my
> application is linking against. An example should explain what I mean.
>
> I use the HDF5 library as part of my project. It can be built either as a
> static or dynamic. If it is built as a static library then I don't need to
> copy it during the install phase. If it is built as a dynamic library then I
> _do_ need to copy it.
>
> Would parsing the HDF5_LIBRARIES variable for a .lib or .dll work? Although
> not sure about that since you link against the .lib on windows but use the
> .dll? This is mainly for Visual Studio use.
>
> Currently there is a #define HDF5_DLL_LIB defined in the H5config.h file. I
> thought of trying a simple try-compile a test file to see if it would
> compile and then base my decision on that.
>
> Other ways? Better ways? Example code?
>
> Thanks
> --
> Mike Jackson Senior Research Engineer
> Innovative Management & Technology Services
>
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
More information about the CMake
mailing list