Skip to content

Building on OSX #1

@ppiecuch

Description

@ppiecuch

A few fixes to build the plugins on OSX:

  1. That's how I load OpenGL headers:
#if defined(__APPLE__)
#define GL_SILENCE_DEPRECATION
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#include <GL/gl.h>
#endif

Some changes in CMakeList:
2. GLEW is not necessary on OSX so I have removed it for CMakeList. Also I have noticed that SDL is not needed on OSX.

if(WIN32)
	# link specific win32 libraries
	target_link_libraries(GodotShaders GLEW::GLEW)
else()
    if(APPLE)
      target_link_libraries(GodotShaders "-framework CoreFoundation -framework Cocoa")
    else()
	  # link linux libraries
	  target_link_libraries(GodotShaders ${GLEW_LIBRARIES})
    endif()
endif()
  1. Force .so extension on OSX (maybe make sense to keep .so on all platforms):
set_target_properties(GodotShaders PROPERTIES OUTPUT_NAME "plugin")
set_target_properties(GodotShaders PROPERTIES PREFIX "")
if(APPLE)
  set_target_properties(GodotShaders PROPERTIES SUFFIX ".so")
endif
if(WIN32)
	# link specific win32 libraries
	target_link_libraries(GodotShaders GLEW::GLEW)
else()
    if(APPLE)
      target_link_libraries(GodotShaders "-framework CoreFoundation -framework Cocoa")
    else()
	  # link linux libraries
	  target_link_libraries(GodotShaders ${GLEW_LIBRARIES})
    endif()
endif()
  1. Fetching repositories if project is not found locally:
# glew
find_package(GLEW QUIET)
if(NOT GLEW_FOUND)
  FetchContent_Declare(
    glew
    URL "https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.zip"
  )
  FetchContent_GetProperties(glew)
  if(NOT glew_POPULATED)
    FetchContent_Populate(glew)
    # Top level doesn't contain the CMakeLists.txt, it is in the "build/cmake" subdirectory
    add_subdirectory(${glew_SOURCE_DIR}/build/cmake ${glew_BINARY_DIR})
  endif()
  set(GLEW_INCLUDE_DIRS ${glew_SOURCE_DIR}/include)
  set(GLEW_LIBRARY_DIRS ${glew_BINARY_DIR}/libs)
  set(GLEW_LIBRARIES glew_s)
endif()

# glm
find_package(GLM QUIET)
if(NOT GLM_FOUND)
  FetchContent_Declare(
    glm
    GIT_REPOSITORY "https://github.com/g-truc/glm.git"
    GIT_TAG "0.9.9.7"
  )
  FetchContent_MakeAvailable(glm)
  set(GLM_INCLUDE_DIRS ${glm_SOURCE_DIR})
  set(GLM_LIBRARY_DIRS ${glm_BINARY_DIR})
endif()

Screenshot 2020-03-29 at 15 29 55

Regards
Pawel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions