From 5f72f96c6ffb68f4a695cb8e78048577bf98336a Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Mon, 10 Oct 2022 16:38:13 -0500 Subject: [PATCH 1/7] Added support for pkg-config. --- CMakeLists.txt | 8 ++++++++ OpenCL-Headers.pc.in | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 OpenCL-Headers.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index d87fa17a..5232de4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,3 +93,11 @@ endif() if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING) AND BUILD_TESTING) add_subdirectory(tests) endif() + +if (UNIX) + 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}) +endif() diff --git a/OpenCL-Headers.pc.in b/OpenCL-Headers.pc.in new file mode 100644 index 00000000..3f3c57c2 --- /dev/null +++ b/OpenCL-Headers.pc.in @@ -0,0 +1,6 @@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: OpenCL-Headers +Description: Khronos OpenCL Headers +Version: 3.0 +Cflags: -I${includedir} From c433161b415528af830ead2e524b38561479f0c8 Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Tue, 11 Oct 2022 11:35:18 -0500 Subject: [PATCH 2/7] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5232de4b..7780b5e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING) AN add_subdirectory(tests) endif() -if (UNIX) +if (NOT MSVC) configure_file(OpenCL-Headers.pc.in OpenCL-Headers.pc @ONLY) set(pkg_config_location ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install( From 07855d3bc65625fbd895582610d9251720692795 Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Tue, 11 Oct 2022 11:37:33 -0500 Subject: [PATCH 3/7] Update OpenCL-Headers.pc.in --- OpenCL-Headers.pc.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenCL-Headers.pc.in b/OpenCL-Headers.pc.in index 3f3c57c2..aab34dd8 100644 --- a/OpenCL-Headers.pc.in +++ b/OpenCL-Headers.pc.in @@ -1,4 +1,5 @@ -includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +prefix=@CMAKE_INSTALL_PREFIX@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: OpenCL-Headers Description: Khronos OpenCL Headers From b510b9377b65447e14e2dcf0f90a05051d10d6fb Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Thu, 13 Oct 2022 11:20:21 -0500 Subject: [PATCH 4/7] Try to add CI for Linux. --- .github/workflows/linux.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f18ee41b..9317b9bc 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -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; \ No newline at end of file + 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" From be171f1bc244e770c02c24f942f3908793977c92 Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Thu, 13 Oct 2022 12:39:50 -0500 Subject: [PATCH 5/7] Try to add CI for pkg-config for MacOS. --- .github/workflows/macos.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 24c16655..2d2828ec 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -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` \ No newline at end of file + 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" From 193a329a520fee6066cf6a435b0f20cbd20d71b4 Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Tue, 29 Nov 2022 18:59:55 -0600 Subject: [PATCH 6/7] Update to same scheme as OpenCL Loader. --- CMakeLists.txt | 5 +++++ OpenCL-Headers.pc.in | 2 +- cmake/JoinPaths.cmake | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 cmake/JoinPaths.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7780b5e9..22610ddb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -94,6 +97,8 @@ if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING) AN add_subdirectory(tests) endif() +join_paths(OPENCL_INCLUDEDIR_PC "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") + if (NOT MSVC) configure_file(OpenCL-Headers.pc.in OpenCL-Headers.pc @ONLY) set(pkg_config_location ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/OpenCL-Headers.pc.in b/OpenCL-Headers.pc.in index aab34dd8..92d241c4 100644 --- a/OpenCL-Headers.pc.in +++ b/OpenCL-Headers.pc.in @@ -1,5 +1,5 @@ prefix=@CMAKE_INSTALL_PREFIX@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +includedir=@OPENCL_INCLUDEDIR_PC@ Name: OpenCL-Headers Description: Khronos OpenCL Headers diff --git a/cmake/JoinPaths.cmake b/cmake/JoinPaths.cmake new file mode 100644 index 00000000..32d6d668 --- /dev/null +++ b/cmake/JoinPaths.cmake @@ -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() From 7c4a070cdff948170e041ebb78a98021e83e5ade Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Tue, 13 Dec 2022 11:46:41 -0600 Subject: [PATCH 7/7] Update CMakeLists.txt --- CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22610ddb..76f840d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,10 +99,8 @@ endif() join_paths(OPENCL_INCLUDEDIR_PC "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") -if (NOT MSVC) - 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}) -endif() +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})