1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
cmake_minimum_required(VERSION 2.8.12)
project(CodeQueryGUI)
#ADD_DEFINITIONS( -Wall )
# with SET() command you can change variables or define new ones
# here we define CODEQUERY_SRCS variable that contains a list of all .cpp files
# note that we don't need \ at the end of line
SET( CODEQUERY_SRCS
sqlqueryadv.cpp
std2qt.cpp
langtable.cpp
fileviewer.cpp
listhandler.cpp
searchhandler.cpp
mainwindow.cpp
graphdialog.cpp
aboutdialog.cpp
fileviewsettingsdialog.cpp
themes.cpp
main_gui.cpp
winmain.cpp
)
# another list, this time it includes all header files that should be treated with moc
SET( CODEQUERY_MOC_HDRS
fileviewer.h
listhandler.h
searchhandler.h
mainwindow.h
graphdialog.h
aboutdialog.h
fileviewsettingsdialog.h
)
# some .ui files
SET( CODEQUERY_UIS
ui/mainWindow.ui
ui/graphDialog.ui
ui/aboutDialog.ui
ui/fileViewSettingsDialog.ui
)
# and finally an resource file
SET( CODEQUERY_RCS
codequery.qrc
)
# translation files
SET( CODEQUERY_TRANS
translations/codequery_de.ts
translations/codequery_en.ts
translations/codequery_es.ts
translations/codequery_fr.ts
translations/codequery_id.ts
translations/codequery_it.ts
translations/codequery_ja.ts
translations/codequery_ko.ts
translations/codequery_zh-CHS.ts
translations/codequery_zh-CHT.ts
)
add_definitions( -DNO_QDESIGNER_WIDGET_EXPORT )
INCLUDE_DIRECTORIES( "${SQLITE_INCLUDE_DIR}" )
INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_BINARY_DIR}" )
INCLUDE_DIRECTORIES( "." )
INCLUDE_DIRECTORIES( "./translations" )
INCLUDE_DIRECTORIES( "../querylib" )
INCLUDE_DIRECTORIES( "../makedb" )
INCLUDE_DIRECTORIES( "../showgraph" )
INCLUDE_DIRECTORIES( "/usr/local/include" )
FIND_PACKAGE( Sqlite REQUIRED )
if (BUILD_QT5)
# this command finds Qt4 libraries and sets all required variables
# note that it's Qt4, not QT4 or qt4
FIND_PACKAGE( Qt5Widgets 5.2.1 REQUIRED )
FIND_PACKAGE( Qt5Core REQUIRED )
FIND_PACKAGE( Qt5Concurrent REQUIRED )
FIND_PACKAGE( Qt5Xml REQUIRED )
FIND_PACKAGE( Qt5LinguistTools REQUIRED )
FIND_PACKAGE( Qt5QScintilla REQUIRED )
add_definitions( -DUSE_QT5 )
set_target_properties(Qt5::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
get_target_property(QT_RCC_EXECUTABLE Qt5::rcc LOCATION)
QT5_ADD_TRANSLATION( QM ${CODEQUERY_TRANS} )
# this command will generate rules that will run rcc on all files from CODEQUERY_RCS
# in result CODEQUERY_RC_SRCS variable will contain paths to files produced by rcc
# QT4_ADD_RESOURCES( CODEQUERY_RC_SRCS ${CODEQUERY_RCS} )
SET( CODEQUERY_RC_NAME codequery )
SET( CODEQUERY_RC_QRC "${CMAKE_CURRENT_SOURCE_DIR}/${CODEQUERY_RC_NAME}.qrc")
SET( CODEQUERY_RC_SRCS "${CMAKE_CURRENT_BINARY_DIR}/qrc_${CODEQUERY_RC_NAME}.cxx")
# Run the resource compiler (rcc_options should already be set). We can't
# use QT4_ADD_RESOURCES because the qrc file may not exist yet.
ADD_CUSTOM_COMMAND(
OUTPUT ${CODEQUERY_RC_SRCS}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${CODEQUERY_RC_NAME} -o ${CODEQUERY_RC_SRCS} ${CODEQUERY_RC_QRC}
DEPENDS ${QM}
)
# this will run uic on .ui files:
QT5_WRAP_UI( CODEQUERY_UI_HDRS ${CODEQUERY_UIS} )
# we need this to be able to include headers produced by uic in our code
# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
INCLUDE_DIRECTORIES( "${Qt5Widgets_INCLUDE_DIRS}" )
INCLUDE_DIRECTORIES( "${QT5QSCINTILLA_INCLUDE_DIRS}" )
if(WIN32)
SET(CQ_WIN_RCS cqwin32.rc)
add_executable( codequery WIN32 ${CODEQUERY_SRCS} ${CODEQUERY_MOC_SRCS} ${CODEQUERY_RC_SRCS} ${CODEQUERY_UI_HDRS} ${QM} ${CQ_WIN_RCS} )
target_link_libraries( codequery Qt5::Widgets Qt5::Concurrent Qt5::WinMain ${SQLITE_LIBRARIES} ${QT5QSCINTILLA_LIBRARIES} sqlquery_lib small_lib cqshowgraph-qt5)
else()
add_executable( codequery ${CODEQUERY_SRCS} ${CODEQUERY_MOC_SRCS} ${CODEQUERY_RC_SRCS} ${CODEQUERY_UI_HDRS} ${QM} )
target_link_libraries( codequery Qt5::Widgets Qt5::Concurrent ${SQLITE_LIBRARIES} ${QT5QSCINTILLA_LIBRARIES} sqlquery_lib small_lib cqshowgraph-qt5)
endif()
install(TARGETS codequery RUNTIME DESTINATION bin)
else (BUILD_QT5)
# by default only QtCore and QtGui modules are enabled
# other modules must be enabled like this:
#SET( QT_USE_QTXML TRUE )
#SET( QT_USE_QTSQL TRUE )
SET( QT_DONT_USE_QTGUI FALSE )
# this command finds Qt4 libraries and sets all required variables
# note that it's Qt4, not QT4 or qt4
FIND_PACKAGE( Qt4 REQUIRED )
FIND_PACKAGE( QScintilla REQUIRED )
# add some useful macros and variables
# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script)
INCLUDE( "${QT_USE_FILE}" )
QT4_ADD_TRANSLATION( QM ${CODEQUERY_TRANS} )
# this command will generate rules that will run rcc on all files from CODEQUERY_RCS
# in result CODEQUERY_RC_SRCS variable will contain paths to files produced by rcc
# QT4_ADD_RESOURCES( CODEQUERY_RC_SRCS ${CODEQUERY_RCS} )
SET( CODEQUERY_RC_NAME codequery )
SET( CODEQUERY_RC_QRC "${CMAKE_CURRENT_SOURCE_DIR}/${CODEQUERY_RC_NAME}.qrc")
SET( CODEQUERY_RC_SRCS "${CMAKE_CURRENT_BINARY_DIR}/qrc_${CODEQUERY_RC_NAME}.cxx")
# Run the resource compiler (rcc_options should already be set). We can't
# use QT4_ADD_RESOURCES because the qrc file may not exist yet.
ADD_CUSTOM_COMMAND(
OUTPUT ${CODEQUERY_RC_SRCS}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS ${rcc_options} -name ${CODEQUERY_RC_NAME} -o ${CODEQUERY_RC_SRCS} ${CODEQUERY_RC_QRC}
DEPENDS ${QM}
)
# this will run uic on .ui files:
QT4_WRAP_UI( CODEQUERY_UI_HDRS ${CODEQUERY_UIS} )
# and finally this will run moc:
QT4_WRAP_CPP( CODEQUERY_MOC_SRCS ${CODEQUERY_MOC_HDRS} )
if(WIN32)
SET(CQ_WIN_RCS cqwin32.rc)
add_executable( codequery WIN32 ${CODEQUERY_SRCS} ${CODEQUERY_MOC_SRCS} ${CODEQUERY_RC_SRCS} ${CODEQUERY_UI_HDRS} ${QM} ${CQ_WIN_RCS} )
else()
add_executable( codequery ${CODEQUERY_SRCS} ${CODEQUERY_MOC_SRCS} ${CODEQUERY_RC_SRCS} ${CODEQUERY_UI_HDRS} ${QM} )
endif()
target_link_libraries( codequery ${QT_LIBRARIES} ${SQLITE_LIBRARIES} ${QSCINTILLA_LIBRARIES} sqlquery_lib small_lib cqshowgraph)
install(TARGETS codequery RUNTIME DESTINATION bin)
endif (BUILD_QT5)
|