Changes in build organization

* targets are now created in top-level build directory
 * more things are now configured through CMake options
 * changed debug build detection from NDEBUG to DEV_BUILD
 * moved po and desktop directories
 * moved last unit test out of src directory
dev-ui
Piotr Dziwinski 2013-06-22 01:11:37 +02:00
parent 1377e48910
commit bfcce26f89
34 changed files with 92 additions and 191 deletions

8
.gitignore vendored
View File

@ -1,6 +1,9 @@
# Ignore the documentation folder # Ignore the documentation folder
/doc /doc
# Ignore targets
/colobot
# Ignore local data # Ignore local data
/colobot.ini /colobot.ini
/savegame /savegame
@ -13,9 +16,8 @@ Makefile
/install_manifest.txt /install_manifest.txt
/Testing /Testing
/CTestTestfile.cmake /CTestTestfile.cmake
/src/CBot/tests/CBot_console/bin/
# Ignore KDevelop files
.kdev4 .kdev4
*.kdev4 *.kdev4
*.flv
*.mp4

View File

@ -33,15 +33,28 @@ endif()
set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_UNRELEASED}") set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_UNRELEASED}")
message(STATUS "Building Colobot \"${COLOBOT_VERSION_CODENAME}\" (${COLOBOT_VERSION_FULL})") message(STATUS "Building Colobot \"${COLOBOT_VERSION_CODENAME}\" (${COLOBOT_VERSION_FULL})")
# Include cmake directory with some additional scripts
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
## ##
# Build options # Build options
## ##
# Global build type # Build targets should be placed in the root build directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# Include cmake directory with some additional scripts
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
# Auto-detect develpment build if not given
if(CMAKE_BUILD_TYPE AND NOT(DEV_BUILD))
if("${CMAKE_BUILD_TYPE}" MATCHES "debug")
SET(DEV_BUILD 1)
else()
SET(DEV_BUILD 0)
endif()
endif()
# Default build type if not given is debug
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE debug) set(CMAKE_BUILD_TYPE debug)
endif() endif()
@ -83,8 +96,14 @@ set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0")
# Asserts can be enabled/disabled regardless of build type # Asserts can be enabled/disabled regardless of build type
option(ASSERTS "Enable assert()s" ON) option(ASSERTS "Enable assert()s" ON)
# Development build can be enabled/disabled regardless of build type
option(DEV_BUILD "Enable development build (enables some debugging tools, local setting paths, etc.)" OFF)
# Building tests can be enabled/disabled # Building tests can be enabled/disabled
option(TESTS "Enable tests" ON) option(TESTS "Build tests" OFF)
# Building tool programs can be enabled/disabled
option(TOOLS "Build tool programs" OFF)
# CBot can also be a static library # CBot can also be a static library
option(CBOT_STATIC "Build CBot as static libary" OFF) option(CBOT_STATIC "Build CBot as static libary" OFF)
@ -187,7 +206,7 @@ endif()
# Clipboard support # Clipboard support
## ##
set(CLIPBOARD_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/clipboard/include) set(CLIPBOARD_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/clipboard/include)
add_subdirectory(${colobot_SOURCE_DIR}/lib/clipboard bin/clipboard) add_subdirectory(lib/clipboard)
## ##
@ -221,7 +240,7 @@ if(${TESTS})
set(GTEST_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/gtest/include) set(GTEST_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/gtest/include)
endif() endif()
add_subdirectory(${GTEST_SRC_DIR} bin/gtest) add_subdirectory(${GTEST_SRC_DIR} lib/gtest)
# Google Mock library # Google Mock library
find_path(GMOCK_SRC_DIR NAMES src/gmock.cc src/gmock-all.cc PATHS /usr/src PATH_SUFFIXES gmock) find_path(GMOCK_SRC_DIR NAMES src/gmock.cc src/gmock-all.cc PATHS /usr/src PATH_SUFFIXES gmock)
@ -236,13 +255,13 @@ if(${TESTS})
message(STATUS "Using bundled gmock library") message(STATUS "Using bundled gmock library")
set(GMOCK_SRC_DIR ${colobot_SOURCE_DIR}/lib/gmock) set(GMOCK_SRC_DIR ${colobot_SOURCE_DIR}/lib/gmock)
set(GMOCK_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/gmock/include) set(GMOCK_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/gmock/include)
add_subdirectory(${GMOCK_SRC_DIR} bin/gmock) add_subdirectory(${GMOCK_SRC_DIR} lib/gmock)
endif() endif()
# Tests targets # Tests targets
enable_testing() enable_testing()
add_subdirectory(test bin/test) add_subdirectory(test)
endif() endif()
@ -271,7 +290,13 @@ else()
endif() endif()
# Subdirectory with sources # Subdirectory with sources
add_subdirectory(src bin) add_subdirectory(src)
add_subdirectory(po)
if(${DESKTOP})
add_subdirectory(desktop)
endif()
## ##

