diff --git a/CMakeLists.txt b/CMakeLists.txt index a8c0271..bca96d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,33 +1,103 @@ -# Check versions message(STATUS "CMake version: ${CMAKE_VERSION}") -cmake_minimum_required(VERSION 3.1) -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +# Check versions +message(STATUS "CMake version: ${CMAKE_VERSION}") +cmake_minimum_required(VERSION 3.1) -# Set the project name -set(PNAME floppy-bird) -project(${PNAME}) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) -# Set up variables, and find SFML -set(SFML_ROOT root CACHE STRING "User specified path") -set(SFML_COMPONENTS graphics window system network audio) +# Set the project name +set(PNAME a-star) +project(${PNAME}) + +# Set up variables, and find SFML +if (WIN32) + set(SFML_ROOT root CACHE STRING "User specified path") + set(SFML_INCLUDE_DIR ${SFML_ROOT}/include) +endif() + +set(SFML_COMPONENTS graphics window system network audio) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +find_package(SFML 2.4 COMPONENTS ${SFML_COMPONENTS} REQUIRED) +message(STATUS "SFML found: ${SFML_FOUND}") + +if (WIN32) + # Find GLEW + find_package(GLEW REQUIRED) + message(STATUS "GLEW found: ${GLEW_FOUND}") +endif() + +# Find OpenGL +find_package(OpenGL REQUIRED) +message(STATUS "OpenGL found: ${OPENGL_FOUND}") + +# Include the directories for the main program, GL, and SFML +include_directories(${SFML_INCLUDE_DIR}) +include_directories(${OpenGL_INCLUDE_DIRS}) +include_directories(include) + +# Glob all thr sources into their values +file(GLOB_RECURSE SOURCES "src/*.cpp") +file(GLOB_RECURSE HEADERS "include/*.h" "include/*.hpp") +file(GLOB_RECURSE SHADERS "shaders/*.vert" "shaders/*.tesc" "shaders/*.tese" "shaders/*.geom" "shaders/*.frag" "shaders/*.comp") + +add_executable(${PNAME} ${SOURCES} ${HEADERS} ${KERNELS} ${SHADERS}) + +# Follow the sub directory structure to add sub-filters in VS +# Gotta do it one by one unfortunately + +foreach (source IN ITEMS ${SOURCES}) + if (IS_ABSOLUTE "${source}") + + get_filename_component(filename ${source} DIRECTORY) + + STRING(REGEX REPLACE "/" "\\\\" filename ${filename}) + + string(REGEX MATCHALL "src(.*)" substrings ${filename}) + list(GET substrings 0 substring) + + SOURCE_GROUP(${substring} FILES ${source}) + + endif() +endforeach() + +foreach (source IN ITEMS ${HEADERS}) + if (IS_ABSOLUTE "${source}") + + get_filename_component(filename ${source} DIRECTORY) + + STRING(REGEX REPLACE "/" "\\\\" filename ${filename}) + + string(REGEX MATCHALL "include(.*)" substrings ${filename}) + list(GET substrings 0 substring) + + SOURCE_GROUP(${substring} FILES ${source}) + + endif() +endforeach() + +foreach (source IN ITEMS ${SHADERS}) + if (IS_ABSOLUTE "${source}") -find_package(SFML 2.1 COMPONENTS ${SFML_COMPONENTS} REQUIRED) -message(STATUS "SFML found: ${SFML_FOUND}") + get_filename_component(filename ${source} DIRECTORY) -# Include the directories for the main program, GL, CL and SFML's headers -include_directories(${SFML_INCLUDE_DIR}) -include_directories(include) + STRING(REGEX REPLACE "/" "\\\\" filename ${filename}) + + string(REGEX MATCHALL "shaders(.*)" substrings ${filename}) + list(GET substrings 0 substring) + + SOURCE_GROUP(${substring} FILES ${source}) + + endif() +endforeach() -# Set the sources, allows VS to filter them properly -file(GLOB SOURCES "*.cpp") -file(GLOB HEADERS "*.h") +# Link CL, GL, and SFML +target_link_libraries (${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES}) +target_link_libraries (${PNAME} ${OPENGL_LIBRARIES}) +target_link_libraries (${PNAME} ${GLEW_LIBRARIES}) -add_executable(${PNAME} ${SOURCES}) +if (NOT WIN32) + target_link_libraries (${PNAME} -lpthread) +endif() -# Link CL, GL, and SFML -target_link_libraries (${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES}) +# Setup to use C++14 +set_property(TARGET ${PNAME} PROPERTY CXX_STANDARD 14) -# Setup to use C++11 + others -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") -set_property(TARGET ${PNAME} PROPERTY CXX_STANDARD 11) # Use C++11 \ No newline at end of file diff --git a/background.png b/assets/background.png similarity index 100% rename from background.png rename to assets/background.png diff --git a/screeny.png b/assets/screeny.png similarity index 100% rename from screeny.png rename to assets/screeny.png diff --git a/App.h b/include/App.h similarity index 100% rename from App.h rename to include/App.h diff --git a/Explorer.h b/include/Explorer.h similarity index 100% rename from Explorer.h rename to include/Explorer.h diff --git a/Map.h b/include/Map.h similarity index 100% rename from Map.h rename to include/Map.h diff --git a/Pather.h b/include/Pather.h similarity index 100% rename from Pather.h rename to include/Pather.h diff --git a/Tile.h b/include/Tile.h similarity index 92% rename from Tile.h rename to include/Tile.h index 7b07e76..08b7465 100644 --- a/Tile.h +++ b/include/Tile.h @@ -1,5 +1,5 @@ #pragma once -#include +#include class Tile { public: diff --git a/node.h b/include/node.h similarity index 100% rename from node.h rename to include/node.h diff --git a/App.cpp b/src/App.cpp similarity index 98% rename from App.cpp rename to src/App.cpp index 2ca1443..fc371fd 100644 --- a/App.cpp +++ b/src/App.cpp @@ -19,7 +19,7 @@ void App::Init() { // Set up the background texture background_texture = new sf::Texture(); - background_texture->loadFromFile("background.png"); + background_texture->loadFromFile("../assets/background.png"); backgroundSprite.setTexture(*background_texture); // Pixel array for drawing the tiles, explorer diff --git a/Explorer.cpp b/src/Explorer.cpp similarity index 100% rename from Explorer.cpp rename to src/Explorer.cpp diff --git a/Map.cpp b/src/Map.cpp similarity index 100% rename from Map.cpp rename to src/Map.cpp diff --git a/Pather.cpp b/src/Pather.cpp similarity index 100% rename from Pather.cpp rename to src/Pather.cpp diff --git a/Tile.cpp b/src/Tile.cpp similarity index 100% rename from Tile.cpp rename to src/Tile.cpp diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp diff --git a/node.cpp b/src/node.cpp similarity index 100% rename from node.cpp rename to src/node.cpp