Repository navigation
configuration mechanism #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
88c57b4
f6c9ff1
7419e16
21279b0
e2a2ad1
2ed3b03
fc33885
d680949
de27aa7
e0c9b47
0b8ca49
b880e9e
e0c730b
b5b7580
af09acd
627b027
c1b7f2d
8c9ddff
c90f185
82028eb
464aaa0
f8cea29
0af1432
73045f1
a28e55e
8e333d8
c9b84f3
3e87443
aa11385
60ecdff
53fb6c4
5aa6e52
54b10b1
24dcab7
2291458
3082114
0b14b37
48613f8
ac5f337
60f09aa
7586978
ec9897a
788e7b4
b895cd9
3e7f817
17ec47a
73a39f6
103f80e
4f9309f
e6a8c45
0dc7fba
ae1209d
2b2448e
66f1a3a
14c6bf1
e31094b
0a82109
6042947
c190a0c
7edb644
010b864
3a3277c
7461633
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,22 @@ | ||
| cmake_minimum_required(VERSION 3.15 FATAL_ERROR) | ||
| project(spla LANGUAGES CXX) | ||
|
|
||
| ###################################################################### | ||
| ## Package version | ||
| ## python/VERSION.md is the single source of truth for the version: | ||
| ## python/setup.py reads it for the PyPI package and the C++ library | ||
| ## gets it as the SPLA_VERSION compile definition. | ||
|
|
||
| file(READ "${CMAKE_CURRENT_LIST_DIR}/python/VERSION.md" SPLA_VERSION_RAW) | ||
| string(STRIP "${SPLA_VERSION_RAW}" SPLA_VERSION) | ||
| message(STATUS "SPLA package version: ${SPLA_VERSION}") | ||
|
|
||
| ###################################################################### | ||
| ## public options | ||
|
|
||
| option(SPLA_BUILD_TESTS "Build test folder with modules tests" YES) | ||
| option(SPLA_BUILD_EXAMPLES "Build library example applications with algorithms" YES) | ||
| option(SPLA_BUILD_TOOLS "Build command line tools (spla)" YES) | ||
| option(SPLA_BUILD_OPENCL "Build library with opencl backend" YES) | ||
|
|
||
| ###################################################################### | ||
|
|
@@ -178,18 +189,40 @@ endfunction() | |
| add_subdirectory(deps/robin_hood) | ||
| add_subdirectory(deps/svector) | ||
|
|
||
| message(STATUS "Add CLI11 as CLI/ENV parser") | ||
| include(FetchContent) | ||
|
|
||
| FetchContent_Declare(CLI11 | ||
| GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git | ||
| GIT_TAG v2.4.2 | ||
| ) | ||
| FetchContent_MakeAvailable(CLI11) | ||
|
|
||
| message(STATUS "Add nlohmann/json as JSON parser") | ||
| FetchContent_Declare(nlohmann_json | ||
| GIT_REPOSITORY https://github.com/nlohmann/json.git | ||
| GIT_TAG v3.11.3 | ||
| ) | ||
| FetchContent_MakeAvailable(nlohmann_json) | ||
|
|
||
| if (SPLA_BUILD_OPENCL) | ||
| if (SPLA_TARGET_MACOSX) | ||
| message(STATUS "Add standard Apple OpenCL package") | ||
| find_package(OpenCL REQUIRED) | ||
| message(STATUS "Use Apple OpenCL framework for linking, headers from deps") | ||
| find_library(OPENCL_FRAMEWORK OpenCL REQUIRED) | ||
|
|
||
| add_library(OpenCLHeaders INTERFACE) | ||
| add_library(OpenCL::Headers ALIAS OpenCLHeaders) | ||
| target_include_directories(OpenCLHeaders INTERFACE ${OpenCL_INCLUDE_DIRS}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I explicitly point to local Khronos headers in deps/ because Apple no longer ships OpenCL header files in the SDK |
||
| target_include_directories(OpenCLHeaders INTERFACE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/deps/opencl-headers) | ||
|
|
||
| add_library(HeadersCpp INTERFACE) | ||
| add_library(OpenCL::HeadersCpp ALIAS HeadersCpp) | ||
| target_include_directories(HeadersCpp INTERFACE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/deps/opencl-headers-hpp/include) | ||
| target_link_libraries(HeadersCpp INTERFACE OpenCL::Headers) | ||
|
|
||
| add_library(OpenCL INTERFACE) | ||
| target_include_directories(OpenCL INTERFACE ${OpenCL_INCLUDE_DIRS}) | ||
| target_link_libraries(OpenCL INTERFACE ${OpenCL_LIBRARIES}) | ||
| target_link_libraries(OpenCL INTERFACE ${OPENCL_FRAMEWORK}) | ||
| else () | ||
| message(STATUS "Add Khronos OpenCL C API header files") | ||
| add_subdirectory(deps/opencl-headers) | ||
|
|
@@ -199,14 +232,13 @@ if (SPLA_BUILD_OPENCL) | |
| set(OPENCL_ICD_LOADER_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) | ||
| set(OPENCL_ICD_LOADER_BUILD_TESTING OFF CACHE BOOL "" FORCE) | ||
| add_subdirectory(deps/opencl-icd-loader) | ||
| endif () | ||
|
|
||
|
|
||
| message(STATUS "Add Khronos OpenCL HPP bindings") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It made to prevent linking against the Apple framework on Linux/Windows |
||
| add_library(HeadersCpp INTERFACE) | ||
| add_library(OpenCL::HeadersCpp ALIAS HeadersCpp) | ||
| target_include_directories(HeadersCpp INTERFACE deps/opencl-headers-hpp/include) | ||
| target_link_libraries(HeadersCpp INTERFACE OpenCL::Headers) | ||
| message(STATUS "Add Khronos OpenCL HPP bindings") | ||
| add_library(HeadersCpp INTERFACE) | ||
| add_library(OpenCL::HeadersCpp ALIAS HeadersCpp) | ||
| target_include_directories(HeadersCpp INTERFACE deps/opencl-headers-hpp/include) | ||
| target_link_libraries(HeadersCpp INTERFACE OpenCL::Headers) | ||
| endif () | ||
| endif () | ||
|
|
||
| if (SPLA_BUILD_EXAMPLES) | ||
|
|
@@ -297,6 +329,9 @@ add_library(spla SHARED | |
| include/spla/vector.hpp | ||
| src/core/accelerator.hpp | ||
| src/core/common.hpp | ||
| src/core/config_status.hpp | ||
| src/core/configure.cpp | ||
| src/core/configure.hpp | ||
| src/core/dispatcher.cpp | ||
| src/core/dispatcher.hpp | ||
| src/core/logger.cpp | ||
|
|
@@ -368,21 +403,35 @@ target_include_directories(spla PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src) | |
|
|
||
| set_target_properties(spla PROPERTIES OUTPUT_NAME "spla_${SPLA_ARCH}") | ||
| target_compile_definitions(spla PRIVATE SPLA_EXPORTS) | ||
| target_compile_definitions(spla PRIVATE SPLA_VERSION="${SPLA_VERSION}") | ||
|
|
||
| target_link_libraries(spla PRIVATE robin_hood) | ||
| target_link_libraries(spla PRIVATE svector) | ||
| target_link_libraries(spla PRIVATE CLI11::CLI11) | ||
| target_link_libraries(spla PRIVATE nlohmann_json::nlohmann_json) | ||
| target_link_libraries(spla PRIVATE ${CMAKE_DL_LIBS}) | ||
|
|
||
| if (SPLA_BUILD_OPENCL) | ||
| target_link_libraries(spla PUBLIC OpenCL) | ||
| target_link_libraries(spla PUBLIC OpenCL::HeadersCpp) | ||
| target_compile_definitions(spla PUBLIC CL_TARGET_OPENCL_VERSION=120) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What the reason of these changes?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. locked C++ bindings to 1.2, same as C bindings |
||
| target_compile_definitions(spla PUBLIC | ||
| CL_TARGET_OPENCL_VERSION=120 | ||
| CL_HPP_TARGET_OPENCL_VERSION=120 | ||
| CL_HPP_MINIMUM_OPENCL_VERSION=120) | ||
| list(APPEND SPLA_DEFINES SPLA_BUILD_OPENCL) | ||
| endif () | ||
|
|
||
| spla_target_compile_definitions(spla) | ||
| spla_target_compile_options(spla) | ||
| spla_target_link_options(spla) | ||
|
|
||
| set(SPLA_CONF_SRC "${CMAKE_CURRENT_LIST_DIR}/python/pyspla/spla_conf.json") | ||
| set(SPLA_CONF_DST "${CMAKE_BINARY_DIR}/spla_conf.json") | ||
| add_custom_command(TARGET spla POST_BUILD | ||
| COMMAND "${CMAKE_COMMAND}" -E copy_if_different | ||
| "${SPLA_CONF_SRC}" "${SPLA_CONF_DST}" | ||
| COMMENT "Copying shipped configuration file spla_conf.json next to the library") | ||
|
|
||
| ###################################################################### | ||
| ## Add examples directory | ||
|
|
||
|
|
@@ -404,6 +453,18 @@ if (SPLA_BUILD_EXAMPLES) | |
| spla_example_application(convert) | ||
| endif () | ||
|
|
||
| ###################################################################### | ||
| ## Add command line tools | ||
|
|
||
| if (SPLA_BUILD_TOOLS) | ||
| message(STATUS "Add command line tools to build") | ||
|
|
||
| add_executable(spla_cli tools/soft_check.cpp) | ||
| target_link_libraries(spla_cli PRIVATE spla) | ||
| target_link_libraries(spla_cli PRIVATE CLI11::CLI11) | ||
| set_target_properties(spla_cli PROPERTIES OUTPUT_NAME spla) | ||
| endif () | ||
|
|
||
| ###################################################################### | ||
| ## Add unit-tests directory | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why these changes required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My code requirs newer OpenCL headers. Apple removed them from macOS SDKs, so find_package fails. I bundle Khronos headers to build new code, while linking the system framework for macOS compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code? Your code just configure existing library. Why it requires newer OpenCL?