Skip to content

Commit e182d7a

Browse files
committed
migrate the build system to CMake
1 parent 6d90596 commit e182d7a

33 files changed

+648
-320
lines changed

.appveyor.yml

+46-38
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,67 @@
11
---
22
version: "{build}-{branch}"
3-
image:
4-
- &linux Ubuntu1804
5-
- &windows Visual Studio 2017
6-
platform:
7-
- x64
8-
- x86
3+
94
before_build:
105
- curl -fsSL https://github.com/reaper-oss/sws/raw/master/reaper/reaper_plugin.h -o vendor/reaper_plugin.h
116
- curl -fsSL https://gist.github.com/cfillion/da355e8278048de08ae065d6fe6031c1/raw/reaper_plugin_functions.h -o vendor/reaper_plugin_functions.h
127
- git clone -q --depth 1 https://github.com/justinfrankel/WDL.git vendor/WDL
8+
139
for:
14-
- matrix: { only: [ image: *linux ] }
10+
- matrix: { only: [ APPVEYOR_BUILD_WORKER_IMAGE: &linux Ubuntu1804 ] }
1511
install:
16-
- sudo service docker start
17-
- docker run --name arch --rm --privileged -tidv `pwd`:/build -w /build
18-
-e CURLSO=:libcurl.so.3 archlinux/base
19-
- docker exec arch
20-
pacman -Syu --noconfirm boost catch2 gcc git libcurl-compat php tup wget
12+
- if [[ "$ARCH" == "i686" ]]; then
13+
export CFLAGS=-m32 CXXFLAGS=-m32;
14+
fi
15+
16+
- docker run --name arch --rm -tid -v `pwd`:/src -w /src
17+
-e CFLAGS -e CXXFLAGS -e CLICOLOR_FORCE=1 archlinux/base
18+
- export RUN="docker exec arch setarch $ARCH"
2119

22-
- if [[ "$PLATFORM" == "x86" ]]; then
23-
docker exec arch sh -c $'
20+
- $RUN
21+
pacman -Syu --noconfirm base-devel boost catch2 cmake gcc git php wget
22+
23+
- |-
24+
if [[ "$ARCH" == "i686" ]]; then
25+
$RUN sh -c $'
2426
echo "[multilib]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf' &&
25-
docker exec arch
26-
pacman -Sy --noconfirm lib32-libcurl-compat lib32-gcc-libs lib32-sqlite;
27-
fi
28-
# HACK: tup needs a parent process to do setpgid successfully
29-
build_script: docker exec arch sh -c "echo tup $PLATFORM | sh"
30-
before_test:
31-
- if [[ "$PLATFORM" == "x86" ]]; then
32-
sudo apt-get update -qq;
33-
sudo apt-get install libcurl4:i386 -qq;
27+
$RUN \
28+
pacman -Sy --noconfirm lib32-libcurl lib32-gcc-libs lib32-sqlite
3429
fi
35-
test_script: '$PLATFORM/bin/test'
30+
build_script:
31+
- $RUN cmake -B build -DCMAKE_BUILD_TYPE=Release
32+
- $RUN cmake --build build
33+
test_script:
34+
- $RUN cmake --build build --target test
3635
artifacts:
37-
- path: $(PLATFORM)/bin/reaper_reapack*.so
38-
- path: $(PLATFORM)/bin/test
36+
- path: build/reaper_reapack*.so
3937

40-
- matrix: { only: [ image: *windows ] }
38+
- matrix: { only: [ APPVEYOR_BUILD_WORKER_IMAGE: &windows Visual Studio 2019 ] }
4139
cache:
4240
- C:\Tools\vcpkg\installed -> vendor\vcpkg-deps.txt
4341
install:
44-
- curl -fsSL http://gittup.org/tup/win32/tup-explicit-variant-v0.7.3-45-gcf6a829.zip -o C:\Tools\tup.zip
45-
- 7z x C:\Tools\tup.zip -oC:\Tools\tup > NUL
46-
- set PATH=C:\Tools\tup;%PATH%
42+
- set VCPKG_ROOT=C:\Tools\vcpkg
43+
- set VCPKG_DEFAULT_TRIPLET=%ARCH%-windows-static
44+
- set /p reapack-deps=<vendor\vcpkg-deps.txt
45+
- vcpkg install %reapack-deps%
4746

48-
- mklink /J vendor\vcpkg C:\Tools\vcpkg > NUL
49-
- set /p vcpkg-deps=<vendor\vcpkg-deps.txt
50-
- vcpkg install --triplet %PLATFORM%-windows-static %vcpkg-deps%
51-
build_script: tup %PLATFORM%
52-
test_script: '%PLATFORM%\bin\test'
47+
- if "%ARCH%" == "x64" call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
48+
- if "%ARCH%" == "x86" call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
49+
build_script:
50+
- cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
51+
- cmake --build build
52+
test_script:
53+
- cmake --build build --target test
5354
artifacts:
54-
- path: $(PLATFORM)\bin\reaper_reapack*.dll
55-
- path: $(PLATFORM)\bin\reaper_reapack*.pdb
56-
- path: $(PLATFORM)\bin\test.exe
55+
- path: build\reaper_reapack*.dll
56+
- path: build\reaper_reapack*.pdb
57+
58+
environment:
59+
matrix:
60+
- { APPVEYOR_BUILD_WORKER_IMAGE: *windows, ARCH: x64 }
61+
- { APPVEYOR_BUILD_WORKER_IMAGE: *windows, ARCH: x86 }
62+
- { APPVEYOR_BUILD_WORKER_IMAGE: *linux, ARCH: x86_64 }
63+
- { APPVEYOR_BUILD_WORKER_IMAGE: *linux, ARCH: i686 }
64+
5765
deploy:
5866
provider: GitHub
5967
draft: true

