Skip to content
Merged
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
15 changes: 14 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,17 @@ jobs:
else
$CTEST_EXE --output-on-failure -C Debug --parallel `nproc`;
$CTEST_EXE --output-on-failure -C Release --parallel `nproc`;
fi;
fi;

- name: Test install
shell: bash
run: if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]];
then
$CMAKE_EXE --build $GITHUB_WORKSPACE/build --target install -- -j`nproc`;
else
$CMAKE_EXE --build $GITHUB_WORKSPACE/build --target install --config Release -- -j`nproc`;
fi;

- name: Test pkg-config
shell: bash
run: PKG_CONFIG_PATH="$GITHUB_WORKSPACE/install/lib/pkgconfig" pkg-config OpenCL-Headers --cflags | grep -q "\-I$GITHUB_WORKSPACE/install/include"
10 changes: 9 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ jobs:
shell: bash
run: |
ctest -C Release --output-on-failure --parallel `sysctl -n hw.logicalcpu`
ctest -C Debug --output-on-failure --parallel `sysctl -n hw.logicalcpu`
ctest -C Debug --output-on-failure --parallel `sysctl -n hw.logicalcpu`

- name: Test install
shell: bash
run: cmake --build $GITHUB_WORKSPACE/build --target install --config Release

- name: Test pkg-config
shell: bash
run: PKG_CONFIG_PATH="$GITHUB_WORKSPACE/install/lib/pkgconfig" pkg-config OpenCL-Headers --cflags | grep -q "\-I$GITHUB_WORKSPACE/install/include"
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ project(OpenCLHeaders
option(OPENCL_HEADERS_BUILD_TESTING "Enable support for OpenCL C headers testing." OFF)
option(OPENCL_HEADERS_BUILD_CXX_TESTS "Enable support for OpenCL C headers testing in C++ mode." ON)

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

include(GNUInstallDirs)

add_library(Headers INTERFACE)
Expand Down Expand Up @@ -93,3 +96,11 @@ endif()
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING) AND BUILD_TESTING)
add_subdirectory(tests)
endif()

join_paths(OPENCL_INCLUDEDIR_PC "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")

configure_file(OpenCL-Headers.pc.in OpenCL-Headers.pc @ONLY)
set(pkg_config_location ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenCL-Headers.pc
DESTINATION ${pkg_config_location})
7 changes: 7 additions & 0 deletions OpenCL-Headers.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
includedir=@OPENCL_INCLUDEDIR_PC@

Name: OpenCL-Headers
Description: Khronos OpenCL Headers
Version: 3.0
Cflags: -I${includedir}
26 changes: 26 additions & 0 deletions cmake/JoinPaths.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This module provides function for joining paths
# known from from most languages
#
# Original license:
# SPDX-License-Identifier: (MIT OR CC0-1.0)
# Explicit permission given to distribute this module under
# the terms of the project as described in /LICENSE.rst.
# Copyright 2020 Jan Tojnar
# https://github.com/jtojnar/cmake-snips
#
# Modelled after Python’s os.path.join
# https://docs.python.org/3.7/library/os.path.html#os.path.join
# Windows not supported
function(join_paths joined_path first_path_segment)
set(temp_path "${first_path_segment}")
foreach(current_segment IN LISTS ARGN)
if(NOT ("${current_segment}" STREQUAL ""))
if(IS_ABSOLUTE "${current_segment}")
set(temp_path "${current_segment}")
else()
set(temp_path "${temp_path}/${current_segment}")
endif()
endif()
endforeach()
set(${joined_path} "${temp_path}" PARENT_SCOPE)
endfunction()