Use cmake export functionality.
authorAlexander Sokolov <sokoloff.a@gmail.com>
Fri, 15 Nov 2013 10:12:09 +0000 (14:12 +0400)
committerAlexander Sokolov <sokoloff.a@gmail.com>
Fri, 15 Nov 2013 10:12:09 +0000 (14:12 +0400)
CMakeLists.txt
cmake/create_pkgconfig_file.cmake [deleted file]
cmake/lxqt-config.cmake.in
cmake/lxqtX-config.cmake.in
cmake/lxqt_use.cmake [deleted file]
cmake/lxqt_use.cmake.in [new file with mode: 0644]
lxqtapplication.h

index 1751145..d4beebb 100644 (file)
@@ -5,7 +5,7 @@ project(liblxqt)
 set(LXQT_MAJOR_VERSION 0)
 set(LXQT_MINOR_VERSION 5)
 set(LXQT_PATCH_VERSION 0)
-
+set(LXGQT_PKG_CONFIG_DESCRIPTION "Shared library for LXQt applications")
 
 set(PUB_HDRS
     aboutdialog/lxqtaboutdialog.h
@@ -120,19 +120,18 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
 
 option(USE_QT5 "Force use the Qt5." $ENV{USE_QT5})
 option(USE_QT4 "Force use the Qt4." $ENV{USE_QT4})
-message("Qt4:${USE_QT4}|Qt5:${USE_QT5}")
 
 if((USE_QT4 AND USE_QT5) OR
    (NOT USE_QT4 AND NOT USE_QT5))
 
     # Autodetect Qt version
-    find_package(Qt5Core QUIET)
-    if (Qt5Core_FOUND)
-        set(USE_QT4 OFF)
-        set(USE_QT5 ON)
-    else()
+    find_package(Qt4 QUIET)
+    if (QT4_FOUND)
         set(USE_QT4 ON)
         set(USE_QT5 OFF)
+    else()
+        set(USE_QT4 OFF)
+        set(USE_QT5 ON)
     endif()
 endif()
 
@@ -163,7 +162,7 @@ if(USE_QT5)
 
     set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
 
-    find_package(XDGQT5 REQUIRED QUIET)
+    #find_package(XDGQT5 REQUIRED QUIET)
 else()
     find_package(Qt4 REQUIRED QUIET)
     message(STATUS "Building with Qt ${QTVERSION}")
@@ -179,14 +178,14 @@ else()
     )
 
     set(LXQT_QT_VERSION "4")
-    find_package(XDGQT4 REQUIRED QUIET)
-
-
+    set(LXQT_PKG_CONFIG_REQUIRES "QtCore, QtXml")
 endif()
 
-include(${XDGQT_USE_FILE})
 find_package(X11 REQUIRED QUIET)
 
+find_package(xdgqt REQUIRED)
+include(${XDGQT_USE_FILE})
+
 include_directories (
     ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
     ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR}
@@ -194,133 +193,182 @@ include_directories (
     ${XDGQT_INCLUDE_DIRS}
 )
 
+# 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}")
+set(LXQT_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/lxqt)
+set(LXQT_TRANSLATIONS_DIR ${LXQT_SHARE_DIR}/translations)
+
+set(LXQT_INTREE_INCLUDE_DIR     ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include)
+set(LXQT_INTREE_TRAGETS_FILE    ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-targets.cmake)
+
+set(LXQT_INSTALL_INCLUDE_DIR   ${CMAKE_INSTALL_FULL_INCLUDEDIR})
+set(LXQT_INSTALL_CMAKE_DIR     ${CMAKE_INSTALL_PREFIX}/share/cmake/)
+
+include(cmake/FindInstallConfigPath.cmake)
+include(create_portable_headers)
+
+
 
 message(STATUS "")
 message(STATUS "liblxqt version: ${LXQT_VERSION}")
 message(STATUS "")
 
 
