Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,17 @@ jobs:
BIN: 32
env:
CMAKE_EXE: /opt/Kitware/CMake/${{ matrix.CMAKE }}/bin/cmake
CPACK_EXE: /opt/Kitware/CMake/${{ matrix.CMAKE }}/bin/cpack
CTEST_EXE: /opt/Kitware/CMake/${{ matrix.CMAKE }}/bin/ctest

steps:
- name: Checkout OpenCL-Headers
uses: actions/checkout@v3

- name: Configure
shell: bash
run: $CMAKE_EXE
run: mkdir $GITHUB_WORKSPACE/build && cd $GITHUB_WORKSPACE/build &&
$CMAKE_EXE
-G "${{matrix.GEN}}"
-D BUILD_TESTING=ON
`if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]]; then echo -D CMAKE_BUILD_TYPE=${{matrix.CONFIG}}; fi;`
Expand All @@ -177,8 +179,8 @@ jobs:
-D CMAKE_CXX_COMPILER=${{matrix.CXX_COMPILER}}
-D CMAKE_CXX_EXTENSIONS=OFF
-D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install
-B$GITHUB_WORKSPACE/build
-H$GITHUB_WORKSPACE
-D CPACK_PACKAGING_INSTALL_PREFIX=/usr
$GITHUB_WORKSPACE

- name: Build
shell: bash
Expand All @@ -201,6 +203,37 @@ jobs:
$CTEST_EXE --output-on-failure -C Release --parallel `nproc`;
fi;

- name: Package DEB
shell: bash
run: $CPACK_EXE
--config "$GITHUB_WORKSPACE/build/CPackConfig.cmake"
-G DEB
-C Release
-B "$GITHUB_WORKSPACE/package-deb"

- name: Consume (Package DEB)
shell: bash
run: dpkg -i $GITHUB_WORKSPACE/package-deb/*.deb &&
mkdir $GITHUB_WORKSPACE/build_package && cd $GITHUB_WORKSPACE/build_package &&
$CMAKE_EXE
-G "${{matrix.GEN}}"
-D BUILD_TESTING=ON
`if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]]; then echo -D CMAKE_BUILD_TYPE=${{matrix.CONFIG}}; fi;`
-D CMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror -m${{matrix.BIN}}"
-D CMAKE_C_COMPILER=${{matrix.C_COMPILER}}
-D CMAKE_C_EXTENSIONS=OFF
-D CMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror -m${{matrix.BIN}}"
-D CMAKE_CXX_COMPILER=${{matrix.CXX_COMPILER}}
-D CMAKE_CXX_EXTENSIONS=OFF
$GITHUB_WORKSPACE/tests/pkgconfig/bare &&
if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]];
then
$CMAKE_EXE --build $GITHUB_WORKSPACE/build -- -j`nproc`;
else
$CMAKE_EXE --build $GITHUB_WORKSPACE/build --config Debug -- -j`nproc`;
$CMAKE_EXE --build $GITHUB_WORKSPACE/build --config Release -- -j`nproc`;
fi;

- name: Test install
shell: bash
run: if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]];
Expand Down
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build dir
[Bb]uild/

# Install dir
[Ii]nstall/

# Package dir
[Pp]ackage[-_\s\d]*/

# Test dir
[Tt]esting/

# CMake
CMakeCache.txt
CMakeFiles/
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if(TARGET Headers)
endif()

project(OpenCLHeaders
VERSION 2.2
VERSION 3.0
LANGUAGES C # Ideally should be NONE, but GNUInstallDirs detects platform arch using try_compile
# https://stackoverflow.com/questions/43379311/why-does-project-affect-cmakes-opinion-on-cmake-sizeof-void-p
)
Expand All @@ -17,6 +17,7 @@ option(OPENCL_HEADERS_BUILD_CXX_TESTS "Enable support for OpenCL C headers testi

set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(JoinPaths)
include(Package)

include(GNUInstallDirs)

Expand Down
41 changes: 41 additions & 0 deletions cmake/Package.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
set(CPACK_PACKAGE_VENDOR "khronos")

set(CPACK_PACKAGE_DESCRIPTION "OpenCL (Open Computing Language) C header files")

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")

set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

if(NOT CPACK_PACKAGING_INSTALL_PREFIX)
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()

# DEB packaging configuration
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_VENDOR})

set(CPACK_DEBIAN_PACKAGE_HOMEPAGE
"https://github.com/KhronosGroup/OpenCL-Headers")

# Version number [epoch:]upstream_version[-debian_revision]
set(LATEST_RELEASE_VERSION "2023.04.17")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity where did this date come from? Will it need to be updated manually? If so, when should it be updated?

set(CPACK_DEBIAN_PACKAGE_VERSION "${PROJECT_VERSION}~${LATEST_RELEASE_VERSION}") # upstream_version
set(CPACK_DEBIAN_PACKAGE_RELEASE "1") # debian_revision (because this is a
# non-native pkg)
set(PACKAGE_VERSION_REVISION "${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}")

set(DEBIAN_PACKAGE_NAME "opencl-c-headers")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an existing package name or something new? If this is a new package name I'd suggest removing "c", since I tend to think of "OpenCL C" as being the kernel language.

set(CPACK_DEBIAN_PACKAGE_NAME
"${DEBIAN_PACKAGE_NAME}"
CACHE STRING "Package name" FORCE)

# Get architecture
execute_process(COMMAND dpkg "--print-architecture" OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
string(STRIP "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" CPACK_DEBIAN_PACKAGE_ARCHITECTURE)

# Package file name in deb format:
# <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
set(CPACK_DEBIAN_FILE_NAME "${CPACK_PACKAGE_VENDOR}-${DEBIAN_PACKAGE_NAME}_${PACKAGE_VERSION_REVISION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")

set(CPACK_DEBIAN_PACKAGE_DEBUG ON)

include(CPack)