From c8357f62dfe15989296213dfaba9de1433bb1ee4 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 2 Mar 2026 02:44:28 +0800 Subject: [PATCH 5/7] macOS-specific adjustments --- CMakeLists.txt | 2 +- icd/freeocl.icd | 2 +- src/icd/icd_loader.cpp | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0fd6d5..60ef461 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,7 @@ add_subdirectory(samples) add_subdirectory(src) if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) - install(FILES icd/freeocl.icd DESTINATION /etc/OpenCL/vendors/) + install(FILES icd/freeocl.icd DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/OpenCL/vendors/) endif(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) # OpenCL headers shouldn't be needed in the runtime package diff --git a/icd/freeocl.icd b/icd/freeocl.icd index 4570ad7..0623890 100644 --- a/icd/freeocl.icd +++ b/icd/freeocl.icd @@ -1 +1 @@ -libFreeOCL.so \ No newline at end of file +libFreeOCL.dylib \ No newline at end of file diff --git a/src/icd/icd_loader.cpp b/src/icd/icd_loader.cpp index c6ffe5f..dd641ec 100644 --- a/src/icd/icd_loader.cpp +++ b/src/icd/icd_loader.cpp @@ -91,7 +91,7 @@ namespace FreeOCL #else // Get the list of all *.icd files in /etc/OpenCL/vendors/ - const std::deque &files = list_files("/etc/OpenCL/vendors/", ".icd"); + const std::deque &files = list_files("@PREFIX@/etc/OpenCL/vendors/", ".icd"); // For each file for(std::deque::const_iterator i = files.begin() ; i != files.end() ; ++i) { @@ -105,13 +105,21 @@ namespace FreeOCL load(lib); file.close(); #ifdef FREEOCL_ALWAYS_LOAD_FREEOCL +#ifdef FREEOCL_OS_DARWIN + b_FreeOCL_loaded |= (lib.find("libFreeOCL.dylib") != std::string::npos); +#else b_FreeOCL_loaded |= (lib.find("libFreeOCL.so") != std::string::npos); +#endif #endif } #ifdef FREEOCL_ALWAYS_LOAD_FREEOCL if (!b_FreeOCL_loaded) +#ifdef FREEOCL_OS_DARWIN + load("libFreeOCL.dylib"); +#else load("libFreeOCL.so"); #endif +#endif #endif }