Skip to content

Commit

Permalink
Bundle OpenMP runtime. Fixes #86
Browse files Browse the repository at this point in the history
Rewrite build process to automatically name binary. Fixes #87

Remove excessive duplication in `CMakePresets.json` by using inheritance
  • Loading branch information
Derpius committed Sep 26, 2022
1 parent 30dadc5 commit 89cc32d
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 92 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- ".gitmodules"
- "libs/**"
- ".github/workflows/build.yml"
- "release/*.dll"
pull_request:
branches:
- master
Expand All @@ -22,8 +23,7 @@ on:
- ".gitmodules"
- "libs/**"
- ".github/workflows/build.yml"
env:
API_VERSION: "0.13"
- "release/*.dll"

jobs:
build:
Expand All @@ -35,17 +35,13 @@ jobs:
include:
- os-prefix: windows
os: windows-latest
dll-platform: win
#- os-prefix: linux
# os: ubuntu-latest
# dll-platform: linux

#- arch: x86
# msvc-arch: amd64_x86
# dll-arch: 32
- arch: x64
msvc-arch: amd64
dll-arch: 64

name: Build module
runs-on: ${{ matrix.os }}
Expand All @@ -63,22 +59,23 @@ jobs:
- name: Get latest CMake and ninja
uses: lukka/get-cmake@latest

- name: Run CMake
- name: Run CMake - OpenMP
id: build
uses: lukka/run-cmake@v10
with:
configurePreset: "${{ matrix.os-prefix }}-${{ matrix.arch }}-${{ matrix.target }}"
buildPreset: "${{ matrix.os-prefix }}-${{ matrix.arch }}-${{ matrix.target }}"

- name: Rename dll
id: rename
run: |
mv out/build/${{ matrix.os-prefix }}-${{ matrix.arch }}-${{ matrix.target }}/VisTrace.dll gmcl_VisTrace-v${{ env.API_VERSION }}_${{ matrix.dll-platform }}${{ matrix.dll-arch }}.dll
if: (matrix.target == 'release') && (steps.build.outcome == 'success') && (github.event_name == 'push')
- name: Run CMake - No OpenMP
id: build
uses: lukka/run-cmake@v10
with:
configurePreset: "${{ matrix.os-prefix }}-${{ matrix.arch }}-${{ matrix.target }}-no-omp"
buildPreset: "${{ matrix.os-prefix }}-${{ matrix.arch }}-${{ matrix.target }}-no-omp"

- name: Upload release binaries
- name: Upload Release Artefact
uses: actions/upload-artifact@v3
with:
name: gmcl_VisTrace-v${{ env.API_VERSION }}_${{ matrix.dll-platform }}${{ matrix.dll-arch }}.dll
path: gmcl_VisTrace-v${{ env.API_VERSION }}_${{ matrix.dll-platform }}${{ matrix.dll-arch }}.dll
if: (matrix.target == 'release') && (steps.rename.outcome == 'success') && (github.event_name == 'push')
name: ${{ matrix.os-prefix }} ${{ matrix.arch }}
path: release
if: (matrix.target == 'release') && (steps.build.outcome == 'success') && (github.event_name == 'push')
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@

# Build Directory
out

# Program Database
*.pdb

# Exclude OpenMP runtime
!release/libomp140.x86_64.dll
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

set(USE_OPENMP 1) # Comment out to disable using OpenMP for debugging

if (USE_OPENMP)
find_package(OpenMP QUIET)
else()
Expand All @@ -24,8 +22,10 @@ add_subdirectory("libs/BSPParser")
add_subdirectory("libs/VTFParser")
add_subdirectory("libs/GMFS")

set(BINARY_NAME gmcl_${PROJECT_NAME}-v${VISTRACE_API_VERSION}_${BINARY_SUFFIX})

add_library(
${PROJECT_NAME} SHARED
${BINARY_NAME} SHARED
"source/VisTrace.cpp"
"source/Utils.cpp"

Expand All @@ -43,7 +43,7 @@ add_library(
)

target_include_directories(
${PROJECT_NAME} PRIVATE
${BINARY_NAME} PRIVATE
"source"
"source/objects"
"source/libraries"
Expand All @@ -63,17 +63,19 @@ target_include_directories(

if (OpenMP_CXX_FOUND AND USE_OPENMP)
target_link_libraries(
${PROJECT_NAME} PRIVATE
${BINARY_NAME} PRIVATE
OpenMP::OpenMP_CXX
libomp.lib
)
endif()

target_link_libraries(
${PROJECT_NAME} PRIVATE
${BINARY_NAME} PRIVATE
BSPParser
bvh
glm
VTFParser
GMFS
)

set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/release/")
Loading

0 comments on commit 89cc32d

Please sign in to comment.