6
bin/.gitignore vendored
View File

@ -1,6 +0,0 @@
# Ignore everything
*
# But not these files...
!.gitignore
!README.txt

View File

@ -1 +0,0 @@
Target directory for binary objects: colobot.exe and CBot/libCBot.dll

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -5,8 +5,8 @@ set(_potFile colobot.pot)
find_program(XGETTEXT_CMD xgettext) find_program(XGETTEXT_CMD xgettext)
add_custom_command(OUTPUT ${_potFile} add_custom_command(OUTPUT ${_potFile}
COMMAND ${XGETTEXT_CMD} ../app/app.cpp --output=${_potFile} COMMAND ${XGETTEXT_CMD} ${colobot_SOURCE_DIR}/src/app/app.cpp --output=${_potFile}
COMMAND ${XGETTEXT_CMD} ../common/restext.cpp --output=${_potFile} --join-existing --extract-all --no-location COMMAND ${XGETTEXT_CMD} ${colobot_SOURCE_DIR}/src/common/restext.cpp --output=${_potFile} --join-existing --extract-all --no-location
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Extract translatable messages to ${_potFile}" COMMENT "Extract translatable messages to ${_potFile}"

View File

@ -8,12 +8,8 @@ set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG})
add_subdirectory(CBot) add_subdirectory(CBot)
add_subdirectory(tools) if(${TOOLS})
add_subdirectory(tools)
add_subdirectory(po)
if(${DESKTOP})
add_subdirectory(desktop)
endif() endif()

View File

@ -47,11 +47,10 @@ bool CProfile::InitCurrentDirectory()
{ {
try try
{ {
// TODO: NDEBUG should be replaced with something like BUILD_TYPE == "DEBUG"/"RELEASE" #if DEV_BUILD
#ifdef NDEBUG
bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree);
#else
bp::ini_parser::read_ini("colobot.ini", m_propertyTree); bp::ini_parser::read_ini("colobot.ini", m_propertyTree);
#else
bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree);
#endif #endif
} }
catch (std::exception & e) catch (std::exception & e)
@ -68,10 +67,10 @@ bool CProfile::SaveCurrentDirectory()
{ {
try try
{ {
#ifdef NDEBUG #if DEV_BUILD
bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree);
#else
bp::ini_parser::write_ini("colobot.ini", m_propertyTree); bp::ini_parser::write_ini("colobot.ini", m_propertyTree);
#else
bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree);
#endif #endif
} }
catch (std::exception & e) catch (std::exception & e)

View File

