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

Use system libs when available #81

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 48 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ option(BONZOMATIC_NDI "Enable NDI?" OFF)

option(BONZOMATIC_TOUCHBAR "Compile with macOS TouchBar support (Xcode 9 or newer required)?" ON)

if (UNIX AND (NOT APPLE))
option(BONZOMATIC_USE_SYSTEMWIDE_GLFW "Use the system-wide version of GLFW instead of the vendored one (this build option is not supported by upstream)?" OFF)
option(BONZOMATIC_USE_SYSTEMWIDE_GLEW "Use the system-wide version of GLEW instead of the vendored one (this build option is not supported by upstream)?" OFF)
endif ()

set(BONZOMATIC_WINDOWS_FLAVOR "DX11" CACHE STRING "Windows renderer flavor selected at CMake configure time (DX11, DX9 or GLFW)")
set_property(CACHE BONZOMATIC_WINDOWS_FLAVOR PROPERTY STRINGS DX11 DX9 GLFW)

Expand Down Expand Up @@ -68,37 +73,54 @@ if (APPLE OR UNIX OR (WIN32 AND (${BONZOMATIC_WINDOWS_FLAVOR} MATCHES "GLFW")))
##############################################################################
# GLFW
# GLFW settings and project inclusion
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
mark_as_advanced(GLFW_BUILD_EXAMPLES GLFW_BUILD_TESTS GLFW_BUILD_DOCS GLFW_INSTALL)
if (APPLE)
set(GLFW_USE_CHDIR OFF CACHE BOOL "" FORCE)
set(GLFW_USE_RETINA OFF CACHE BOOL "" FORCE)
set(GLFW_USE_MENUBAR ON CACHE BOOL "" FORCE)
mark_as_advanced(GLFW_USE_CHDIR GLFW_USE_RETINA GLFW_USE_MENUBAR)
elseif (WIN32)
set(USE_MSVC_RUNTIME_LIBRARY_DLL OFF CACHE BOOL "" FORCE)
mark_as_advanced(USE_MSVC_RUNTIME_LIBRARY_DLL)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND AND BONZOMATIC_USE_SYSTEMWIDE_GLFW)
pkg_check_modules(GLFW glfw3)
endif()
if (BONZOMATIC_USE_SYSTEMWIDE_GLFW AND GLFW_FOUND)
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${GLFW_INCLUDES})
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${GLFW_LIBRARIES})
else()
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
mark_as_advanced(GLFW_BUILD_EXAMPLES GLFW_BUILD_TESTS GLFW_BUILD_DOCS GLFW_INSTALL)
if (APPLE)
set(GLFW_USE_CHDIR OFF CACHE BOOL "" FORCE)
set(GLFW_USE_RETINA OFF CACHE BOOL "" FORCE)
set(GLFW_USE_MENUBAR ON CACHE BOOL "" FORCE)
mark_as_advanced(GLFW_USE_CHDIR GLFW_USE_RETINA GLFW_USE_MENUBAR)
elseif (WIN32)
set(USE_MSVC_RUNTIME_LIBRARY_DLL OFF CACHE BOOL "" FORCE)
mark_as_advanced(USE_MSVC_RUNTIME_LIBRARY_DLL)
endif()
add_subdirectory(${CMAKE_SOURCE_DIR}/external/glfw/)
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/glfw/include)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} glfw ${GLFW_LIBRARIES})
endif()
add_subdirectory(${CMAKE_SOURCE_DIR}/external/glfw/)
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/glfw/include)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} glfw ${GLFW_LIBRARIES})

##############################################################################
# GLEW
set(GLEW_SRCS
${CMAKE_SOURCE_DIR}/external/glew/glew.c
)
add_library(bzc_glew STATIC ${GLEW_SRCS})
target_include_directories(bzc_glew PUBLIC ${CMAKE_SOURCE_DIR}/external/glew)
target_compile_definitions(bzc_glew PUBLIC -DGLEW_STATIC)
if (MSVC)
target_compile_options(bzc_glew PUBLIC "$<$<CONFIG:Release>:/MT>")
if (PKG_CONFIG_FOUND AND BONZOMATIC_USE_SYSTEMWIDE_GLEW)
pkg_check_modules(GLEW glew)
endif()
if (BONZOMATIC_USE_SYSTEMWIDE_GLEW AND GLEW_FOUND)
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${GLEW_INCLUDES})
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${GLEW_LIBRARIES})
else ()
set(GLEW_SRCS
${CMAKE_SOURCE_DIR}/external/glew/glew.c
)
add_library(bzc_glew STATIC ${GLEW_SRCS})
target_include_directories(bzc_glew PUBLIC ${CMAKE_SOURCE_DIR}/external/glew)
target_compile_definitions(bzc_glew PUBLIC -DGLEW_STATIC)
if (MSVC)
target_compile_options(bzc_glew PUBLIC "$<$<CONFIG:Release>:/MT>")
endif ()
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/glew)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} bzc_glew)
endif ()
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/glew)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} bzc_glew)
else ()
# for windows, use DirectX
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} $ENV{DXSDK_DIR}/Include)
Expand Down