More CMake bullshit

This commit is contained in:
sippeangelo
2015-11-30 11:16:43 +01:00
parent 8419d2e7b9
commit 52278d7bc2
20 changed files with 264 additions and 85 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
#set(Boost_DEBUG ON)
set(Boost_USE_STATIC_LIBS on)
add_definitions(-DBOOST_ALL_NO_LIB)
#set(BOOST_LIBRARYDIR $ENV{BOOST_ROOT}/lib64-msvc-14.0)
set(BOOST_LIBRARYDIR $ENV{BOOST_ROOT}/lib64-msvc-14.0)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
+3 -3
View File
@@ -3,9 +3,9 @@ Libraries bundled along with binaries for Windows (MSVC14), available as a submo
| Project | Version | License |
| ------------------------------------------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **[GLFW](http://www.glfw.org)** | ? | [zlib/libpng License](http://www.glfw.org/license.html) |
| **[GLM](http://glm.g-truc.net/0.9.5/index.html)** | ? | [MIT License](http://glm.g-truc.net/copying.txt) |
| **[GLEW](http://glew.sourceforge.net)** | ? | [Modified BSD License](http://glew.sourceforge.net/glew.txt), [Mesa 3-D License](http://glew.sourceforge.net/mesa.txt), [Khronos License](http://glew.sourceforge.net/khronos.txt) |
| **[GLFW](http://www.glfw.org)** | 3.1.2 | [zlib/libpng License](http://www.glfw.org/license.html) |
| **[GLM](http://glm.g-truc.net/0.9.5/index.html)** | 0.9.7.1 | [MIT License](http://glm.g-truc.net/copying.txt) |
| **[GLEW](http://glew.sourceforge.net)** | 1.13.0 | [Modified BSD License](http://glew.sourceforge.net/glew.txt), [Mesa 3-D License](http://glew.sourceforge.net/mesa.txt), [Khronos License](http://glew.sourceforge.net/khronos.txt) |
| **[Assimp](http://assimp.sourceforge.net)** | 3.1.1 | [BSD 3-Clause License](http://assimp.sourceforge.net/main_license.html) |
| **[zlib](http://www.zlib.net)** | 1.28 | [zlib License](http://www.zlib.net/zlib_license.html) |
| **[libpng](http://www.libpng.org/pub/png/libpng.html)** | 1.6.19 | [libpng License](http://www.libpng.org/pub/png/src/libpng-LICENSE.txt) |
+48
View File
@@ -0,0 +1,48 @@
# GLFW_FOUND
# GLFW_INCLUDE_DIRS
# GLFW_LIBRARYS
find_path(GLFW_INCLUDE_DIR GLFW/glfw3.h
$ENV{GLFWDIR}/include
$ENV{GLFW_HOME}/include
${OPENGL_INCLUDE_DIR}
/usr/include
/usr/local/include
/usr/include/GL
/sw/include
/opt/local/include
/opt/graphics/OpenGL/include
/opt/graphics/OpenGL/contrib/libglfw
DOC "The directory where GL/glfw.h resides"
)
find_library(GLFW_LIBRARY
NAMES glfw3 glfw glfw3dll glfwdll
PATHS
$ENV{GLFWDIR}/lib
$ENV{GLFWDIR}/lib/x64
$ENV{GLFWDIR}/lib/cocoa
$ENV{GLFWDIR}/lib-msvc120
$ENV{GLFW_HOME}/lib
$ENV{GLFW_HOME}/lib/x64
$ENV{GLFW_HOME}/lib/cocoa
$ENV{GLFW_HOME}/lib-msvc120
$ENV{GLFW_HOME}/build/src
$ENV{GLFW_HOME}/build-debug/src
$ENV{GLFW_HOME}/build-release/src
/usr/lib64
/usr/local/lib64
/sw/lib64
/opt/local/lib64
/usr/lib
/usr/local/lib
/sw/lib
/opt/local/lib
DOC "The GLFW library"
)
set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_DIR})
set(GLFW_LIBRARIES ${GLFW_LIBRARY})
find_package_handle_standard_args(GLFW DEFAULT_MSG GLFW_LIBRARY GLFW_INCLUDE_DIR)
mark_as_advanced(GLFW_FOUND GLFW_INCLUDE_DIR GLFW_LIBRARY)
+22
View File
@@ -0,0 +1,22 @@
find_path(
assimp_INCLUDE_DIR
NAMES
assimp/postprocess.h
assimp/scene.h
assimp/version.h
assimp/config.h
assimp/cimport.h
PATHS /usr/local/include/
)
find_library(
assimp_LIBRARY
NAMES assimp
PATHS /usr/local/lib/
)
set(assimp_INCLUDE_DIRS ${assimp_INCLUDE_DIR})
set(assimp_LIBRARIES ${assimp_LIBRARY})
find_package_handle_standard_args(assimp REQUIRED_VARS assimp_INCLUDE_DIR assimp_LIBRARY)
mark_as_advanced(assimp_INCLUDE_DIR assimp_LIBRARY)
+1 -1
Submodule deps updated: 2ecb61a3d0...65d3f3bc31
+2 -2
View File
@@ -16,7 +16,7 @@
class InputManager
{
public:
InputManager(GLFWwindow* window, std::shared_ptr<dd::EventBroker> eventBroker)
InputManager(GLFWwindow* window, std::shared_ptr<::EventBroker> eventBroker)
: m_GLFWWindow(window)
, EventBroker(eventBroker)
, m_CurrentKeyState()
@@ -37,7 +37,7 @@ public:
private:
GLFWwindow* m_GLFWWindow;
std::shared_ptr<dd::EventBroker> EventBroker;
std::shared_ptr<::EventBroker> EventBroker;
EventRelay<InputManager, Events::LockMouse> m_ELockMouse;
bool OnLockMouse(const Events::LockMouse &event);
-1
View File
@@ -9,7 +9,6 @@
#include <fstream>
#include "Util/UnorderedMapPair.h"
#include "Util/Factory.h"
#include "Util/FileWatcher.h"
/** Base Resource class.
+13
View File
@@ -0,0 +1,13 @@
#ifndef BoostPathHash_h__
#define BoostPathHash_h__
struct BoostPathHash
{
template <typename T>
std::size_t operator()(const boost::filesystem::path& p) const
{
return boost::filesystem::hash_value(p);
}
};
#endif
+14
View File
@@ -0,0 +1,14 @@
#ifndef EnumClassHash_h__
#define EnumClassHash_h__
// http://stackoverflow.com/a/24847480/417018
struct EnumClassHash
{
template <typename T>
std::size_t operator()(T t) const
{
return static_cast<std::size_t>(t);
}
};
#endif
+67
View File
@@ -0,0 +1,67 @@
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <functional>
#include <unordered_map>
#include "Logging.h"
#include "BoostPathHash.h"
class FileWatcher
{
public:
enum class FileEventFlags;
typedef std::function<void(std::string, FileEventFlags)> FileEventCallback_t;
FileWatcher();
FileWatcher(std::string rootPath);
~FileWatcher();
std::string RootPath() const { return m_RootPath.string(); }
void AddWatch(std::string path, FileEventCallback_t callback);
void Start();
bool IsRunning() const { return m_IsRunning; }
void Stop();
void Check();
private:
class Worker;
boost::filesystem::path m_RootPath;
boost::thread m_Thread;
Worker* m_Worker = nullptr;
bool m_IsRunning = false;
};
enum class FileWatcher::FileEventFlags
{
Nothing = 0,
Created = 1 << 0,
SizeChanged = 1 << 1,
TimestampChanged = 1 << 2,
Deleted = 1 << 3
};
inline FileWatcher::FileEventFlags operator|(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast<FileWatcher::FileEventFlags>(static_cast<int>(a) | static_cast<int>(b)); }
inline bool operator&(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast<int>(a)& static_cast<int>(b); }
class FileWatcher::Worker
{
public:
void operator()();
void AddWatch(std::string path, FileEventCallback_t callback);
void Check();
private:
struct FileInfo
{
int Size;
std::time_t Timestamp;
};
std::unordered_map<boost::filesystem::path, FileEventCallback_t, BoostPathHash> m_FileCallbacks;
std::unordered_map<boost::filesystem::path, FileInfo, BoostPathHash> m_FileInfo;
boost::mutex m_Mutex;
FileInfo GetFileInfo(boost::filesystem::path path);
FileEventFlags UpdateFileInfo(boost::filesystem::path path);
};
+3 -3
View File
@@ -1,5 +1,5 @@
#ifndef Util_Logging_h__
#define Util_Logging_h__
#ifndef Logging_h__
#define Logging_h__
#ifdef _WIN32
// http://stackoverflow.com/a/2282433
@@ -19,7 +19,7 @@
#include <cstdio>
#include <stdarg.h>
enum class LogLevel
enum _LOG_LEVEL
{
LOG_LEVEL_ERROR,
LOG_LEVEL_INFO,
@@ -0,0 +1,17 @@
#ifndef UnorderedMapPair_h__
#define UnorderedMapPair_h__
#include <boost/functional/hash.hpp>
template<typename S, typename T> struct std::hash<std::pair<S, T>>
{
inline std::size_t operator()(const std::pair<S, T> &v) const
{
std::size_t seed = 0;
boost::hash_combine(seed, v.first);
boost::hash_combine(seed, v.second);
return seed;
}
};
#endif
+19
View File
@@ -0,0 +1,19 @@
#ifndef Image_h
#define Image_h
struct Image
{
enum class ImageFormat
{
Unknown,
RGB,
RGBA
};
unsigned int Width = 0;
unsigned int Height = 0;
ImageFormat Format = ImageFormat::Unknown;
unsigned char* Data = nullptr;
};
#endif
+3 -3
View File
@@ -47,9 +47,9 @@ public:
struct MaterialGroup
{
float Shininess;
std::shared_ptr<dd::Texture> Texture;
std::shared_ptr<dd::Texture> NormalMap;
std::shared_ptr<dd::Texture> SpecularMap;
std::shared_ptr<::Texture> Texture;
std::shared_ptr<::Texture> NormalMap;
std::shared_ptr<::Texture> SpecularMap;
unsigned int StartIndex;
unsigned int EndIndex;
};
+8 -68
View File
@@ -1,20 +1,20 @@
project(TacticalZ)
project(TacticalZ-Engine)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
#find_package(GLEW REQUIRED)
find_package(GLFW REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem thread chrono)
find_package(assimp REQUIRED)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
# Because FindOpenAL is retarded
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/deps/include/AL")
find_package(OpenAL REQUIRED)
#set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/deps/include/AL")
#find_package(OpenAL REQUIRED)
if(UNIX)
find_package(X11 REQUIRED)
endif()
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include/Engine)
include_directories(
${INCLUDE_PATH}
${OPENGL_INCLUDE_DIR}
@@ -23,8 +23,8 @@ include_directories(
${Boost_INCLUDE_DIRS}
${assimp_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${X11_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
${X11_INCLUDE_DIRS}
)
file(GLOB SOURCE_FILES_Core
@@ -49,63 +49,12 @@ file(GLOB SOURCE_FILES_Rendering
"Rendering/*.cpp"
)
source_group(Rendering FILES ${SOURCE_FILES_Rendering})
file(GLOB SOURCE_FILES_Rendering_OpenGL
"${INCLUDE_PATH}/Rendering/OpenGL/Rendering/*.h"
"Rendering/OpenGL/*.cpp"
)
source_group(Rendering\\OpenGL FILES ${SOURCE_FILES_Rendering_OpenGL})
file(GLOB SOURCE_FILES_Rendering_DirectX
"${INCLUDE_PATH}/Rendering/DirectX/Rendering/*.h"
"Rendering/DirectX/*.cpp"
)
source_group(Rendering\\DirectX FILES ${SOURCE_FILES_Rendering_DirectX})
file(GLOB SOURCE_FILES_Transform
"${INCLUDE_PATH}/Transform/*.h"
"Transform/*.cpp"
)
source_group(Transform FILES ${SOURCE_FILES_Transform})
file(GLOB SOURCE_FILES_Physics
"${INCLUDE_PATH}/Physics/*.h"
"Physics/*.cpp"
)
source_group(Physics FILES ${SOURCE_FILES_Physics})
file(GLOB SOURCE_FILES_Game
"${INCLUDE_PATH}/Game/*.h"
"Game/*.cpp"
)
source_group(Game FILES ${SOURCE_FILES_Game})
file(GLOB SOURCE_FILES_Game_GUI
"${INCLUDE_PATH}/Game/GUI/*.h"
"Game/GUI/*.cpp"
)
source_group(Game\\GUI FILES ${SOURCE_FILES_Game_GUI})
file(GLOB SOURCE_FILES_Sound
"${INCLUDE_PATH}/Sound/*.h"
"Sound/*.cpp"
)
source_group(Sound FILES ${SOURCE_FILES_Sound})
file(GLOB SOURCE_FILES_GUI
"${INCLUDE_PATH}/GUI/*.h"
"GUI/*.cpp"
)
source_group(GUI FILES ${SOURCE_FILES_GUI})
set(SOURCE_FILES
${SOURCE_FILES_Core}
${SOURCE_FILES_Core_Util}
${SOURCE_FILES_Input}
#${SOURCE_FILES_Input}
${SOURCE_FILES_Rendering}
${SOURCE_FILES_Transform}
${SOURCE_FILES_Physics}
${SOURCE_FILES_Game}
${SOURCE_FILES_Game_GUI}
${SOURCE_FILES_Sound}
${SOURCE_FILES_GUI}
)
set(LIBRARIES
@@ -115,8 +64,8 @@ set(LIBRARIES
${Boost_LIBRARIES}
${assimp_LIBRARIES}
${PNG_LIBRARIES}
${X11_LIBRARIES}
${OPENAL_LIBRARY}
${X11_LIBRARIES}
)
if(CMAKE_COMPILER_IS_GNUCXX)
@@ -129,12 +78,3 @@ add_library(Engine ${SOURCE_FILES})
target_link_libraries(Engine
${LIBRARIES}
)
add_executable(Game
main.cpp
)
target_link_libraries(Game
Engine
${LIBRARIES}
)
-1
View File
@@ -20,7 +20,6 @@ unsigned int ResourceManager::GetTypeID(std::string resourceType)
return m_ResourceTypeIDs[resourceType];
}
void ResourceManager::Reload(std::string resourceName)
{
auto it = m_ResourceFromName.find(resourceName);
+36
View File
@@ -0,0 +1,36 @@
project(TacticalZ-Game)
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
include_directories(
${INCLUDE_PATH}/Engine
${INCLUDE_PATH}/Game
)
file(GLOB SOURCE_FILES
"${INCLUDE_PATH}*.h"
"*.cpp"
)
#source_group(Core FILES ${SOURCE_FILES})
set(SOURCE_FILES
${SOURCE_FILES}
)
set(LIBRARIES
)
add_library(Game ${SOURCE_FILES})
target_link_libraries(Game
Engine
${LIBRARIES}
)
add_executable(TacticalZ
main.cpp
)
target_link_libraries(TacticalZ
Game
${LIBRARIES}
)
View File
+5 -2
View File
@@ -1,9 +1,12 @@
project(Tests)
project(TacticalZ-Tests)
find_package(Boost REQUIRED COMPONENTS chrono thread unit_test_framework)
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
include_directories(
${CMAKE_SOURCE_DIR}/include
${INCLUDE_PATH}/Engine
${INCLUDE_PATH}/Game
${INCLUDE_PATH}/Tests
${Boost_INCLUDE_DIRS}
)
+2
View File
@@ -0,0 +1,2 @@
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>