Clean up CMakeLists.txt and drop Qt 4 support
authorJerome Leclanche <jerome@leclan.ch>
Thu, 16 Oct 2014 23:54:13 +0000 (01:54 +0200)
committerJerome Leclanche <jerome@leclan.ch>
Thu, 16 Oct 2014 23:54:13 +0000 (01:54 +0200)
CMakeLists.txt
cmake/FindInstallConfigPath.cmake
translatorsinfo/CMakeLists.txt

index 50ace64..72b5067 100644 (file)
@@ -12,11 +12,11 @@ set(LXQT_PKG_CONFIG_DESCRIPTION "Shared library for LXQt applications")
 
 set(PUB_HDRS
     aboutdialog/lxqtaboutdialog.h
+    addplugindialog/lxqtaddplugindialog.h
     lxqtsettings.h
     lxqtxfitman.h
     lxqtplugininfo.h
     lxqtpowermanager.h
-    addplugindialog/lxqtaddplugindialog.h
     lxqtscreensaver.h
     lxqtapplication.h
     lxqttranslator.h
@@ -79,18 +79,18 @@ set(SRCS
 
     lxqtpower/lxqtpower.cpp
     lxqtpower/lxqtpowerproviders.cpp
-    lxqtnotification.cpp
     lxqtautostartentry.cpp
-    translatorsinfo/translatorsinfo.cpp
+    lxqtnotification.cpp
     lxqtgridlayout.cpp
     lxqtrotatedwidget.cpp
+    translatorsinfo/translatorsinfo.cpp
 )
 
 set(MOCS
     aboutdialog/lxqtaboutdialog.h
     aboutdialog/lxqtaboutdialog_p.h
-    lxqtpowermanager.h
     addplugindialog/lxqtaddplugindialog.h
+    lxqtpowermanager.h
     lxqtsettings.h
     lxqtscreensaver.h
     lxqtapplication.h
@@ -114,107 +114,71 @@ set(FORMS
 
 set(TRANSLATION_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/translations/source.ts")
 file(GLOB TS_FILES
-    ${CMAKE_CURRENT_SOURCE_DIR}/translations/liblxqt_*.ts
+    "${CMAKE_CURRENT_SOURCE_DIR}/translations/liblxqt_*.ts"
 )
 
 # additional cmake files
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
 
-option(USE_QT5 "Build with Qt5." $ENV{USE_QT5})
-
-option (UPDATE_TRANSLATIONS "Update source translation translations/*.ts files")
+option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files")
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
-if(USE_QT5)
-    set(CMAKE_AUTOMOC ON)
-    find_package(Qt5Widgets REQUIRED QUIET)
-    find_package(Qt5DBus REQUIRED QUIET)
-    find_package(Qt5X11Extras REQUIRED QUIET)
-    find_package(Qt5LinguistTools REQUIRED QUIET)
-    find_package(Qt5Xdg REQUIRED)
-    message(STATUS "Building with Qt ${Qt5Core_VERSION_STRING}")
-
-    QT5_WRAP_UI(UIS ${FORMS})
-    if (UPDATE_TRANSLATIONS)
-        qt5_create_translation(QM_FILES ${SRCS} ${FORMS} ${TS_FILES} OPTIONS -locations absolute)
-        qt5_create_translation(TS_SOURCE_FILE
-            ${SRCS} ${FORMS}
-            ${TRANSLATION_TEMPLATE}
-            OPTIONS -locations absolute
-        )
-    else()
-        QT5_ADD_TRANSLATION(QM_FILES ${TS_FILES})
-    endif()
-    QT5_ADD_DBUS_INTERFACE(SRCS
-        dbus/org.freedesktop.Notifications.xml
-        notifications_interface
+set(CMAKE_AUTOMOC ON)
+find_package(Qt5Widgets REQUIRED QUIET)
+find_package(Qt5DBus REQUIRED QUIET)
+find_package(Qt5X11Extras REQUIRED QUIET)
+find_package(Qt5LinguistTools REQUIRED QUIET)
+find_package(Qt5Xdg REQUIRED)
+message(STATUS "Building with Qt ${Qt5Core_VERSION_STRING}")
+
+QT5_WRAP_UI(UIS ${FORMS})
+if (UPDATE_TRANSLATIONS)
+    qt5_create_translation(QM_FILES ${SRCS} ${FORMS} ${TS_FILES} OPTIONS -locations absolute)
+    qt5_create_translation(TS_SOURCE_FILE
+        ${SRCS} ${FORMS}
+        ${TRANSLATION_TEMPLATE}
+        OPTIONS -locations absolute
     )
-
-    set(LXQT_QT_VERSION "5")
-    set(LXQT_QT_VERSION_SUFFIX "-qt5")
-    set(LXQT_PKG_CONFIG_REQUIRES "Qt5Widgets Qt5Xml Qt5DBus Qt5X11Extras")
 else()
-    find_package(Qt4 REQUIRED QtCore QtGui QUIET)
-    find_package(QTXDG REQUIRED)
-    message(STATUS "Building with Qt ${QTVERSION}")
-
-    include(${QT_USE_FILE})
-
-    QT4_WRAP_CPP(MOCS ${MOCS})
-    QT4_WRAP_UI(UIS ${FORMS})
-    if (UPDATE_TRANSLATIONS)
-        qt4_create_translation(QM_FILES ${SRCS} ${FORMS} ${TS_FILES} OPTIONS -locations absolute)
-        qt4_create_translation(TS_SOURCE_FILE
-            ${SRCS} ${FORMS}
-            ${TRANSLATION_TEMPLATE}
-            OPTIONS -locations absolute
-        )
-    else()
-        QT4_ADD_TRANSLATION(QM_FILES ${TS_FILES})
-    endif()
-    QT4_ADD_DBUS_INTERFACE(SRCS
-        dbus/org.freedesktop.Notifications.xml
-        notifications_interface
-    )
-
-    set(LXQT_QT_VERSION "4")
-    set(LXQT_QT_VERSION_SUFFIX "")
-    set(LXQT_PKG_CONFIG_REQUIRES "QtCore, QtXml")
+    QT5_ADD_TRANSLATION(QM_FILES ${TS_FILES})
 endif()
+QT5_ADD_DBUS_INTERFACE(SRCS
+    dbus/org.freedesktop.Notifications.xml
+    notifications_interface
+)
+
+set(LXQT_QT_VERSION "5")
+set(LXQT_QT_VERSION_SUFFIX "-qt5")
+set(LXQT_PKG_CONFIG_REQUIRES "Qt5Widgets Qt5Xml Qt5DBus Qt5X11Extras")
 
 include(${QTXDG_USE_FILE})
 
 find_package(X11 REQUIRED QUIET)
 
-include_directories (
-    ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
-    ${X11_INCLUDE_DIR}
-    ${QTXDG_INCLUDE_DIRS}
+include_directories(
+    "${CMAKE_CURRENT_SOURCE_DIR}"
+    "${CMAKE_CURRENT_BINARY_DIR}"
+    "${X11_INCLUDE_DIR}"
+    "${QTXDG_INCLUDE_DIRS}"
 )
 
-if (NOT USE_QT5)
-    include_directories (
-        ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR}
-    )
-endif()
-
 # Standard directories for installation
 include(GNUInstallDirs)
 
 set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSION})
 set(LXQT_LIBRARY_NAME "lxqt${LXQT_QT_VERSION_SUFFIX}")
 set(LXQT_RELATIVE_SHARE_DIR "${LXQT_LIBRARY_NAME}")
-set(LXQT_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/${LXQT_RELATIVE_SHARE_DIR})
+set(LXQT_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/${LXQT_RELATIVE_SHARE_DIR}")
 set(LXQT_RELATIVE_TRANSLATIONS_DIR "${LXQT_LIBRARY_NAME}/translations")
 set(LXQT_TRANSLATIONS_DIR "${LXQT_SHARE_DIR}/translations")
 
-set(LXQT_INTREE_INCLUDE_DIR     ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include)
-set(LXQT_INTREE_TARGETS_FILE    ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-targets.cmake)
+set(LXQT_INTREE_INCLUDE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include")
+set(LXQT_INTREE_TARGETS_FILE "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-targets.cmake")
 
-set(LXQT_INSTALL_INCLUDE_DIR   ${CMAKE_INSTALL_FULL_INCLUDEDIR}/${LXQT_LIBRARY_NAME})
-set(LXQT_INSTALL_CMAKE_DIR     ${CMAKE_INSTALL_PREFIX}/share/cmake)
+set(LXQT_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}")
+set(LXQT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}/share/cmake")
 
 include(cmake/FindInstallConfigPath.cmake)
 include(create_portable_headers)
@@ -227,10 +191,7 @@ message(STATUS "")
 # Copy public headers
 foreach(h ${PUB_HDRS})
     get_filename_component(bh ${h} NAME)
-    configure_file(${h} ${LXQT_INTREE_INCLUDE_DIR}/LXQt/${bh} COPYONLY)
-    if (NOT USE_QT5)
-        configure_file(${h} ${LXQT_INTREE_INCLUDE_DIR}/lxqt/${bh} COPYONLY)
-    endif()
+    configure_file(${h} "${LXQT_INTREE_INCLUDE_DIR}/LXQt/${bh}" COPYONLY)
 endforeach()
 
 # Create the portable headers
@@ -261,22 +222,22 @@ include(${CFG_LXQT_USE_FILE})
 
 
 #************************************************
-# Create instalable build infrastructure
+# Create installable build infrastructure
 #************************************************
-set(CFG_LXQT_INCLUDE_DIR    ${LXQT_INSTALL_INCLUDE_DIR})
-set(CFG_LXQT_LIBRARY        ${LXQT_LIBRARY_NAME})
-set(CFG_LXQT_USE_FILE       ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}_use.cmake)
-set(CFG_LXQT_TARGETS_FILE   ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake)
+set(CFG_LXQT_INCLUDE_DIR "${LXQT_INSTALL_INCLUDE_DIR}")
+set(CFG_LXQT_LIBRARY ${LXQT_LIBRARY_NAME})
+set(CFG_LXQT_USE_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}_use.cmake")
+set(CFG_LXQT_TARGETS_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake")
 
 configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake
+    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in"
+    "${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
     @ONLY
 )
 
 # use gcc visibility feature to decrease unnecessary exported symbols
 if (CMAKE_COMPILER_IS_GNUCXX)
-    # set visibility to hidden to hide symbols, unlesss they're exporeted
+    # set visibility to hidden to hide symbols, unlesss they're exported
     # manually in the code
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wl,-no-undefined -Wall")
 endif()
@@ -305,11 +266,7 @@ install(EXPORT
 
 include(translatorsinfo/CMakeLists.txt)
 get_translatorsinfo_qrc(translatorsinfo_qrc)
-if(USE_QT5)
-    qt5_add_resources(QRC_CXX_SOURCES ${translatorsinfo_qrc})
-else()
-    qt4_add_resources(QRC_CXX_SOURCES ${translatorsinfo_qrc})
-endif()
+qt5_add_resources(QRC_CXX_SOURCES ${translatorsinfo_qrc})
 
 add_library(${LXQT_LIBRARY_NAME}
     SHARED ${PUB_HDRS}
@@ -323,20 +280,11 @@ add_library(${LXQT_LIBRARY_NAME}
 
 )
 
-if (USE_QT5)
-       qt5_use_modules(${LXQT_LIBRARY_NAME} Widgets DBus X11Extras)
-    target_link_libraries(${LXQT_LIBRARY_NAME}
-        ${X11_X11_LIB}
-        ${QTXDG_LIBRARIES}
-    )
-else()
-    target_link_libraries(${LXQT_LIBRARY_NAME}
-        ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}
-        ${QT_QTDBUS_LIBRARY}
-        ${X11_X11_LIB}
-        ${QTXDG_LIBRARIES}
-    )
-endif()
+qt5_use_modules(${LXQT_LIBRARY_NAME} Widgets DBus X11Extras)
+target_link_libraries(${LXQT_LIBRARY_NAME}
+    ${X11_X11_LIB}
+    ${QTXDG_LIBRARIES}
+)
 
 set_target_properties(${LXQT_LIBRARY_NAME} PROPERTIES
     VERSION   ${LXQT_VERSION}
@@ -353,15 +301,9 @@ install(TARGETS
 
 export(TARGETS ${LXQT_LIBRARY_NAME} ${QTXDG_TARGET} FILE ${LXQT_INTREE_TARGETS_FILE})
 
-install(FILES ${PUB_HDRS}                DESTINATION ${LXQT_INSTALL_INCLUDE_DIR}/LXQt)
-
-if (NOT USE_QT5)
-    install(FILES ${PUB_HDRS}   DESTINATION ${LXQT_INSTALL_INCLUDE_DIR})
-endif()
-
-install(FILES ${INTREE_PORTABLE_HEADERS} DESTINATION ${LXQT_INSTALL_INCLUDE_DIR}/LXQt)
-
-install(FILES ${QM_FILES} DESTINATION ${LXQT_TRANSLATIONS_DIR}/liblxqt)
+install(FILES ${PUB_HDRS} DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt")
+install(FILES ${INTREE_PORTABLE_HEADERS} DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt")
+install(FILES ${QM_FILES} DESTINATION "${LXQT_TRANSLATIONS_DIR}/liblxqt")
 
 #************************************************
 # Create pkgconfig file
@@ -376,11 +318,11 @@ lxqt_create_pkgconfig_file(${LXQT_LIBRARY_NAME}
 
 
 # building tarball with CPack -------------------------------------------------
-include (InstallRequiredSystemLibraries)
-set (CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION})
-set (CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION})
-set (CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION})
-set (CPACK_GENERATOR TBZ2)
-set (CPACK_SOURCE_GENERATOR TBZ2)
-set (CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
-include (CPack)
+include(InstallRequiredSystemLibraries)
+set(CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION})
+set(CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION})
+set(CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION})
+set(CPACK_GENERATOR TBZ2)
+set(CPACK_SOURCE_GENERATOR TBZ2)
+set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
+include(CPack)
index 8bcd3fa..446e223 100644 (file)
@@ -5,18 +5,16 @@
 #   qmake -query QT_INSTALL_CONFIGURATION
 #
 if(NOT DEFINED LXQT_ETC_XDG_DIR)
-    if (USE_QT5)
-        get_target_property(QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
-        message(STATUS "${QT_QMAKE_EXECUTABLE}")
-    endif()
+    get_target_property(QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
+    message(STATUS "${QT_QMAKE_EXECUTABLE}")
 
     if(NOT QT_QMAKE_EXECUTABLE)
-        message(FATAL_ERROR "LXQT_ETC_XDG_DIR: qmake not found or wrongly detected (inlude before qt configured?)")
+        message(FATAL_ERROR "LXQT_ETC_XDG_DIR: qmake executable not found (included before qt was configured?)")
     endif()
 
     execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_CONFIGURATION
-                        OUTPUT_VARIABLE LXQT_ETC_XDG_DIR
-                        OUTPUT_STRIP_TRAILING_WHITESPACE)
+                    OUTPUT_VARIABLE LXQT_ETC_XDG_DIR
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
 
     message(STATUS "LXQT_ETC_XDG_DIR autodetected as '${LXQT_ETC_XDG_DIR}'")
     message(STATUS "You can set it manually with -DLXQT_ETC_XDG_DIR=<value>")
index 824aa4e..0b51768 100644 (file)
@@ -1,28 +1,26 @@
-
 function(create_translatorsinfo_file _infoFile)
-    file(GLOB IN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translatorsinfo/*.info)
+    file(GLOB IN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/translatorsinfo/*.info")
 
-    set(_outFile ${CMAKE_CURRENT_BINARY_DIR}/translators.info)
-    file(WRITE ${_outFile} "")
+    set(_outFile "${CMAKE_CURRENT_BINARY_DIR}/translators.info")
+    file(WRITE "${_outFile}" "")
 
     foreach (_file ${IN_FILES})
-        get_filename_component (_name  ${_file} NAME)
-        file(APPEND ${_outFile} "[${_name}]\n")
+        get_filename_component(_name "${_file}" NAME)
+        file(APPEND "${_outFile}" "[${_name}]\n")
 
-        file(READ ${_file} _content)
-        file(APPEND ${_outFile} "${_content}\n")
+        file(READ "${_file}" _content)
+        file(APPEND "${_outFile}" "${_content}\n")
     endforeach(_file)
 
-    set(${_infoFile} ${_outFile} PARENT_SCOPE)
-endfunction(create_translatorsinfo_file)
-
+    set("${_infoFile}" "${_outFile}" PARENT_SCOPE)
+endfunction()
 
 function(get_translatorsinfo_qrc _qrcFile)
-    get_filename_component (srcDir translatorsinfo/ ABSOLUTE)
+    get_filename_component(srcDir translatorsinfo/ ABSOLUTE)
     string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" txSrcDir ${srcDir})
 
     file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tx/translatorsinfo.tx.sh"
-        "[ -f ${srcDir}/translators.info.src ] || exit 0\n"    
+        "[ -f ${srcDir}/translators.info.src ] || exit 0\n"
         "echo '[lxde-qt.translatorsinfo]'\n"
         "echo 'type = MOZILLAPROPERTIES'\n"
         "echo 'source_lang = en'\n"
@@ -30,12 +28,11 @@ function(get_translatorsinfo_qrc _qrcFile)
         "echo 'file_filter = ${txSrcDir}/translators_<lang>.info'\n"
         "echo ''\n"
     )
-   
+
     create_translatorsinfo_file(TRANSLATORS_INFO_FILE)
     configure_file(
         translatorsinfo/translatorsinfo.qrc.in
-        ${CMAKE_CURRENT_BINARY_DIR}/translatorsinfo.qrc
+        "${CMAKE_CURRENT_BINARY_DIR}/translatorsinfo.qrc"
     )
-    set(${_qrcFile}
-        ${CMAKE_CURRENT_BINARY_DIR}/translatorsinfo.qrc PARENT_SCOPE)
-endfunction(get_translatorsinfo_qrc)
+    set(${_qrcFile} "${CMAKE_CURRENT_BINARY_DIR}/translatorsinfo.qrc PARENT_SCOPE")
+endfunction()