Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
darktorres committed Feb 9, 2025
1 parent 0c709e5 commit 1e8484e
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
# =================================

runs-on: ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
# =================================

runs-on: ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name

steps:
- uses: actions/checkout@v4
Expand Down
45 changes: 24 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project(wiredpanda VERSION 4.2.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
Expand All @@ -11,19 +12,16 @@ set(CMAKE_AUTORCC ON)
find_package(Qt6 6.2 QUIET COMPONENTS Core Gui PrintSupport Multimedia Widgets Svg Test)
if(Qt6_FOUND)
set(QT_VERSION_MAJOR 6)
set(QT_DIR ${Qt6_DIR})
set(QT_LIBS Qt6::Core Qt6::Gui Qt6::PrintSupport Qt6::Multimedia Qt6::Widgets Qt6::Svg Qt6::Test)
else()
find_package(Qt5 5.12 REQUIRED COMPONENTS Core Gui PrintSupport Multimedia Widgets Svg Test)
set(QT_VERSION_MAJOR 5)
set(QT_DIR ${Qt5_DIR})
set(QT_LIBS Qt5::Core Qt5::Gui Qt5::PrintSupport Qt5::Multimedia Qt5::Widgets Qt5::Svg Qt5::Test)
endif()

if(QT_VERSION_MAJOR EQUAL 5 AND Qt5_VERSION VERSION_LESS 5.12)
message(FATAL_ERROR "Qt 5.12 or newer is required.")
elseif(QT_VERSION_MAJOR EQUAL 6 AND Qt6_VERSION VERSION_LESS 6.2)
message(FATAL_ERROR "For Qt6, the minimum version is 6.2.0.")
if((QT_VERSION_MAJOR EQUAL 5 AND Qt5_VERSION VERSION_LESS 5.12) OR
(QT_VERSION_MAJOR EQUAL 6 AND Qt6_VERSION VERSION_LESS 6.2))
message(FATAL_ERROR "Minimum required Qt version is 5.12 for Qt5 or 6.2 for Qt6.")
endif()

add_compile_definitions(
Expand All @@ -33,20 +31,26 @@ add_compile_definitions(
QT_MESSAGELOGCONTEXT
)

if (MSVC)
add_compile_options(/W4 /external:I ${QT_DIR} /external:W0 /permissive-)
if(MSVC)
add_compile_options(/W4 /external:W0 /permissive-)
else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_program(CCACHE_BIN ccache)
find_program(MOLD_BIN mold)
if(MOLD_BIN)
add_link_options("-fuse-ld=mold")
endif()

if(CCACHE_BIN)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_BIN})
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_BIN})
if(NOT MSVC)
find_program(CCACHE_BIN ccache)
if(CCACHE_BIN)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_BIN})
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_BIN})
endif()
endif()

if (QT_VERSION_MAJOR EQUAL 5)
if(QT_VERSION_MAJOR EQUAL 5)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
else()
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
Expand All @@ -71,15 +75,10 @@ include_directories(

# ========= LIB ===================================

add_library(wiredpanda_lib STATIC
${SOURCES}
${HEADERS}
${FORMS}
)

add_library(wiredpanda_lib STATIC ${SOURCES} ${HEADERS} ${FORMS})
target_link_libraries(wiredpanda_lib PUBLIC ${QT_LIBS})

if(MSVC)
if(NOT CCACHE_BIN)
target_precompile_headers(wiredpanda_lib PRIVATE pch.h)
endif()

Expand All @@ -88,6 +87,10 @@ endif()
add_executable(wiredpanda app/main.cpp ${RESOURCES_RCC})
target_link_libraries(wiredpanda PRIVATE wiredpanda_lib)

if(NOT CCACHE_BIN)
target_precompile_headers(wiredpanda PRIVATE pch.h)
endif()

if(WIN32)
set(WINDOWS_APP_NAME "wiRedPanda - Logic Circuit Simulator")
set(RC_FILE "resources/wpanda.ico")
Expand All @@ -111,6 +114,6 @@ add_executable(test ${TEST_SOURCES} ${TEST_HEADERS} ${RESOURCES_RCC})
target_link_libraries(test PRIVATE wiredpanda_lib)
target_compile_definitions(test PRIVATE CURRENTDIR=${CMAKE_CURRENT_SOURCE_DIR}/test)

if(MSVC)
if(NOT CCACHE_BIN)
target_precompile_headers(test PRIVATE pch.h)
endif()
2 changes: 1 addition & 1 deletion app/arduino/codegenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <QRegularExpression>

#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
#define endl Qt::endl
#endif

Expand Down
6 changes: 3 additions & 3 deletions app/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Q_DECLARE_LOGGING_CATEGORY(five)
#undef qCDebug // to add noquote() and nospace()

#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0)
#define qCDebug(category, ...) \
#define qCDebug(category) \
for (bool qt_category_enabled = category().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).debug(__VA_ARGS__).noquote().nospace()
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).debug().noquote().nospace()
#else
#define qCDebug(category, ...) QT_MESSAGE_LOGGER_COMMON(category, QtDebugMsg).debug(__VA_ARGS__).noquote().nospace()
#define qCDebug(category) QT_MESSAGE_LOGGER_COMMON(category, QtDebugMsg).debug().noquote().nospace()
#endif

class Comment
Expand Down
10 changes: 8 additions & 2 deletions app/graphicelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ void GraphicElement::loadNewFormat(QDataStream &stream, QMap<quint64, QNEPort *>
++skin;
}

m_usingDefaultSkin = (m_defaultSkins == m_alternativeSkins);
m_usingDefaultSkin = std::equal(
m_defaultSkins.begin(), m_defaultSkins.end(),
m_alternativeSkins.begin(), m_alternativeSkins.end()
);

refresh();
}
Expand Down Expand Up @@ -542,7 +545,10 @@ void GraphicElement::loadPixmapSkinNames(QDataStream &stream, const QVersionNumb
loadPixmapSkinName(stream, static_cast<int>(skin));
}

m_usingDefaultSkin = (m_defaultSkins == m_alternativeSkins);
m_usingDefaultSkin = std::equal(
m_defaultSkins.begin(), m_defaultSkins.end(),
m_alternativeSkins.begin(), m_alternativeSkins.end()
);

refresh();
}
Expand Down
2 changes: 2 additions & 0 deletions config.pri
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ msvc {
QMAKE_CXXFLAGS_DEBUG += /Ob1
QMAKE_CXXFLAGS_RELEASE += /GL
QMAKE_LFLAGS_RELEASE += /LTCG
} else {
QMAKE_CXXFLAGS += -Wall -Wextra -Wpedantic
}

mac {
Expand Down

0 comments on commit 1e8484e

Please sign in to comment.