.gitignore

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
/.tup/
2-
3-
bin/
4-
build/
5-
resource.rc_mac*
6-
resource.res
7-
8-
/vendor/*/
9-
/vendor/reaper_plugin*.h
1+
/build/
2+
/vendor

.travis.yml

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
---
2-
language: c++
2+
language: cpp
33
os: osx
4-
osx_image: xcode9.2 # 10.12 with custom kext loading allowed (for osxfuse)
4+
osx_image: xcode9.4 # macOS 10.13
55
env:
6-
- PLATFORM=x64
7-
- PLATFORM=x86
6+
- ARCH=x86_64
7+
- ARCH=i386
88
install:
9-
- brew update
10-
- brew cask install osxfuse
11-
- brew install llvm tup
12-
- export PATH="/usr/local/opt/llvm/bin:$PATH"
13-
14-
- wget -nv https://github.com/catchorg/Catch2/raw/master/single_include/catch2/catch.hpp -P vendor/catch2
15-
169
- wget -nv https://github.com/reaper-oss/sws/raw/master/reaper/reaper_plugin.h -P vendor
1710
- wget -nv https://gist.github.com/cfillion/da355e8278048de08ae065d6fe6031c1/raw/reaper_plugin_functions.h -P vendor
1811
- git clone -q --depth 1 https://github.com/justinfrankel/WDL.git vendor/WDL
@@ -23,7 +16,20 @@ install:
2316
- curl -fsSL https://github.com/cfillion/WDL/commit/45ca4c819d4aaaed98540b8e5125085c05044786.patch | git -C vendor/WDL am
2417
# SWELL: disable rich text in multiline textboxes on macOS
2518
- curl -fsSL https://github.com/cfillion/WDL/commit/af9df173570edbb1d022045a7036d8d3296977b6.patch | git -C vendor/WDL am
26-
script: tup $PLATFORM && $PLATFORM/bin/test
19+
script:
20+
- cmake -B build
21+
-DCMAKE_BUILD_TYPE=RelWithDebInfo
22+
-DCMAKE_OSX_ARCHITECTURES="$ARCH"
23+
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.7
24+
-DCMAKE_TOOLCHAIN_FILE=cmake/brew-llvm.cmake
25+
- cmake --build build --target all test
26+
addons:
27+
homebrew:
28+
packages:
29+
- catch2
30+
- cmake
31+
- llvm
32+
update: true
2733
deploy:
2834
provider: releases
2935
name: $TRAVIS_TAG
@@ -34,7 +40,7 @@ deploy:
3440
skip_cleanup: true
3541
api_key:
3642
secure: O7kvtWqx0hsVzWev3qzNxf9CuctG76I7dXmn4IG10AFkKmot+QT9V1OARqLhOLj/QSuPWQY7X/hSPuSLqcRTweADWfOl7uKvBd38KKfEXSVfRNRgDzCTOKYmCUAzL3WFB5wGTWIP47/4GPAiqhtLriejbbMCcF6b4diZ3rD4rZN/4BI85wXh3mID0fD4i2cSzAx2ONn4I3xIAiRhigJQ0VRp3v4wMGB0hGPM3fRDMzDuGEMo3CAgyhO/ldh9QPOS4F5LNOM3prBSYmFaARQO46vmhF4hI+ydRZrntGhL5NryEtsZVqONv+Pq6z8TnCOH7uPYE9uHiU3K/s4XpYRdSMbrZfRylmTEo8p66KLjfDvMlMBmwmvsTIE8z/w9XuUskhSSq7eNYyX1QxaIiBh+o0ho/FIbLuEZK56dFCO/6yUY9LC23/+iMdPluMdQNzTPjvVqI1AnZQeBqQ2hZG9jp96Rblptz3lJFMDo3hoGNbPHE6iiCW7S0RvncGIRt5JL8BuQwyowIKqBg4eEx+74aYX7JvVLQpfzw9btr6f56k9N7OFP2tU2eNEnOWTjmkqsicU3nAp1Zji66+ncOhfJTJSIc5xNJGmVfRBSIAMYcjfo+1sxoM0NYyODXrwVt5rMUGdmuIutC7K8IcuCIOBTG924exXpBAcCYUaXd2iewss=
37-
file: 'x*/bin/reaper_reapack*.dylib'
43+
file: build/reaper_reapack*.dylib
3844
file_glob: true
3945
on:
4046
tags: true