-set(LXQT_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/lxqt)
-set(LXQT_TRANSLATIONS_DIR ${LXQT_SHARE_DIR}/translations)
-include(cmake/FindInstallConfigPath.cmake)
-include(create_portable_headers)
+# Copy public headers
+foreach(h ${PUB_HDRS})
+    get_filename_component(bh ${h} NAME)
+    configure_file(${h} ${LXQT_INTREE_INCLUDE_DIR}/LxQt/${bh} COPYONLY)
+    configure_file(${h} ${LXQT_INTREE_INCLUDE_DIR}/lxqt/${bh} COPYONLY)
+endforeach()
+
+# Create the portable headers
+create_portable_headers(INTREE_PORTABLE_HEADERS ${LXQT_INTREE_INCLUDE_DIR}/lxqt ${PUBLIC_CLASSES})
+check_portable_headers(H_FILES ${PUB_HDRS} LINKS ${INTREE_PORTABLE_HEADERS})
+
+create_portable_headers(INTREE_PORTABLE_HEADERS ${LXQT_INTREE_INCLUDE_DIR}/LxQt ${PUBLIC_CLASSES})
+check_portable_headers(H_FILES ${PUB_HDRS} LINKS ${INTREE_PORTABLE_HEADERS})
+
 
 #************************************************
 # Create in-tree build infrastructure
 #************************************************
-if(INTREE_ROOT_DIR)
-    # Copy public headers
-    foreach(h ${PUB_HDRS})
-        get_filename_component(bh ${h} NAME)
-        configure_file(${h} ${INTREE_ROOT_DIR}/include/LxQt/${bh} COPYONLY)
-        configure_file(${h} ${INTREE_ROOT_DIR}/include/lxqt/${bh} COPYONLY)
-    endforeach()
-
-    # Create the portable headers
-    create_portable_headers(INTREE_PORTABLE_HEADERS ${INTREE_ROOT_DIR}/include/lxqt ${PUBLIC_CLASSES})
-    check_portable_headers(H_FILES ${PUB_HDRS} LINKS ${INTREE_PORTABLE_HEADERS})
-
-    create_portable_headers(INTREE_PORTABLE_HEADERS ${INTREE_ROOT_DIR}/include/LxQt ${PUBLIC_CLASSES})
-    check_portable_headers(H_FILES ${PUB_HDRS} LINKS ${INTREE_PORTABLE_HEADERS})
-
-
-    # Create config.cmake & use.cmake files
-    set(LXQT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR};${INTREE_ROOT_DIR}/include")
-    configure_file(
-        ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in
-        ${INTREE_ROOT_DIR}/cmake/lxqt-config.cmake
-        @ONLY
-    )
+set(CFG_LXQT_INCLUDE_DIR    ${LXQT_INTREE_INCLUDE_DIR})
+set(CFG_LXQT_LIBRARY        ${LXQT_LIBRARY_NAME})
+set(CFG_LXQT_USE_FILE       ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}_use.cmake)
+set(CFG_LXQT_TRAGETS_FILE   ${LXQT_INTREE_TRAGETS_FILE})
 
-    configure_file(
-        ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in
-        ${INTREE_ROOT_DIR}/cmake/lxqt${LXQT_QT_VERSION}-config.cmake
-        @ONLY
-    )
 
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in 
+    ${CMAKE_BINARY_DIR}/lxqt-config.cmake
+    @ONLY
+)
+
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in 
+    ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config.cmake
+    @ONLY
+)
+
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake.in
+    ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}_use.cmake
+    @ONLY
+)
+
+
+include(${CFG_LXQT_USE_FILE})
 
-    configure_file(
-        ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake
-        ${INTREE_ROOT_DIR}/cmake/lxqt${LXQT_QT_VERSION}_use.cmake
-        @ONLY
-    )
-endif()
 
 
 #************************************************
 # Create instalable build infrastructure
 #************************************************
