Skip to content

Commit fb1505a

Browse files
committed
Add CXX interface test application and add it to workflows
1 parent b33eed3 commit fb1505a

8 files changed

Lines changed: 130 additions & 1 deletion

File tree

.github/workflows/build_linux.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
-DCMAKE_VERBOSE_MAKEFILE=YES \
6565
-DBUILD_SHARED_LIBS="${shared_libs}" \
6666
-DENABLE_BOOST_FILESYSTEM="${use_boost}" \
67+
-DENABLE_CXX_INTERFACE=YES \
6768
-DBUILD_TESTING=YES
6869
6970
- name: Build Debug
@@ -80,6 +81,16 @@ jobs:
8081
cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --target install
8182
cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --target install
8283
84+
- name: Test C++ Interface
85+
run: |
86+
cmake -G "Ninja Multi-Config" \
87+
-S "${{ github.workspace }}/tests/cxx-interface" \
88+
-B "${{ github.workspace }}/cmake-build-cxx-api" \
89+
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/install"
90+
91+
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Debug"
92+
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Release"
93+
8394
- name: Upload Artifact
8495
uses: actions/upload-artifact@v4
8596
with:

.github/workflows/build_osx.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
-DBUILD_SHARED_LIBS="${shared_libs}" \
6666
-DENABLE_BOOST_FILESYSTEM="${use_boost}" \
6767
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" \
68+
-DENABLE_CXX_INTERFACE=YES \
6869
-DBUILD_TESTING=YES
6970
7071
- name: Build Debug
@@ -81,6 +82,17 @@ jobs:
8182
cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --target install
8283
cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --target install
8384
85+
- name: Test C++ Interface
86+
run: |
87+
cmake -G "Ninja Multi-Config" \
88+
-S "${{ github.workspace }}/tests/cxx-interface" \
89+
-B "${{ github.workspace }}/cmake-build-cxx-api" \
90+
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" \
91+
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/install"
92+
93+
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Debug"
94+
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Release"
95+
8496
- name: Upload Artifact
8597
uses: actions/upload-artifact@v4
8698
with:

.github/workflows/build_windows.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ jobs:
9696
-DCMAKE_VERBOSE_MAKEFILE=YES `
9797
-DBUILD_SHARED_LIBS="$($shared_libs)" `
9898
-DENABLE_BOOST_FILESYSTEM="$($use_boost)" `
99-
-DBUILD_TESTING=YES
99+
-DENABLE_CXX_INTERFACE=YES `
100+
-DBUILD_TESTING=YES `
101+
-DCMAKE_VERBOSE_MAKEFILE=ON
100102
101103
- name: Build Debug
102104
run: cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --parallel
@@ -112,6 +114,39 @@ jobs:
112114
cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --target INSTALL
113115
cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --target INSTALL
114116
117+
- name: Test C++ Interface
118+
run: |
119+
if("${{ matrix.fslib }}" -eq "boost") {
120+
$use_boost = "ON"
121+
} else {
122+
$use_boost = "OFF"
123+
}
124+
if("${{ matrix.arch }}" -eq "X64") {
125+
$triplet = "x64-windows"
126+
} else {
127+
$triplet = "x86-windows"
128+
}
129+
if("${{ matrix.libs }}" -eq "shared") {
130+
$runtime = "DLL"
131+
} else {
132+
$runtime = ""
133+
$triplet = $triplet + "-static"
134+
}
135+
136+
cmake -G "Visual Studio 17 2022" `
137+
-A "${{ matrix.arch }}" `
138+
-S "${{ github.workspace }}/tests/cxx-interface" `
139+
-B "${{ github.workspace }}/cmake-build-cxx-api" `
140+
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/install" `
141+
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>$($runtime)" `
142+
-DCMAKE_TOOLCHAIN_FILE="${Env:VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" `
143+
-DVCPKG_TARGET_TRIPLET="$($triplet)" `
144+
-DENABLE_BOOST_FILESYSTEM="$($use_boost)" `
145+
-DCMAKE_VERBOSE_MAKEFILE=ON
146+
147+
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Debug"
148+
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Release"
149+
115150
- name: Upload Artifact
116151
uses: actions/upload-artifact@v4
117152
with:

tests/cxx-interface/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
2+
3+
option(ENABLE_BOOST_FILESYSTEM "Force the use of boost::filesystem, even if the compiler supports C++17." OFF)
4+
5+
if(ENABLE_BOOST_FILESYSTEM)
6+
list(APPEND VCPKG_MANIFEST_FEATURES boost-filesystem)
7+
endif()
8+
9+
project(projectM_CXX_Test
10+
LANGUAGES C CXX
11+
)
12+
13+
find_package(projectM4 REQUIRED)
14+
15+
add_executable(projectM4_CXX_Test
16+
main.cpp
17+
)
18+
19+
target_link_libraries(projectM4_CXX_Test
20+
libprojectM::projectM
21+
)

tests/cxx-interface/ReadMe.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
C++ Interface Test Suite
2+
========================
3+
4+
This is a small, standalone test build suite made to test if the C++ API links properly.
5+
6+
It must not be included in the main libprojectM build process, as the application requires the final installation layout
7+
instead of the build dir.
8+
9+
For a successful test, libprojectM must be built with the `ENABLE_CXX_INTERFACE` option enabled.

tests/cxx-interface/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <projectM-4/Logging.hpp>
2+
#include <projectM-4/ProjectM.hpp>
3+
4+
int main()
5+
{
6+
auto logLevel = libprojectM::Logging::GetLogLevel();
7+
8+
libprojectM::ProjectM pm;
9+
10+
auto frameData = pm.PCM().GetFrameAudioData();
11+
12+
return 0;
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"default-registry": {
3+
"kind": "git",
4+
"baseline": "b6070378242bbf0a69b33c38fb5c1d7713330293",
5+
"repository": "https://github.com/microsoft/vcpkg"
6+
}
7+
}

tests/cxx-interface/vcpkg.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "projectm-cxx-test",
3+
"version": "1.0.0",
4+
"description": "Tests the projectM C++ interface.",
5+
"homepage": "https://github.com/projectM-visualizer/projectm",
6+
"license": "LGPL-2.1-only",
7+
"dependencies": [
8+
{
9+
"name": "glew",
10+
"platform": "windows"
11+
}
12+
],
13+
"features": {
14+
"boost-filesystem": {
15+
"description": "Force using boost::filesystem instead of std::filesystem",
16+
"dependencies": [
17+
"boost-filesystem"
18+
]
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)