Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on OSX #1

Open
ppiecuch opened this issue Mar 29, 2020 · 0 comments
Open

Building on OSX #1

ppiecuch opened this issue Mar 29, 2020 · 0 comments

Comments

@ppiecuch
Copy link

ppiecuch commented Mar 29, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant