From 62e5e26b0ee7f50768317f6609b6c7122f7de3f1 Mon Sep 17 00:00:00 2001 From: Timo Bingmann Date: Sat, 21 Dec 2024 10:58:11 -0800 Subject: [PATCH] switch to CMake as build system and Woodpecker CI --- .travis.yml | 25 ------------- .woodpecker/build-test-mxe.yaml | 29 +++++++++++++++ .woodpecker/build-test.yaml | 38 ++++++++++++++++++++ CMakeLists.txt | 63 +++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 58 ++++++++++++++++++++++++++++++ 5 files changed, 188 insertions(+), 25 deletions(-) delete mode 100644 .travis.yml create mode 100644 .woodpecker/build-test-mxe.yaml create mode 100644 .woodpecker/build-test.yaml create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8ceb67abc..000000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: cpp - -branches: - only: - - master - -env: - global: - - CXXFLAGS="-W -Wall" - matrix: - # gcc builds - - BUILD_CC="gcc" BUILD_CXX="g++" - # clang builds - - BUILD_CC="clang" BUILD_CXX="clang++" - -install: - - sudo apt-get -qq update - - sudo apt-get install libsdl2-dev libwxgtk3.0-dev - -before_script: - - mkdir build && cd build && ../configure CC=$BUILD_CC CXX=$BUILD_CXX - -script: - - make - - make check diff --git a/.woodpecker/build-test-mxe.yaml b/.woodpecker/build-test-mxe.yaml new file mode 100644 index 000000000..6c47215c5 --- /dev/null +++ b/.woodpecker/build-test-mxe.yaml @@ -0,0 +1,29 @@ +when: + - event: pull_request + - event: manual + - event: push + repo: bingmann/sound-of-sorting + branch: master + +matrix: + include: + - IMAGE: mxe-24.04-1 + BUILD_TYPE: Release + C_COMPILER: gcc + CXX_COMPILER: g++ + CXX_FLAGS: + CMAKE_FLAGS: + +steps: + - name: build + image: docker.io/bingmann/dev:${IMAGE} + commands: + - /opt/mxe/usr/bin/i686-w64-mingw32.static-cmake --version + - mkdir build && cd build + - /opt/mxe/usr/bin/i686-w64-mingw32.static-cmake ${CMAKE_FLAGS} + -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" + -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" + -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" + -DCMAKE_C_COMPILER="${C_COMPILER}" + .. + - make VERBOSE=1 -j4 diff --git a/.woodpecker/build-test.yaml b/.woodpecker/build-test.yaml new file mode 100644 index 000000000..e13dde121 --- /dev/null +++ b/.woodpecker/build-test.yaml @@ -0,0 +1,38 @@ +when: + - event: pull_request + - event: manual + - event: push + repo: bingmann/sound-of-sorting + branch: master + +matrix: + include: + - IMAGE: ubuntu-24.04 + BUILD_TYPE: Debug + C_COMPILER: gcc + CXX_COMPILER: g++ + CXX_FLAGS: + CMAKE_FLAGS: + + - IMAGE: ubuntu-24.04 + BUILD_TYPE: Release + C_COMPILER: gcc + CXX_COMPILER: g++ + CXX_FLAGS: + CMAKE_FLAGS: + +steps: + - name: build + image: docker.io/bingmann/dev:${IMAGE} + commands: + - cmake --version + - mkdir build && cd build + - cmake ${CMAKE_FLAGS} + -G Ninja + -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" + -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" + -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" + -DCMAKE_C_COMPILER="${C_COMPILER}" + .. + - ninja + - ninja test diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..d2d7be067 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,63 @@ +############################################################################### +# CMakeLists.txt +# +# Build script for The Sound of Sorting +# +############################################################################### +# Copyright (C) 2024 Timo Bingmann +# +# This program is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . +############################################################################### + +cmake_minimum_required(VERSION 3.5) + +project(sound-of-sorting) + +add_definitions(-DPACKAGE_VERSION="0.7.0") + +# custom cmake scripts +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +# prohibit in-source builds +if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") + message(SEND_ERROR "In-source builds are not allowed.") +endif() + +# default to Debug building for single-config generators +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message("Defaulting CMAKE_BUILD_TYPE to Debug") + set(CMAKE_BUILD_TYPE "Debug") +endif() + +# enable warnings +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall") + +# enable use of "make test" +enable_testing() + +### Find wxGTK Libraries ### + +find_package(wxWidgets REQUIRED COMPONENTS adv core base) +if(wxWidgets_USE_FILE) + include(${wxWidgets_USE_FILE}) +endif() + +### Find SDL2 Libraries ### + +find_package(SDL2 REQUIRED) + +### Done with Libraries ### + +# descend into source +add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..c6879c54a --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,58 @@ +############################################################################### +# CMakeLists.txt +# +# Build script for The Sound of Sorting +# +############################################################################### +# Copyright (C) 2024 Timo Bingmann +# +# This program is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . +############################################################################### + +include_directories(${SDL2_INCLUDE_DIRS}) + +add_library(sorting-algorithms + SortAlgo.cpp + SortAlgo.h + SortArray.cpp + SortArray.h + SortSound.cpp + algorithms/timsort.cpp + algorithms/wikisort.cpp +) + +add_executable(sound-of-sorting + WMain.cpp + WMain.h + WSortView.cpp + WSortView.h + wxClickText.cpp + wxClickText.h + wxg/WAbout_wxg.cpp + wxg/WAbout_wxg.h + wxg/WMain_wxg.cpp + wxg/WMain_wxg.h +) + +target_link_libraries(sound-of-sorting + sorting-algorithms ${wxWidgets_LIBRARIES} ${SDL2_LIBRARIES}) + +add_executable(sorting-test + SortTest.cpp +) + +target_link_libraries(sorting-test + sorting-algorithms ${wxWidgets_LIBRARIES}) + +add_test(sorting-test sorting-test)