bump year
[lxde/liblxqt.git] / CMakeLists.txt
index 152e4c1..e93abef 100644 (file)
@@ -3,23 +3,12 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
 project(liblxqt)
 
 set(LXQT_MAJOR_VERSION 0)
-set(LXQT_MINOR_VERSION 9)
+set(LXQT_MINOR_VERSION 10)
 set(LXQT_PATCH_VERSION 0)
 
 include(CMakePackageConfigHelpers)
-include(CheckCXXCompilerFlag)
 include(GNUInstallDirs) # Standard directories for installation
 
-CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
-if(COMPILER_SUPPORTS_CXX11)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-elseif(COMPILER_SUPPORTS_CXX0X)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-else()
-    message(FATAL "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. C++11 support is required")
-endif()
-
 #-----------------------------------------------------------------------------
 # LXQT_DATA_DIR defaults to CMAKE_INSTALL_FULL_DATADIR. It's added to
 #   XDG_DATA_DIRS by the startlxqt script
@@ -129,8 +118,9 @@ set(FORMS
 
 # additional cmake files
 list(APPEND CMAKE_MODULE_PATH
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmake
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
+    "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/find-modules"
 )
 
 option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
@@ -139,6 +129,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
 set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
 find_package(Qt5Widgets REQUIRED QUIET)
 find_package(Qt5DBus REQUIRED QUIET)
 find_package(Qt5X11Extras REQUIRED QUIET)
@@ -147,8 +139,6 @@ find_package(Qt5Xdg REQUIRED QUIET)
 find_package(KF5WindowSystem REQUIRED QUIET)
 message(STATUS "Building with Qt ${Qt5Core_VERSION_STRING}")
 
-QT5_WRAP_UI(UIS ${FORMS})
-
 QT5_ADD_DBUS_INTERFACE(SRCS
     dbus/org.freedesktop.Notifications.xml
     notifications_interface
@@ -156,7 +146,7 @@ QT5_ADD_DBUS_INTERFACE(SRCS
 
 QT5_ADD_DBUS_ADAPTOR(SRCS
     dbus/org.lxqt.SingleApplication.xml
-    lxqtsingleapplication.h LxQt::SingleApplication
+    lxqtsingleapplication.h LXQt::SingleApplication
 )
 
 set(LXQT_QT_VERSION "5")
@@ -166,6 +156,7 @@ set(LXQT_PKG_CONFIG_REQUIRES "Qt5Xdg >= 1.2.0, Qt5Widgets, Qt5Xml, Qt5DBus, Qt5X
 
 
 # Standard directories for installation
+include(LXQtCompilerSettings NO_POLICY_SCOPE)
 include(LXQtCreatePkgConfigFile)
 include(cmake/FindInstallConfigPath.cmake) # sets LXQT_ETC_XDG_DIR, if unset
 include(create_portable_headers)
@@ -173,15 +164,16 @@ include(create_portable_headers)
 set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSION})
 set(LXQT_LIBRARY_NAME "lxqt" CACHE STRING "lxqt")
 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_FULL_DATAROOTDIR}/${LXQT_RELATIVE_SHARE_DIR}")
 set(LXQT_RELATIVE_TRANSLATIONS_DIR "${LXQT_LIBRARY_NAME}/translations")
 set(LXQT_TRANSLATIONS_DIR "${LXQT_SHARE_DIR}/translations")
+set(LXQT_GRAPHICS_DIR "${LXQT_SHARE_DIR}/graphics")
 
 set(LXQT_INTREE_INCLUDE_DIR "${CMAKE_CURRENT_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_CMAKE_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/cmake")
 
 
 ## Translations
@@ -194,7 +186,7 @@ lxqt_translate_ts(QM_FILES
         ${SRCS}
         ${FORMS}
     INSTALL_DIR
-        ${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
+        "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}"
 )
 
 message(STATUS "")
@@ -209,16 +201,16 @@ foreach(h ${PUB_HDRS})
 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
 #************************************************
-set(CFG_LXQT_INCLUDE_DIR    ${LXQT_INTREE_INCLUDE_DIR})
-set(CFG_LXQT_LIBRARY        ${LXQT_LIBRARY_NAME})
-set(CFG_LXQT_TARGETS_FILE   ${LXQT_INTREE_TARGETS_FILE})
+set(CFG_LXQT_TARGETS_FILE   "${LXQT_INTREE_TARGETS_FILE}")
 set(CFG_LXQT_CMAKE_MODULES_DIR "${PROJECT_SOURCE_DIR}/cmake/modules")
+set(CFG_LXQT_CMAKE_FIND_MODULES_DIR "${PROJECT_SOURCE_DIR}/cmake/find-modules")
+
 
 configure_package_config_file(
     "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in"
@@ -229,10 +221,9 @@ configure_package_config_file(
 #************************************************
 # Create installable build infrastructure
 #************************************************
-set(CFG_LXQT_INCLUDE_DIR "${LXQT_INSTALL_INCLUDE_DIR}")
-set(CFG_LXQT_LIBRARY ${LXQT_LIBRARY_NAME})
 set(CFG_LXQT_TARGETS_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake")
 set(CFG_LXQT_CMAKE_MODULES_DIR "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/modules")
+set(CFG_LXQT_CMAKE_FIND_MODULES_DIR "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/find-modules")
 
 configure_package_config_file(
     "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in"
@@ -240,13 +231,6 @@ configure_package_config_file(
     INSTALL_DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}"
 )
 
-# use gcc visibility feature to decrease unnecessary exported symbols
-if (CMAKE_COMPILER_IS_GNUCXX)
-    # 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()
-
 write_basic_package_version_file(
     "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config-version.cmake"
     VERSION ${LXQT_VERSION}
@@ -256,7 +240,7 @@ write_basic_package_version_file(
 install(FILES
     "${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
     "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config-version.cmake"
-    DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}
+    DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}"
     COMPONENT Devel
 )
 
@@ -266,6 +250,16 @@ install(EXPORT
     COMPONENT Devel
 )
 
+file(GLOB toInstallFindModules
+    "${PROJECT_SOURCE_DIR}/cmake/find-modules/*.cmake"
+)
+
+install(
+    FILES ${toInstallFindModules}
+    DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/find-modules"
+    COMPONENT Devel
+)
+
 file(GLOB toInstallModules
     "${PROJECT_SOURCE_DIR}/cmake/modules/*.cmake"
     "${PROJECT_SOURCE_DIR}/cmake/modules/*.in"
@@ -273,7 +267,7 @@ file(GLOB toInstallModules
 
 install(
     FILES ${toInstallModules}
-    DESTINATION  "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/modules"
+    DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/modules"
     COMPONENT Devel
 )
 
@@ -306,6 +300,7 @@ target_compile_definitions(${LXQT_LIBRARY_NAME}
     PRIVATE "LXQT_SHARE_DIR=\"${LXQT_SHARE_DIR}\""
     PRIVATE "LXQT_RELATIVE_SHARE_TRANSLATIONS_DIR=\"${LXQT_RELATIVE_TRANSLATIONS_DIR}\""
     PRIVATE "LXQT_SHARE_TRANSLATIONS_DIR=\"${LXQT_TRANSLATIONS_DIR}\""
+    PRIVATE "LXQT_GRAPHICS_DIR=\"${LXQT_GRAPHICS_DIR}\""
     PRIVATE "LXQT_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\""
     PRIVATE "LXQT_DATA_DIR=\"${LXQT_DATA_DIR}\""
     PRIVATE "LXQT_VERSION=\"${LXQT_VERSION}\""
@@ -329,16 +324,28 @@ target_include_directories(${LXQT_LIBRARY_NAME}
 
 install(TARGETS
     ${LXQT_LIBRARY_NAME}
-    DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    DESTINATION "${CMAKE_INSTALL_LIBDIR}"
     EXPORT ${LXQT_LIBRARY_NAME}-targets
-    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+    COMPONENT Runtime
 )
 
+export(TARGETS ${LXQT_LIBRARY_NAME}
+    APPEND FILE "${LXQT_INTREE_TARGETS_FILE}"
+    EXPORT_LINK_INTERFACE_LIBRARIES
+)
 
-export(TARGETS ${LXQT_LIBRARY_NAME} APPEND FILE "${LXQT_INTREE_TARGETS_FILE}")
+install(FILES
+    ${PUB_HDRS}
+    DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt"
+    COMPONENT Devel
+)
 
-install(FILES ${PUB_HDRS} DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt")
-install(FILES ${INTREE_PORTABLE_HEADERS} DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt")
+install(FILES
+    ${INTREE_PORTABLE_HEADERS}
+    DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt"
+    COMPONENT Devel
+)
 
 #************************************************
 # Create and install pkgconfig file