-
-# Create the portable headers
-create_portable_headers(PORTABLE_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/include ${PUBLIC_CLASSES})
-check_portable_headers(H_FILES ${PUB_HDRS} LINKS ${PORTABLE_HEADERS})
+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_TRAGETS_FILE   ${LXQT_INSTALL_CMAKE_DIR}${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake)
 
 
-# Create config.cmake & use.cmake files
-set(LXQT_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
 configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/cmake/lxqt-config.cmake
+    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in 
+    ${CMAKE_CURRENT_BINARY_DIR}/install/lxqt-config.cmake
     @ONLY
 )
 
 configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in
-    ${CMAKE_CURRENT_BINARY_DIR}/cmake/lxqt{LXQT_QT_VERSION}-config.cmake
+    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in 
+    ${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake
     @ONLY
 )
 
-
 configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake
-    ${CMAKE_CURRENT_BINARY_DIR}/cmake/lxqt{LXQT_QT_VERSION}_use.cmake
+    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}_use.cmake
     @ONLY
 )
 
-#************************************************
+install(FILES 
+    ${CMAKE_CURRENT_BINARY_DIR}/install/lxqt-config.cmake
+    DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/lxqt
+    COMPONENT Devel
+)
+
+
+install(FILES 
+    ${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake
+    ${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}_use.cmake
+    DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}
+    COMPONENT Devel
+)
 
-include(cmake/lxqt_use.cmake)
+install(EXPORT 
+    ${LXQT_LIBRARY_NAME}-targets
+    DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}
+    COMPONENT Devel
+)
 
 
 include(translatorsinfo/CMakeLists.txt)
 get_translatorsinfo_qrc(translatorsinfo_qrc)
 qt4_add_resources(QRC_CXX_SOURCES ${translatorsinfo_qrc})
 
-add_library(lxqt
+add_library(${LXQT_LIBRARY_NAME}
     SHARED ${PUB_HDRS}
            ${PRIV_HDRS}
            ${SRCS}
            ${dbus_generated}
            ${UIS} ${MOCS}
            ${QM_FILES}
-           ${QRC_CXX_SOURCES})
+           ${QRC_CXX_SOURCES}
+           
+)
 
-target_link_libraries(lxqt
+
+target_link_libraries(${LXQT_LIBRARY_NAME}
     ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}
     ${QT_QTDBUS_LIBRARY}
     ${X11_X11_LIB}
     ${XDGQT_LIBRARIES}
 )
 
-set_target_properties(lxqt PROPERTIES
+set_target_properties(${LXQT_LIBRARY_NAME} PROPERTIES
     VERSION   ${LXQT_VERSION}
     SOVERSION ${LXQT_MAJOR_VERSION}
 )
 
-install(TARGETS lxqt DESTINATION lib${LIB_SUFFIX})
+install(TARGETS 
+    ${LXQT_LIBRARY_NAME} 
+    DESTINATION ${CMAKE_INSTALL_LIBDIR} 
+    EXPORT ${LXQT_LIBRARY_NAME}-targets
+    LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}        
+)
+
+
+export(TARGETS ${LXQT_LIBRARY_NAME} ${XDGQT_TARGET} FILE ${LXQT_INTREE_TRAGETS_FILE})
+
+
 
 # Install in two places for inclusions like "include <lxde/lxdeclass.h>" and "include <LxQt/Class>".
-install(FILES ${PUB_HDRS}         DESTINATION ${LXQT_INCLUDE_DIR}/lxqt)
-install(FILES ${PORTABLE_HEADERS} DESTINATION ${LXQT_INCLUDE_DIR}/lxqt)
+install(FILES ${PUB_HDRS}         DESTINATION ${LXQT_INSTALL_INCLUDE_DIR}/lxqt)
+install(FILES ${PORTABLE_HEADERS} DESTINATION ${LXQT_INSTALL_INCLUDE_DIR}/lxqt)
 
