[CMake] Explicit <NAME>_LIBRARIES and <NAME>_INCLUDE_DIRS

Mateusz Loskot mateusz at loskot.net
Mon Mar 25 08:16:20 EDT 2013


On 23 March 2013 14:29, Alexander Neundorf <a.neundorf-work at gmx.net> wrote:
> On Friday 22 March 2013, Mateusz Loskot wrote:
>> On 22 March 2013 18:01, Sergei Nikulov <sergey.nikulov at gmail.com> wrote:
>> > 2013/3/22 Mateusz Loskot <mateusz at loskot.net>
>> >
>> >> I'm trying to build software which uses libE57 library which has
>> >> Xerces as dependency.
>> >> I build Xerces too as part of my project and I deploy it in custom
>> >> locations
>> >> and Xerces library has custom name.
>> >>
>> >> libE57 provides FindXerces.cmake [1] and I've been trying to figure
>> >> out how I can
>> >> make this module find Xerces I provide, I tried to explicitly the two
>> >> variables:
>> >> Xerces_INCLUDE_DIR
>> >> Xerces_LIBRARY
>> >> on invocation of cmake, but obviously this FindXerces.cmake is still
>> >> nagging me
>> >> about XERCES_ROOT
>> >>
>> >> This is first time when I have to deal with CMake-based software and
>> >> custom
>> >> names and locations of libraries, so I'm not sure either I'm missing
>> >> some important tricks here or this FindXerces.cmake is just poorly
>> >> written module
>> >> and it does not check if user passes <NAME>_INCLUDE or <NAME>_LIBRARY
>> >> directly.
>> >>
>> >> I know I can also use CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH,
>> >> but how to deal with custom library names, when this module expects
>> >> two options only [2].
>> >>
>> >> Could anyone advise about workaround?
>> >>
>> >> Is this an issue in the FindXerces.cmake and would you say it's worth
>> >> to submit bug report to libE57?
>> >>
>> >> [1]
>> >> http://sourceforge.net/p/e57-3d-imgfmt/code/331/tree/trunk/cmake/Modules
>> >> /FindXerces.cmake [2]
>> >> http://sourceforge.net/p/e57-3d-imgfmt/code/331/tree/trunk/cmake/Modules
>> >> /FindXerces.cmake#l44
>> >
>> > Hi Mateusz,
>> >
>> > FindXerces is not part of officially supported modules, so you're on your
>> > own here :-)
>> > As workaround - try provide for script you're pointed with two more
>> > parameters _LIBRARY_DEBUG & _LIBRARY_RELEASE.
>> > AFAIR you need all vars be set to avoid error message from
>> > "find_package_handle_standard_args".
>> > Custom name add to NAMES.
>>
>> Sergei,
>>
>> I tried that, I specified location of my build of .lib of Xerces using
>> all the three
>> variables:
>>
>> Xerces_LIBRARY_DEBUG
>> Xerces_LIBRARY_RELEASE
>> Xerces_LIBRARY
>
> This should work.
> You don't have to set Xerces_LIBRARY, since this is set in the find-module:
> set (Xerces_LIBRARY debug ${Xerces_LIBRARY_DEBUG} optimized
> ${Xerces_LIBRARY_RELEASE})


Alexander, spot on!

I missed the fact that both Xerces_LIBRARY_DEBUG *and* Xerces_LIBRARY_RELEASE
need to be set together. I have been trying to set either _DEBUG or _RELEASE,
as I keep separate build trees.

Once I provide both,  _DEBUG and _RELEASE, pointing to Xerces .lib file,
then FindPackageHandleStandardArgs behaves correctly.

I haven't met such requirement before.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net


More information about the CMake mailing list