Add Traditional Chinese desktop entry
[lxde/compton-conf.git] / CMakeLists.txt
CommitLineData
012d3267
HJYP
1project(compton-conf)
2
2c6ec7ee 3cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
976fc51f 4set(LXQTBT_MINIMUM_VERSION "0.4.0")
012d3267 5
307f9854
LP
6option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
7
46c428b8 8find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
0ab5c6eb
AG
9
10if(NOT CMAKE_BUILD_TYPE)
11 set(CMAKE_BUILD_TYPE Release)
12endif()
13
14set(COMPTONCONF_MAJOR_VERSION 0)
976fc51f
AG
15set(COMPTONCONF_MINOR_VERSION 3)
16set(COMPTONCONF_PATCH_VERSION 0)
0ab5c6eb 17set(COMPTONCONF_VERSION ${COMPTONCONF_MAJOR_VERSION}.${COMPTONCONF_MINOR_VERSION}.${COMPTONCONF_PATCH_VERSION})
c8feddb4
LP
18add_definitions(
19 "-DCOMPTONCONF_VERSION=\"${COMPTONCONF_VERSION}\""
20 "-DQT_NO_FOREACH"
21)
0ab5c6eb
AG
22
23
04fafe05 24include(LXQtConfigVars)
307f9854 25include(LXQtTranslateTs)
69e1992b 26include(LXQtTranslateDesktop)
307f9854 27
80ebe77d
AG
28# Support Qt4
29option(USE_QT4 "Build with Qt4." $ENV{USE_QT4})
7407665b
HJYP
30set(CMAKE_INCLUDE_CURRENT_DIR ON)
31set(CMAKE_POSITION_INDEPENDENT_CODE ON)
32set(CMAKE_AUTOMOC ON)
80ebe77d
AG
33
34if(USE_QT4)
8a16c16d 35 set(USE_QT5 FALSE)
80ebe77d
AG
36 find_package(Qt4 REQUIRED QtCore QtGui QtDbus)
37 include(${QT_USE_FILE})
8a16c16d 38 add_definitions(-DUSE_QT4)
80ebe77d
AG
39 message(STATUS "Building with Qt${QTVERSION}")
40else()
8a16c16d 41 set(USE_QT5 TRUE)
2c6ec7ee 42 cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
7407665b
HJYP
43 find_package(Qt5Widgets REQUIRED)
44 find_package(Qt5DBus REQUIRED)
45 find_package(Qt5LinguistTools REQUIRED QUIET)
46 message(STATUS "Building with Qt${Qt5Core_VERSION_STRING}")
7407665b 47endif()
012d3267
HJYP
48
49# libconfig using pkg-config
c3b7cf80 50find_package(PkgConfig REQUIRED)
012d3267
HJYP
51pkg_check_modules(LIBCONFIG REQUIRED
52 libconfig
53)
54
c3b7cf80 55include(GNUInstallDirs REQUIRED)
1703a4c4 56include(LXQtCompilerSettings NO_POLICY_SCOPE) # must be after cmake_minimum_required()
c3b7cf80 57
1703a4c4 58set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_KEYWORDS")
012d3267 59
80ebe77d 60if(USE_QT4)
7407665b
HJYP
61 set(QTX_INCLUDE_DIRS ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTDBUS_DIR})
62 set(QTX_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDBUS_LIBRARY})
80ebe77d
AG
63else()
64 set(QTX_INCLUDE_DIRS "")
65 set(QTX_LIBRARIES Qt5::Widgets Qt5::DBus)
7407665b
HJYP
66endif()
67
012d3267 68include_directories(
7407665b 69 ${QTX_INCLUDE_DIRS}
012d3267
HJYP
70 ${LIBCONFIG_INCLUDE_DIRS}
71 ${CMAKE_CURRENT_BINARY_DIR}
72)
73
307f9854
LP
74
75set(compton-conf_HS
76 compton-conf.h
77 maindialog.h
78)
79
012d3267
HJYP
80set(compton-conf_SRCS
81 maindialog.cpp
82 compton-conf.cpp
83)
84
85set(compton-conf_UIS
86 maindialog.ui
87)
88
69e1992b
LP
89set(compton-conf_DESKTOP_FILES_IN
90 compton-conf.desktop.in
91)
92
307f9854 93lxqt_translate_ts(compton-conf_QM_FILES
8a16c16d 94 USE_QT5 ${USE_QT5}
307f9854
LP
95 UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS}
96 SOURCES
97 ${compton-conf_HS}
98 ${compton-conf_SRCS}
99 ${compton-conf_UIS}
100 INSTALL_DIR
101 ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/translations
e8bc9409
PK
102 PULL_TRANSLATIONS
103 ${PULL_TRANSLATIONS}
104 CLEAN_TRANSLATIONS
105 ${CLEAN_TRANSLATIONS}
106 TRANSLATIONS_REPO
107 ${TRANSLATIONS_REPO}
108 TRANSLATIONS_REFSPEC
109 ${TRANSLATIONS_REFSPEC}
307f9854
LP
110)
111
69e1992b
LP
112lxqt_translate_desktop(compton-conf_DESKTOP_FILES SOURCES ${compton-conf_DESKTOP_FILES_IN})
113
80ebe77d 114if(USE_QT4)
7407665b 115 qt4_wrap_ui(compton-conf_UI_H ${compton-conf_UIS})
80ebe77d
AG
116else()
117 qt5_wrap_ui(compton-conf_UI_H ${compton-conf_UIS})
7407665b 118endif()
012d3267 119
0c445108
LP
120set_property(SOURCE ${compton-conf_UI_H} PROPERTY SKIP_AUTOMOC ON)
121
c3b7cf80
HJYP
122add_definitions(
123 -DCOMPTON_CONF_DATA_DIR="${CMAKE_INSTALL_FULL_DATADIR}/compton-conf"
124)
125
012d3267
HJYP
126add_executable(compton-conf
127 ${compton-conf_SRCS}
128 ${compton-conf_UI_H}
307f9854
LP
129 ${compton-conf_QM_FILES}
130 ${compton-conf_QM_LOADER}
69e1992b 131 ${compton-conf_DESKTOP_FILES}
012d3267
HJYP
132)
133
134target_link_libraries(compton-conf
7407665b 135 ${QTX_LIBRARIES}
012d3267
HJYP
136 ${LIBCONFIG_LIBRARIES}
137)
138
139install(TARGETS compton-conf RUNTIME DESTINATION bin)
c3b7cf80 140install(FILES compton.conf.example DESTINATION ${CMAKE_INSTALL_DATADIR}/compton-conf)
69e1992b 141install(FILES ${compton-conf_DESKTOP_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/applications/)
962d547c
AG
142
143# merged from lxqt-common
144add_subdirectory(autostart)
145