Skip to content
Browse files

Reorganize the build system

  • Loading branch information...
1 parent bef0aee commit c4118cde0e15cef77e274453f8214f9b8436860f @Kazade committed Apr 27, 2012
Showing with 69 additions and 34 deletions.
  1. +3 −0 .gitmodules
  2. +15 −27 CMakeLists.txt
  3. +23 −0 cmake_modules/FindKAZMATH.cmake
  4. +1 −0 kazbase
  5. +5 −0 kglt/CMakeLists.txt
  6. +2 −2 kglt/scene.cpp
  7. +10 −3 kglt/shader.cpp
  8. +2 −2 kglt/shader.h
  9. +8 −0 samples/CMakeLists.txt
View
3 .gitmodules
@@ -0,0 +1,3 @@
+[submodule "kazbase"]
+ path = kazbase
+ url = https://Kazade@github.com/Kazade/kazbase.git
View
42 CMakeLists.txt
@@ -1,9 +1,9 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
-PROJECT(kglt_sample)
+PROJECT(kglt)
FIND_PACKAGE(PkgConfig)
-ADD_DEFINITIONS(-Wall -std=c++0x -g)
+ADD_DEFINITIONS("-Wall -std=c++0x -g")
PKG_CHECK_MODULES(SDL QUIET sdl)
PKG_CHECK_MODULES(GL QUIET gl)
@@ -12,18 +12,8 @@ PKG_CHECK_MODULES(SIGC QUIET sigc++-2.0)
FIND_PACKAGE(Boost COMPONENTS system filesystem thread date_time REQUIRED)
-FILE(GLOB_RECURSE KGLT_SOURCES kglt/*.cpp)
-FILE(GLOB_RECURSE KAZBASE_SOURCES kazbase/*.cpp)
-
-SET(SAMPLE_SOURCES
- sample.cpp
-)
-
-SET(Q2_SAMPLE_SOURCES
- q2bsp_sample.cpp
-)
-
INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}
${SDL_INCLUDE_DIRS}
${GL_INCLUDE_DIRS}
${GLU_INCLUDE_DIRS}
@@ -42,18 +32,16 @@ LINK_LIBRARIES(
SOIL
)
-ADD_EXECUTABLE(
- kglt_sample
- ${KGLT_SOURCES}
- ${KAZMATH_SOURCES}
- ${KAZBASE_SOURCES}
- ${SAMPLE_SOURCES}
-)
+ADD_SUBDIRECTORY(kglt)
+
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
+FIND_PACKAGE(KAZMATH)
+IF(KAZMATH_FOUND)
+ ADD_SUBDIRECTORY(samples)
+ELSE(KAZMATH_FOUND)
+ MESSAGE("Couldn't find kazmath, not building the samples")
+ENDIF(KAZMATH_FOUND)
+#ADD_SUBDIRECTORY(tests)
+
+
-ADD_EXECUTABLE(
- kglt_bsp_sample
- ${KGLT_SOURCES}
- ${KAZMATH_SOURCES}
- ${KAZBASE_SOURCES}
- ${Q2_SAMPLE_SOURCES}
-)
View
23 cmake_modules/FindKAZMATH.cmake
@@ -0,0 +1,23 @@
+FIND_PATH( KAZMATH_INCLUDE_DIRS kazmath/vec3.h /usr/include /usr/local/include $ENV{INCLUDE} )
+FIND_LIBRARY( KAZMATH_LIBRARIES NAMES kazmath PATHS /usr/lib /usr/local/lib )
+
+IF(KAZMATH_INCLUDE_DIRS)
+ MESSAGE(STATUS "Found Kazmath include dir: ${KAZMATH_INCLUDE_DIRS}")
+ELSE(KAZMATH_INCLUDE_DIRS)
+ MESSAGE(STATUS "Could NOT find Kazmath headers.")
+ENDIF(KAZMATH_INCLUDE_DIRS)
+
+IF(KAZMATH_LIBRARIES)
+ MESSAGE(STATUS "Found Kazmath library: ${KAZMATH_LIBRARIES}")
+ELSE(KAZMATH_LIBRARIES)
+ MESSAGE(STATUS "Could NOT find Kazmath library.")
+ENDIF(KAZMATH_LIBRARIES)
+
+IF(KAZMATH_INCLUDE_DIRS AND KAZMATH_LIBRARIES)
+ SET(KAZMATH_FOUND "YES")
+ELSE(KAZMATH_INCLUDE_DIRS AND KAZMATH_LIBRARIES)
+ SET(KAZMATH_FOUND "NO")
+ IF(KAZMATH_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find Kazmath. Please install Kazmath (http://launchpad.net/kazmath)")
+ ENDIF(KAZMATH_FIND_REQUIRED)
+ENDIF(KAZMATH_INCLUDE_DIRS AND KAZMATH_LIBRARIES)
1 kazbase
@@ -0,0 +1 @@
+Subproject commit 61cffc9201591acc55b7a34a6aa2da56b60e069d
View
5 kglt/CMakeLists.txt
@@ -0,0 +1,5 @@
+FILE(GLOB_RECURSE KGLT_FILES *.cpp)
+FILE(GLOB_RECURSE KAZBASE_FILES ../kazbase/*.cpp)
+FILE(GLOB_RECURSE GLEE_FILES ../glee/*.c)
+
+ADD_LIBRARY(kglt STATIC ${KGLT_FILES} ${KAZBASE_FILES} ${GLEE_FILES})
View
4 kglt/scene.cpp
@@ -77,8 +77,8 @@ void Scene::init() {
ShaderProgram& def = shader(new_shader()); //Create a default shader;
assert(glGetError() == GL_NO_ERROR);
- def.add_and_compile(SHADER_TYPE_VERTEX, kglt::default_vert_shader_120);
- def.add_and_compile(SHADER_TYPE_FRAGMENT, kglt::default_frag_shader_120);
+ def.add_and_compile(SHADER_TYPE_VERTEX, kglt::get_default_vert_shader_120());
+ def.add_and_compile(SHADER_TYPE_FRAGMENT, kglt::get_default_frag_shader_120());
def.activate();
}
View
13 kglt/shader.cpp
@@ -10,7 +10,8 @@
namespace kglt {
-const std::string default_vert_shader_120 = R"(
+const std::string get_default_vert_shader_120() {
+ const std::string default_vert_shader_120 = R"(
#version 120
uniform mat4 modelview_projection_matrix;
@@ -23,8 +24,12 @@ void main() {
}
)";
+
+ return default_vert_shader_120;
+}
-const std::string default_frag_shader_120 = R"(
+const std::string get_default_frag_shader_120() {
+ const std::string default_frag_shader_120 = R"(
#version 120
uniform sampler2D texture_1;
@@ -43,7 +48,9 @@ void main() {
gl_FragColor = texture2D(texture_1, gl_TexCoord[0].st);
}
-)";
+)";
+ return default_frag_shader_120;
+}
ShaderProgram::ShaderProgram():
program_id_(0) {
View
4 kglt/shader.h
@@ -15,8 +15,8 @@
namespace kglt {
-extern const std::string default_vert_shader_120;
-extern const std::string default_frag_shader_120;
+const std::string get_default_vert_shader_120();
+const std::string get_default_frag_shader_120();
enum ShaderType {
SHADER_TYPE_VERTEX,
View
8 samples/CMakeLists.txt
@@ -0,0 +1,8 @@
+
+LINK_LIBRARIES(
+ kglt
+ ${KAZMATH_LIBRARIES}
+)
+
+ADD_EXECUTABLE(sample sample.cpp)
+ADD_EXECUTABLE(q2_sample q2bsp_sample.cpp)

0 comments on commit c4118cd

Please sign in to comment.
Something went wrong with that request. Please try again.