Skip to content

Commit

Permalink
Merge pull request #5 from yousefvand/dev
Browse files Browse the repository at this point in the history
saving progress
  • Loading branch information
yousefvand authored Sep 29, 2024
2 parents 758f107 + 6f0a72b commit 56d5144
Show file tree
Hide file tree
Showing 35 changed files with 1,405 additions and 717 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/cmake-multi-platform.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
Expand All @@ -16,8 +14,6 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
Expand All @@ -28,26 +24,42 @@ jobs:
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

steps:
- uses: actions/checkout@v4

# Install dependencies for Ubuntu
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev ninja-build

# Install dependencies for macOS
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: brew install ninja

# Set up MSVC on Windows
- name: Set up MSVC (Windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
# Set reusable strings
- name: Set reusable strings
id: strings
shell: bash
run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

# Configure CMake
- name: Configure CMake
run: |
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
Expand All @@ -57,11 +69,13 @@ jobs:
-G "Ninja" \
-S ${{ github.workspace }}
# Build the project
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

# Run tests
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
env:
DISPLAY: ':0' # Necessary for GUI tests on Ubuntu
run: ctest --build-config ${{ matrix.build_type }}
run: ctest --output-on-failure --build-config ${{ matrix.build_type }}
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .vscode/settings.json
100644 → 100755
Empty file.
93 changes: 35 additions & 58 deletions CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,86 +6,63 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
# Use C++20 standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
# Find Qt6 libraries
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets LinguistTools)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Concurrent)

set(TS_FILES Notepad--_en_GB.ts)
# Translation file path in 'translations' folder
set(TS_FILES translations/Notepad--_en_GB.ts)

# Project sources, organized under 'src' and 'src/languages' folders
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
document.cpp
document.h
languages/cppsyntaxhighlighter.cpp
languages/cppsyntaxhighlighter.h
languages/pythonsyntaxhighlighter.cpp
languages/pythonsyntaxhighlighter.h
languages/languagemanager.cpp
languages/languagemanager.h
${TS_FILES}
src/main.cpp
src/mainwindow.cpp
src/mainwindow.h
src/mainwindow.ui
src/document.cpp
src/document.h
src/codeeditor.cpp
src/codeeditor.h
src/languages/cppsyntaxhighlighter.cpp
src/languages/cppsyntaxhighlighter.h
src/languages/pythonsyntaxhighlighter.cpp
src/languages/pythonsyntaxhighlighter.h
src/languages/languagemanager.cpp
src/languages/languagemanager.h
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(Notepad--
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET Notepad-- APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
# Add executable for Qt6
qt_add_executable(Notepad--
MANUAL_FINALIZATION
${PROJECT_SOURCES}
src/fileloaderworker.h src/fileloaderworker.cpp

qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
if(ANDROID)
add_library(Notepad-- SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(Notepad--
${PROJECT_SOURCES}
codeeditor.h
codeeditor.cpp
languages/pythonsyntaxhighlighter.h languages/pythonsyntaxhighlighter.cpp
)
endif()

qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
)

# Link necessary Qt6 libraries
target_link_libraries(Notepad--
PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent)
PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Concurrent
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.Notepad--)
endif()
# Set target properties for macOS/iOS
set_target_properties(Notepad-- PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)

# Installation setup
include(GNUInstallDirs)
install(TARGETS Notepad--
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(Notepad--)
endif()
# Finalize executable for Qt6
qt_finalize_executable(Notepad--)
Loading

0 comments on commit 56d5144

Please sign in to comment.