CMakeLists.txt

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
4+
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
5+
CACHE STRING "")
6+
endif()
7+
8+
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
9+
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
10+
endif()
11+
12+
project(reapack LANGUAGES C CXX)
13+
14+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
15+
16+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
17+
if(WIN32)
18+
set(USER_CONFIG_DIR "$ENV{APPDATA}")
19+
elseif(APPLE)
20+
set(USER_CONFIG_DIR "~/Library/Application Support")
21+
else()
22+
set(USER_CONFIG_DIR "~/.config")
23+
endif()
24+
25+
set(CMAKE_INSTALL_PREFIX "${USER_CONFIG_DIR}/REAPER" CACHE PATH
26+
"REAPER resource path where to install ReaPack" FORCE)
27+
endif()
28+
29+
if(CMAKE_OSX_ARCHITECTURES)
30+
list(JOIN CMAKE_OSX_ARCHITECTURES "-" ARCH_NAME)
31+
elseif(MSVC_CXX_ARCHITECTURE_ID)
32+
set(ARCH_NAME ${MSVC_CXX_ARCHITECTURE_ID})
33+
else()
34+
set(ARCH_NAME ${CMAKE_SYSTEM_PROCESSOR})
35+
endif()
36+
37+
STRING(TOLOWER "${ARCH_NAME}" ARCH_NAME)
38+
39+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vendor/reaper_plugin.h")
40+
message(FATAL_ERROR
41+
"reaper_plugin.h cannot be found in ${CMAKE_CURRENT_SOURCE_DIR}/vendor.\n"
42+
43+
"The latest version can be downloaded from the SWS repository rather than "
44+
"the REAPER SDK."
45+
"https://github.com/reaper-oss/sws/raw/master/reaper/reaper_plugin.h"
46+
)
47+
endif()
48+
49+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vendor/reaper_plugin_functions.h")
50+
message(FATAL_ERROR
51+
"reaper_plugin_functions.h cannot be found in "
52+
"${CMAKE_CURRENT_SOURCE_DIR}/vendor.\n"
53+
54+
"Generate it using the following REAPER action: "
55+
"[developer] Write C++ API functions header."
56+
)
57+
endif()
58+
59+
set(CMAKE_CXX_EXTENSIONS OFF)
60+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
61+
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
62+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
63+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
64+
65+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON)
66+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
67+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON)
68+
69+
if(WIN32)
70+
add_compile_definitions(NOMINMAX UNICODE)
71+
72+
foreach(arg
73+
CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG
74+
CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
75+
CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO
76+
CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
77+
)
78+
# Embed debug information in the object files
79+
string(REGEX REPLACE "/Z[iI]" "/Z7" ${arg} "${${arg}}")
80+
endforeach()
81+
82+
add_compile_options(
83+
# Exception handling model
84+
/EHsc
85+
86+
# Enhance optimized debugging
87+
$<$<NOT:$<CONFIG:Debug>>:/Zo>
88+
89+
# Eliminate duplicate strings
90+
$<$<NOT:$<CONFIG:Debug>>:/GF>
91+
92+
# Enable function-level linking
93+
$<$<NOT:$<CONFIG:Debug>>:/Gy>
94+
95+
# Remove unreferenced COMDAT
96+
$<$<NOT:$<CONFIG:Debug>>:/Zc:inline>
97+
)
98+
99+
add_link_options(
100+
# Remove unreferenced code
101+
$<$<NOT:$<CONFIG:Debug>>:/OPT:REF>
102+
103+
# Remove duplicate sections
104+
$<$<NOT:$<CONFIG:Debug>>:/OPT:ICF>
105+
106+
# Use relative path to the PDB file to avoid exposing the full path
107+
/PDBALTPATH:%_PDB%
108+
)
109+
else()
110+
add_compile_options(-fstack-protector-strong -fdiagnostics-color)
111+
endif()
112+
113+
find_package(Ruby)
114+
if(RUBY_FOUND)
115+
add_custom_target(prepare
116+
COMMAND ruby prepare.rb src/*.{{h,c}pp,mm}
117+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
118+
)
119+
endif()
120+
121+
add_library(reaper_reapack SHARED)
122+
123+
set_target_properties(reaper_reapack PROPERTIES
124+
PREFIX "" # disable the "lib" prefix
125+
OUTPUT_NAME "reaper_reapack-${ARCH_NAME}"
126+
)
127+
128+
add_subdirectory(src)
129+
add_subdirectory(test)
130+
131+
target_link_libraries(reaper_reapack reapack)
132+
133+
add_custom_target(test
134+
COMMAND $<TARGET_FILE:tests>
135+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
136+
USES_TERMINAL
137+
)
138+
139+
add_dependencies(test tests)
140+
141+
set(REAPER_USER_PLUGINS "UserPlugins")
142+
143+
install(TARGETS reaper_reapack
144+
COMPONENT ReaPack
145+
RUNTIME DESTINATION "${REAPER_USER_PLUGINS}" # Windows .dll
146+
LIBRARY DESTINATION "${REAPER_USER_PLUGINS}" # Linux .so/macOS .dylib
147+
)

Makefile

-12
This file was deleted.

0 commit comments

Comments
 (0)