third_party_opencl-headers/CMakeLists.txt

96 lines
2.8 KiB
CMake
Raw Normal View History

Comprehensive CMake Package Config support (#107) * Add CMake Packaging + CI For Package * Uniform formatting * Explicit compiler detection * Simplify exported target name * Changed include dir to SYSTEM BEFORE * Remove travis * Initial Github Actions yaml * Fix CWD * Remove CWD from YAML * MSVC warning flags * Fix CWD for CTest invocations * Relative CWD * runner.workspace * enable tests in build * Move to C flags * Enable testing in CI * GCC warnings * Don't meddle with compiler flags in CMake * C2059: syntax error: 'bad suffix on number' * C4001: nonstd ext 'single line comment' was used * /wd4001 * /wd4001 again * Remove Za builds of cl_icd_h.c * Fix oeprator precedence * Refrain from altering global state * Add C_STANDARD to GCC build * Add 32-bit and 64-bit matrix dims * Change -march to -m * Try adding host * install gcc-multilib * Add GCC 8 & 9 multilib * Install GCC multilib conditionally * Add note on Windows C versions incoming * Add INCRMENTAL to silence notice on full link * Experiment with disabling * Initial MacOS config * Add ninja to MacOS build * Fix nproc * nproc -> sysctl * Xcode * cmd -> bash * which gcc-9 * Actual GCC invocation * Check gcc if symlink * follow link * Obtain env * Cleanup * Re-enable Windows and Linux * Check pkgconfig * Syntax fix * INSTALL_PREFIX to PREFIX_PATH * Use CONFIG * Added bare and SDK consumption * Fix bare target * Fix test for unsued variable * Add missing semi-colons * Rework SDK emulation * Fix indentation * Fix build path for SDK consumption * Add Windows consumption test * MacOS * Fix indentation * Enable MacOS * CMAKE_INSTALL_PREFIX >> CMAKE_PREFIX_PATH * Fix install * Install Release on Windows * Re-enable Linux and Windows * Added C99 builds * Removed pkgconfig.c duplication * Fix out-of-sync target in readme * Added policy to make readme sample work * match up paths in readme samples * Homogenize target names * Remove all warnings from sample readme Co-authored-by: sL1pKn07 <sl1pkn07@gmail.com>
2020-11-24 18:18:58 +00:00
cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION 3.0...3.22)
# Include guard for including this project multiple times
if(TARGET Headers)
return()
endif()
Comprehensive CMake Package Config support (#107) * Add CMake Packaging + CI For Package * Uniform formatting * Explicit compiler detection * Simplify exported target name * Changed include dir to SYSTEM BEFORE * Remove travis * Initial Github Actions yaml * Fix CWD * Remove CWD from YAML * MSVC warning flags * Fix CWD for CTest invocations * Relative CWD * runner.workspace * enable tests in build * Move to C flags * Enable testing in CI * GCC warnings * Don't meddle with compiler flags in CMake * C2059: syntax error: 'bad suffix on number' * C4001: nonstd ext 'single line comment' was used * /wd4001 * /wd4001 again * Remove Za builds of cl_icd_h.c * Fix oeprator precedence * Refrain from altering global state * Add C_STANDARD to GCC build * Add 32-bit and 64-bit matrix dims * Change -march to -m * Try adding host * install gcc-multilib * Add GCC 8 & 9 multilib * Install GCC multilib conditionally * Add note on Windows C versions incoming * Add INCRMENTAL to silence notice on full link * Experiment with disabling * Initial MacOS config * Add ninja to MacOS build * Fix nproc * nproc -> sysctl * Xcode * cmd -> bash * which gcc-9 * Actual GCC invocation * Check gcc if symlink * follow link * Obtain env * Cleanup * Re-enable Windows and Linux * Check pkgconfig * Syntax fix * INSTALL_PREFIX to PREFIX_PATH * Use CONFIG * Added bare and SDK consumption * Fix bare target * Fix test for unsued variable * Add missing semi-colons * Rework SDK emulation * Fix indentation * Fix build path for SDK consumption * Add Windows consumption test * MacOS * Fix indentation * Enable MacOS * CMAKE_INSTALL_PREFIX >> CMAKE_PREFIX_PATH * Fix install * Install Release on Windows * Re-enable Linux and Windows * Added C99 builds * Removed pkgconfig.c duplication * Fix out-of-sync target in readme * Added policy to make readme sample work * match up paths in readme samples * Homogenize target names * Remove all warnings from sample readme Co-authored-by: sL1pKn07 <sl1pkn07@gmail.com>
2020-11-24 18:18:58 +00:00
project(OpenCLHeaders
VERSION 2.2
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
)
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)
include(GNUInstallDirs)
Comprehensive CMake Package Config support (#107) * Add CMake Packaging + CI For Package * Uniform formatting * Explicit compiler detection * Simplify exported target name * Changed include dir to SYSTEM BEFORE * Remove travis * Initial Github Actions yaml * Fix CWD * Remove CWD from YAML * MSVC warning flags * Fix CWD for CTest invocations * Relative CWD * runner.workspace * enable tests in build * Move to C flags * Enable testing in CI * GCC warnings * Don't meddle with compiler flags in CMake * C2059: syntax error: 'bad suffix on number' * C4001: nonstd ext 'single line comment' was used * /wd4001 * /wd4001 again * Remove Za builds of cl_icd_h.c * Fix oeprator precedence * Refrain from altering global state * Add C_STANDARD to GCC build * Add 32-bit and 64-bit matrix dims * Change -march to -m * Try adding host * install gcc-multilib * Add GCC 8 & 9 multilib * Install GCC multilib conditionally * Add note on Windows C versions incoming * Add INCRMENTAL to silence notice on full link * Experiment with disabling * Initial MacOS config * Add ninja to MacOS build * Fix nproc * nproc -> sysctl * Xcode * cmd -> bash * which gcc-9 * Actual GCC invocation * Check gcc if symlink * follow link * Obtain env * Cleanup * Re-enable Windows and Linux * Check pkgconfig * Syntax fix * INSTALL_PREFIX to PREFIX_PATH * Use CONFIG * Added bare and SDK consumption * Fix bare target * Fix test for unsued variable * Add missing semi-colons * Rework SDK emulation * Fix indentation * Fix build path for SDK consumption * Add Windows consumption test * MacOS * Fix indentation * Enable MacOS * CMAKE_INSTALL_PREFIX >> CMAKE_PREFIX_PATH * Fix install * Install Release on Windows * Re-enable Linux and Windows * Added C99 builds * Removed pkgconfig.c duplication * Fix out-of-sync target in readme * Added policy to make readme sample work * match up paths in readme samples * Homogenize target names * Remove all warnings from sample readme Co-authored-by: sL1pKn07 <sl1pkn07@gmail.com>
2020-11-24 18:18:58 +00:00
add_library(Headers INTERFACE)
add_library(OpenCL::Headers ALIAS Headers)
if(CMAKE_SYSTEM_NAME MATCHES Darwin)
execute_process(
COMMAND ln -shf ${CMAKE_CURRENT_SOURCE_DIR}/CL ${CMAKE_CURRENT_BINARY_DIR}/CL
COMMAND ln -shf ${CMAKE_CURRENT_SOURCE_DIR}/CL ${CMAKE_CURRENT_BINARY_DIR}/OpenCL
)
target_include_directories(Headers
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install(CODE "
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/CL)
execute_process(
COMMAND ln -shf CL ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/OpenCL
)"
)
else()
target_include_directories(Headers
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endif()
Comprehensive CMake Package Config support (#107) * Add CMake Packaging + CI For Package * Uniform formatting * Explicit compiler detection * Simplify exported target name * Changed include dir to SYSTEM BEFORE * Remove travis * Initial Github Actions yaml * Fix CWD * Remove CWD from YAML * MSVC warning flags * Fix CWD for CTest invocations * Relative CWD * runner.workspace * enable tests in build * Move to C flags * Enable testing in CI * GCC warnings * Don't meddle with compiler flags in CMake * C2059: syntax error: 'bad suffix on number' * C4001: nonstd ext 'single line comment' was used * /wd4001 * /wd4001 again * Remove Za builds of cl_icd_h.c * Fix oeprator precedence * Refrain from altering global state * Add C_STANDARD to GCC build * Add 32-bit and 64-bit matrix dims * Change -march to -m * Try adding host * install gcc-multilib * Add GCC 8 & 9 multilib * Install GCC multilib conditionally * Add note on Windows C versions incoming * Add INCRMENTAL to silence notice on full link * Experiment with disabling * Initial MacOS config * Add ninja to MacOS build * Fix nproc * nproc -> sysctl * Xcode * cmd -> bash * which gcc-9 * Actual GCC invocation * Check gcc if symlink * follow link * Obtain env * Cleanup * Re-enable Windows and Linux * Check pkgconfig * Syntax fix * INSTALL_PREFIX to PREFIX_PATH * Use CONFIG * Added bare and SDK consumption * Fix bare target * Fix test for unsued variable * Add missing semi-colons * Rework SDK emulation * Fix indentation * Fix build path for SDK consumption * Add Windows consumption test * MacOS * Fix indentation * Enable MacOS * CMAKE_INSTALL_PREFIX >> CMAKE_PREFIX_PATH * Fix install * Install Release on Windows * Re-enable Linux and Windows * Added C99 builds * Removed pkgconfig.c duplication * Fix out-of-sync target in readme * Added policy to make readme sample work * match up paths in readme samples * Homogenize target names * Remove all warnings from sample readme Co-authored-by: sL1pKn07 <sl1pkn07@gmail.com>
2020-11-24 18:18:58 +00:00
install(
TARGETS Headers
EXPORT OpenCLHeadersTargets
)
install(
DIRECTORY CL
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
Comprehensive CMake Package Config support (#107) * Add CMake Packaging + CI For Package * Uniform formatting * Explicit compiler detection * Simplify exported target name * Changed include dir to SYSTEM BEFORE * Remove travis * Initial Github Actions yaml * Fix CWD * Remove CWD from YAML * MSVC warning flags * Fix CWD for CTest invocations * Relative CWD * runner.workspace * enable tests in build * Move to C flags * Enable testing in CI * GCC warnings * Don't meddle with compiler flags in CMake * C2059: syntax error: 'bad suffix on number' * C4001: nonstd ext 'single line comment' was used * /wd4001 * /wd4001 again * Remove Za builds of cl_icd_h.c * Fix oeprator precedence * Refrain from altering global state * Add C_STANDARD to GCC build * Add 32-bit and 64-bit matrix dims * Change -march to -m * Try adding host * install gcc-multilib * Add GCC 8 & 9 multilib * Install GCC multilib conditionally * Add note on Windows C versions incoming * Add INCRMENTAL to silence notice on full link * Experiment with disabling * Initial MacOS config * Add ninja to MacOS build * Fix nproc * nproc -> sysctl * Xcode * cmd -> bash * which gcc-9 * Actual GCC invocation * Check gcc if symlink * follow link * Obtain env * Cleanup * Re-enable Windows and Linux * Check pkgconfig * Syntax fix * INSTALL_PREFIX to PREFIX_PATH * Use CONFIG * Added bare and SDK consumption * Fix bare target * Fix test for unsued variable * Add missing semi-colons * Rework SDK emulation * Fix indentation * Fix build path for SDK consumption * Add Windows consumption test * MacOS * Fix indentation * Enable MacOS * CMAKE_INSTALL_PREFIX >> CMAKE_PREFIX_PATH * Fix install * Install Release on Windows * Re-enable Linux and Windows * Added C99 builds * Removed pkgconfig.c duplication * Fix out-of-sync target in readme * Added policy to make readme sample work * match up paths in readme samples * Homogenize target names * Remove all warnings from sample readme Co-authored-by: sL1pKn07 <sl1pkn07@gmail.com>
2020-11-24 18:18:58 +00:00
export(
EXPORT OpenCLHeadersTargets
FILE ${PROJECT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersTargets.cmake
NAMESPACE OpenCL::
)
file(
WRITE ${PROJECT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersConfig.cmake
"include(\"\${CMAKE_CURRENT_LIST_DIR}/OpenCLHeadersTargets.cmake\")"
)
set(config_package_location ${CMAKE_INSTALL_DATADIR}/cmake/OpenCLHeaders)
install(
EXPORT OpenCLHeadersTargets
FILE OpenCLHeadersTargets.cmake
NAMESPACE OpenCL::
DESTINATION ${config_package_location}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersConfig.cmake
DESTINATION ${config_package_location}
)
unset(CMAKE_SIZEOF_VOID_P)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersConfigVersion.cmake
DESTINATION ${config_package_location}
)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING)
Comprehensive CMake Package Config support (#107) * Add CMake Packaging + CI For Package * Uniform formatting * Explicit compiler detection * Simplify exported target name * Changed include dir to SYSTEM BEFORE * Remove travis * Initial Github Actions yaml * Fix CWD * Remove CWD from YAML * MSVC warning flags * Fix CWD for CTest invocations * Relative CWD * runner.workspace * enable tests in build * Move to C flags * Enable testing in CI * GCC warnings * Don't meddle with compiler flags in CMake * C2059: syntax error: 'bad suffix on number' * C4001: nonstd ext 'single line comment' was used * /wd4001 * /wd4001 again * Remove Za builds of cl_icd_h.c * Fix oeprator precedence * Refrain from altering global state * Add C_STANDARD to GCC build * Add 32-bit and 64-bit matrix dims * Change -march to -m * Try adding host * install gcc-multilib * Add GCC 8 & 9 multilib * Install GCC multilib conditionally * Add note on Windows C versions incoming * Add INCRMENTAL to silence notice on full link * Experiment with disabling * Initial MacOS config * Add ninja to MacOS build * Fix nproc * nproc -> sysctl * Xcode * cmd -> bash * which gcc-9 * Actual GCC invocation * Check gcc if symlink * follow link * Obtain env * Cleanup * Re-enable Windows and Linux * Check pkgconfig * Syntax fix * INSTALL_PREFIX to PREFIX_PATH * Use CONFIG * Added bare and SDK consumption * Fix bare target * Fix test for unsued variable * Add missing semi-colons * Rework SDK emulation * Fix indentation * Fix build path for SDK consumption * Add Windows consumption test * MacOS * Fix indentation * Enable MacOS * CMAKE_INSTALL_PREFIX >> CMAKE_PREFIX_PATH * Fix install * Install Release on Windows * Re-enable Linux and Windows * Added C99 builds * Removed pkgconfig.c duplication * Fix out-of-sync target in readme * Added policy to make readme sample work * match up paths in readme samples * Homogenize target names * Remove all warnings from sample readme Co-authored-by: sL1pKn07 <sl1pkn07@gmail.com>
2020-11-24 18:18:58 +00:00
include(CTest)
endif()
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING) AND BUILD_TESTING)
Comprehensive CMake Package Config support (#107) * Add CMake Packaging + CI For Package * Uniform formatting * Explicit compiler detection * Simplify exported target name * Changed include dir to SYSTEM BEFORE * Remove travis * Initial Github Actions yaml * Fix CWD * Remove CWD from YAML * MSVC warning flags * Fix CWD for CTest invocations * Relative CWD * runner.workspace * enable tests in build * Move to C flags * Enable testing in CI * GCC warnings * Don't meddle with compiler flags in CMake * C2059: syntax error: 'bad suffix on number' * C4001: nonstd ext 'single line comment' was used * /wd4001 * /wd4001 again * Remove Za builds of cl_icd_h.c * Fix oeprator precedence * Refrain from altering global state * Add C_STANDARD to GCC build * Add 32-bit and 64-bit matrix dims * Change -march to -m * Try adding host * install gcc-multilib * Add GCC 8 & 9 multilib * Install GCC multilib conditionally * Add note on Windows C versions incoming * Add INCRMENTAL to silence notice on full link * Experiment with disabling * Initial MacOS config * Add ninja to MacOS build * Fix nproc * nproc -> sysctl * Xcode * cmd -> bash * which gcc-9 * Actual GCC invocation * Check gcc if symlink * follow link * Obtain env * Cleanup * Re-enable Windows and Linux * Check pkgconfig * Syntax fix * INSTALL_PREFIX to PREFIX_PATH * Use CONFIG * Added bare and SDK consumption * Fix bare target * Fix test for unsued variable * Add missing semi-colons * Rework SDK emulation * Fix indentation * Fix build path for SDK consumption * Add Windows consumption test * MacOS * Fix indentation * Enable MacOS * CMAKE_INSTALL_PREFIX >> CMAKE_PREFIX_PATH * Fix install * Install Release on Windows * Re-enable Linux and Windows * Added C99 builds * Removed pkgconfig.c duplication * Fix out-of-sync target in readme * Added policy to make readme sample work * match up paths in readme samples * Homogenize target names * Remove all warnings from sample readme Co-authored-by: sL1pKn07 <sl1pkn07@gmail.com>
2020-11-24 18:18:58 +00:00
add_subdirectory(tests)
endif()