[cmake-developers] Generating imported library targets without the cmake executable
Stephen Kelly
steveire at gmail.com
Tue Nov 29 20:34:45 EST 2011
Alexander Neundorf wrote:
> On Tuesday 29 November 2011, Stephen Kelly wrote:
>> Alexander Neundorf wrote:
>> >> I can't generate the files. I'm asking people with windows and mac
>> >> setups to generate them and post them for review. I don't have those
>> >> setups.
>> >
>> > Just the ones for Linux would already help :-)
>>
>> I managed to get generated files for windows and mac through some IRC
>> puppeteering, so I've attached them here now.
>>
>> Thanks,
>
> I looked through the QtCore files.
>
> Some things:
>
> if (NOT _Qt5Core_target)
> set(_Qt5Core_target 1)
> add_library(Qt5Core SHARED IMPORTED)
> if (NOT "" STREQUAL "")
> set_property(TARGET Qt5Core PROPERTY FRAMEWORK 1)
> endif()
> endif()
>
> I think you can simply do:
>
> if(NOT TARGET Qt5Core)
> add_library(Qt5Core SHARED IMPORTED)
> if (NOT "" STREQUAL "")
> set_property(TARGET Qt5Core PROPERTY FRAMEWORK 1)
> endif()
> endif()
I didn't do it like this because that could potentially hide errors as
described here:
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/2147/focus=2152
Someone else could define a target called QtCore (in theory at least), and
it makes sense to show a failure as early as possible.
>
>
> Can this also handle already static builds of Qt ?
Nope, not yet.
Static builds of Qt are no longer tested by Nokia at least as far as I know.
I don't know if it is even possible to build Qt statically on all (or any)
platforms anymore. If it is possible, I'm sure I can generate suitable
config files for that.
>
> Why do you have an if() around including Qt5CoreMacros.cmake and
> Qt5CoreConfigExtras.cmake ?
Not all Qt modules have a Macros file or a ConfigExtras file. Qt5Sql for
example.
I didn't want to check if the file exists at CMake time and only include()
it then. I wanted to determine at QMake time whether it should be there or
not. If it is not there (due to installation or packaging error etc), the
include() will be called and will fail with an error message instead of
being quietly not included.
Thanks for the review.
Steve.
More information about the cmake-developers
mailing list