Skip to content

Commit 545210e

Browse files
Don't require FF_HAVE_OPENCL on Apple
1 parent 6f60423 commit 545210e

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,6 @@ if(APPLE)
325325
PRIVATE "-framework OpenGL"
326326
PRIVATE "-framework OpenCL"
327327
)
328-
329-
target_compile_definitions(libfastfetch
330-
PRIVATE FF_HAVE_OPENCL=1
331-
)
332328
endif()
333329

334330
target_include_directories(libfastfetch

src/modules/opencl.c

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
#define FF_OPENCL_MODULE_NAME "OpenCL"
55
#define FF_OPENCL_NUM_FORMAT_ARGS 3
66

7-
#ifdef FF_HAVE_OPENCL
7+
#if defined(FF_HAVE_OPENCL) || defined(__APPLE__)
88
#include "common/library.h"
99
#include "common/parsing.h"
1010
#include <string.h>
1111

1212
#define CL_TARGET_OPENCL_VERSION 100
1313
#ifdef __APPLE__
14-
#include <OpenCL/cl.h>
14+
#include <OpenCL/cl.h>
1515
#else
16-
#include <CL/cl.h>
16+
#include <CL/cl.h>
1717
#endif
1818

1919
typedef struct OpenCLData
@@ -75,36 +75,43 @@ static const char* openCLHandelData(FFinstance* instance, OpenCLData* data)
7575
return NULL;
7676
}
7777

78+
#endif // FF_HAVE_OPENCL || __APPLE__
79+
80+
#ifdef FF_HAVE_OPENCL
81+
7882
static const char* printOpenCL(FFinstance* instance)
7983
{
8084
OpenCLData data;
8185

82-
#ifdef __APPLE__
83-
data.ffclGetPlatformIDs = clGetPlatformIDs;
84-
data.ffclGetDeviceIDs = clGetDeviceIDs;
85-
data.ffclGetDeviceInfo = clGetDeviceInfo;
86-
#else
87-
FF_LIBRARY_LOAD(opencl, instance->config.libOpenCL, "dlopen libOpenCL.so failed", "libOpenCL.so", 1);
88-
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetPlatformIDs);
89-
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceIDs);
90-
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceInfo);
91-
#endif
86+
FF_LIBRARY_LOAD(opencl, instance->config.libOpenCL, "dlopen libOpenCL.so failed", "libOpenCL.so", 1);
87+
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetPlatformIDs);
88+
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceIDs);
89+
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetDeviceInfo);
9290

9391
const char* error = openCLHandelData(instance, &data);
92+
dlclose(opencl);
93+
return error;
94+
}
9495

95-
#ifndef __APPLE__
96-
dlclose(opencl);
97-
#endif
96+
#elif __APPLE__ // FF_HAVE_OPENCL
9897

99-
return error;
98+
static const char* printOpenCL(FFinstance* instance)
99+
{
100+
OpenCLData data;
101+
data.ffclGetPlatformIDs = clGetPlatformIDs;
102+
data.ffclGetDeviceIDs = clGetDeviceIDs;
103+
data.ffclGetDeviceInfo = clGetDeviceInfo;
104+
105+
return openCLHandelData(instance, &data);
100106
}
101-
#endif
107+
108+
#endif // __APPLE__
102109

103110
void ffPrintOpenCL(FFinstance* instance)
104111
{
105112
const char* error;
106113

107-
#ifdef FF_HAVE_OPENCL
114+
#if defined(FF_HAVE_OPENCL) || defined(__APPLE__)
108115
error = printOpenCL(instance);
109116
#else
110117
error = "Fastfetch was build without OpenCL support";

0 commit comments

Comments
 (0)