Skip to content

Commit 5e5c144

Browse files
Fix build on apple
1 parent ac33043 commit 5e5c144

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

CMakeLists.txt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,22 +315,19 @@ ff_lib_enable(GLX glx)
315315
ff_lib_enable(OSMESA osmesa)
316316
ff_lib_enable(OPENCL OpenCL)
317317

318-
function(ff_framwork_enable LIBNAME)
319-
if(NOT APPLE)
320-
return()
321-
endif()
322-
323-
find_package(${LIBNAME} REQUIRED)
324-
325-
target_include_directories(libfastfetch PRIVATE ${${LIBNAME}_INCLUDE_DIRS})
326-
target_link_directories(libfastfetch PRIVATE ${${LIBNAME}_LIBRARY_DIRS})
327-
target_link_libraries(libfastfetch PRIVATE ${${LIBNAME}_LIBRARIES})
328-
endfunction()
318+
if(APPLE)
319+
target_link_libraries(libfastfetch
320+
PRIVATE "-framework CoreFoundation"
321+
PRIVATE "-framework IOKit"
322+
PRIVATE "-framework CoreGraphics"
323+
PRIVATE "-framework OpenGL"
324+
PRIVATE "-framework OpenCL"
325+
)
329326

330-
ff_framwork_enable(IOKit)
331-
ff_framwork_enable(CoreGraphics)
332-
ff_framwork_enable(OpenGL)
333-
ff_framwork_enable(OpenCL)
327+
target_compile_definitions(libfastfetch
328+
PRIVATE FF_HAVE_OPENCL=1
329+
)
330+
endif()
334331

335332
target_include_directories(libfastfetch
336333
PUBLIC ${PROJECT_BINARY_DIR}

src/detection/displayserver/displayserver_apple.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ static void detectResolution(FFDisplayServerResult* ds)
3232
CGDisplayCount screenCount;
3333
CGGetOnlineDisplayList(INT_MAX, NULL, &screenCount);
3434
if(screenCount == 0)
35-
{
36-
dlclose(cg);
3735
return;
38-
}
3936

4037
CGDirectDisplayID* screens = malloc(screenCount * sizeof(CGDirectDisplayID));
4138
CGGetOnlineDisplayList(INT_MAX, screens, &screenCount);

src/detection/gpu/gpu_apple.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ void ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
2727
CFMutableDictionaryRef matchDict = IOServiceMatching("IOPCIDevice");
2828
io_iterator_t iterator;
2929
if(IOServiceGetMatchingServices(0, matchDict, &iterator) != kIOReturnSuccess)
30-
{
31-
dlclose(iokit);
3230
return;
33-
}
3431

3532
io_registry_entry_t registryEntry;
3633
while((registryEntry = IOIteratorNext(iterator)) != 0)

src/modules/opengl.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ static const char* osMesaPrint(FFinstance* instance)
341341

342342
#ifdef __APPLE__
343343

344+
#include <OpenGL/OpenGL.h> // This brings in CGL, not GL
345+
344346
typedef struct CGLData
345347
{
346348
CGLPixelFormatObj pixelFormat;
@@ -370,18 +372,20 @@ static const char* cglHandlePixelFormat(FFinstance* instance, CGLData* data)
370372

371373
static const char* cglPrint(FFinstance* instance)
372374
{
375+
CGLData data;
376+
373377
CGLPixelFormatAttribute attrs[] = {
374378
kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core,
375379
kCGLPFAAccelerated,
376380
0
377381
};
378382

379383
GLint num;
380-
if (CGLChoosePixelFormat(attrs, &data->pixelFormat, &num) != kCGLNoError)
384+
if (CGLChoosePixelFormat(attrs, &data.pixelFormat, &num) != kCGLNoError)
381385
return "CGLChoosePixelFormat() failed";
382386

383-
const char* error = cglHandlePixelFormat(instance, data);
384-
CGLDestroyPixelFormat(data->pixelFormat);
387+
const char* error = cglHandlePixelFormat(instance, &data);
388+
CGLDestroyPixelFormat(data.pixelFormat);
385389
return error;
386390
}
387391

0 commit comments

Comments
 (0)