@ -112,7 +112,7 @@ void CLightManager::DebugDumpLights()
continue; continue;
int deviceLight = -1; int deviceLight = -1;
for (int j = 0; j < m_lightMap.size(); ++j) for (int j = 0; j < static_cast<int>( m_lightMap.size() ); ++j)
{ {
if (m_lightMap[j] == i) if (m_lightMap[j] == i)
{ {

View File

@ -1,28 +0,0 @@
cmake_minimum_required(VERSION 2.8)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE debug)
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(MODELFILE_TEST_SOURCES
modelfile_test.cpp
../modelfile.cpp
../../../common/logger.cpp
../../../common/stringutils.cpp
)
add_definitions(-DMODELFILE_NO_ENGINE)
include_directories(
.
../../..
${GTEST_INCLUDE_DIR}
)
add_executable(modelfile_test ${MODELFILE_TEST_SOURCES})
target_link_libraries(modelfile_test gtest)
add_test(modelfile_test modelfile_test)

View File

@ -669,11 +669,13 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_showPos = false; m_showPos = false;
m_selectInsect = false; m_selectInsect = false;
m_showSoluce = false; m_showSoluce = false;
#ifdef NDEBUG
m_showAll = false; #if DEV_BUILD
#else
m_showAll = true; // for development m_showAll = true; // for development
#else
m_showAll = false;
#endif #endif
m_cheatRadar = false; m_cheatRadar = false;
m_fixScene = false; m_fixScene = false;
m_trainerPilot = false; m_trainerPilot = false;

View File

@ -192,7 +192,7 @@ class CRobotMain : public CSingleton<CRobotMain>
{ {
public: public:
CRobotMain(CApplication* app, bool loadProfile); CRobotMain(CApplication* app, bool loadProfile);
~CRobotMain(); virtual ~CRobotMain();
Gfx::CCamera* GetCamera(); Gfx::CCamera* GetCamera();
Gfx::CTerrain* GetTerrain(); Gfx::CTerrain* GetTerrain();

View File

@ -175,12 +175,12 @@ CMainDialog::CMainDialog()
m_sceneDir = "levels"; m_sceneDir = "levels";
// TODO: replace NDEBUG with something like BUILD_TYPE == "DEBUG"/"RELEASE" #if DEV_BUILD
#ifdef NDEBUG
m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation();
#else
m_savegameDir = "savegame"; m_savegameDir = "savegame";
#else
m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation();
#endif #endif
m_publicDir = "program"; m_publicDir = "program";
m_userDir = "user"; m_userDir = "user";
m_filesDir = m_savegameDir; m_filesDir = m_savegameDir;

View File

@ -10,8 +10,6 @@
#include "app/system_mock.h" #include "app/system_mock.h"
#include "common/logger.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
using testing::_; using testing::_;
@ -57,7 +55,6 @@ protected:
long long relTimeReal, long long absTimeReal); long long relTimeReal, long long absTimeReal);
protected: protected:
CLogger logger;
CApplicationWrapper* app; CApplicationWrapper* app;
CSystemUtilsMock* systemUtils; CSystemUtilsMock* systemUtils;

View File

@ -1,22 +1,5 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
#include "common/logger.h"
#include "graphics/engine/modelfile.h" #include "graphics/engine/modelfile.h"
#include "math/func.h" #include "math/func.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
@ -63,17 +46,17 @@ void Init()
{ {
TRIANGLE_1.p1 = Gfx::VertexTex2(Math::Vector(-12.4099, 10.0016, -2.54558), TRIANGLE_1.p1 = Gfx::VertexTex2(Math::Vector(-12.4099, 10.0016, -2.54558),
Math::Vector(1, 0, 1.87319e-07), Math::Vector(1, 0, 1.87319e-07),
Math::Point(0.970703, 0.751953), Math::Point(0.970703, 0.751953),
Math::Point(0, 0)); Math::Point(0, 0));
TRIANGLE_1.p2 = Gfx::VertexTex2(Math::Vector(-12.4099, 10.0016, 2.54558), TRIANGLE_1.p2 = Gfx::VertexTex2(Math::Vector(-12.4099, 10.0016, 2.54558),
Math::Vector(1, 0, 1.87319e-07), Math::Vector(1, 0, 1.87319e-07),
Math::Point(0.998047, 0.751953), Math::Point(0.998047, 0.751953),
Math::Point(0, 0)); Math::Point(0, 0));
TRIANGLE_1.p3 = Gfx::VertexTex2(Math::Vector(-12.4099, 4.00165, -2.54558), TRIANGLE_1.p3 = Gfx::VertexTex2(Math::Vector(-12.4099, 4.00165, -2.54558),
Math::Vector(1, 0, 1.87319e-07), Math::Vector(1, 0, 1.87319e-07),
Math::Point(0.970703, 0.998047), Math::Point(0.970703, 0.998047),
Math::Point(0, 0)); Math::Point(0, 0));
TRIANGLE_1.material.diffuse = Gfx::Color(1, 1, 1, 0); TRIANGLE_1.material.diffuse = Gfx::Color(1, 1, 1, 0);
TRIANGLE_1.material.ambient = Gfx::Color(0.5, 0.5, 0.5, 0); TRIANGLE_1.material.ambient = Gfx::Color(0.5, 0.5, 0.5, 0);
TRIANGLE_1.material.specular = Gfx::Color(0, 0, 0, 0); TRIANGLE_1.material.specular = Gfx::Color(0, 0, 0, 0);
@ -83,17 +66,17 @@ void Init()
TRIANGLE_1.state = 1024; TRIANGLE_1.state = 1024;
TRIANGLE_2.p1 = Gfx::VertexTex2(Math::Vector(-19, -1, 4), TRIANGLE_2.p1 = Gfx::VertexTex2(Math::Vector(-19, -1, 4),
Math::Vector(-1, 0, 0), Math::Vector(-1, 0, 0),
Math::Point(0.248047, 0.123047), Math::Point(0.248047, 0.123047),
Math::Point(0.905224, 0.52067)); Math::Point(0.905224, 0.52067));
TRIANGLE_2.p2 = Gfx::VertexTex2(Math::Vector(-19, 4, 4), TRIANGLE_2.p2 = Gfx::VertexTex2(Math::Vector(-19, 4, 4),
Math::Vector(-1, 0, 0), Math::Vector(-1, 0, 0),
Math::Point(0.248047, 0.00195312), Math::Point(0.248047, 0.00195312),
Math::Point(0.905224, 0.614223)); Math::Point(0.905224, 0.614223));
TRIANGLE_2.p3 = Gfx::VertexTex2(Math::Vector(-19, 4, -4), TRIANGLE_2.p3 = Gfx::VertexTex2(Math::Vector(-19, 4, -4),
Math::Vector(-1, 0, 0), Math::Vector(-1, 0, 0),
Math::Point(0.00195312, 0.00195312), Math::Point(0.00195312, 0.00195312),
Math::Point(0.0947756, 0.614223)); Math::Point(0.0947756, 0.614223));
TRIANGLE_2.material.diffuse = Gfx::Color(1, 1, 1, 0); TRIANGLE_2.material.diffuse = Gfx::Color(1, 1, 1, 0);
TRIANGLE_2.material.ambient = Gfx::Color(0.5, 0.5, 0.5, 0); TRIANGLE_2.material.ambient = Gfx::Color(0.5, 0.5, 0.5, 0);
TRIANGLE_2.material.specular = Gfx::Color(0, 0, 0, 0); TRIANGLE_2.material.specular = Gfx::Color(0, 0, 0, 0);
@ -250,14 +233,3 @@ TEST(ModelFileTest, RWOldModel)
EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[0], TRIANGLE_1)); EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[0], TRIANGLE_1));
EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[1], TRIANGLE_2)); EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[1], TRIANGLE_2));
} }
int main(int argc, char **argv)
{
CLogger logger;
Init();
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -14,10 +14,14 @@
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
#include "gtest/gtest.h" #include "common/logger.h"
#include <gtest/gtest.h>
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
CLogger logger;
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();

View File

@ -1,26 +1,10 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
/* /*
Unit tests for math functions. Unit tests for math functions.
*/ */
#include "math/func.h" #include "math/func.h"
#include "gtest/gtest.h" #include <gtest/gtest.h>
TEST(IsPowerOfTwo, TestDifferentValues) TEST(IsPowerOfTwo, TestDifferentValues)

View File

@ -1,25 +1,9 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
/* Unit tests for functions in geometry.h */ /* Unit tests for functions in geometry.h */
#include "math/func.h" #include "math/func.h"
#include "math/geometry.h" #include "math/geometry.h"
#include "gtest/gtest.h" #include <gtest/gtest.h>
const float TEST_TOLERANCE = 1e-5; const float TEST_TOLERANCE = 1e-5;

View File

@ -1,19 +1,3 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
/* /*
Unit tests for Matrix struct Unit tests for Matrix struct
@ -24,7 +8,7 @@
#include "math/func.h" #include "math/func.h"
#include "math/matrix.h" #include "math/matrix.h"
#include "gtest/gtest.h" #include <gtest/gtest.h>
const float TEST_TOLERANCE = 1e-6; const float TEST_TOLERANCE = 1e-6;

View File

@ -1,19 +1,3 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
/* /*
Unit tests for Vector struct Unit tests for Vector struct
@ -24,7 +8,7 @@
#include "math/func.h" #include "math/func.h"
#include "math/vector.h" #include "math/vector.h"
#include "gtest/gtest.h" #include <gtest/gtest.h>
const float TEST_TOLERANCE = 1e-6; const float TEST_TOLERANCE = 1e-6;

View File

@ -1,10 +1,13 @@
#include "app/app.h" #include "app/app.h"
#include "ui/edit.h" #include "ui/edit.h"
#include "mocks/text_mock.h" #include "mocks/text_mock.h"
#include <fstream>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <fstream>
class CEditTest : public testing::Test class CEditTest : public testing::Test
{ {