1
0
Fork 0

Split CMake project into separate subprojets

This commit is contained in:
Meoweg 2015-11-17 08:03:11 +00:00
parent da7554d11f
commit 3f7a0157f4
31 changed files with 51 additions and 35 deletions

4
.gitmodules vendored
View file

@ -1,5 +1,5 @@
[submodule "build"]
path = build
[submodule "build/examples/demo"]
path = build/examples/demo
url = git@github.com:meoweg/Matabstrix.git
branch = gh-pages
[submodule "vendor/glm"]

View file

@ -1,25 +1,6 @@
cmake_minimum_required (VERSION 3.0)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "build")
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "build")
project (Matabstrix)
add_definitions ("-std=c++14 -Wall -Wextra")
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "--embed-file data -s TOTAL_MEMORY=67108864")
file (GLOB_RECURSE sources "src/**.cpp")
file (GLOB_RECURSE examples "examples/**.cpp")
add_library (matabstrix STATIC ${sources})
add_executable (example ${examples})
set (CMAKE_EXECUTABLE_SUFFIX ".html")
set_target_properties (example PROPERTIES OUTPUT_NAME "index")
target_link_libraries (example matabstrix)
find_package (GLM REQUIRED)
include_directories (${GLM_INCLUDE_DIRS})
find_package (STB REQUIRED)
include_directories (${STB_INCLUDE_DIRS})
add_subdirectory (src)
add_subdirectory (examples)

1
build

@ -1 +0,0 @@
Subproject commit bca6b67d90f75f7dfbd9dba75aaa3eadc61b9e9e

1
build/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/src

1
build/examples/demo Submodule

@ -0,0 +1 @@
Subproject commit 4eeedda5469f4a4e72a99c029cb49310de4a117a

6
configure vendored
View file

@ -1,11 +1,13 @@
#!/bin/sh
VENDOR="vendor"
VENDOR="../vendor"
GLM="$VENDOR/glm"
STB="$VENDOR/stb"
cmake \
cd "build"
cmake .. \
-DCMAKE_TOOLCHAIN_FILE="$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake" \
-DGLM_INCLUDE_DIR="$GLM" \
-DSTB_INCLUDE_DIR="$STB"

3
examples/CMakeLists.txt Normal file
View file

@ -0,0 +1,3 @@
include_directories ("../src")
add_subdirectory (demo)

View file

@ -0,0 +1,15 @@
set (DATA "${CMAKE_CURRENT_LIST_DIR}/data@/")
project (demo)
add_definitions ("-std=c++14 -Wall -Wextra")
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "--embed-file ${DATA} -s TOTAL_MEMORY=67108864")
file (GLOB_RECURSE sources "**.cpp")
add_executable (demo ${sources})
set (CMAKE_EXECUTABLE_SUFFIX ".html")
set_target_properties (demo PROPERTIES OUTPUT_NAME "index")
target_link_libraries (demo matabstrix)
find_package (GLM REQUIRED)
include_directories (${GLM_INCLUDE_DIRS})

View file

Before

Width:  |  Height:  |  Size: 226 KiB

After

Width:  |  Height:  |  Size: 226 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View file

Before

Width:  |  Height:  |  Size: 961 KiB

After

Width:  |  Height:  |  Size: 961 KiB

View file

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -1,10 +1,10 @@
#include "../src/adapters/adapter.hpp"
#include "../src/scene.hpp"
#include "../src/camera.hpp"
#include "../src/lights/sun.hpp"
#include "../src/models/raw.hpp"
#include "../src/models/static.hpp"
#include "../src/objects/with_model.hpp"
#include <adapters/adapter.hpp>
#include <scene.hpp>
#include <camera.hpp>
#include <lights/sun.hpp>
#include <models/raw.hpp>
#include <models/static.hpp>
#include <objects/with_model.hpp>
#include <cstdlib>

14
src/CMakeLists.txt Normal file
View file

@ -0,0 +1,14 @@
cmake_minimum_required (VERSION 3.0)
project (libmatabstrix)
add_definitions ("-std=c++14 -Wall -Wextra")
file (GLOB_RECURSE sources "**.cpp")
add_library (matabstrix STATIC ${sources})
find_package (GLM REQUIRED)
include_directories (${GLM_INCLUDE_DIRS})
find_package (STB REQUIRED)
include_directories (${STB_INCLUDE_DIRS})

View file

@ -30,7 +30,7 @@ const T *Adapter::load(const std::string &name) const
template <class T>
const std::string Adapter::filename(const std::string &name) const
{
return "/data" + T::filename(name);
return T::filename(name);
}
#endif // _ADAPTER_HPP_