Skip to content

Commit

Permalink
Reorganize the build system
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazade committed Apr 27, 2012
1 parent bef0aee commit c4118cd
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "kazbase"]
path = kazbase
url = https://Kazade@github.com/Kazade/kazbase.git
42 changes: 15 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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}
Expand All @@ -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}
)
23 changes: 23 additions & 0 deletions cmake_modules/FindKAZMATH.cmake
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions kazbase
Submodule kazbase added at 61cffc
5 changes: 5 additions & 0 deletions kglt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
4 changes: 2 additions & 2 deletions kglt/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
13 changes: 10 additions & 3 deletions kglt/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions kglt/shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.