Skip to content

Commit

Permalink
Qt6 made default
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben2020 committed May 21, 2024
1 parent dd7625a commit d2d5ee8
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 148 deletions.
44 changes: 19 additions & 25 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,64 +164,58 @@ jobs:
shell: bash
if: "contains(matrix.config.name, 'Ubuntu-latest GCC Qt6')"
run: |
mkdir -p build
cd build
export CC=gcc
export CXX=g++
cmake -G Ninja -DBUILD_QT6=ON ..
ninja
cmake -G Ninja -S . -B build
cmake --build build
sudo cmake --install build
cd build
ninja package
sudo ninja install
- name: Configure CMake and Build on Ubuntu GCC Qt5
shell: bash
if: "contains(matrix.config.name, 'Ubuntu-latest GCC Qt5') || contains(matrix.config.name, 'Ubuntu 20.04 GCC Qt5')"
run: |
mkdir -p build
cd build
export CC=gcc
export CXX=g++
cmake -G Ninja -DBUILD_QT5=ON ..
ninja
cmake -G Ninja -DBUILD_QT5=ON -S . -B build
cmake --build build
sudo cmake --install build
cd build
ninja package
sudo ninja install
- name: Configure CMake and Build on Ubuntu-latest GCC NoGui
shell: bash
if: contains(matrix.config.name, 'Ubuntu-latest GCC NoGui')
run: |
mkdir -p build
cd build
export CC=gcc
export CXX=g++
cmake -G Ninja -DNO_GUI=ON ..
ninja
cmake -G Ninja -DNO_GUI=ON -S . -B build
cmake --build build
sudo cmake --install build
cd build
ninja package
sudo ninja install
- name: Configure CMake and Build on macOS Clang Qt6
shell: bash
if: contains(matrix.config.name, 'macOS Clang Qt6')
run: |
mkdir -p build
cd build
export CC=clang
export CXX=clang++
cmake -G Ninja -DBUILD_QT6=ON -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@6/lib/cmake ..
ninja
sudo ninja install
cmake -G Ninja -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@6/lib/cmake -S . -B build
cmake --build build
sudo cmake --install build
- name: Configure CMake and Build on macOS Clang Qt5
shell: bash
if: contains(matrix.config.name, 'macOS Clang Qt5')
run: |
mkdir -p build
cd build
export CC=clang
export CXX=clang++
cmake -G Ninja -DBUILD_QT5=ON -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/qt@5/lib/cmake ..
ninja
sudo ninja install
cmake -G Ninja -DBUILD_QT5=ON -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/qt@5/lib/cmake -S . -B build
cmake --build build
sudo cmake --install build
- name: Configure CMake and Build on Windows MinGW Qt6
shell: cmd
Expand Down
31 changes: 12 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,21 @@
cmake_minimum_required(VERSION 3.16.0)
project(CodeQuery)

option(BUILD_QT6 "Qt6 option" OFF)
option(BUILD_QT5 "Qt5 option" ON)
option(BUILD_QT6 "Qt6 option" ON)
option(BUILD_QT5 "Qt5 option" OFF)
option(NO_GUI "No GUI option" OFF)
option(GHAWIN "GitHub Actions on Windows" OFF)

MESSAGE("-- NO_GUI = " ${NO_GUI})
if (NO_GUI)
MESSAGE("-- NO_GUI = " ${NO_GUI})
else (NO_GUI)

if (BUILD_QT6)
message("-- BUILD_QT6 = " ${BUILD_QT6})
else (BUILD_QT6)

message("-- BUILD_QT6 = " ${BUILD_QT6})
message("-- BUILD_QT5 = " ${BUILD_QT5})

if (BUILD_QT5)
message("-- BUILD_QT5 = " ${BUILD_QT5})
else (BUILD_QT5)
message(FATAL_ERROR "Qt4 is no longer supported!")
message("-- BUILD_QT6 = " ${BUILD_QT6})
endif(BUILD_QT5)

endif(BUILD_QT6)
endif(NO_GUI)

