From c0cbf8c257e92b62c44b718f958dba7261734164 Mon Sep 17 00:00:00 2001 From: 4VRDriver <44267643+4VRDriver@users.noreply.github.com> Date: Sat, 5 Sep 2020 19:05:25 +0200 Subject: [PATCH] Small cmake changes --- CMakeLists.txt | 7 +++++++ cmake/FindGLFW3.cmake | 49 +++++++++++++++++++++++++++++++++++++++++++ lib/CMakeLists.txt | 6 ------ src/CMakeLists.txt | 2 +- src/Controller.cpp | 2 +- src/Model.cpp | 2 +- 6 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 cmake/FindGLFW3.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a05266..4962e8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,15 @@ cmake_minimum_required(VERSION 3.10) project(Fall-Fever) +#if(WIN32) + set(GLFW3_ROOT "${PROJECT_SOURCE_DIR}/glfw") +#endif(WIN32) + +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") + set(OpenGL_GL_PREFERENCE "GLVND") +find_package(GLFW3 REQUIRED) find_package(OpenGL REQUIRED) # Specify the C++ standard diff --git a/cmake/FindGLFW3.cmake b/cmake/FindGLFW3.cmake new file mode 100644 index 0000000..13bbb84 --- /dev/null +++ b/cmake/FindGLFW3.cmake @@ -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) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b792168..4d98bfc 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,10 +1,4 @@ -# Only build GLFW library -set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) -set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) -set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stb) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glm) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/assimp) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glfw-3.3.2) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c5cddd2..c49896f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,7 +15,7 @@ target_link_libraries( Fall-Fever PRIVATE glad stb - glfw + ${GLFW3_LIBRARY} ${OPENGL_LIBRARIES} assimp ) diff --git a/src/Controller.cpp b/src/Controller.cpp index 3bcccd9..3532578 100644 --- a/src/Controller.cpp +++ b/src/Controller.cpp @@ -86,7 +86,7 @@ void Controller::run() { new Texture("res/textures/tex1.png", texture_diffuse) }; - Model model1("res/models/backpack.obj"); + Model model1("res/models/cube.obj"); //Mesh mesh1(vertices, indices, textures); diff --git a/src/Model.cpp b/src/Model.cpp index 3e7ac3c..b1cc8d6 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -116,7 +116,7 @@ std::vector Model::loadMaterialTextures(aiMaterial *mat, aiTextureType std::string currentPath = directory + '/' + filename.C_Str(); bool skip = 0; - for(uint j = 0; j < loadedTextures.size(); j++) { + for(uint32_t j = 0; j < loadedTextures.size(); j++) { if(std::strcmp(loadedTextures[j]->getPath().c_str(), currentPath.c_str()) == 0) { textures.push_back(loadedTextures[j]); skip = 1;