commit 4c1330e1942027577e9728b0daee766ad7663b1b
parent 6d9059656c08bff714b51d4ed0b56893d17b5d36
Author: cfillion <cfillion@users.noreply.github.com>
Date: Thu, 28 Nov 2019 11:17:02 -0500
Merge branch 'cmake'
Diffstat:
34 files changed, 721 insertions(+), 322 deletions(-)
diff --git a/.appveyor.yml b/.appveyor.yml
@@ -1,59 +1,99 @@
---
version: "{build}-{branch}"
-image:
- - &linux Ubuntu1804
- - &windows Visual Studio 2017
-platform:
- - x64
- - x86
+
before_build:
- curl -fsSL https://github.com/reaper-oss/sws/raw/master/reaper/reaper_plugin.h -o vendor/reaper_plugin.h
- curl -fsSL https://gist.github.com/cfillion/da355e8278048de08ae065d6fe6031c1/raw/reaper_plugin_functions.h -o vendor/reaper_plugin_functions.h
- git clone -q --depth 1 https://github.com/justinfrankel/WDL.git vendor/WDL
+
+test_script:
+ - cmake --build build --target test
+
for:
- - matrix: { only: [ image: *linux ] }
+ - matrix: { only: [ APPVEYOR_BUILD_WORKER_IMAGE: &linux Ubuntu1804 ] }
install:
- - sudo service docker start
- - docker run --name arch --rm --privileged -tidv `pwd`:/build -w /build
- -e CURLSO=:libcurl.so.3 archlinux/base
- - docker exec arch
- pacman -Syu --noconfirm boost catch2 gcc git libcurl-compat php tup wget
+ - sudo sed -i '/arch=/! s/^deb/deb [arch=amd64,i386]/' /etc/apt/sources.list
+ - |-
+ awk '
+ $3 !~ /ubuntu\.com/ { next }
+ $1 == "deb" {
+ $2 = "[arch=armhf,arm64]";
+ $3 = "http://ports.ubuntu.com/ubuntu-ports/"
+ } 1' /etc/apt/sources.list | sudo dd of=/etc/apt/sources.list.d/ports.list
+
+ - |-
+ install-libs() {
+ local arch="$1"; shift
+ local packages=(
+ libboost-dev libcurl4-openssl-dev libsqlite3-dev libssl-dev zlib1g-dev
+ )
+
+ sudo dpkg --add-architecture $arch && sudo apt-get update -qq &&
+ sudo apt-get install -qq --no-install-recommends "$@" ${packages[@]/%/:$arch}
+ }
- - if [[ "$PLATFORM" == "x86" ]]; then
- docker exec arch sh -c $'
- echo "[multilib]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf' &&
- docker exec arch
- pacman -Sy --noconfirm lib32-libcurl-compat lib32-gcc-libs lib32-sqlite;
- fi
- # HACK: tup needs a parent process to do setpgid successfully
- build_script: docker exec arch sh -c "echo tup $PLATFORM | sh"
- before_test:
- - if [[ "$PLATFORM" == "x86" ]]; then
- sudo apt-get update -qq;
- sudo apt-get install libcurl4:i386 -qq;
- fi
- test_script: '$PLATFORM/bin/test'
+ - |-
+ case $ARCH in
+ x86_64)
+ install-libs amd64
+ ;;
+ i686)
+ install-libs i386 g++-multilib &&
+ export TOOLCHAIN=cmake/linux-cross.cmake \
+ TOOLCHAIN_PREFIX=i386-linux-gnu
+ ;;
+ armv7l)
+ install-libs armhf g++-arm-linux-gnueabihf &&
+ export TOOLCHAIN=cmake/linux-cross.cmake \
+ TOOLCHAIN_PREFIX=arm-linux-gnueabihf
+ ;;
+ aarch64)
+ install-libs arm64 g++-aarch64-linux-gnu &&
+ export TOOLCHAIN=cmake/linux-cross.cmake \
+ TOOLCHAIN_PREFIX=aarch64-linux-gnu
+ ;;
+ esac
+
+ - sudo apt-get install -qq --no-install-recommends php qemu-user-binfmt
+
+ - git clone --depth 1 --branch v2.11.0 -c advice.detachedHead=false
+ https://github.com/catchorg/Catch2.git
+ - cmake Catch2 -B Catch2/build -DBUILD_TESTING=OFF
+ - sudo cmake --build Catch2/build --target install > /dev/null
+ build_script:
+ - cmake -B build
+ -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN
+ - cmake --build build
artifacts:
- - path: $(PLATFORM)/bin/reaper_reapack*.so
- - path: $(PLATFORM)/bin/test
+ - path: build/reaper_reapack*.so
- - matrix: { only: [ image: *windows ] }
+ - matrix: { only: [ APPVEYOR_BUILD_WORKER_IMAGE: &windows Visual Studio 2019 ] }
cache:
- C:\Tools\vcpkg\installed -> vendor\vcpkg-deps.txt
install:
- - curl -fsSL http://gittup.org/tup/win32/tup-explicit-variant-v0.7.3-45-gcf6a829.zip -o C:\Tools\tup.zip
- - 7z x C:\Tools\tup.zip -oC:\Tools\tup > NUL
- - set PATH=C:\Tools\tup;%PATH%
+ - set VCPKG_ROOT=C:\Tools\vcpkg
+ - set VCPKG_DEFAULT_TRIPLET=%ARCH%-windows-static
+ - set /p reapack-deps=<vendor\vcpkg-deps.txt
+ - vcpkg install %reapack-deps%
- - mklink /J vendor\vcpkg C:\Tools\vcpkg > NUL
- - set /p vcpkg-deps=<vendor\vcpkg-deps.txt
- - vcpkg install --triplet %PLATFORM%-windows-static %vcpkg-deps%
- build_script: tup %PLATFORM%
- test_script: '%PLATFORM%\bin\test'
+ - if "%ARCH%" == "x64" call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
+ - if "%ARCH%" == "x86" call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
+ build_script:
+ - cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
+ - cmake --build build
artifacts:
- - path: $(PLATFORM)\bin\reaper_reapack*.dll
- - path: $(PLATFORM)\bin\reaper_reapack*.pdb
- - path: $(PLATFORM)\bin\test.exe
+ - path: build\reaper_reapack*.dll
+ - path: build\reaper_reapack*.pdb
+
+environment:
+ matrix:
+ - { APPVEYOR_BUILD_WORKER_IMAGE: *windows, ARCH: x64 }
+ - { APPVEYOR_BUILD_WORKER_IMAGE: *windows, ARCH: x86 }
+ - { APPVEYOR_BUILD_WORKER_IMAGE: *linux, ARCH: x86_64 }
+ - { APPVEYOR_BUILD_WORKER_IMAGE: *linux, ARCH: i686 }
+ - { APPVEYOR_BUILD_WORKER_IMAGE: *linux, ARCH: armv7l }
+ - { APPVEYOR_BUILD_WORKER_IMAGE: *linux, ARCH: aarch64 }
+
deploy:
provider: GitHub
draft: true
diff --git a/.gitignore b/.gitignore
@@ -1,9 +1,2 @@
-/.tup/
-
-bin/
-build/
-resource.rc_mac*
-resource.res
-
-/vendor/*/
-/vendor/reaper_plugin*.h
+/build/
+/vendor
diff --git a/.travis.yml b/.travis.yml
@@ -1,18 +1,11 @@
---
-language: c++
+language: cpp
os: osx
-osx_image: xcode9.2 # 10.12 with custom kext loading allowed (for osxfuse)
+osx_image: xcode9.4 # macOS 10.13
env:
- - PLATFORM=x64
- - PLATFORM=x86
+ - ARCH=x86_64
+ - ARCH=i386
install:
- - brew update
- - brew cask install osxfuse
- - brew install llvm tup
- - export PATH="/usr/local/opt/llvm/bin:$PATH"
-
- - wget -nv https://github.com/catchorg/Catch2/raw/master/single_include/catch2/catch.hpp -P vendor/catch2
-
- wget -nv https://github.com/reaper-oss/sws/raw/master/reaper/reaper_plugin.h -P vendor
- wget -nv https://gist.github.com/cfillion/da355e8278048de08ae065d6fe6031c1/raw/reaper_plugin_functions.h -P vendor
- git clone -q --depth 1 https://github.com/justinfrankel/WDL.git vendor/WDL
@@ -23,7 +16,20 @@ install:
- curl -fsSL https://github.com/cfillion/WDL/commit/45ca4c819d4aaaed98540b8e5125085c05044786.patch | git -C vendor/WDL am
# SWELL: disable rich text in multiline textboxes on macOS
- curl -fsSL https://github.com/cfillion/WDL/commit/af9df173570edbb1d022045a7036d8d3296977b6.patch | git -C vendor/WDL am
-script: tup $PLATFORM && $PLATFORM/bin/test
+script:
+ - cmake -B build
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo
+ -DCMAKE_OSX_ARCHITECTURES="$ARCH"
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9
+ -DCMAKE_TOOLCHAIN_FILE=cmake/brew-llvm.cmake
+ - cmake --build build --target all test
+addons:
+ homebrew:
+ packages:
+ - catch2
+ - cmake
+ - llvm
+ update: true
deploy:
provider: releases
name: $TRAVIS_TAG
@@ -34,7 +40,7 @@ deploy:
skip_cleanup: true
api_key:
secure: O7kvtWqx0hsVzWev3qzNxf9CuctG76I7dXmn4IG10AFkKmot+QT9V1OARqLhOLj/QSuPWQY7X/hSPuSLqcRTweADWfOl7uKvBd38KKfEXSVfRNRgDzCTOKYmCUAzL3WFB5wGTWIP47/4GPAiqhtLriejbbMCcF6b4diZ3rD4rZN/4BI85wXh3mID0fD4i2cSzAx2ONn4I3xIAiRhigJQ0VRp3v4wMGB0hGPM3fRDMzDuGEMo3CAgyhO/ldh9QPOS4F5LNOM3prBSYmFaARQO46vmhF4hI+ydRZrntGhL5NryEtsZVqONv+Pq6z8TnCOH7uPYE9uHiU3K/s4XpYRdSMbrZfRylmTEo8p66KLjfDvMlMBmwmvsTIE8z/w9XuUskhSSq7eNYyX1QxaIiBh+o0ho/FIbLuEZK56dFCO/6yUY9LC23/+iMdPluMdQNzTPjvVqI1AnZQeBqQ2hZG9jp96Rblptz3lJFMDo3hoGNbPHE6iiCW7S0RvncGIRt5JL8BuQwyowIKqBg4eEx+74aYX7JvVLQpfzw9btr6f56k9N7OFP2tU2eNEnOWTjmkqsicU3nAp1Zji66+ncOhfJTJSIc5xNJGmVfRBSIAMYcjfo+1sxoM0NYyODXrwVt5rMUGdmuIutC7K8IcuCIOBTG924exXpBAcCYUaXd2iewss=
- file: 'x*/bin/reaper_reapack*.dylib'
+ file: build/reaper_reapack*.dylib
file_glob: true
on:
tags: true
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -0,0 +1,152 @@
+cmake_minimum_required(VERSION 3.15)
+
+if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
+ set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
+ CACHE STRING "")
+endif()
+
+if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
+ set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
+endif()
+
+project(reapack LANGUAGES C CXX)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ if(WIN32)
+ set(USER_CONFIG_DIR "$ENV{APPDATA}")
+ elseif(APPLE)
+ set(USER_CONFIG_DIR "~/Library/Application Support")
+ else()
+ set(USER_CONFIG_DIR "~/.config")
+ endif()
+
+ set(CMAKE_INSTALL_PREFIX "${USER_CONFIG_DIR}/REAPER" CACHE PATH
+ "REAPER resource path where to install ReaPack" FORCE)
+endif()
+
+if(CMAKE_OSX_ARCHITECTURES)
+ list(JOIN CMAKE_OSX_ARCHITECTURES "-" ARCH_NAME)
+elseif(MSVC_CXX_ARCHITECTURE_ID)
+ set(ARCH_NAME ${MSVC_CXX_ARCHITECTURE_ID})
+else()
+ set(ARCH_NAME ${CMAKE_SYSTEM_PROCESSOR})
+endif()
+
+STRING(TOLOWER "${ARCH_NAME}" ARCH_NAME)
+
+if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vendor/reaper_plugin.h")
+ message(FATAL_ERROR
+ "reaper_plugin.h cannot be found in ${CMAKE_CURRENT_SOURCE_DIR}/vendor.\n"
+
+ "The latest version can be downloaded from the SWS repository rather than "
+ "the REAPER SDK."
+ "https://github.com/reaper-oss/sws/raw/master/reaper/reaper_plugin.h"
+ )
+endif()
+
+if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vendor/reaper_plugin_functions.h")
+ message(FATAL_ERROR
+ "reaper_plugin_functions.h cannot be found in "
+ "${CMAKE_CURRENT_SOURCE_DIR}/vendor.\n"
+
+ "Generate it using the following REAPER action: "
+ "[developer] Write C++ API functions header."
+ )
+endif()
+
+set(CMAKE_CXX_EXTENSIONS OFF)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
+set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON)
+set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
+set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON)
+
+if(VCPKG_TOOLCHAIN)
+ set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL Release)
+ set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release)
+endif()
+
+if(WIN32)
+ add_compile_definitions(NOMINMAX UNICODE)
+
+ foreach(arg
+ CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG
+ CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
+ )
+ # Embed debug information in the object files
+ string(REGEX REPLACE "/Z[iI]" "/Z7" ${arg} "${${arg}}")
+ endforeach()
+
+ add_compile_options(
+ # Exception handling model
+ /EHsc
+
+ # Enhance optimized debugging
+ $<$<NOT:$<CONFIG:Debug>>:/Zo>
+
+ # Eliminate duplicate strings
+ $<$<NOT:$<CONFIG:Debug>>:/GF>
+
+ # Enable function-level linking
+ $<$<NOT:$<CONFIG:Debug>>:/Gy>
+
+ # Remove unreferenced COMDAT
+ $<$<NOT:$<CONFIG:Debug>>:/Zc:inline>
+ )
+
+ add_link_options(
+ # Remove unreferenced code
+ $<$<NOT:$<CONFIG:Debug>>:/OPT:REF>
+
+ # Remove duplicate sections
+ $<$<NOT:$<CONFIG:Debug>>:/OPT:ICF>
+
+ # Use relative path to the PDB file to avoid exposing the full path
+ /PDBALTPATH:%_PDB%
+ )
+else()
+ add_compile_options(-fstack-protector-strong -fdiagnostics-color)
+endif()
+
+find_package(Ruby)
+if(RUBY_FOUND)
+ add_custom_target(prepare
+ COMMAND ruby prepare.rb src/*.{{h,c}pp,mm}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+endif()
+
+add_library(reaper_reapack SHARED)
+
+set_target_properties(reaper_reapack PROPERTIES
+ PREFIX "" # disable the "lib" prefix
+ OUTPUT_NAME "reaper_reapack-${ARCH_NAME}"
+)
+
+add_subdirectory(src)
+add_subdirectory(test)
+
+target_link_libraries(reaper_reapack reapack)
+
+add_custom_target(test
+ COMMAND $<TARGET_FILE:tests>
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ USES_TERMINAL
+)
+
+add_dependencies(test tests)
+
+set(REAPER_USER_PLUGINS "UserPlugins")
+
+install(TARGETS reaper_reapack
+ COMPONENT ReaPack
+ RUNTIME DESTINATION "${REAPER_USER_PLUGINS}" # Windows .dll
+ LIBRARY DESTINATION "${REAPER_USER_PLUGINS}" # Linux .so/macOS .dylib
+)
diff --git a/Makefile b/Makefile
@@ -1,12 +0,0 @@
-.PHONY: all
-all:
- $(error Run 'tup' to build or 'make test' instead)
-
-.PHONY: prepare
-prepare:
- @ruby prepare.rb src/*.{{h,c}pp,mm}
-
-.PHONY: test
-test:
- -x64/bin/test
- -x86/bin/test
diff --git a/README.md b/README.md
@@ -4,25 +4,18 @@
[](https://travis-ci.com/cfillion/reapack)
[](https://www.paypal.com/cgi-bin/webscr?business=T3DEWBQJAV7WL&cmd=_donations¤cy_code=CAD&item_name=ReaPack%3A+Package+manager+for+REAPER)
-Visit the [ReaPack website](https://reapack.com/) for ready-to-use binaries
-and the user guide.
+Visit the [ReaPack website](https://reapack.com/) for ready-to-use binaries,
+the user guide or the package upload tool.
-## Compilation
+## Building from source
-The following section describes how to build ReaPack on your computer.
-The build system is based on [Tup](http://gittup.org/tup/).
-A modern compiler (gcc/clang/msvc) with C++17 support is needed.
+### Prerequisites
-By default the `tup` command triggers both the 64-bit and 32-bit builds.
-Use `tup x64` or `tup x86` to select a single architecture. Run the test suite
-with `make test`.
+Software requirements:
-The 64-bit and 32-bit binaries (such as `reaper_reapack64.so`) are created in
-`x64/bin` and `x86/bin` respectively. Copy or link the desired one into
-`<REAPER resource path>/UserPlugins` and restart REAPER to use it.
-
-Compiling ReaPack requires a few external libraries and files depending
-on the operating system.
+- [CMake](https://cmake.org/) 3.15 or newer
+- C++17 compiler (MSVC on Windows)
+- PHP (Linux and macOS only)
Put the REAPER extension SDK into the `vendor` directory:
@@ -33,59 +26,123 @@ Put the REAPER extension SDK into the `vendor` directory:
Clone [WDL](http://www.cockos.com/wdl/): `git clone https://github.com/justinfrankel/WDL.git vendor/WDL`
-### Linux
+#### Linux
-Install GCC/G++, tup, PHP and the development files for Boost (1.56 or later),
-Catch2, libcurl, SQLite3 and zlib matching the target architecture(s).
+Install the following libraries (and development headers if your system provides
+them separately):
-#### Custom compiler
+- [Boost](https://www.boost.org/) (1.56 or later)
+- [Catch2](https://github.com/catchorg/Catch2)
+- [libcurl](https://curl.haxx.se/libcurl/)
+- [OpenSSL](https://www.openssl.org/) or compatible
+- [SQLite](https://www.sqlite.org/)
+- [zlib](https://www.zlib.net/)
-Set the `CXX` environement variable to select a different compiler
-(default is `gcc` if unset).
+#### macOS
- CXX=gcc-8 tup x64
+Install Boost and Catch2 using [Homebrew](https://brew.sh) (recommended).
+The build tools can be installed using `xcode-select --install` or the Xcode IDE.
-#### Custom libcurl
+Apply these patches to WDL:
-Set the `CURLSO` environment variable to override the system default libcurl
-used for linking. Some older distributions still ship libcurl with the old
-pre-7.16 SONAME. Consider using a libcurl built with `--disable-versioned-symbols`
-to produce more compatible binaries (`libcurl-compat` on Arch Linux for example).
+- [optimize-listview-setitemtext](https://github.com/cfillion/WDL/commit/a6d7f802762e5e9d9833829bab83696e0db50de6.patch)
+- [resize-redraw-fix](https://github.com/cfillion/WDL/commit/45ca4c819d4aaaed98540b8e5125085c05044786.patch)
+- [richtext-off](https://github.com/cfillion/WDL/commit/af9df173570edbb1d022045a7036d8d3296977b6.patch)
- CURLSO=:libcurl.so.3 tup
+#### Windows
-### macOS
+MSVC can be installed with the [Build Tools for Visual Studio](
+https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools)
+or the Visual Studio IDE.
-Install Boost, tup and Xcode Command Line Tools. Using [Homebrew](http://brew.sh/):
+Use the x64 or x86 Native Tools Command Prompt for VS 20XX matching the target
+architecture when configuring or building ReaPack.
- xcode-select --install
- brew cask install osxfuse
- brew install boost tup
+Install [vcpkg](https://docs.microsoft.com/cpp/build/vcpkg) in any directory:
-Download the single header version of
-[Catch2](https://github.com/catchorg/Catch2) (catch.hpp) into `vendor/catch2`.
+ git clone https://github.com/Microsoft/vcpkg.git C:\path\to\vcpkg
+ C:\path\to\vcpkg\bootstrap-vcpkg.bat
-Apply these patches to WDL:
+Set the `VCPKG_ROOT` and `VCPKG_DEFAULT_TRIPLET` environment variables
+(only required when running `vcpkg install` or creating a new build tree):
-- [optimize-listview-setitemtext](https://github.com/cfillion/WDL/commit/a6d7f802762e5e9d9833829bab83696e0db50de6.patch)
-- [resize-redraw-fix](https://github.com/cfillion/WDL/commit/45ca4c819d4aaaed98540b8e5125085c05044786.patch)
-- [richtext-off](https://github.com/cfillion/WDL/commit/af9df173570edbb1d022045a7036d8d3296977b6.patch)
+ set VCPKG_ROOT=C:\path\to\vcpkg
+ set VCPKG_DEFAULT_TRIPLET=%PLATFORM%-windows-static
+
+Install ReaPack's build dependencies:
+
+ set /p reapack-deps=<vendor\vcpkg-deps.txt
+ %VCPKG_ROOT%\vcpkg install %reapack-deps%
+
+### Build configuration
+
+Create and configure a new build tree inside of the `build` directory.
+
+ cmake -B build -DCMAKE_BUILD_TYPE=Debug
+
+Using the [Ninja](https://ninja-build.org/) generator is recommended for
+best performances:
+
+ cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
+
+Alternatively, multiple build trees can be created if desired:
+
+ cmake -B build/debug -DCMAKE_BUILD_TYPE=Debug
+ cmake -B build/release -DCMAKE_BUILD_TYPE=Release
+ cmake -B build/portable -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+ -DCMAKE_INSTALL_PREFIX=/path/to/reaper/portable/install
+
+The vcpkg install is automatically detected and configured from the `VCPKG_ROOT`
+and `VCPKG_DEFAULT_TRIPLET` environment variables when creating a build tree on
+Windows.
+
+### Compile and install
+
+To compile a build tree:
+
+ cmake --build build
+
+To install ReaPack into your REAPER installation after building:
+
+ cmake --build build --target install
+
+The following targets are available:
+
+- **`all`**: Build ReaPack (default target)
+- **`clean`**: Delete all generated files
+ (can be run before building another target using `--clean-first`)
+- **`install`**: Build and install ReaPack into REAPER's resource directory
+ (as specified in `CMAKE_INSTALL_PREFIX`)
+- **`test`**: Build and run the test suite
+
+### Cross-compilation
+
+#### Linux
+
+`g++-$TOOLCHAIN_PREFIX` will be used when compiling for architectures other than
+i686. Libraries for the target architecture are expected to be in
+`/usr/{include,lib}/$TOOLCHAIN_PREFIX`, `/usr/$TOOLCHAIN_PREFIX/{include,lib}`
+or `/usr/lib32`.
+
+ ARCH=i686 TOOLCHAIN_PREFIX=i386-linux-gnu \
+ cmake -B build/i686 -DCMAKE_TOOLCHAIN_FILE=cmake/linux-cross.cmake
-### Windows
+ ARCH=armv7l TOOLCHAIN_PREFIX=arm-linux-gnueabihf \
+ cmake -B build/arm32 -DCMAKE_TOOLCHAIN_FILE=cmake/linux-cross.cmake
-Install tup ([explicit-variant](http://gittup.org/tup/win32/tup-explicit-variant-v0.7.3-45-gcf6a829.zip)
-branch, see [this thread](https://groups.google.com/d/topic/tup-users/UNUSE15PQdA/discussion))
-and [Visual Studio 2017 with C++ support](https://www.visualstudio.com/vs/community/).
+ ARCH=aarch64 TOOLCHAIN_PREFIX=aarch64-linux-gnu \
+ cmake -B build/arm64 -DCMAKE_TOOLCHAIN_FILE=cmake/linux-cross.cmake
-Clone [vcpkg](https://github.com/Microsoft/vcpkg) into `vendor` and install
-the build dependencies:
+#### macOS
- git clone https://github.com/Microsoft/vcpkg.git vendor\vcpkg
- vendor\vcpkg\bootstrap-vcpkg.bat
+macOS 10.14 or older, Xcode 9 and the latest Clang (`brew install llvm`) are
+required for producing 32-bit builds.
- set /p vcpkg-deps=<vendor\vcpkg-deps.txt
- vendor\vcpkg\vcpkg install --triplet x64-windows-static %vcpkg-deps%
- vendor\vcpkg\vcpkg install --triplet x86-windows-static %vcpkg-deps%
+ cmake -B build \
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+ -DCMAKE_OSX_ARCHITECTURES=i386 \
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
+ -DCMAKE_TOOLCHAIN_FILE=cmake/brew-llvm.cmake
## Support and feedback
@@ -94,4 +151,6 @@ Ask any ReaPack-releated questions in the
Questions related to development or packaging can be asked in the
[development thread](https://forum.cockos.com/showthread.php?t=169127).
-Report bugs or request features in the [issue tracker](https://github.com/cfillion/reapack/issues).
+Report bugs or request features in the
+[issue tracker](https://github.com/cfillion/reapack/issues).
+Send code contributions as pull requests.
diff --git a/Tupfile b/Tupfile
@@ -1,18 +0,0 @@
-WDL := vendor/WDL/WDL
-WDLSOURCE := $(WDL)/wingui/wndsize.cpp
-
-TINYXML := $(WDL)/tinyxml
-WDLSOURCE += $(TINYXML)/tinyxml.cpp $(TINYXML)/tinystr.cpp
-WDLSOURCE += $(TINYXML)/tinyxmlparser.cpp $(TINYXML)/tinyxmlerror.cpp
-
-ZLIB := $(WDL)/zlib
-WDLSOURCE += $(ZLIB)/zip.c $(ZLIB)/unzip.c $(ZLIB)/ioapi.c
-
-include @(TUP_PLATFORM).tup
-
-: foreach src/*.cpp | $(BUILDDEPS) |> !build $(SRCFLAGS) |> build/%B.o
-: foreach $(WDLSOURCE) |> !build $(WDLFLAGS) |> build/wdl_%B.o
-: build/*.o | $(LINKDEPS) |> !link $(SOFLAGS) |> $(SOTARGET)
-
-: foreach test/*.cpp |> !build -Isrc $(SRCFLAGS) $(TSTFLAGS) |> build/test/%B.o
-: build/*.o build/test/*.o | $(LINKDEPS) |> !link $(TSFLAGS) |> $(TSTARGET)
diff --git a/Tupfile.ini b/Tupfile.ini
diff --git a/cmake/FindMiniZip.cmake b/cmake/FindMiniZip.cmake
@@ -0,0 +1,28 @@
+if(MiniZip_FOUND)
+ return()
+endif()
+
+find_package(WDL REQUIRED)
+find_path(MiniZip_INCLUDE_DIR
+ NAMES unzip.h
+ PATHS ${WDL_DIR}
+ PATH_SUFFIXES zlib
+ NO_DEFAULT_PATH
+)
+mark_as_advanced(MiniZip_INCLUDE_DIR)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MiniZip REQUIRED_VARS MiniZip_INCLUDE_DIR)
+
+add_library(minizip
+ ${MiniZip_INCLUDE_DIR}/ioapi.c
+ ${MiniZip_INCLUDE_DIR}/unzip.c
+ ${MiniZip_INCLUDE_DIR}/zip.c
+)
+
+target_include_directories(minizip INTERFACE ${MiniZip_INCLUDE_DIR})
+
+find_package(ZLIB REQUIRED)
+target_link_libraries(minizip ZLIB::ZLIB)
+
+add_library(MiniZip::MiniZip ALIAS minizip)
diff --git a/cmake/FindPHP.cmake b/cmake/FindPHP.cmake
@@ -0,0 +1,19 @@
+find_program(PHP_EXECUTABLE php)
+mark_as_advanced(PHP_EXECUTABLE)
+
+execute_process(
+ COMMAND ${PHP_EXECUTABLE} -v
+ OUTPUT_VARIABLE PHP_VERSION_OUTPUT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+if(PHP_VERSION_OUTPUT MATCHES "PHP ([^ ]+) ")
+ set(PHP_VERSION "${CMAKE_MATCH_1}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(PHP
+ REQUIRED_VARS PHP_EXECUTABLE
+ VERSION_VAR PHP_VERSION
+)
diff --git a/cmake/FindSWELL.cmake b/cmake/FindSWELL.cmake
@@ -0,0 +1,55 @@
+if(WIN32 OR SWELL_FOUND)
+ return()
+endif()
+
+find_package(WDL REQUIRED)
+
+find_path(SWELL_INCLUDE_DIR
+ NAMES swell/swell.h
+ PATHS ${WDL_DIR}
+ NO_DEFAULT_PATH
+)
+mark_as_advanced(SWELL_INCLUDE_DIR)
+
+set(SWELL_DIR "${SWELL_INCLUDE_DIR}/swell")
+set(SWELL_RESGEN "${SWELL_DIR}/mac_resgen.php")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SWELL REQUIRED_VARS SWELL_DIR SWELL_INCLUDE_DIR)
+
+if(APPLE)
+ add_library(swell
+ ${SWELL_DIR}/swell.cpp
+ ${SWELL_DIR}/swell-ini.cpp
+ ${SWELL_DIR}/swell-miscdlg.mm
+ ${SWELL_DIR}/swell-gdi.mm
+ ${SWELL_DIR}/swell-kb.mm
+ ${SWELL_DIR}/swell-menu.mm
+ ${SWELL_DIR}/swell-misc.mm
+ ${SWELL_DIR}/swell-dlg.mm
+ ${SWELL_DIR}/swell-wnd.mm
+ )
+
+ target_compile_definitions(swell PRIVATE SWELL_APP_PREFIX=SWELL_REAPACK)
+ set_target_properties(swell PROPERTIES CXX_STANDARD 98)
+
+ find_library(COCOA Cocoa)
+ find_library(CARBON Carbon)
+ find_library(METAL Metal)
+ mark_as_advanced(COCOA CARBON METAL)
+ target_link_libraries(swell PUBLIC ${COCOA} ${CARBON})
+
+ if(METAL)
+ target_link_libraries(swell PUBLIC ${METAL})
+ else()
+ target_compile_definitions(swell PRIVATE SWELL_NO_METAL)
+ endif()
+else()
+ add_library(swell ${SWELL_DIR}/swell-modstub-generic.cpp)
+
+ target_compile_definitions(swell PUBLIC SWELL_PROVIDED_BY_APP)
+endif()
+
+target_include_directories(swell INTERFACE ${SWELL_INCLUDE_DIR})
+
+add_library(SWELL::swell ALIAS swell)
diff --git a/cmake/FindTinyXML.cmake b/cmake/FindTinyXML.cmake
@@ -0,0 +1,25 @@
+if(TinyXML_FOUND)
+ return()
+endif()
+
+find_package(WDL REQUIRED)
+
+find_path(TinyXML_INCLUDE_DIR
+ NAMES tinyxml.h
+ PATHS ${WDL_DIR}
+ PATH_SUFFIXES tinyxml
+ NO_DEFAULT_PATH
+)
+mark_as_advanced(TinyXML_INCLUDE_DIR)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(TinyXML REQUIRED_VARS TinyXML_INCLUDE_DIR)
+
+add_library(tinyxml
+ ${TinyXML_INCLUDE_DIR}/tinyxml.cpp ${TinyXML_INCLUDE_DIR}/tinystr.cpp
+ ${TinyXML_INCLUDE_DIR}/tinyxmlparser.cpp ${TinyXML_INCLUDE_DIR}/tinyxmlerror.cpp
+)
+
+target_include_directories(tinyxml INTERFACE ${TinyXML_INCLUDE_DIR})
+
+add_library(TinyXML::TinyXML ALIAS tinyxml)
diff --git a/cmake/FindWDL.cmake b/cmake/FindWDL.cmake
@@ -0,0 +1,27 @@
+if(WDL_FOUND)
+ return()
+endif()
+
+find_path(WDL_INCLUDE_DIR
+ NAMES WDL/wdltypes.h
+ PATHS ${CMAKE_SOURCE_DIR}/vendor/WDL
+ NO_DEFAULT_PATH
+)
+mark_as_advanced(WDL_INCLUDE_DIR)
+
+set(WDL_DIR "${WDL_INCLUDE_DIR}/WDL")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WDL REQUIRED_VARS WDL_DIR WDL_INCLUDE_DIR)
+
+add_library(wdl ${WDL_DIR}/wingui/wndsize.cpp)
+
+target_compile_definitions(wdl INTERFACE WDL_NO_DEFINE_MINMAX)
+target_include_directories(wdl INTERFACE ${WDL_INCLUDE_DIR})
+
+find_package(SWELL)
+if(SWELL_FOUND)
+ target_link_libraries(wdl SWELL::swell)
+endif()
+
+add_library(WDL::WDL ALIAS wdl)
diff --git a/cmake/brew-llvm.cmake b/cmake/brew-llvm.cmake
@@ -0,0 +1,3 @@
+set(CMAKE_C_COMPILER /usr/local/opt/llvm/bin/clang)
+set(CMAKE_CXX_COMPILER /usr/local/opt/llvm/bin/clang++)
+set(CMAKE_PREFIX_PATH /usr/local/opt/llvm)
diff --git a/cmake/linux-cross.cmake b/cmake/linux-cross.cmake
@@ -0,0 +1,22 @@
+if(NOT DEFINED ENV{ARCH})
+ message(FATAL_ERROR "The ARCH environment variable is not set.")
+endif()
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR $ENV{ARCH})
+
+if($ENV{ARCH} STREQUAL "i686")
+ set(CMAKE_C_FLAGS -m32)
+ set(CMAKE_CXX_FLAGS -m32)
+elseif(NOT DEFINED ENV{TOOLCHAIN_PREFIX})
+ message(FATAL_ERROR "The TOOLCHAIN_PREFIX environment variable is not set.")
+else()
+ set(CMAKE_C_COMPILER $ENV{TOOLCHAIN_PREFIX}-gcc)
+ set(CMAKE_CXX_COMPILER $ENV{TOOLCHAIN_PREFIX}-g++)
+endif()
+
+if(DEFINED ENV{TOOLCHAIN_PREFIX})
+ set(CMAKE_FIND_ROOT_PATH /usr/$ENV{TOOLCHAIN_PREFIX})
+ set(CMAKE_LIBRARY_PATH /usr/lib/$ENV{TOOLCHAIN_PREFIX})
+ set(CMAKE_INCLUDE_PATH /usr/include/$ENV{TOOLCHAIN_PREFIX})
+endif()
diff --git a/linux.tup b/linux.tup
@@ -1,35 +0,0 @@
-export CXX
-CXX := ${CXX:-gcc}
-
-REAPACK_FILE = reaper_reapack@(SUFFIX).so
-
-CXXFLAGS := -Wall -Wextra -Werror
-CXXFLAGS += -Wno-unused-parameter -Wno-missing-field-initializers
-CXXFLAGS += -Wno-unused-function -Wno-missing-braces
-CXXFLAGS += -fdiagnostics-color -fstack-protector-strong -fvisibility=hidden
-CXXFLAGS += -fdata-sections -ffunction-sections
-CXXFLAGS += -pipe -fPIC -O2 -m@(SUFFIX)
-CXXFLAGS += -Ivendor -Ivendor/WDL -Ivendor/WDL/WDL -Ivendor/WDL/WDL/swell
-CXXFLAGS += -DWDL_NO_DEFINE_MINMAX -DSWELL_PROVIDED_BY_APP -DSWELL_TARGET_GDK
-CXXFLAGS += -DREAPACK_FILE=\"$(REAPACK_FILE)\"
-
-SRCFLAGS := -std=c++17
-WDLFLAGS := -w
-
-SWELL := $(WDL)/swell
-WDLSOURCE += $(SWELL)/swell-modstub-generic.cpp
-
-export CURLSO
-LDFLAGS := -lstdc++ -lpthread -ldl -lcrypto -l${CURLSO:-curl} -lm -lsqlite3 -lz
-LDFLAGS += -Wl,--gc-sections
-
-SOFLAGS := -shared
-SOTARGET := bin/$(REAPACK_FILE)
-
-TSTARGET := bin/test
-
-!build = |> $(CXX) $(CXXFLAGS) -c %f -o %o |>
-!link = |> $(CXX) $(CXXFLAGS) %f $(LDFLAGS) -o %o |>
-
-BUILDDEPS := src/resource.rc_mac_menu src/resource.rc_mac_dlg
-: src/resource.rc |> php $(SWELL)/mac_resgen.php %f |> $(BUILDDEPS)
diff --git a/macosx.tup b/macosx.tup
@@ -1,41 +0,0 @@
-CXX := clang
-
-REAPACK_FILE = reaper_reapack@(SUFFIX).dylib
-
-CXXFLAGS := -Wall -Wextra -Werror
-CXXFLAGS += -Wno-unused-parameter -Wno-missing-field-initializers
-CXXFLAGS += -Wno-unused-function -Wno-unused-private-field -Wno-missing-braces
-CXXFLAGS += -fdiagnostics-color -fstack-protector-strong -fvisibility=hidden
-CXXFLAGS += -fdata-sections -ffunction-sections
-CXXFLAGS += -pipe -fPIC -O2 -arch @(ARCH) -mmacosx-version-min=10.7
-CXXFLAGS += -Ivendor -Ivendor/WDL -Ivendor/WDL/WDL -Ivendor/WDL/WDL/swell
-CXXFLAGS += -DWDL_NO_DEFINE_MINMAX -DSWELL_APP_PREFIX=SWELL_REAPACK
-CXXFLAGS += -DREAPACK_FILE=\"$(REAPACK_FILE)\"
-
-SRCFLAGS := -std=c++17 -stdlib=libc++
-WDLFLAGS := -w
-
-# std::uncaught_exceptions is unavailable prior to macOS 10.12
-TSTFLAGS := -DCATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
-
-SWELL := $(WDL)/swell
-WDLSOURCE += $(SWELL)/swell.cpp $(SWELL)/swell-ini.cpp $(SWELL)/swell-miscdlg.mm
-WDLSOURCE += $(SWELL)/swell-gdi.mm $(SWELL)/swell-kb.mm $(SWELL)/swell-menu.mm
-WDLSOURCE += $(SWELL)/swell-misc.mm $(SWELL)/swell-dlg.mm $(SWELL)/swell-wnd.mm
-
-LDFLAGS := -framework Cocoa -framework Carbon -lc++ -lcurl -lsqlite3 -lz
-LDFLAGS += -Wl,-dead_strip
-
-SOFLAGS := -dynamiclib
-SOTARGET := bin/$(REAPACK_FILE)
-
-TSTARGET := bin/test
-
-!build = |> $(CXX) $(CXXFLAGS) -c %f -o %o |>
-!link = |> $(CXX) $(CXXFLAGS) %f $(LDFLAGS) -o %o |>
-
-BUILDDEPS := src/resource.rc_mac_menu src/resource.rc_mac_dlg
-: src/resource.rc |> php $(SWELL)/mac_resgen.php %f |> $(BUILDDEPS)
-
-# build Objective-C files
-: foreach src/*.mm | $(BUILDDEPS) |> !build $(SRCFLAGS) |> build/%B_mm.o
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
@@ -0,0 +1,126 @@
+add_library(reapack OBJECT
+ about.cpp
+ action.cpp
+ api.cpp
+ api_misc.cpp
+ api_package.cpp
+ api_repo.cpp
+ archive.cpp
+ archive_tasks.cpp
+ browser.cpp
+ browser_entry.cpp
+ config.cpp
+ control.cpp
+ database.cpp
+ dialog.cpp
+ download.cpp
+ event.cpp
+ filedialog.cpp
+ filesystem.cpp
+ filter.cpp
+ hash.cpp
+ iconlist.cpp
+ import.cpp
+ index.cpp
+ index_v1.cpp
+ install.cpp
+ listview.cpp
+ main.cpp
+ manager.cpp
+ menu.cpp
+ metadata.cpp
+ obsquery.cpp
+ package.cpp
+ path.cpp
+ platform.cpp
+ progress.cpp
+ reapack.cpp
+ receipt.cpp
+ registry.cpp
+ remote.cpp
+ report.cpp
+ resource.rc
+ serializer.cpp
+ source.cpp
+ string.cpp
+ synchronize.cpp
+ tabbar.cpp
+ task.cpp
+ thread.cpp
+ time.cpp
+ transaction.cpp
+ version.cpp
+ win32.cpp
+)
+
+if(APPLE)
+ target_sources(reapack PRIVATE richedit.mm)
+elseif(WIN32)
+ target_sources(reapack PRIVATE richedit-win32.cpp)
+else()
+ target_sources(reapack PRIVATE richedit-gtk.cpp)
+endif()
+
+target_compile_features(reapack PUBLIC cxx_std_17)
+
+target_compile_definitions(reapack PRIVATE
+ REAPACK_FILE="$<TARGET_FILE_NAME:reaper_reapack>"
+)
+
+target_include_directories(reapack PRIVATE
+ ${CMAKE_SOURCE_DIR}/vendor ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+if(WIN32)
+ target_compile_options(reapack PUBLIC /W3 /WX /wd4996)
+ target_link_libraries(reapack Bcrypt Comctl32 Comdlg32 Gdi32 Shell32 User32)
+else()
+ target_compile_options(reapack PUBLIC
+ -Wall -Wextra -Werror
+ -Wno-unused-parameter -Wno-missing-field-initializers
+ -Wno-unused-function -Wno-missing-braces
+ )
+endif()
+
+find_package(Boost 1.56 REQUIRED)
+find_package(CURL REQUIRED)
+find_package(MiniZip REQUIRED)
+find_package(Threads REQUIRED)
+find_package(TinyXML REQUIRED)
+find_package(WDL REQUIRED)
+
+target_link_libraries(reapack
+ ${CMAKE_DL_LIBS} Boost::headers CURL::libcurl MiniZip::MiniZip
+ Threads::Threads TinyXML::TinyXML WDL::WDL
+)
+
+if(VCPKG_TOOLCHAIN)
+ # for selecting the right debug or release version
+ find_package(SQLite3 CONFIG REQUIRED)
+ target_link_libraries(reapack sqlite3)
+else()
+ find_package(SQLite3 REQUIRED)
+ target_link_libraries(reapack SQLite::SQLite3)
+endif()
+
+if(NOT APPLE AND NOT WIN32)
+ find_package(OpenSSL REQUIRED COMPONENTS Crypto)
+ target_link_libraries(reapack OpenSSL::Crypto)
+endif()
+
+find_package(SWELL)
+if(SWELL_FOUND)
+ target_link_libraries(reapack SWELL::swell)
+
+ find_package(PHP REQUIRED)
+
+ # Transpile the Win32 resource file
+ add_custom_command(
+ OUTPUT resource.rc_mac_dlg resource.rc_mac_menu
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/resource.rc ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${PHP_EXECUTABLE} ${SWELL_RESGEN} resource.rc
+ DEPENDS ${SWELL_RESGEN}
+ MAIN_DEPENDENCY resource.rc
+ )
+endif()
diff --git a/src/archive.cpp b/src/archive.cpp
@@ -30,9 +30,9 @@
#include <iomanip>
#include <sstream>
-#include <zlib/zip.h>
-#include <zlib/unzip.h>
-#include <zlib/ioapi.h>
+#include <zip.h>
+#include <unzip.h>
+#include <ioapi.h>
static const Path ARCHIVE_TOC("toc");
static const size_t BUFFER_SIZE = 4096;
diff --git a/src/dialog.hpp b/src/dialog.hpp
@@ -27,8 +27,8 @@
#include <vector>
#include <reaper_plugin.h>
-#include <wdltypes.h>
-#include <wingui/wndsize.h>
+#include <WDL/wdltypes.h>
+#include <WDL/wingui/wndsize.h>
class Control;
diff --git a/src/filedialog.cpp b/src/filedialog.cpp
@@ -21,7 +21,7 @@
#include "win32.hpp"
#ifndef _WIN32
-# include <swell.h>
+# include <swell/swell.h>
#endif
#ifdef _WIN32
diff --git a/src/iconlist.hpp b/src/iconlist.hpp
@@ -26,7 +26,7 @@
# include <windows.h>
# include <commctrl.h>
#else
-# include <swell.h>
+# include <swell/swell.h>
#endif
class IconList {
diff --git a/src/index.cpp b/src/index.cpp
@@ -22,7 +22,7 @@
#include "path.hpp"
#include "remote.hpp"
-#include <WDL/tinyxml/tinyxml.h>
+#include <tinyxml.h>
Path Index::pathFor(const std::string &name)
{
diff --git a/src/index_v1.cpp b/src/index_v1.cpp
@@ -20,7 +20,7 @@
#include "errors.hpp"
#include <sstream>
-#include <WDL/tinyxml/tinyxml.h>
+#include <tinyxml.h>
static void LoadMetadataV1(TiXmlElement *, Metadata *);
static void LoadCategoryV1(TiXmlElement *, Index *);
diff --git a/src/menu.cpp b/src/menu.cpp
@@ -24,7 +24,7 @@
#endif
#ifndef _WIN32
-# include <swell.h>
+# include <swell/swell.h>
#endif
#include <reaper_plugin_functions.h>
diff --git a/src/menu.hpp b/src/menu.hpp
@@ -23,7 +23,7 @@
#ifdef _WIN32
# include <windows.h>
#else
-# include <swell-types.h>
+# include <swell/swell-types.h>
#endif
class Menu {
diff --git a/src/richedit-gtk.cpp b/src/richedit-gtk.cpp
@@ -17,9 +17,7 @@
#include "richedit.hpp"
-#ifdef SWELL_TARGET_GDK
-
-// Starting here and onward is the Linux implementation of RichEdit
+// This is the Linux implementation of RichEdit
// See also richedit.mm and richedit-win32.cpp
void RichEdit::Init()
@@ -48,5 +46,3 @@ bool RichEdit::setRichText(const std::string &)
{
return false;
}
-
-#endif
diff --git a/src/richedit-win32.cpp b/src/richedit-win32.cpp
@@ -17,9 +17,7 @@
#include "richedit.hpp"
-#ifdef _WIN32
-
-// Starting here and onward is the Win32 implementation of RichEdit
+// This is the Win32 implementation of RichEdit
// The macOS implementation is in richedit.mm, Linux is in richedit-gtk.cpp
#include "win32.hpp"
@@ -101,4 +99,3 @@ bool RichEdit::setRichText(const std::string &rtf)
return true;
}
-#endif
diff --git a/src/win32.hpp b/src/win32.hpp
@@ -27,7 +27,7 @@
# include <windows.h>
#else
# define L(str) str
-# include <swell-types.h>
+# include <swell/swell-types.h>
#endif
namespace Win32 {
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
@@ -0,0 +1,39 @@
+add_executable(tests EXCLUDE_FROM_ALL
+ action.cpp
+ api.cpp
+ database.cpp
+ event.cpp
+ filesystem.cpp
+ filter.cpp
+ hash.cpp
+ helper.cpp
+ helper.hpp
+ index.cpp
+ index_v1.cpp
+ main.cpp
+ metadata.cpp
+ package.cpp
+ path.cpp
+ platform.cpp
+ receipt.cpp
+ registry.cpp
+ remote.cpp
+ serializer.cpp
+ source.cpp
+ string.cpp
+ time.cpp
+ version.cpp
+ win32.cpp
+)
+
+# std::uncaught_exceptions is unavailable prior to macOS 10.12
+target_compile_definitions(tests PRIVATE CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS)
+
+target_include_directories(tests PRIVATE
+ ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/vendor
+)
+
+find_package(Catch2 REQUIRED)
+mark_as_advanced(Catch2_DIR)
+
+target_link_libraries(tests Catch2::Catch2 reapack)
diff --git a/win32.tup b/win32.tup
@@ -1,39 +0,0 @@
-# wrapper.bat selects which compiler to execute depending on the architecture
-export ProgramData
-export ProgramFiles(x86)
-WRAP := cmd /C wrapper.bat @(ARCH)
-
-CXX := $(WRAP) cl
-
-REAPACK_FILE := reaper_reapack@(SUFFIX)
-
-VCPKG = vendor/vcpkg/installed/@(VCPKG_TRIPLET)
-
-CXXFLAGS := /nologo /std:c++17 /W3 /WX /wd4996 /EHsc /MT /O2 /Z7 /Zo
-CXXFLAGS += /Ivendor /I$(VCPKG)/include /Ivendor/WDL /Ivendor/WDL/WDL
-CXXFLAGS += /DNOMINMAX /DWDL_NO_DEFINE_MINMAX /DCURL_STATICLIB /DUNICODE
-CXXFLAGS += /DNDEBUG /DREAPACK_FILE#\"$(REAPACK_FILE).dll\"
-
-LD := $(WRAP) link
-LDFLAGS := /nologo User32.lib Shell32.lib Gdi32.lib Comdlg32.lib Comctl32.lib Bcrypt.lib
-LDFLAGS += $(VCPKG)/lib/libcurl.lib Ws2_32.lib Wldap32.lib Crypt32.lib Advapi32.lib
-LDFLAGS += $(VCPKG)/lib/sqlite3.lib $(VCPKG)/lib/zlib.lib
-LDFLAGS += $(TUP_VARIANTDIR)/src/resource.res
-LDFLAGS += /DEBUG /OPT:REF /PDBALTPATH:%_PDB%
-
-LINKDEPS := src/resource.res
-
-RC := $(WRAP) rc
-RCFLAGS += /nologo /fo $(TUP_VARIANTDIR)/src/resource.res
-
-TARGET := bin/$(REAPACK_FILE)
-SOFLAGS := /DLL /OUT:$(TUP_VARIANTDIR)/$(TARGET).dll
-SOTARGET := $(TARGET).dll $(TARGET).lib $(TARGET).exp $(TARGET).pdb
-
-TSFLAGS := /OUT:$(TUP_VARIANTDIR)/bin/test.exe
-TSTARGET := bin/test.exe bin/test.lib bin/test.exp bin/test.pdb
-
-!build = |> $(CXX) $(CXXFLAGS) /c %f /Fo%o |>
-!link = |> $(LD) $(LDFLAGS) %f |>
-
-: src/resource.rc |> $(RC) $(RCFLAGS) %f |> src/resource.res
diff --git a/wrapper.bat b/wrapper.bat
@@ -1,37 +0,0 @@
-@echo off
-setlocal
-
-set arch=%1%
-set program=%2%
-set args=
-
-:next_arg
-if "%3%"=="" goto continue
-set args=%args% %3%
-shift
-goto next_arg
-:continue
-
-if defined VCtupINSTALLDIR (
- set ENVTOOLS=%VCINSTALLDIR%\Auxiliary\Build
-) else (
- rem https://github.com/Microsoft/vswhere
- for /f "usebackq tokens=*" %%i in (
- `"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
- -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
- -property installationPath`) do (
- set ENVTOOLS=%%i\VC\Auxiliary\Build
- )
-)
-
-if "%arch%"=="x86_64" (
- call "%ENVTOOLS%\vcvars64.bat" > NUL
-) else ( if "%arch%"=="i386" (
- rem Using the x86 64-bit cross-compiler to avoid conflicts on the pdb file with tup
- call "%ENVTOOLS%\vcvarsamd64_x86.bat" > NUL
-) else (
- echo Unknown Architecture: %arch%
- exit /b 42
-))
-
-"%program%" %args%
diff --git a/x64/tup.config b/x64/tup.config
@@ -1,3 +0,0 @@
-CONFIG_ARCH=x86_64
-CONFIG_SUFFIX=64
-CONFIG_VCPKG_TRIPLET=x64-windows-static
diff --git a/x86/tup.config b/x86/tup.config
@@ -1,3 +0,0 @@
-CONFIG_ARCH=i386
-CONFIG_SUFFIX=32
-CONFIG_VCPKG_TRIPLET=x86-windows-static