restructuring and updating CMakeLists

master
MitchellHansen 7 years ago
parent 769c37f148
commit aa593870df

@ -1,33 +1,103 @@
# Check versions message(STATUS "CMake version: ${CMAKE_VERSION}") # Check versions
cmake_minimum_required(VERSION 3.1) message(STATUS "CMake version: ${CMAKE_VERSION}")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) cmake_minimum_required(VERSION 3.1)
# Set the project name set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(PNAME floppy-bird)
project(${PNAME})
# Set up variables, and find SFML # Set the project name
set(SFML_ROOT root CACHE STRING "User specified path") set(PNAME a-star)
set(SFML_COMPONENTS graphics window system network audio) 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}) 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) get_filename_component(filename ${source} DIRECTORY)
message(STATUS "SFML found: ${SFML_FOUND}")
# Include the directories for the main program, GL, CL and SFML's headers STRING(REGEX REPLACE "/" "\\\\" filename ${filename})
include_directories(${SFML_INCLUDE_DIR})
include_directories(include) 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 # Link CL, GL, and SFML
file(GLOB SOURCES "*.cpp") target_link_libraries (${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
file(GLOB HEADERS "*.h") 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 # Setup to use C++14
target_link_libraries (${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES}) 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

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

@ -1,5 +1,5 @@
#pragma once #pragma once
#include <SFML\Graphics.hpp> #include <SFML/Graphics.hpp>
class Tile { class Tile {
public: public:

@ -19,7 +19,7 @@ void App::Init() {
// Set up the background texture // Set up the background texture
background_texture = new sf::Texture(); background_texture = new sf::Texture();
background_texture->loadFromFile("background.png"); background_texture->loadFromFile("../assets/background.png");
backgroundSprite.setTexture(*background_texture); backgroundSprite.setTexture(*background_texture);
// Pixel array for drawing the tiles, explorer // Pixel array for drawing the tiles, explorer
Loading…
Cancel
Save