-install(FILES ${PUB_HDRS}         DESTINATION ${LXQT_INCLUDE_DIR}/LxQt)
-install(FILES ${PORTABLE_HEADERS} DESTINATION ${LXQT_INCLUDE_DIR}/LxQt)
+install(FILES ${PUB_HDRS}         DESTINATION ${LXQT_INSTALL_INCLUDE_DIR}/LxQt)
+install(FILES ${PORTABLE_HEADERS} DESTINATION ${LXQT_INSTALL_INCLUDE_DIR}/LxQt)
 
 install(FILES ${QM_FILES} DESTINATION ${LXQT_TRANSLATIONS_DIR})
 
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/lxqt-config.cmake DESTINATION share/cmake/lxqt)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/lxqt_use.cmake    DESTINATION share/cmake/lxqt)
 
-include(cmake/create_pkgconfig_file.cmake)
-create_pkgconfig_file(lxqt "Shared library for LXQt applications")
+#************************************************
+# Create pkgconfig file
+#************************************************
+lxqt_create_pkgconfig_file(${LXQT_LIBRARY_NAME}
+    ${LXGQT_PKG_CONFIG_DESCRIPTION}
+    ${LXQT_PKG_CONFIG_REQUIRES}
+    ${LXQT_LIBRARY_NAME}
+    ${LXQT_VERSION}
+)
+#************************************************
diff --git a/cmake/create_pkgconfig_file.cmake b/cmake/create_pkgconfig_file.cmake
deleted file mode 100644 (file)
index 96ac25a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Write a pkg-config pc file for given "name" with "decription"
-# Arguments:
-#   name: a library name (withoud "lib" prefix and "so" suffixes
-#   desc: a desription string
-#
-macro (create_pkgconfig_file name desc)
-    set(_pkgfname "${CMAKE_CURRENT_BINARY_DIR}/${name}.pc")
-    #message(STATUS "${name}: writing pkgconfig file ${_pkgfname}")
-
-    file(WRITE "${_pkgfname}"
-            "# file generated by razor-qt cmake build\n"
-            "prefix=${CMAKE_INSTALL_PREFIX}\n"
-            "libdir=\${prefix}/lib${LIB_SUFFIX}\n"
-            "includedir=\${prefix}/include\n"
-            "\n"
-            "Name: ${name}\n"
-            "Description: ${desc}\n"
-            "Version: ${RAZOR_VERSION}\n"
-            "Libs: -L\${libdir} -l${name}\n"
-            "Cflags: -I\${includedir}\n"
-            "\n"
-    )
-
-    install(FILES ${_pkgfname} DESTINATION lib${LIB_SUFFIX}/pkgconfig)
-endmacro()
index 4caff7a..a365fe8 100644 (file)
@@ -57,13 +57,13 @@ option(USE_QT4 "Force use the Qt4." $ENV{USE_QT4})
 if((USE_QT4 AND USE_QT5) OR
    (NOT USE_QT4 AND NOT USE_QT5))
     # Autodetect Qt version
-    find_package(LxQt5 QUIET)
-    if (LXQT5_FOUND)
-        set(USE_QT4 OFF)
-        set(USE_QT5 ON)
-    else()
+    find_package(LxQt4 QUIET)
+    if (LXQT4_FOUND)
         set(USE_QT4 ON)
         set(USE_QT5 OFF)
+    else()
+        set(USE_QT4 OFF)
+        set(USE_QT5 ON)
     endif()
 endif()
 
@@ -80,4 +80,4 @@ if(USE_QT5)
   find_package(LxQt5 ${REQUIRED_OPT} ${QUIET_OPT})
 else()
   find_package(LxQt4 ${REQUIRED_OPT} ${QUIET_OPT})
-endif()
\ No newline at end of file
+endif()
index dd48254..9ea70b3 100644 (file)
@@ -51,6 +51,7 @@
 #   add_executable(myexe main.cpp)
 #   target_link_libraries(myexe $LXQT_LIBRARIES})
 
