FindQtX and QtXMacros CMake modules

48 views
Skip to first unread message

Luís Pereira

unread,
May 21, 2014, 6:22:08 PM5/21/14
to razo...@googlegroups.com, lxde-list
Hi everybody:

I wrote two CMake modules to help in the effort of building Qt4 and
Qt5 projects from the same source.
Today I had the time and polished it a little bit. IMO they are now
usable. There's an sample that shows how to use the modules.

It might be helpful in the task of porting LXQt to Qt5. Comments are welcome.
The repo are at: https://github.com/luis-pereira/qtxmodules

The sample project CMakeLists.txt:
project(sample-project)
cmake_minimum_required(VERSION 2.6.2)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../..")

include(FindQtX)

FindQtX(
QT4_MINIMUM_REQUIRED 4.8.1
QT5_MINIMUM_REQUIRED 5.0.1
QT4_MODULES Gui
QT5_MODULES Widgets
COMMON_MODULES Core DBus
)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_VERBOSE_MAKEFILE ON)

set(UI_FILES
dialog.ui
)

set(MOC_FILES
dialog.h
)

set(HEADER_FILESproject(sample-project)
cmake_minimum_required(VERSION 2.6.2)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../..")

include(FindQtX)

FindQtX(
QT4_MINIMUM_REQUIRED 4.8.1
QT5_MINIMUM_REQUIRED 5.0.1
QT4_MODULES Gui
QT5_MODULES Widgets
COMMON_MODULES Core DBus
)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_VERBOSE_MAKEFILE ON)

set(UI_FILES
dialog.ui
)

set(MOC_FILES
dialog.h
)

set(HEADER_FILES
dialog.h
)

set(CPP_FILES
main.cpp
dialog.cpp
)


qtx_wrap_cpp(MOC_SOURCES ${MOC_FILES})
qtx_wrap_ui(UI_HEADERS ${UI_FILES})
qtx_add_dbus_interface(CPP_FILES
org.freedesktop.Notifications.xml
notifications_interface
)

add_executable(sample-project
${CPP_FILES}
${UI_HEADERS}
${MOC_SOURCES}
dialog.h
)

set(CPP_FILES
main.cpp
dialog.cpp
)


qtx_wrap_cpp(MOC_SOURCES ${MOC_FILES})
qtx_wrap_ui(UI_HEADERS ${UI_FILES})
qtx_add_dbus_interface(CPP_FILES
org.freedesktop.Notifications.xml
notifications_interface
)

add_executable(sample-project
${CPP_FILES}
${UI_HEADERS}
${MOC_SOURCES}



Regards,
--
Luís Pereira

Kuzma Shapran

unread,
May 21, 2014, 6:28:11 PM5/21/14
to razo...@googlegroups.com, lxde-list
I'm glad we're moving towards Qt5!

But is it possible to control properties of dbus interfaces and adaptors?
Look at lxqt-globalkeys/config/CMakeLists.txt and lxqt-globalkeys/daemon/CMakeLists.txt to see what I mean.
Search for `set_source_files_properties` there.

Cheers,
Kuzma




--
--
You received this message because you are subscribed to the Google
Groups "Razor-qt" group.
For more options, visit this group at
http://groups.google.com/group/razor-qt?hl=en

---
You received this message because you are subscribed to the Google Groups "Razor-qt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to razor-qt+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luís Pereira

unread,
May 21, 2014, 7:14:45 PM5/21/14
to razo...@googlegroups.com, lxde-list
On Wed, May 21, 2014 at 3:28 PM, Kuzma Shapran <leaf.o...@gmail.com> wrote:
> I'm glad we're moving towards Qt5!

Qt5 is the future. Although Qt4 will be around for many years.

> But is it possible to control properties of dbus interfaces and adaptors?
> Look at lxqt-globalkeys/config/CMakeLists.txt and
> lxqt-globalkeys/daemon/CMakeLists.txt to see what I mean.

I didn't try it. But I think that the only thing one have to do in
there is change qt4_add_dbus_interface() to qtx_add_dbus_interface().
The set_source_files_properties() stuff remains unchanged.
I'm not sure if we are talking about the same thing.

--
Luís Pereira

Kuzma Shapran

unread,
May 21, 2014, 7:49:37 PM5/21/14
to razo...@googlegroups.com, lxde-list
I see now what you mean. It's just version-based redirection.
What I'm trying to say that as the ext step it would be nice to have somewhere wrappers for stuff like this:

foreach(DBUS_ADAPTOR ${${PROJECT_NAME}_DBUS_ADAPTORS})
get_filename_component(DBUS_ADAPTOR_FILENAME ${DBUS_ADAPTOR} NAME)
configure_file(
${DBUS_ADAPTOR}
${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME}
@ONLY
)
get_source_file_property(DBUS_ADAPTOR_INCLUDE ${DBUS_ADAPTOR} INCLUDE)
get_source_file_property(DBUS_ADAPTOR_PARENT_CLASSNAME ${DBUS_ADAPTOR} PARENT_CLASSNAME)
get_source_file_property(DBUS_ADAPTOR_BASENAME ${DBUS_ADAPTOR} BASENAME)
get_source_file_property(DBUS_ADAPTOR_CLASSNAME ${DBUS_ADAPTOR} CLASSNAME)
if(DBUS_ADAPTOR_BASENAME)
if(DBUS_ADAPTOR_CLASSNAME)
qtx_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME} ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME} ${DBUS_ADAPTOR_CLASSNAME})
else()
qtx_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME} ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME} ${DBUS_ADAPTOR_BASENAME})
endif()
else()
qtx_add_dbus_adaptor(${PROJECT_NAME}_DBUS_ADAPTOR_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBUS_ADAPTOR_FILENAME} ${DBUS_ADAPTOR_INCLUDE} ${DBUS_ADAPTOR_PARENT_CLASSNAME})
endif()
endforeach()

Luís Pereira

unread,
May 21, 2014, 8:08:15 PM5/21/14
to razo...@googlegroups.com, lxde-list
On Wed, May 21, 2014 at 4:49 PM, Kuzma Shapran <Kuzma....@gmail.com> wrote:
> I see now what you mean. It's just version-based redirection.

Yes, The QtXMacros are just simple redirections. Although that, I
think they help.


> What I'm trying to say that as the ext step it would be nice to have
> somewhere wrappers for stuff like this:

That's another level, not related to Qt4/Qt5 ports.
It can be added later on.

--
Luís Pereira
Reply all
Reply to author
Forward
0 new messages