Skip to content

Commit d8a0150

Browse files
authored
chore: Add support for Qt Creator version to the plugin build script (#87)
This will allow to add code conditional on the Qt Creator version to the plugin codebase. The Qt Creator version will be passed from the build script automatically. This will also allow to easily extend the Github Actions job matrix to create releases for more than one Qt Creator version. Using QT_VERSION_CHECK allows to reuse existing Qt patterns of checking versions. Code has been tested by invoking QODEASSIST_QT_CREATOR_VERSION in code.
1 parent 3b18874 commit d8a0150

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

.github/workflows/build_cmake.yml

+12
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ jobs:
187187
set(ENV{CXX} ${{ matrix.config.cxx }})
188188
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${{ env.MACOS_DEPLOYMENT_TARGET }}")
189189
190+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" version_match "$ENV{QT_CREATOR_VERSION}")
191+
set(QT_CREATOR_VERSION_MAJOR "${CMAKE_MATCH_1}")
192+
set(QT_CREATOR_VERSION_MINOR "${CMAKE_MATCH_2}")
193+
set(QT_CREATOR_VERSION_PATCH "${CMAKE_MATCH_3}")
194+
195+
if(NOT version_match)
196+
message(FATAL_ERROR "Failed to parse Qt Creator version string: $ENV{QT_CREATOR_VERSION}")
197+
endif()
198+
190199
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
191200
execute_process(
192201
COMMAND "${{ matrix.config.environment_script }}" && set
@@ -223,6 +232,9 @@ jobs:
223232
--qt-path "${{ steps.qt.outputs.qt_dir }}"
224233
--qtc-path "${{ steps.qt_creator.outputs.qtc_dir }}"
225234
--output-path "$ENV{GITHUB_WORKSPACE}"
235+
--add-config=-DQODEASSIST_QT_CREATOR_VERSION_MAJOR=${QT_CREATOR_VERSION_MAJOR}
236+
--add-config=-DQODEASSIST_QT_CREATOR_VERSION_MINOR=${QT_CREATOR_VERSION_MINOR}
237+
--add-config=-DQODEASSIST_QT_CREATOR_VERSION_PATCH=${QT_CREATOR_VERSION_PATCH}
226238
RESULT_VARIABLE result
227239
)
228240
if (NOT result EQUAL 0)

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1313
find_package(QtCreator REQUIRED COMPONENTS Core)
1414
find_package(Qt6 COMPONENTS Core Gui Quick Widgets Network REQUIRED)
1515

16+
add_definitions(
17+
-DQODEASSIST_QT_CREATOR_VERSION_MAJOR=${QODEASSIST_QT_CREATOR_VERSION_MAJOR}
18+
-DQODEASSIST_QT_CREATOR_VERSION_MINOR=${QODEASSIST_QT_CREATOR_VERSION_MINOR}
19+
-DQODEASSIST_QT_CREATOR_VERSION_PATCH=${QODEASSIST_QT_CREATOR_VERSION_PATCH}
20+
)
21+
1622
add_subdirectory(llmcore)
1723
add_subdirectory(settings)
1824
add_subdirectory(logger)

Version.hpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (C) 2025 Povilas Kanapickas <[email protected]>
3+
*
4+
* This file is part of QodeAssist.
5+
*
6+
* QodeAssist is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* QodeAssist is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with QodeAssist. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
#pragma once
21+
22+
#include <QtGlobal>
23+
24+
#define QODEASSIST_QT_CREATOR_VERSION \
25+
QT_VERSION_CHECK( \
26+
QODEASSIST_QT_CREATOR_VERSION_MAJOR, \
27+
QODEASSIST_QT_CREATOR_VERSION_MINOR, \
28+
QODEASSIST_QT_CREATOR_VERSION_PATCH)

0 commit comments

Comments
 (0)