+set(LXQT_USEQT@LXQT_QT_VERSION@             ON)
 set(LXQT_QT_VERSION         @LXQT_QT_VERSION@)
 set(LXQT_MAJOR_VERSION      @LXQT_MAJOR_VERSION@)
 set(LXQT_MINOR_VERSION      @LXQT_MINOR_VERSION@)
@@ -60,14 +61,19 @@ set(LXQT_VERSION            @LXQT_VERSION@)
 set(LXQT_SHARE_DIR          @LXQT_SHARE_DIR@)
 set(LXQT_TRANSLATIONS_DIR   @LXQT_TRANSLATIONS_DIR@)
 set(LXQT_ETC_XDG_DIR        @LXQT_ETC_XDG_DIR@)
-set(LXQT_INCLUDE_DIR        @LXQT_INCLUDE_DIR@)
-set(LXQT_LIBRARY            lxqt@LXQT_QT_VERSION@)
 
-set(LXQT_LIBRARIES          ${LXQT_LIBRARY} )
-set(LXQT_INCLUDE_DIRS       ${LXQT_INCLUDE_DIR} )
-set(LXQT_USE_FILE           ${CMAKE_CURRENT_LIST_DIR}/lxqt@LXQT_QT_VERSION@_use.cmake)
+set(LXQT_INCLUDE_DIR        @CFG_LXQT_INCLUDE_DIR@)
+set(LXQT_INCLUDE_DIRS       @CFG_LXQT_INCLUDE_DIR@)
+
+set(LXQT_LIBRARY            @CFG_LXQT_LIBRARY@)
+set(LXQT_LIBRARIES          @CFG_LXQT_LIBRARY@)
+
+set(LXQT_USE_FILE           @CFG_LXQT_USE_FILE@)
 set(LXQT_FOUND              1)
 set(LXQT@LXQT_QT_VERSION@_FOUND             1)
 
+
+include(@CFG_LXQT_TRAGETS_FILE@)
+
 mark_as_advanced(LXQT_LIBRARY LXQT_INCLUDE_DIR)
 
