converted sparrowinput to cmake template

This commit is contained in:
Anselme 2016-03-08 13:29:57 +01:00
parent 306d12de27
commit b449d95f11
9 changed files with 632 additions and 454 deletions

View File

@ -1,53 +1,15 @@
project(SparrowInput) project(SparrowInput)
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
if(WIN32) # choose source file
set(SYSTEM_LIB_PATH "win32") file(GLOB LIB_SRC_LIST src/*.cpp)
else(WIN32) file(GLOB LIB_HEAD_LIST src/*.h)
set(SYSTEM_LIB_PATH "linux") list(REMOVE_ITEM LIB_SRC_LIST src/main.cpp)
endif(WIN32) set(EXEC_SRC_LIST src/main.cpp)
set(LIB_SRC_LIST input.cpp keybindings.cpp textbuffer.cpp) #set compilation option
set(IS_LIBRARY True)
set(USE_OPENGL True)
set(USE_SFML True)
set(EXECUTABLE_NAME "test${PROJECT_NAME}") include(template.cmake)
set(LIBRARY_NAME ${PROJECT_NAME})
set(DEPENDENCIES_ROOT ${PROJECT_SOURCE_DIR}/../cpp_dependencies)
set(INCLUDE_ROOT ${DEPENDENCIES_ROOT}/include)
set(LIB_ROOT ${DEPENDENCIES_ROOT}/lib/${SYSTEM_LIB_PATH})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_ROOT}) #for SHARED
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_ROOT}) #for STATIC
add_library(${LIBRARY_NAME} STATIC ${LIB_SRC_LIST})
add_executable(${EXECUTABLE_NAME} main.cpp)
add_definitions(-std=c++11)
include_directories(
${INCLUDE_ROOT}
)
find_library(SFML_LIBRARY_WINDOW
NAMES
sfml-window
PATHS
${LIB_ROOT}
)
find_library(SFML_LIBRARY_SYSTEM
NAMES
sfml-system
PATHS
${LIB_ROOT}
)
target_link_libraries(
${LIBRARY_NAME}
${SFML_LIBRARY_WINDOW}
${SFML_LIBRARY_SYSTEM}
)
target_link_libraries(
${EXECUTABLE_NAME}
${LIBRARY_NAME}
)

View File

@ -1,167 +1,167 @@
/** /**
* @author: Thomas Brandého * @author: Thomas Brandého
*/ */
#include "input.h" #include "input.h"
#include <iostream> #include <iostream>
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <list> #include <list>
Input::Input(sf::Window *w): window(w) Input::Input(sf::Window *w): window(w)
{ {
heldkeys = std::vector<sf::Keyboard::Key>(); heldkeys = std::vector<sf::Keyboard::Key>();
action_file = std::queue<int>(); action_file = std::queue<int>();
window->setKeyRepeatEnabled(false); window->setKeyRepeatEnabled(false);
} }
void Input::setKeysMap(IKeysMap km){ void Input::setKeysMap(IKeysMap km){
keysmap = km; keysmap = km;
} }
void Input::updateEvents(){ void Input::updateEvents(){
sf::Event event; sf::Event event;
KeyBindings kb; KeyBindings kb;
char c; char c;
/* reset variables */ /* reset variables */
closeRequested = false; closeRequested = false;
hasBeenResized = false; hasBeenResized = false;
delta_vertical_scroll = 0; delta_vertical_scroll = 0;
/* global affectation */ /* global affectation */
kb = keybindings[current_context]; kb = keybindings[current_context];
/* event-parsing loop */ /* event-parsing loop */
while(window->pollEvent(event)){ while(window->pollEvent(event)){
switch(event.type){ switch(event.type){
case sf::Event::Closed: case sf::Event::Closed:
closeRequested = true; closeRequested = true;
break; break;
case sf::Event::TextEntered: case sf::Event::TextEntered:
c = (char) event.text.unicode; c = (char) event.text.unicode;
buffer.append(&c); buffer.append(&c);
break; break;
case sf::Event::KeyPressed: case sf::Event::KeyPressed:
action_file.push(kb.getPressedAction(event.key.code)); action_file.push(kb.getPressedAction(event.key.code));
heldkeys.push_back(event.key.code); heldkeys.push_back(event.key.code);
break; break;
case sf::Event::KeyReleased: case sf::Event::KeyReleased:
action_file.push(kb.getReleasedAction(event.key.code)); action_file.push(kb.getReleasedAction(event.key.code));
releaseHeldKeys(event.key.code); releaseHeldKeys(event.key.code);
break; break;
case sf::Event::MouseButtonPressed: case sf::Event::MouseButtonPressed:
action_file.push(kb.getPressedAction(sf::Keyboard::KeyCount + event.mouseButton.button)); action_file.push(kb.getPressedAction(sf::Keyboard::KeyCount + event.mouseButton.button));
heldkeys.push_back((sf::Keyboard::Key) (sf::Keyboard::KeyCount + event.mouseButton.button)); heldkeys.push_back((sf::Keyboard::Key) (sf::Keyboard::KeyCount + event.mouseButton.button));
break; break;
case sf::Event::MouseButtonReleased: case sf::Event::MouseButtonReleased:
action_file.push(kb.getReleasedAction(sf::Keyboard::KeyCount + event.mouseButton.button)); action_file.push(kb.getReleasedAction(sf::Keyboard::KeyCount + event.mouseButton.button));
releaseHeldKeys((sf::Keyboard::Key) (sf::Keyboard::KeyCount + event.mouseButton.button)); releaseHeldKeys((sf::Keyboard::Key) (sf::Keyboard::KeyCount + event.mouseButton.button));
break; break;
case sf::Event::MouseWheelScrolled: case sf::Event::MouseWheelScrolled:
if (event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel) if (event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel)
delta_vertical_scroll = event.mouseWheelScroll.delta; delta_vertical_scroll = event.mouseWheelScroll.delta;
break; break;
case sf::Event::MouseMoved: case sf::Event::MouseMoved:
last_mouse_position = mouse_position; last_mouse_position = mouse_position;
mouse_position = sf::Mouse::getPosition(); mouse_position = sf::Mouse::getPosition();
break; break;
case sf::Event::MouseEntered: case sf::Event::MouseEntered:
// action MouseEntered // action MouseEntered
break; break;
case sf::Event::MouseLeft: case sf::Event::MouseLeft:
//action MouseLeft //action MouseLeft
break; break;
case sf::Event::Resized: case sf::Event::Resized:
hasBeenResized = true; hasBeenResized = true;
break; break;
} }
} }
for (auto key: heldkeys){ for (auto key: heldkeys){
action_file.push(kb.getHoldAction(key)); action_file.push(kb.getHoldAction(key));
} }
} }
int Input::getAction() int Input::getAction()
{ {
if (action_file.empty()) if (action_file.empty())
return -1; return -1;
int val = action_file.front(); int val = action_file.front();
action_file.pop(); action_file.pop();
return val; return val;
} }
/* context-related functions */ /* context-related functions */
void Input::addContext(Context context) void Input::addContext(Context context)
{ {
contexts.push_back(context); contexts.push_back(context);
} }
void Input::setCurrentContext(std::string context_name){ void Input::setCurrentContext(std::string context_name){
current_context = context_name; current_context = context_name;
} }
void Input::updateKeyBindings(){ void Input::updateKeyBindings(){
keybindings.clear(); keybindings.clear();
for (auto iter= contexts.begin(); iter != contexts.end(); ++iter) for (auto iter= contexts.begin(); iter != contexts.end(); ++iter)
keybindings[iter->getName()]= KeyBindings(*iter,keysmap); keybindings[iter->getName()]= KeyBindings(*iter,keysmap);
} }
/* window-related function */ /* window-related function */
bool Input::isCloseRequested() const bool Input::isCloseRequested() const
{ {
return closeRequested; return closeRequested;
} }
bool Input::isResized() const bool Input::isResized() const
{ {
return hasBeenResized; return hasBeenResized;
} }
/* keyboard-related functions */ /* keyboard-related functions */
bool Input::isKeyPressed(int key) const bool Input::isKeyPressed(int key) const
{ {
return sf::Keyboard::isKeyPressed((sf::Keyboard::Key) key); return sf::Keyboard::isKeyPressed((sf::Keyboard::Key) key);
} }
void Input::releaseHeldKeys(sf::Keyboard::Key keycode){ void Input::releaseHeldKeys(sf::Keyboard::Key keycode){
auto iter = heldkeys.begin(); auto iter = heldkeys.begin();
while(*iter != keycode) ++iter; while(*iter != keycode) ++iter;
heldkeys.erase(iter); heldkeys.erase(iter);
} }
/* mouse-related functions */ /* mouse-related functions */
sf::Vector2i Input::getPosition() const sf::Vector2i Input::getPosition() const
{ {
return mouse_position; return mouse_position;
} }
sf::Vector2i Input::getDeltaPosition() const sf::Vector2i Input::getDeltaPosition() const
{ {
return mouse_position - last_mouse_position; return mouse_position - last_mouse_position;
} }
float Input::getDeltaVerticalScroll() const float Input::getDeltaVerticalScroll() const
{ {
return delta_vertical_scroll; return delta_vertical_scroll;
} }
/* ------ */ /* ------ */
void Input::test() void Input::test()
{ {
KeyBindings kb = keybindings[current_context]; KeyBindings kb = keybindings[current_context];
int action; int action;
action = kb.getPressedAction(sf::Keyboard::I); action = kb.getPressedAction(sf::Keyboard::I);
if (action != NO_ACTION) if (action != NO_ACTION)
std::cerr << action << std::endl; std::cerr << action << std::endl;
action = kb.getPressedAction(sf::Keyboard::O); action = kb.getPressedAction(sf::Keyboard::O);
if (action != NO_ACTION) if (action != NO_ACTION)
std::cerr << action << std::endl; std::cerr << action << std::endl;
} }

View File

@ -1,75 +1,75 @@
/** /**
* @author: Thomas Brandého * @author: Thomas Brandého
*/ */
#ifndef INPUT_H #ifndef INPUT_H
#define INPUT_H #define INPUT_H
#include "keybindings.h" #include "keybindings.h"
#include <queue> #include <queue>
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include "textbuffer.h" #include "textbuffer.h"
class Input{ class Input{
public: public:
/* Constructors */ /* Constructors */
Input(sf::Window *w); Input(sf::Window *w);
/* general action-mapping functions */ /* general action-mapping functions */
void setKeysMap(IKeysMap km); void setKeysMap(IKeysMap km);
void updateEvents(); void updateEvents();
int getAction(); int getAction();
/* context-related functions */ /* context-related functions */
void addContext(Context context); void addContext(Context context);
void setCurrentContext(std::string context_name); void setCurrentContext(std::string context_name);
void updateKeyBindings(); void updateKeyBindings();
/* window-related function */ /* window-related function */
bool isCloseRequested() const; bool isCloseRequested() const;
bool isResized() const; bool isResized() const;
/* keyboard-related functions */ /* keyboard-related functions */
bool isKeyPressed(int key) const; bool isKeyPressed(int key) const;
/* mouse-related function */ /* mouse-related function */
sf::Vector2i getPosition() const; sf::Vector2i getPosition() const;
sf::Vector2i getDeltaPosition() const; sf::Vector2i getDeltaPosition() const;
float getDeltaVerticalScroll() const; float getDeltaVerticalScroll() const;
/* text-related function */ /* text-related function */
std::string getText(); std::string getText();
void test(); void test();
private: private:
/* window-related variables */ /* window-related variables */
sf::Window* window; sf::Window* window;
bool closeRequested; bool closeRequested;
bool hasBeenResized; bool hasBeenResized;
/* general action-mapping variables */ /* general action-mapping variables */
IKeysMap keysmap; IKeysMap keysmap;
std::queue<int> action_file; std::queue<int> action_file;
int nb_actions; int nb_actions;
/* context-related variables */ /* context-related variables */
std::string current_context; std::string current_context;
//std::unordered_map<std::string, std::vector<int>> contexts; //std::unordered_map<std::string, std::vector<int>> contexts;
std::vector<Context> contexts; std::vector<Context> contexts;
std::unordered_map<std::string,KeyBindings> keybindings; std::unordered_map<std::string,KeyBindings> keybindings;
/* keyboard-related variables */ /* keyboard-related variables */
std::vector<sf::Keyboard::Key> heldkeys; std::vector<sf::Keyboard::Key> heldkeys;
void releaseHeldKeys(sf::Keyboard::Key keycode); void releaseHeldKeys(sf::Keyboard::Key keycode);
/* mouse-related variables */ /* mouse-related variables */
sf::Vector2i mouse_position; sf::Vector2i mouse_position;
sf::Vector2i last_mouse_position; sf::Vector2i last_mouse_position;
float delta_vertical_scroll; float delta_vertical_scroll;
/* text-related variable */ /* text-related variable */
std::string buffer; std::string buffer;
}; };
#endif //INPUT_H #endif //INPUT_H

View File

@ -1,107 +1,107 @@
/** /**
* @author: Thomas Brandého * @author: Thomas Brandého
*/ */
#include "keybindings.h" #include "keybindings.h"
#include <iostream> #include <iostream>
/* Implementation of IKeysMap class /* Implementation of IKeysMap class
* @author: Thomas Brandého * @author: Thomas Brandého
* @info: This class register all the association between key and action. * @info: This class register all the association between key and action.
*/ */
IKeysMap::IKeysMap() IKeysMap::IKeysMap()
{ {
} }
std::vector<Binding> IKeysMap::getBindings(int action) const { std::vector<Binding> IKeysMap::getBindings(int action) const {
std::vector<Binding> bindings; std::vector<Binding> bindings;
for (auto binding : keys) for (auto binding : keys)
if (binding.action == action) bindings.push_back(binding); if (binding.action == action) bindings.push_back(binding);
return bindings; return bindings;
} }
/* Implementation of KeyBindings class /* Implementation of KeyBindings class
* @author: Thomas Brandého * @author: Thomas Brandého
* @info: This class map a list of action with the associated keys, for a quick access in-game. * @info: This class map a list of action with the associated keys, for a quick access in-game.
* The map is read-only, so if you want to add of remove action from the map, you have to create a new instance of KeyBindings * The map is read-only, so if you want to add of remove action from the map, you have to create a new instance of KeyBindings
*/ */
KeyBindings::KeyBindings() KeyBindings::KeyBindings()
{ {
} }
KeyBindings::KeyBindings(const Context &context, const IKeysMap &keysmap) KeyBindings::KeyBindings(const Context &context, const IKeysMap &keysmap)
{ {
std::vector<int> actions = context.getActions(); std::vector<int> actions = context.getActions();
for (int action : actions){ for (int action : actions){
for (Binding binding : keysmap.getBindings(action)){ for (Binding binding : keysmap.getBindings(action)){
switch(binding.type){ switch(binding.type){
case IKeysMap::PRESSED: case IKeysMap::PRESSED:
setPressedAction(binding.key,binding.action); setPressedAction(binding.key,binding.action);
break; break;
case IKeysMap::RELEASED: case IKeysMap::RELEASED:
setReleasedAction(binding.key,binding.action); setReleasedAction(binding.key,binding.action);
break; break;
case IKeysMap::HOLD: case IKeysMap::HOLD:
setHoldAction(binding.key,binding.action); setHoldAction(binding.key,binding.action);
break; break;
default: default:
//raiseError; //raiseError;
break; break;
} }
} }
} }
} }
int KeyBindings::getPressedAction(int key) const int KeyBindings::getPressedAction(int key) const
{ {
return bindings_pressed.count(key) == 1? bindings_pressed.at(key) : -1; return bindings_pressed.count(key) == 1? bindings_pressed.at(key) : -1;
} }
int KeyBindings::getReleasedAction(int key) const int KeyBindings::getReleasedAction(int key) const
{ {
return bindings_released.count(key) == 1? bindings_released.at(key) : -1; return bindings_released.count(key) == 1? bindings_released.at(key) : -1;
} }
int KeyBindings::getHoldAction(int key) const int KeyBindings::getHoldAction(int key) const
{ {
return bindings_hold.count(key) == 1? bindings_hold.at(key) : -1; return bindings_hold.count(key) == 1? bindings_hold.at(key) : -1;
} }
void KeyBindings::setPressedAction(int key, int action) void KeyBindings::setPressedAction(int key, int action)
{ {
bindings_pressed[key]=action; bindings_pressed[key]=action;
} }
void KeyBindings::setReleasedAction(int key, int action) void KeyBindings::setReleasedAction(int key, int action)
{ {
bindings_released[key]=action; bindings_released[key]=action;
} }
void KeyBindings::setHoldAction(int key, int action) void KeyBindings::setHoldAction(int key, int action)
{ {
bindings_hold[key]=action; bindings_hold[key]=action;
} }
/* Implementation of Context class /* Implementation of Context class
* @author: Thomas Brandého * @author: Thomas Brandého
* @info: This class contains a list of actions available in a given situation (context). * @info: This class contains a list of actions available in a given situation (context).
*/ */
/* Implementation of Context class /* Implementation of Context class
* @author: Thomas Brandého * @author: Thomas Brandého
* @info: This class contains a list of action associated to a given situation (context). * @info: This class contains a list of action associated to a given situation (context).
*/ */
Context::Context(std::string _name, std::vector<int> _actions): name(_name), actions(_actions) Context::Context(std::string _name, std::vector<int> _actions): name(_name), actions(_actions)
{ {
} }
std::string Context::getName() std::string Context::getName()
{ {
return name; return name;
} }
std::vector<int> Context::getActions() const std::vector<int> Context::getActions() const
{ {
return actions; return actions;
} }

View File

@ -1,57 +1,57 @@
/** /**
* @author: Thomas Brandého * @author: Thomas Brandého
*/ */
#ifndef KEYBINDINGS_H #ifndef KEYBINDINGS_H
#define KEYBINDINGS_H #define KEYBINDINGS_H
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <unordered_map> #include <unordered_map>
#define NO_KEY -1 #define NO_KEY -1
#define NO_ACTION -1 #define NO_ACTION -1
typedef struct{ typedef struct{
int action; int action;
int key; int key;
int type; int type;
} Binding; } Binding;
class IKeysMap{ class IKeysMap{
public: public:
enum {PRESSED, RELEASED, HOLD}; enum {PRESSED, RELEASED, HOLD};
IKeysMap(); IKeysMap();
std::vector<Binding> getBindings(int action) const; std::vector<Binding> getBindings(int action) const;
protected: protected:
std::vector<Binding> keys; std::vector<Binding> keys;
}; };
class Context { class Context {
public: public:
Context(std::string name, std::vector<int> actions); Context(std::string name, std::vector<int> actions);
std::string getName(); std::string getName();
std::vector<int> getActions() const; std::vector<int> getActions() const;
private: private:
std::string name; std::string name;
std::vector<int> actions; std::vector<int> actions;
}; };
class KeyBindings { class KeyBindings {
public: public:
KeyBindings(); KeyBindings();
KeyBindings(const Context &context, const IKeysMap &keysmap); KeyBindings(const Context &context, const IKeysMap &keysmap);
int getPressedAction(int key) const; int getPressedAction(int key) const;
int getReleasedAction(int key) const; int getReleasedAction(int key) const;
int getHoldAction(int key) const; int getHoldAction(int key) const;
private: private:
std::unordered_map<int,int> bindings_pressed; std::unordered_map<int,int> bindings_pressed;
std::unordered_map<int,int> bindings_released; std::unordered_map<int,int> bindings_released;
std::unordered_map<int,int> bindings_hold; std::unordered_map<int,int> bindings_hold;
void setPressedAction(int key, int action); void setPressedAction(int key, int action);
void setReleasedAction(int key, int action); void setReleasedAction(int key, int action);
void setHoldAction(int key, int action); void setHoldAction(int key, int action);
}; };
#endif #endif

216
template.cmake Normal file
View File

@ -0,0 +1,216 @@
# Variable that you need to define to use this template
# USE_SFML, USE_RENDERER, USE_INPUT, USE_BULLET, USE_OPENGL, USE_QT5
#
# Container for list of file to be compiled :
# LIB_SRC_LIST, LIB_HEAD_LIST, EXEC_SRC_LIST, EXEC_HEAD_LIST
#
# If you want to specify a supplementary folder for include, use :
# EXTRA_INCLUDE_PATHS
cmake_minimum_required(VERSION 2.8)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#detect system and version
if(WIN32)
set(LIB_DEBUG_FOLDER "libDebug/mingw32")
set(LIB_RELEASE_FOLDER "libRelease/mingw32")
elseif(UNIX)
if(${CMAKE_SYSTEM_VERSION} MATCHES "i686")
set(LIB_DEBUG_FOLDER "libDebug/i686")
set(LIB_RELEASE_FOLDER "libRelease/i686")
elseif(${CMAKE_SYSTEM_VERSION} MATCHES "x86_64")
set(LIB_DEBUG_FOLDER "libDebug/x86_64")
set(LIB_RELEASE_FOLDER "libRelease/x86_64")
endif()
endif()
#set dependencies paths
set(DEPENDENCIES_ROOT ${PROJECT_SOURCE_DIR}/../cpp_dependencies)
set(INCLUDE_ROOT ${DEPENDENCIES_ROOT}/include)
set(LIB_DEBUG_PATH ${DEPENDENCIES_ROOT}/${LIB_DEBUG_FOLDER})
set(LIB_RELEASE_PATH ${DEPENDENCIES_ROOT}/${LIB_RELEASE_FOLDER})
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_DEBUG_PATH}) #for STATIC
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_DEBUG_PATH}) #for SHARED
list(APPEND LIB_PATHS ${LIB_DEBUG_PATH})
list(APPEND LIB_PATHS "\n" ${LIB_RELEASE_PATH})
else()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_RELEASE_PATH}) #for STATIC
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_RELEASE_PATH}) #for SHARED
list(APPEND LIB_PATHS ${LIB_RELEASE_PATH})
endif()
#create library and executable
if(LIB_SRC_LIST)
set(IS_LIBRARY True)
set(LIBRARY_NAME ${PROJECT_NAME})
add_library(${LIBRARY_NAME} STATIC ${LIB_SRC_LIST} ${RESOURCES_FILES})
if(EXEC_SRC_LIST)
set(EXECUTABLE_NAME "test${PROJECT_NAME}")
add_executable(${EXECUTABLE_NAME} ${EXEC_SRC_LIST} ${RESOURCES_FILES})
endif()
elseif(EXEC_SRC_LIST)
set(EXECUTABLE_NAME "${PROJECT_NAME}")
add_executable(${EXECUTABLE_NAME} ${EXEC_SRC_LIST} ${RESOURCES_FILES})
else()
message(WARNING "NO SOURCE FILE PROVIDED")
endif()
add_definitions(-std=c++11)
#find libraries
set(LIB_DEPENDENCIES_LIST "")
set(INCLUDE_PATHS ${INCLUDE_ROOT})
# not used for now
# foreach(EXTENSION ${INCLUDE_PATHS_EXTENSION})
# LIST(APPEND INCLUDE_PATHS ${INCLUDE_ROOT}${EXTENSION} " ")
# endforeach()
# TODO: Complete SFML
if(USE_SFML)
find_library(SFML_LIBRARY_WINDOW
NAMES
sfml-window
PATHS
${LIB_PATHS}
)
find_library(SFML_LIBRARY_SYSTEM
NAMES
sfml-system
PATHS
${LIB_PATHS}
)
find_library(SFML_LIBRARY_AUDIO
NAMES
sfml-audio
PATHS
${LIB_PATHS}
)
find_library(SFML_LIBRARY_GRAPHICS
NAMES
sfml-graphics
PATHS
${LIB_PATHS}
)
add_definitions(-DSFML_STATIC)
LIST(APPEND LIB_DEPENDENCIES_LIST ${SFML_LIBRARY_AUDIO} ${SFML_LIBRARY_GRAPHICS} ${SFML_LIBRARY_WINDOW} ${SFML_LIBRARY_SYSTEM})
endif()
if(USE_RENDERER)
find_library(SPARROW_RENDERER_LIBRARY
NAMES
SparrowRenderer
PATHS
${LIB_PATHS}
)
LIST(APPEND INCLUDE_PATHS "\n" ${PROJECT_SOURCE_DIR}/../sparrowrenderer/src)
LIST(APPEND LIB_DEPENDENCIES_LIST ${SPARROW_RENDERER_LIBRARY})
endif()
if(USE_INPUT)
find_library(SPARROW_INPUT_LIBRARY
NAMES
SparrowInput
PATHS
${LIB_PATHS}
)
LIST(APPEND INCLUDE_PATHS "\n" ${PROJECT_SOURCE_DIR}/../sparrowinput/src)
LIST(APPEND LIB_DEPENDENCIES_LIST ${SPARROW_INPUT_LIBRARY})
endif()
if(USE_BULLET)
find_library(BULLET_COLLISION_LIBRARY
NAMES
BulletCollision
PATHS
${LIB_PATHS}
)
find_library(BULLET_DYNAMICS_LIBRARY
NAMES
BulletDynamics
PATHS
${LIB_PATHS}
)
find_library(LINEAR_MATH_LIBRARY
NAMES
LinearMath
PATHS
${LIB_PATHS}
)
LIST(APPEND LIB_DEPENDENCIES_LIST ${BULLET_COLLISION_LIBRARY} ${BULLET_DYNAMICS_LIBRARY} ${LINEAR_MATH_LIBRARY})
LIST(APPEND INCLUDE_PATHS "\n" ${INCLUDE_ROOT}/bullet)
endif()
if(USE_OPENGL)
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
LIST(APPEND LIB_DEPENDENCIES_LIST ${OPENGL_LIBRARIES})
endif()
endif()
# TODO: Complete QT5
if(USE_QT5)
if(${QT_MODULE} MATCHES "core")
endif()
if(${QT_MODULE} MATCHES "gui")
endif()
if(${QT_MODULE} MATCHES "opengl")
find_package(Qt5OpenGL REQUIRED)
if(QT5OPENGL_FOUND)
LIST(APPEND LIB_DEPENDENCIES_LIST ${Qt5OpenGL_LIBRARIES})
add_definitions(${Qt5OpenGL_DEFINITIONS})
LIST(APPEND INCLUDE_PATHS "\n" ${Qt5OpenGL_INCLUDES})
endif()
endif()
if(${QT_MODULE} MATCHES "widgets")
find_package(Qt5Widgets REQUIRED)
if(QT5WIDGETS_FOUND)
LIST(APPEND LIB_DEPENDENCIES_LIST ${Qt5Widgets_LIBRARIES})
add_definitions(${Qt5Widgets_DEFINITIONS})
LIST(APPEND INCLUDE_PATHS "\n" ${Qt5Widgets_INCLUDES})
endif()
endif()
if(${QT_MODULE} MATCHES "network")
endif()
endif()
include_directories(
${INCLUDE_PATHS}
${EXTRA_INCLUDE}
)
if(LIB_SRC_LIST)
target_link_libraries(
${LIBRARY_NAME}
${LIB_DEPENDENCIES_LIST}
)
if(EXEC_SRC_LIST)
target_link_libraries(
${EXECUTABLE_NAME}
${LIBRARY_NAME}
)
endif()
elseif(EXEC_SRC_LIST)
target_link_libraries(
${EXECUTABLE_NAME}
${LIB_DEPENDENCIES_LIST}
)
endif()