Re: [cmake-developers] A type for static plugins?

2013-09-21 Thread Stephen Kelly
Brad King wrote:

 On 09/20/2013 01:40 PM, Stephen Kelly wrote:
 macro(qt_add_plugin name type)
   if (${type} STREQUAL STATIC OR ${type} STREQUAL MODULE)
 set(_type ${type})
 set(args ${ARGN})
   else()
 set(_type MODULE)
 set(args ${type} ${ARGN})
   endif()
   add_library(${name} ${_type} ${ARGN})
 
 s/ARGN/args/ ?

Yes.

 
   if (_type STREQUAL STATIC)
 set_target_properties(${name} PROPERTIES
   PLUGIN 1
   # Not sure if this is a Qt/KDE convention:
   PREFIX 
 )
   endif()
 endmacro()
 
 Don't you want an empty prefix for MODULE too?

Yes. I was assuming the existence of 

 set(CMAKE_SHARED_MODULE_PREFIX )

Actually the empty prefix doesn't seem to be a Qt convention, only a KDE 
one:

 stephen@hal:~/dev/build/qtbase/qtbase$ l plugins/imageformats/
 libqgif.so*  libqico.so*  libqjpeg.so*

So it wouldn't belong in a qt_add_plugin macro anyway, and kde would need 
its own wrapper macro to set the prefix.

Those layers of wrapper macros are exactly what I'm aiming to avoid with 
modern CMake patterns, so I will not add the qt_add_plugin macro to Qt 5.

Thanks,

Steve.


--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers


Re: [cmake-developers] A type for static plugins?

2013-09-20 Thread Brad King
On 09/20/2013 08:14 AM, Stephen Kelly wrote:
 Any comments on adding a new STATIC_MODULE type to CMake?

Other than the TYPE being a different name, how would CMake
treat this target type differently?

-Brad
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers


Re: [cmake-developers] A type for static plugins?

2013-09-20 Thread Stephen Kelly
Brad King wrote:

 On 09/20/2013 08:14 AM, Stephen Kelly wrote:
 Any comments on adding a new STATIC_MODULE type to CMake?
 
 Other than the TYPE being a different name, how would CMake
 treat this target type differently?

In the case of Qt, I don't see much else relevantly different between static 
libraries and static plugins. So the answer is, 'probably nothing'.

The other thing Qt does with static plugins is generate a file with 
Q_IMPORT_PLUGIN calls. That part relates to the INTERFACE_SOURCES concept:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/7082

I could imagine it being useful for any project which can build shared or 
static and has a plugin interface with a similar need for a PP define 
though.

Thanks,

Steve.


--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers


Re: [cmake-developers] A type for static plugins?

2013-09-20 Thread Brad King
On 09/20/2013 08:54 AM, Stephen Kelly wrote:
 Brad King wrote:
 Other than the TYPE being a different name, how would CMake
 treat this target type differently?
 
 So the answer is, 'probably nothing'.

In that case I do not think we can justify a special CMake
target type for it.  All the special cases for STATIC_LIBRARY
targets will have to be updated to also account for the new
type with no difference in logic.

Can't this work with a simple explicit property?  Just put

 $$BOOL:$TARGET_PROPERTY:QT_STATICPLUGIN:QT_STATICPLUGIN

in Qt5::Core's INTERFACE_COMPILE_DEFINITIONS and then

 add_library(mystatic_library STATIC foo.cpp)
 set_property(TARGET mystatic_library PROPERTY QT_STATICPLUGIN 1)
 target_link_libraries(mystatic_library Qt5::Core)

-Brad
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers


Re: [cmake-developers] A type for static plugins?

2013-09-20 Thread Brad King
On 09/20/2013 09:10 AM, Stephen Kelly wrote:
 Brad King wrote:
 add_library(mystatic_library STATIC foo.cpp)
 set_property(TARGET mystatic_library PROPERTY QT_STATICPLUGIN 1)
 target_link_libraries(mystatic_library Qt5::Core)
 
 Yes, but I don't think that's better than
 
  add_library(mystatic_library STATIC foo.cpp)
  target_compile_definitions(mystatic_library PRIVATE QT_STATICPLUGIN)
  target_link_libraries(mystatic_library Qt5::Core)

If Qt adds some other usage requirement for static modules in the
future then the declarative property is better than a user spelling
out the specific compile definitions requirement.

-Brad
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers


Re: [cmake-developers] A type for static plugins?

2013-09-20 Thread Stephen Kelly
Brad King wrote:

 So the answer is, 'probably nothing'.
 
 In that case I do not think we can justify a special CMake
 target type for it.  All the special cases for STATIC_LIBRARY
 targets will have to be updated to also account for the new
 type with no difference in logic.

Another alternative would be for 

 add_library(myplugin STATIC_MODULE foo.cpp)

be exactly equivalent to 

 add_library(myplugin STATIC foo.cpp)
 set_property(TARGET myplugin PROPERTY STATICPLUGIN 1)

and document the STATICPLUGIN target property. Then I can use that in the 
Qt5::Core INTERFACE_COMPILE_DEFINITIONS, and no handling of static libraries 
in CMake would need to be extended for the new type. The cmAddLibraryCommand 
would set the property.

Thanks,

Steve.



--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers


Re: [cmake-developers] A type for static plugins?

2013-09-20 Thread Brad King
On 09/20/2013 09:59 AM, Stephen Kelly wrote:
 Another alternative would be for 
 
  add_library(myplugin STATIC_MODULE foo.cpp)
 
 be exactly equivalent to 
 
  add_library(myplugin STATIC foo.cpp)
  set_property(TARGET myplugin PROPERTY STATICPLUGIN 1)

IMO that's too special-purpose.  However, since it is so common to
add a library and then set properties on it, perhaps there should be
a syntax in add_library and add_executable to inline property settings.

For example, we could add a keyword signature to declare SOURCES
and PROPERTIES in one call:

 add_library(myplugin STATIC
   SOURCES foo.cpp
   PROPERTIES QT_STATICPLUGIN 1
   )

-Brad
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers