HPCE / hpce-2018-cw3

1 stars 5 forks source link

OpenCL on MacOS #90

Closed ashleydavies closed 5 years ago

ashleydavies commented 5 years ago

The default makefile won't build on MacOS (unless I'm missing something), but it works with the following modification (inspired by https://stackoverflow.com/questions/714100/os-detecting-makefile)

CPPFLAGS += -I include
CPPFLAGS += -W -Wall
CPPFLAGS += -std=c++11
CPPFLAGS += -O3

ifeq ($(OS),Windows_NT)
  OPENCL_FLAG += -lOpenCL
else
    UNAME := $(shell uname -s)

    ifeq ($(UNAME),Linux)
      OPENCL_FLAG += -lOpenCL
  endif
    ifeq ($(UNAME),Darwin)
        OPENCL_FLAG += -framework OpenCL
    endif
endif

# LDLIBS += $(OPENCL_FLAG)

all : bin/make_world bin/render_world bin/step_world

bin/% : src/%.cpp src/heat.cpp
    mkdir -p $(dir $@)
    $(CXX) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)

bin/test_opencl : src/test_opencl.cpp
    mkdir -p $(dir $@)
    $(CXX) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(OPENCL_FLAG)

Haven't sent this as a PR as I haven't tried this on Linux or Windows yet and it's pretty ugly, but thought it might help out others who run into the same issue I did.

If I missed something and this is unnecessary, please let me know!

ashleydavies commented 5 years ago

🤦🏻‍♂️sorry, I just read on in the specification and noticed this is already documented. My bad!