Skip to content

Commit

Permalink
stop fetching the glfw package by default
Browse files Browse the repository at this point in the history
  • Loading branch information
K1ngst0m committed Jan 15, 2024
1 parent e1e058e commit 8b9d17b
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 9 deletions.
3 changes: 0 additions & 3 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ Branch: vulkan-sdk-1.3.268
[mimalloc]
Branch: v2.1.2

[glfw]
Branch: 3.3.8

[vma]
Branch: master

Expand Down
7 changes: 5 additions & 2 deletions cmake/AphExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ if(NOT (APH_WSI_BACKEND IN_LIST VALID_WSI_BACKENDS))
endif()

if(APH_WSI_BACKEND STREQUAL "Auto" OR APH_WSI_BACKEND STREQUAL "GLFW")
add_subdirectory(${APH_EXTERNAL_DIR}/glfw EXCLUDE_FROM_ALL)
find_package(GLFW3)
if(NOT GLFW3_FOUND)
message(FATAL_ERROR "GLFW3 library not found!")
endif()
elseif(APH_WSI_BACKEND STREQUAL "SDL2")
find_package(SDL2)
find_package(SDL2 CONFIG REQUIRED)
if(NOT SDL2_FOUND)
message(FATAL_ERROR "SDL2 library not found!")
endif()
Expand Down
49 changes: 49 additions & 0 deletions cmake/modules/FindGLFW3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Locate the glfw3 library
#
# This module defines the following variables:
#
# GLFW3_LIBRARY the name of the library;
# GLFW3_INCLUDE_DIR where to find glfw include files.
# GLFW3_FOUND true if both the GLFW3_LIBRARY and GLFW3_INCLUDE_DIR have been found.
#
# To help locate the library and include file, you can define a
# variable called GLFW3_ROOT which points to the root of the glfw library
# installation.
#
# default search dirs
#
# Cmake file from: https://github.com/daw42/glslcookbook

set( _glfw3_HEADER_SEARCH_DIRS
"/usr/include"
"/usr/local/include"
"${CMAKE_SOURCE_DIR}/includes"
"C:/Program Files (x86)/glfw/include" )
set( _glfw3_LIB_SEARCH_DIRS
"/usr/lib"
"/usr/local/lib"
"${CMAKE_SOURCE_DIR}/lib"
"C:/Program Files (x86)/glfw/lib-msvc110" )

# Check environment for root search directory
set( _glfw3_ENV_ROOT $ENV{GLFW3_ROOT} )
if( NOT GLFW3_ROOT AND _glfw3_ENV_ROOT )
set(GLFW3_ROOT ${_glfw3_ENV_ROOT} )
endif()

# Put user specified location at beginning of search
if( GLFW3_ROOT )
list( INSERT _glfw3_HEADER_SEARCH_DIRS 0 "${GLFW3_ROOT}/include" )
list( INSERT _glfw3_LIB_SEARCH_DIRS 0 "${GLFW3_ROOT}/lib" )
endif()

# Search for the header
FIND_PATH(GLFW3_INCLUDE_DIR "GLFW/glfw3.h"
PATHS ${_glfw3_HEADER_SEARCH_DIRS} )

# Search for the library
FIND_LIBRARY(GLFW3_LIBRARY NAMES glfw3 glfw
PATHS ${_glfw3_LIB_SEARCH_DIRS} )
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW3 DEFAULT_MSG
GLFW3_LIBRARY GLFW3_INCLUDE_DIR)
3 changes: 2 additions & 1 deletion engine/wsi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ if(APH_WSI_BACKEND STREQUAL "Auto" OR APH_WSI_BACKEND STREQUAL "GLFW")
${APH_ENGINE_WSI_DIR}/wsi_glfw.cpp
${APH_ENGINE_WSI_DIR}/imgui_impl_glfw.cpp
)
target_link_libraries(wsi PRIVATE glfw)
target_include_directories(wsi PRIVATE ${GLFW3_INCLUDE_DIR})
target_link_libraries(wsi PRIVATE ${GLFW3_LIBRARY})
elseif(APH_WSI_BACKEND STREQUAL "SDL2")
if(NOT SDL2_FOUND)
message(FATAL_ERROR "SDL2 library not found!")
Expand Down
2 changes: 0 additions & 2 deletions engine/wsi/wsi_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ bool WSI::update()
case SDL_KEYDOWN:
{
state = KeyState::Pressed;
CM_LOG_DEBUG("key down: %s", KeyToStr(gkey));
if(gkey == Key::Escape)
{
close();
Expand Down Expand Up @@ -160,7 +159,6 @@ bool WSI::update()
{
int x, y;
SDL_GetMouseState(&x, &y);
CM_LOG_INFO("cursor pos: %d, %d", x, y);

static int lastX = getWidth() / 2;
static int lastY = getHeight() / 2;
Expand Down
1 change: 0 additions & 1 deletion scripts/fetch_external_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def CheckOut(self):
GitRepo("https://github.com/KhronosGroup/SPIRV-Tools.git", "spirv-tools", "spirv-tools"),
GitRepo("https://github.com/KhronosGroup/SPIRV-Headers.git", "spirv-headers", "spirv-headers"),
GitRepo("https://github.com/KhronosGroup/SPIRV-Cross.git", "spirv-cross", "spirv-cross"),
GitRepo("https://github.com/glfw/glfw", "glfw", "glfw"),
GitRepo("https://github.com/martinus/unordered_dense", "unordered_dense", "unordered_dense"),
GitRepo("https://github.com/syoyo/tinygltf", "tinygltf", "tinygltf"),
GitRepo("https://github.com/g-truc/glm", "glm", "glm"),
Expand Down

0 comments on commit 8b9d17b

Please sign in to comment.