diff --git a/cmake/lxqt_use.cmake b/cmake/lxqt_use.cmake
deleted file mode 100644 (file)
index 701bc2a..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-# - Find the LXQt include and library dirs and define a some macros
-#
-# The module defines the following functions
-#
-# lxqt_translate_desktop(desktop_files
-#                         SOURCES sources ...
-#                         [TRANSLATION_DIR] translation_directory
-#                        )
-#     out: desktop_files
-#     generates commands to create .desktop files from sources.
-#     The generated filenames can be found in desktop_files.
-#
-#     in: sources
-#     List of the desktop.in files
-#
-#     in: translation_directory
-#     A relative path to the directory with translations files, it is
-#     relative to the CMakeList.txt. By default is "translations"
-#
-#
-# lxqt_set_default_value(VAR_NAME VAR_VALUE)
-#
-#
-#
-# The module defines the following definitions
-#
-#  -DLXQT_SHARE_DIR      - This allows to install and read the configs from non-standard locations
-#
-#  -DLXQT_ETC_XDG_DIR    - XDG standards expects system-wide configuration files in the
-#                          /etc/xdg/razor location. Unfortunately QSettings we are using internally
-#                          can be overriden in the Qt compilation time to use different path for
-#                          system-wide configs. (for example configure ... -sysconfdir /etc/settings ...)
-#                          This path can be found calling Qt4's qmake:
-#                             qmake -query QT_INSTALL_CONFIGURATION
-#
-#
-#
-
-include_directories(${LXQT_INCLUDE_DIRS})
-
-#cmake_policy(SET CMP0005 NEW)
-add_definitions(-DLXQT_SHARE_DIR=\"${LXQT_SHARE_DIR}\")
-add_definitions(-DLXQT_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\")
-add_definitions(-DLXQT_VERSION=\"${LXQT_VERSION}\")
-
-# for backward compatability ----->
-add_definitions(-DRAZOR_SHARE_DIR=\"${LXQT_SHARE_DIR}\")
-add_definitions(-DRAZOR_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\")
-add_definitions(-DRAZOR_VERSION=\"${LXQT_VERSION}\")
-# for backward compatability <-----
-
-#if(LXQT_QT_VERSION STREQUAL "5")
-
-
-
-#else()
-#    find_package(Qt4 REQUIRED QUIET)
-#    include(${QT_USE_FILE})
-
-#endif()
-
-#**********************************************************
-# DESKTOP files
-#**********************************************************
-
-function(lxqt_translate_desktop _RESULT)
-    set(_translationDir "translations")
-
-    # Parse arguments ***************************************
-    set(_state "")
-    foreach (_arg ${ARGN})
-        if (
-            ("${_arg}_I_HATE_CMAKE" STREQUAL "SOURCES_I_HATE_CMAKE") OR
-            ("${_arg}_I_HATE_CMAKE" STREQUAL "TRANSLATION_DIR_I_HATE_CMAKE")
-           )
-
-            set(_state ${_arg})
-
-        else()
-            if("${_state}" STREQUAL "SOURCES")
-                get_filename_component (__file ${_arg} ABSOLUTE)
-                set(_sources  ${_sources} ${__file})
-                #set(_sources  ${_sources} ${_arg})
-
-            elseif("${_state}" STREQUAL "TRANSLATION_DIR")
-                set(_translationDir ${_arg})
-                set(_state "")
-
-            else()
-                MESSAGE(FATAL_ERROR
-                  "Unknown argument '${_arg}'.\n"
-                  "See ${CMAKE_CURRENT_LIST_FILE} for more information.\n"
-                )
-            endif()
-        endif()
-    endforeach(_arg)
-
-    get_filename_component (_translationDir ${_translationDir} ABSOLUTE)
-
-    foreach (_inFile ${_sources})
-        get_filename_component(_inFile   ${_inFile} ABSOLUTE)
-        get_filename_component(_fileName ${_inFile} NAME_WE)
-        #Extract the real extension ............
-        get_filename_component(_fileExt  ${_inFile} EXT)
-        string(REPLACE ".in" "" _fileExt ${_fileExt})
-        #.......................................
-        set(_outFile "${CMAKE_CURRENT_BINARY_DIR}/${_fileName}${_fileExt}")
-
-        file(GLOB _translations
-            ${_translationDir}/${_fileName}_*${_fileExt}
-            ${_translationDir}/local/${_fileName}_*${_fileExt}
-        )
-
-        set(_pattern "'\\[.*]\\s*='")
-        if (_translations)
-            add_custom_command(OUTPUT ${_outFile}
-                COMMAND grep -v "'#TRANSLATIONS_DIR='" ${_inFile} > ${_outFile}
-                COMMAND grep --no-filename ${_pattern} ${_translations} >> ${_outFile}
-                COMMENT "Generating ${_fileName}${_fileExt}"
-            )
-        else()
-            add_custom_command(OUTPUT ${_outFile}
-                COMMAND grep -v "'#TRANSLATIONS_DIR='" ${_inFile} > ${_outFile}
-                COMMENT "Generating ${_fileName}${_fileExt}"
-            )
-        endif()
-
-        set(__result ${__result} ${_outFile})
-    endforeach()
-
-    set(${_RESULT} ${__result} PARENT_SCOPE)
-endfunction()
-
-
-macro(lxqt_set_default_value VAR_NAME VAR_VALUE)
-    if (NOT DEFINED ${VAR_NAME})
-        set (${VAR_NAME} ${VAR_VALUE})
-    endif ()
-endmacro()
diff --git a/cmake/lxqt_use.cmake.in b/cmake/lxqt_use.cmake.in
new file mode 100644 (file)
index 0000000..f2fb27c
--- /dev/null
@@ -0,0 +1,187 @@
+# - Find the LXQt include and library dirs and define a some macros
+#
+# The module defines the following functions
+#
+# lxqt_translate_desktop(desktop_files
+#                         SOURCES sources ...
+#                         [TRANSLATION_DIR] translation_directory
+#                        )
+#     out: desktop_files
+#     generates commands to create .desktop files from sources.
+#     The generated filenames can be found in desktop_files.
+#
+#     in: sources
+#     List of the desktop.in files
+#
+#     in: translation_directory
+#     A relative path to the directory with translations files, it is
+#     relative to the CMakeList.txt. By default is "translations"
+#
+#
+# lxqt_set_default_value(VAR_NAME VAR_VALUE)
+#
+#
+# lxqt_create_pkgconfig_file(name 
+#                            desc 
+#                            requires 
+#                            include_rel_dir 
+#                            version)
+#     Write a pkg-config pc file for given "name" with "decription"
+#     Arguments:
+#       name: a library name (withoud "lib" prefix and "so" suffixes
+#       desc: a desription string
+#       requires: required libraries
+#       include_rel_dir: include directory, relative to includedir
+#       version: package version
+#
+#
+#
+# The module defines the following definitions
+#
+#  -DLXQT_SHARE_DIR      - This allows to install and read the configs from non-standard locations
+#
+#  -DLXQT_ETC_XDG_DIR    - XDG standards expects system-wide configuration files in the
+#                          /etc/xdg/razor location. Unfortunately QSettings we are using internally
+#                          can be overriden in the Qt compilation time to use different path for
+#                          system-wide configs. (for example configure ... -sysconfdir /etc/settings ...)
+#                          This path can be found calling Qt4's qmake:
+#                             qmake -query QT_INSTALL_CONFIGURATION
+#
+#
+#
+
+include_directories(${LXQT_INCLUDE_DIRS})
+
+#cmake_policy(SET CMP0005 NEW)
+add_definitions(-DLXQT_SHARE_DIR=\"${LXQT_SHARE_DIR}\")
+add_definitions(-DLXQT_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\")
+add_definitions(-DLXQT_VERSION=\"${LXQT_VERSION}\")
+
+# for backward compatability ----->
+add_definitions(-DRAZOR_SHARE_DIR=\"${LXQT_SHARE_DIR}\")
+add_definitions(-DRAZOR_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\")
+add_definitions(-DRAZOR_VERSION=\"${LXQT_VERSION}\")
+# for backward compatability <-----
+
+#if(NOT "${PROJECT_NAME}" STREQUAL "liblxqt")
+#    message("#################${PROJECT_NAME} liblxqt${LXQT_QT_VERSION}")
+#    add_dependencies("lxqt${LXQT_QT_VERSION}")
+SET_SOURCE_FILES_PROPERTIES(LXQT_LIBRARIES PROPERTIES OBJECT_DEPENDS lxqt${LXQT_QT_VERSION})
+#endif()
+
+
+
+
+#else()
+#    find_package(Qt4 REQUIRED QUIET)
+#    include(${QT_USE_FILE})
+
+#endif()
+
+#**********************************************************
+# DESKTOP files
+#**********************************************************
+
+function(lxqt_translate_desktop _RESULT)
+    set(_translationDir "translations")
+
+    # Parse arguments ***************************************
+    set(_state "")
+    foreach (_arg ${ARGN})
+        if (
+            ("${_arg}_I_HATE_CMAKE" STREQUAL "SOURCES_I_HATE_CMAKE") OR
+            ("${_arg}_I_HATE_CMAKE" STREQUAL "TRANSLATION_DIR_I_HATE_CMAKE")
+           )
+
+            set(_state ${_arg})
+
+        else()
+            if("${_state}" STREQUAL "SOURCES")
+                get_filename_component (__file ${_arg} ABSOLUTE)
+                set(_sources  ${_sources} ${__file})
+                #set(_sources  ${_sources} ${_arg})
+
+            elseif("${_state}" STREQUAL "TRANSLATION_DIR")
+                set(_translationDir ${_arg})
+                set(_state "")
+
+            else()
+                MESSAGE(FATAL_ERROR
+                  "Unknown argument '${_arg}'.\n"
+                  "See ${CMAKE_CURRENT_LIST_FILE} for more information.\n"
+                )
+            endif()
+        endif()
+    endforeach(_arg)
+
+    get_filename_component (_translationDir ${_translationDir} ABSOLUTE)
+
+    foreach (_inFile ${_sources})
+        get_filename_component(_inFile   ${_inFile} ABSOLUTE)
+        get_filename_component(_fileName ${_inFile} NAME_WE)
+        #Extract the real extension ............
+        get_filename_component(_fileExt  ${_inFile} EXT)
+        string(REPLACE ".in" "" _fileExt ${_fileExt})
+        #.......................................
+        set(_outFile "${CMAKE_CURRENT_BINARY_DIR}/${_fileName}${_fileExt}")
+
+        file(GLOB _translations
+            ${_translationDir}/${_fileName}_*${_fileExt}
+            ${_translationDir}/local/${_fileName}_*${_fileExt}
+        )
+
+        set(_pattern "'\\[.*]\\s*='")
+        if (_translations)
+            add_custom_command(OUTPUT ${_outFile}
+                COMMAND grep -v "'#TRANSLATIONS_DIR='" ${_inFile} > ${_outFile}
+                COMMAND grep --no-filename ${_pattern} ${_translations} >> ${_outFile}
+                COMMENT "Generating ${_fileName}${_fileExt}"
+            )
+        else()
+            add_custom_command(OUTPUT ${_outFile}
+                COMMAND grep -v "'#TRANSLATIONS_DIR='" ${_inFile} > ${_outFile}
+                COMMENT "Generating ${_fileName}${_fileExt}"
+            )
+        endif()
+
+        set(__result ${__result} ${_outFile})
+    endforeach()
+
+    set(${_RESULT} ${__result} PARENT_SCOPE)
+endfunction()
+
+
+macro(lxqt_set_default_value VAR_NAME VAR_VALUE)
+    if (NOT DEFINED ${VAR_NAME})
+        set (${VAR_NAME} ${VAR_VALUE})
+    endif ()
+endmacro()
+
+
+#
+# Write a pkg-config pc file for given "name" with "decription"
+# Arguments:
+#   name: a library name (withoud "lib" prefix and "so" suffixes
+#   desc: a desription string
+#
+macro(lxqt_create_pkgconfig_file name desc requires include_rel_dir version)
+    set(_pkgfname "${CMAKE_CURRENT_BINARY_DIR}/${name}.pc")
+    message(STATUS "${name}: writing pkgconfig file ${_pkgfname}")
+
+    file(WRITE "${_pkgfname}"
+            "# file generated by razor-qt cmake build\n"
+            "prefix=${CMAKE_INSTALL_PREFIX}\n"
+            "libdir=\${prefix}/${CMAKE_INSTALL_LIBDIR}\n"
+            "includedir=\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}\n"
+            "\n"
+            "Name: ${name}\n"
+            "Description: ${desc}\n"
+            "Version: ${version}\n"
+            "Requires: ${requires}\n"
+            "Libs: -L\${libdir} -l${name}\n"
+            "Cflags: -I\${includedir} -I\${includedir}/${include_rel_dir}\n"
+            "\n"
+        )
+
+    install(FILES ${_pkgfname} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+endmacro()
index 2aee5f5..efe26f1 100644 (file)
@@ -28,8 +28,8 @@
 #ifndef LXQTAPPLICATION_H
 #define LXQTAPPLICATION_H
 
-#include <QtGui/QApplication>
-#include <QtGui/QProxyStyle>
+#include <QApplication>
+#include <QProxyStyle>
 
 namespace LxQt
 {