if (GHAWIN)
Expand Down Expand Up @@ -84,17 +77,17 @@ set( CPACK_PACKAGE_NAME "codequery-nogui" )
set( CPACK_DEBIAN_PACKAGE_DEPENDS "libsqlite3-0 (>= 3.11.0) " )

else (NO_GUI)
if (BUILD_QT6)

set( CPACK_PACKAGE_NAME "codequery-qt6" )
set( CPACK_DEBIAN_PACKAGE_DEPENDS "qtbase5-dev (>= 5.5.1) , libsqlite3-0 (>= 3.11.0) " )

else (BUILD_QT6)
if (BUILD_QT5)

set( CPACK_PACKAGE_NAME "codequery-qt5" )
set( CPACK_DEBIAN_PACKAGE_DEPENDS "qtbase5-dev (>= 5.9.0) , libsqlite3-0 (>= 3.11.0) " )

endif (BUILD_QT6)
else (BUILD_QT5)

set( CPACK_PACKAGE_NAME "codequery-qt6" )
set( CPACK_DEBIAN_PACKAGE_DEPENDS "qt6-base-dev (>= 6.4.0) , libsqlite3-0 (>= 3.11.0) " )

endif (BUILD_QT5)
endif (NO_GUI)


Expand Down
29 changes: 11 additions & 18 deletions doc/INSTALL-LINUX.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,26 @@ Step 3: Unzip to a directory and change to that directory.
cd ~/myrepos/codequery
```

Step 4: Create a directory called build and change to it.
Step 4: Run cmake (first line for Qt6 OR second line for Qt5 OR third line for no GUI).
```bash
mkdir build
cd build
cmake -G Ninja -S . -B build
cmake -G Ninja -DBUILD_QT5=ON -S . -B build
cmake -G Ninja -DNO_GUI=ON -S . -B build
```

Step 5: Run cmake (first line for Qt5 OR second line for Qt6 OR third line for no GUI).
Qt5 and no GUI are the stable versions, while Qt6 is for development testing.
Step 5: Run make and make install.
```bash
cmake -G Ninja -DBUILD_QT5=ON ..
cmake -G Ninja -DBUILD_QT6=ON ..
cmake -G Ninja -DNO_GUI=ON ..
```

Step 6: Run make and make install.
```bash
ninja
sudo ninja install
cmake --build build
sudo cmake --install build
```

If you want to install to an alternative directory instead of the default one, use the following:
```bash
cmake -DCMAKE_INSTALL_PREFIX="/home/johndoe/tools/" -G Ninja -DBUILD_QT5=ON ..
ninja
ninja install
cmake -DCMAKE_INSTALL_PREFIX="/home/johndoe/tools/" -G Ninja -DBUILD_QT5=ON -S . -B build
cmake --build build
sudo cmake --install build
```


Step 7: Please read [HOWTO-LINUX](HOWTO-LINUX.md) to learn how to use this software.
Step 6: Please read [HOWTO-LINUX](HOWTO-LINUX.md) to learn how to use this software.

99 changes: 47 additions & 52 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ endif()
ui/aboutDialog.ui
ui/fileViewSettingsDialog.ui
)

SET( CODEQUERY_QT4_UIS
ui_qt4/mainWindow.ui
ui_qt4/graphDialog.ui
ui_qt4/aboutDialog.ui
ui_qt4/fileViewSettingsDialog.ui
)

# and finally an resource file
#SET( CODEQUERY_RCS
Expand Down Expand Up @@ -130,22 +123,33 @@ find_package(Sqlite REQUIRED)
include_directories( "${SQLITE_INCLUDE_DIR}" )
endif(GHAWIN)

if (BUILD_QT6)
if (BUILD_QT5)

find_package(Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Xml LinguistTools )
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC OFF)
set(CMAKE_AUTOUIC OFF)
# this command finds Qt4 libraries and sets all required variables
# note that it's Qt4, not QT4 or qt4
FIND_PACKAGE( Qt5Widgets REQUIRED )
FIND_PACKAGE( Qt5Core REQUIRED )
FIND_PACKAGE( Qt5Concurrent REQUIRED )
FIND_PACKAGE( Qt5Xml REQUIRED )
FIND_PACKAGE( Qt5LinguistTools REQUIRED )

add_definitions( -DUSE_QT5 )
add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)
#add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)

set_target_properties(Qt6::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")
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 Qt6::rcc LOCATION)
get_target_property(QT_RCC_EXECUTABLE Qt5::rcc LOCATION)

qt6_add_translation( QM ${CODEQUERY_TRANS} )
QT5_ADD_TRANSLATION( QM ${CODEQUERY_TRANS} )

# this command will generate rules that will run rcc on all files from CODEQUERY_RCS
# in result CQIMAGES_RC_SRCS variable will contain paths to files produced by rcc
# QT4_ADD_RESOURCES( CQIMAGES_RC_SRCS ${CODEQUERY_RCS} )

# Run the resource compiler (rcc_options should already be set).
ADD_CUSTOM_COMMAND(
OUTPUT ${CQIMAGES_RC_SRCS}
COMMAND ${QT_RCC_EXECUTABLE}
Expand All @@ -164,47 +168,43 @@ if (BUILD_QT6)
COMMAND ${COPY_COMMAND}
ARGS ${CQTRANS_RC_QRCT_CP} ${CQTRANS_RC_QRC_CP}
)


qt6_wrap_ui( CODEQUERY_UI_HDRS ${CODEQUERY_UIS} )
# 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}" )

if(WIN32)
SET(CQ_WIN_RCS cqwin64.rc)
add_executable( codequery WIN32 ${CODEQUERY_SRCS} ${CODEQUERY_MOC_SRCS} ${CQIMAGES_RC_SRCS} ${CQTRANS_RC_SRCS} ${CODEQUERY_UI_HDRS} ${QM} ${CQ_WIN_RCS} )
target_link_libraries( codequery PRIVATE Qt6::Widgets Qt6::Concurrent ${SQLITE_LIBRARIES} cqshowgraph-qt6 scintillaedit lexilla )
target_link_libraries( codequery Qt5::Widgets Qt5::Concurrent Qt5::WinMain ${SQLITE_LIBRARIES} cqshowgraph-qt5 scintillaedit lexilla)
else()
add_executable( codequery ${CODEQUERY_SRCS} ${CODEQUERY_MOC_SRCS} ${CQIMAGES_RC_SRCS} ${CQTRANS_RC_SRCS} ${CODEQUERY_UI_HDRS} ${QM} )
target_link_libraries( codequery PRIVATE Qt6::Widgets Qt6::Concurrent ${SQLITE_LIBRARIES} cqshowgraph-qt6 scintillaedit lexilla )
target_link_libraries( codequery Qt5::Widgets Qt5::Concurrent ${SQLITE_LIBRARIES} cqshowgraph-qt5 scintillaedit lexilla)
endif()

install(TARGETS codequery RUNTIME DESTINATION bin)

else (BUILD_QT6)

# this command finds Qt4 libraries and sets all required variables
# note that it's Qt4, not QT4 or qt4
FIND_PACKAGE( Qt5Widgets REQUIRED )
FIND_PACKAGE( Qt5Core REQUIRED )
FIND_PACKAGE( Qt5Concurrent REQUIRED )
FIND_PACKAGE( Qt5Xml REQUIRED )
FIND_PACKAGE( Qt5LinguistTools REQUIRED )

else (BUILD_QT5)

find_package(Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Xml LinguistTools )
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC OFF)
set(CMAKE_AUTOUIC OFF)

add_definitions( -DUSE_QT5 )
#add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)
add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)

set_target_properties(Qt5::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")

SET(CMAKE_AUTOMOC ON)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
set_target_properties(Qt6::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")

get_target_property(QT_RCC_EXECUTABLE Qt5::rcc LOCATION)
get_target_property(QT_RCC_EXECUTABLE Qt6::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 CQIMAGES_RC_SRCS variable will contain paths to files produced by rcc
# QT4_ADD_RESOURCES( CQIMAGES_RC_SRCS ${CODEQUERY_RCS} )
qt6_add_translation( QM ${CODEQUERY_TRANS} )

# Run the resource compiler (rcc_options should already be set).
ADD_CUSTOM_COMMAND(
OUTPUT ${CQIMAGES_RC_SRCS}
COMMAND ${QT_RCC_EXECUTABLE}
Expand All @@ -223,25 +223,20 @@ else (BUILD_QT6)
COMMAND ${COPY_COMMAND}
ARGS ${CQTRANS_RC_QRCT_CP} ${CQTRANS_RC_QRC_CP}
)


# 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}" )
qt6_wrap_ui( CODEQUERY_UI_HDRS ${CODEQUERY_UIS} )

if(WIN32)
SET(CQ_WIN_RCS cqwin64.rc)
add_executable( codequery WIN32 ${CODEQUERY_SRCS} ${CODEQUERY_MOC_SRCS} ${CQIMAGES_RC_SRCS} ${CQTRANS_RC_SRCS} ${CODEQUERY_UI_HDRS} ${QM} ${CQ_WIN_RCS} )
target_link_libraries( codequery Qt5::Widgets Qt5::Concurrent Qt5::WinMain ${SQLITE_LIBRARIES} cqshowgraph-qt5 scintillaedit lexilla)
target_link_libraries( codequery PRIVATE Qt6::Widgets Qt6::Concurrent ${SQLITE_LIBRARIES} cqshowgraph-qt6 scintillaedit lexilla )
else()
add_executable( codequery ${CODEQUERY_SRCS} ${CODEQUERY_MOC_SRCS} ${CQIMAGES_RC_SRCS} ${CQTRANS_RC_SRCS} ${CODEQUERY_UI_HDRS} ${QM} )
target_link_libraries( codequery Qt5::Widgets Qt5::Concurrent ${SQLITE_LIBRARIES} cqshowgraph-qt5 scintillaedit lexilla)
target_link_libraries( codequery PRIVATE Qt6::Widgets Qt6::Concurrent ${SQLITE_LIBRARIES} cqshowgraph-qt6 scintillaedit lexilla )
endif()

install(TARGETS codequery RUNTIME DESTINATION bin)

endif (BUILD_QT6)

endif (BUILD_QT5)

30 changes: 15 additions & 15 deletions scintilla/qt/ScintillaEdit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,7 @@ project(ScintillaEdit)

find_package( Threads REQUIRED )

if (BUILD_QT6)

find_package(Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Core5Compat )

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set_target_properties(Qt6::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")

qt6_add_library( scintillaedit STATIC ${SCINTILLA_SRCS} ${SCINTILLA_MOC_SRCS} ${SCINT_SRCS} )
target_link_libraries( scintillaedit PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Core5Compat Threads::Threads )

else (BUILD_QT6)
if (BUILD_QT5)

FIND_PACKAGE( Qt5Widgets REQUIRED )
FIND_PACKAGE( Qt5Core REQUIRED )
Expand All @@ -62,5 +49,18 @@ else (BUILD_QT6)
add_library( scintillaedit STATIC ${SCINTILLA_SRCS} ${SCINTILLA_MOC_SRCS} ${SCINT_SRCS} )
target_link_libraries( scintillaedit Qt5::Widgets Qt5::Concurrent Threads::Threads )

endif (BUILD_QT6)
else (BUILD_QT5)

find_package(Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Core5Compat )

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set_target_properties(Qt6::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")

qt6_add_library( scintillaedit STATIC ${SCINTILLA_SRCS} ${SCINTILLA_MOC_SRCS} ${SCINT_SRCS} )
target_link_libraries( scintillaedit PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Core5Compat Threads::Threads )

endif (BUILD_QT5)

Loading

0 comments on commit d2d5ee8

Please sign in to comment.