Skip to content

Commit

Permalink
[skip ci] cmake add GLEW_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Feb 25, 2020
1 parent f18db4e commit f47420b
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions cmake/TaichiCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endif()

option(USE_STDCPP "Use -stdlib=libc++" OFF)
option(TI_WITH_CUDA "Build with CUDA support" OFF)
option(TI_WITH_OPENGL "Build with OpenGL backend" ON)

include_directories(${CMAKE_SOURCE_DIR})
include_directories(external/xxhash)
Expand Down Expand Up @@ -53,6 +54,25 @@ if (TI_WITH_CUDA)
endif()
endif()

if (TI_WITH_OPENGL)
if(NOT GLEW_VERSION)
set(GLEW_VERSION 2.0.0)
endif()
find_package(GLEW ${GLEW_VERSION})
if (GLEW_FOUND)
message("Building with GLEW ${GLEW_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTI_WITH_OPENGL=1")
#if (MSVC)
# TODO(archibate): figure out how GL is installed on Windows...
#else()
target_link_libraries(${LIBRARY_NAME} /usr/lib/libGLEW.so GLEW)
target_link_libraries(${LIBRARY_NAME} /usr/lib/libglfw.so glfw)
#endif()
else()
message(WARNING "GLEW not found, ignoring TI_WITH_OPENGL.")
endif()
endif()

# http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
find_package(LLVM REQUIRED CONFIG 8.0)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
Expand Down Expand Up @@ -88,9 +108,6 @@ if (TI_WITH_CUDA)
target_link_libraries(${LIBRARY_NAME} ${llvm_ptx_libs})
endif()

target_link_libraries(${LIBRARY_NAME} /usr/lib/libGLEW.so GLEW)
target_link_libraries(${LIBRARY_NAME} /usr/lib/libglfw.so glfw)

# add_executable(runtime runtime/runtime.cpp)

# Optional dependencies
Expand Down

0 comments on commit f47420b

Please sign in to comment.