Skip to content

Commit 6b21e80

Browse files
committed
squash! Update workflows and pre-commit
Switch to CPack for distribution of the Umbra demo
1 parent a990cf1 commit 6b21e80

4 files changed

Lines changed: 30 additions & 33 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ jobs:
3737
env:
3838
# Indicates the CMake build directory where project files and binaries are being produced.
3939
CMAKE_BUILD_DIR: ${{ github.workspace }}/build
40-
archive-name: ""
4140

4241
steps:
4342
- name: Install APT packages
@@ -77,41 +76,22 @@ jobs:
7776
-G Ninja \
7877
-D VCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \
7978
-D CMAKE_BUILD_TYPE="${{ env.BUILD_TYPE }}" \
80-
-D BUILD_UMBRA_DEMO=ON
79+
-D UMBRA_DEMO=ON
80+
-D UMBRA_CPACK=ON
8181
# Build the whole project with Ninja (which is spawn by CMake).
8282
- name: Build
8383
run: cmake --build "${CMAKE_BUILD_DIR}"
8484
- name: Show contents of the build directory
8585
run: find "${CMAKE_BUILD_DIR}"
86-
# Sets env.archive-name, which is used to name the distribution folder and archive.
87-
- name: Set archive name
88-
run: |
89-
ARCHIVE_NAME=${{ env.project-name }}-`git describe --always`-${{ matrix.platform-name }}
90-
echo "Archive name set to: $ARCHIVE_NAME"
91-
echo "archive-name=$ARCHIVE_NAME" >> $GITHUB_ENV
9286
# Copy files from the CMake build and data directory into a new distribution folder.
93-
- name: Package distribution
94-
run: |
95-
mkdir -p dist/${{ env.archive-name }}
96-
cp "${CMAKE_BUILD_DIR}/bin"/* dist/${{ env.archive-name }}
97-
cp -R data dist/${{ env.archive-name }}
98-
- name: Show contents of the dist directory
99-
run: find dist/${{ env.archive-name }}
100-
# Zip the distribution folder, using the platform appropriate tools.
101-
- name: Tar files
102-
if: runner.os != 'Windows'
103-
working-directory: ./dist
104-
run: tar --format=ustar -czvf "../${{ env.archive-name }}.tar.gz" */
105-
- name: Archive files
106-
if: runner.os == 'Windows'
107-
shell: pwsh
108-
run: Compress-Archive dist/*/ ${{ env.archive-name }}.zip
87+
- name: CPack
88+
run: cpack --verbose --config ${{env.CMAKE_BUILD_DIR}}/CPackConfig.cmake -B dist -R `git describe --always`
10989
# Upload archives as artifacts, these can be downloaded from the GitHub Actions page.
11090
- name: "Upload Artifact"
11191
uses: actions/upload-artifact@v6
11292
with:
11393
name: automated-builds-${{ matrix.triplet }}
114-
path: ${{ env.archive-name }}.*
94+
path: dist/*.*
11595
retention-days: 7
11696
compression-level: 0
11797
if-no-files-found: error
@@ -121,7 +101,7 @@ jobs:
121101
uses: svenstaro/upload-release-action@v2
122102
with:
123103
repo_token: ${{ secrets.GITHUB_TOKEN }}
124-
file: ${{ env.archive-name }}.*
104+
file: dist/*.*
125105
file_glob: true
126106
tag: ${{ github.ref }}
127107
overwrite: true

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"-Wdeprecated",
1515
],
1616
"cmake.configureSettings": {
17-
"BUILD_UMBRA_DEMO": "ON"
17+
"UMBRA_DEMO": "ON",
18+
"UMBRA_CPACK": "ON"
1819
},
1920
"files.associations": {
2021
"cstdint": "cpp",

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ project(
1111
LANGUAGES C CXX
1212
)
1313

14-
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
15-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") # Keep all runtime files in one directory.
16-
endif()
17-
1814
file(
1915
GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS
2016
${PROJECT_SOURCE_DIR}/src/umbra/*.cpp
@@ -50,7 +46,17 @@ target_link_libraries(
5046
)
5147
add_library(umbra::umbra ALIAS ${PROJECT_NAME})
5248

53-
set(BUILD_UMBRA_DEMO OFF CACHE BOOL "Build the demo program.")
54-
if(BUILD_UMBRA_DEMO)
49+
option(UMBRA_DEMO "Build the Umbra demo program" OFF)
50+
if(UMBRA_DEMO)
5551
add_subdirectory(src/demo)
5652
endif()
53+
54+
option(UMBRA_CPACK "Enable CPack for Umbra" OFF)
55+
if(UMBRA_CPACK)
56+
if (WIN32)
57+
set(CPACK_GENERATOR "ZIP")
58+
else()
59+
set(CPACK_GENERATOR "TGZ")
60+
endif()
61+
include(CPack)
62+
endif()

src/demo/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,13 @@ target_link_libraries(
3333
libtcod::libtcod
3434
umbra::umbra
3535
)
36+
37+
# Portable install
38+
install(
39+
TARGETS ${PROJECT_NAME}
40+
DESTINATION ${PROJECT_NAME}
41+
)
42+
install(
43+
DIRECTORY ../../data
44+
DESTINATION ${PROJECT_NAME}
45+
)

0 commit comments

Comments
 (0)