Merge pull request #7 from gaaf/patch-1
[qgit4/redivivus.git] / CMakeLists.txt
blob27daca40d4a7f596cdfcacc801d4273ba2ce51ef
2 # see http://qt-project.org/doc/qt-5/cmake-manual.html
4 # see also http://www.kdab.com/using-cmake-with-qt-5/
5 # see also http://stackoverflow.com/questions/16245147/unable-to-include-a-ui-form-header-of-qt5-in-cmake
6 # see also http://www.qtcentre.org/wiki/index.php?title=Compiling_Qt4_apps_with_CMake
8 cmake_minimum_required(VERSION 2.8.11)
10 project(qgit)
11 include(GNUInstallDirs)
13 # As moc files are generated in the binary dir, tell CMake
14 # to always look for includes there:
15 set(CMAKE_INCLUDE_CURRENT_DIR ON)
17 # Instruct CMake to run moc automatically when needed.
18 set(CMAKE_AUTOMOC ON)
20 option(UseQt5 "Use Qt5?" ON)
21 if (UseQt5)
22   find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
23   set(QT_LIBRARIES Qt5::Widgets)
25   macro(qt_wrap_ui)
26     qt5_wrap_ui(${ARGN})
27   endmacro()
28   macro(qt_add_resources)
29     qt5_add_resources(${ARGN})
30   endmacro()
31 else()
32   find_package(Qt4 REQUIRED COMPONENTS QtCore QtGui)
33   include(${QT_USE_FILE})
35   macro(qt_wrap_ui)
36     qt4_wrap_ui(${ARGN})
37   endmacro()
38   macro(qt_add_resources)
39     qt4_add_resources(${ARGN})
40   endmacro()
41 endif()
43 include_directories(
44     ${CMAKE_SOURCE_DIR}/src
47 set(CPP_SOURCES
48     src/annotate.cpp
49     src/cache.cpp
50     src/commitimpl.cpp
51     src/common.cpp
52     src/consoleimpl.cpp
53     src/customactionimpl.cpp
54     src/dataloader.cpp
55     src/domain.cpp
56     src/exceptionmanager.cpp
57     src/filecontent.cpp
58     src/FileHistory.cc
59     src/filelist.cpp
60     src/fileview.cpp
61     src/git.cpp
62     src/lanes.cpp
63     src/listview.cpp
64     src/inputdialog.cpp
65     src/mainimpl.cpp
66     src/myprocess.cpp
67     src/namespace_def.cpp
68     src/patchcontent.cpp
69     src/patchview.cpp
70     src/qgit.cpp
71     src/rangeselectimpl.cpp
72     src/revdesc.cpp
73     src/revsview.cpp
74     src/settingsimpl.cpp
75     src/smartbrowse.cpp
76     src/treeview.cpp
79 # UIS_HDRS will be used later in add_executable
80 QT_WRAP_UI(UIS_HDRS
81     src/commit.ui
82     src/console.ui
83     src/customaction.ui
84     src/fileview.ui
85     src/help.ui
86     src/mainview.ui
87     src/patchview.ui
88     src/rangeselect.ui
89     src/revsview.ui
90     src/settings.ui
93 # and finally an resource file
94 SET(RESOURCE_FILES
95     src/icons.qrc
98 # this command will generate rules that will run rcc on all files from SAMPLE_RCS
99 # in result SAMPLE_RC_SRCS variable will contain paths to files produced by rcc
100 QT_ADD_RESOURCES(RC_SRCS ${RESOURCE_FILES})
102 add_executable(qgit ${CPP_SOURCES} ${UIS_HDRS} ${RC_SRCS})
103 target_link_libraries(qgit ${QT_LIBRARIES})
106 install(TARGETS qgit DESTINATION bin)
108 if (UNIX)
109     install(FILES src/resources/qgit.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps)
110     install(FILES qgit.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
111     install(FILES qgit.appdata.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo)
112 endif()
114 # kate: indent-width 4; replace-tabs on;
116 # notes:
117 # http://stackoverflow.com/questions/15054117/aligning-qgraphicsitems-to-a-grid-when-dragging-and-dropping