diff --git a/.gitignore b/.gitignore index 0e9774c2..d2c6fbc9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Ignore the documentation folder /doc +# Ignore targets +/colobot + # Ignore local data /colobot.ini /savegame @@ -13,9 +16,8 @@ Makefile /install_manifest.txt /Testing /CTestTestfile.cmake -/src/CBot/tests/CBot_console/bin/ + +# Ignore KDevelop files .kdev4 *.kdev4 -*.flv -*.mp4 diff --git a/CMakeLists.txt b/CMakeLists.txt index ed6008ab..acacda92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,15 +33,28 @@ endif() 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})") -# Include cmake directory with some additional scripts -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake") ## # 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) set(CMAKE_BUILD_TYPE debug) endif() @@ -83,8 +96,14 @@ set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0") # Asserts can be enabled/disabled regardless of build type 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 -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 option(CBOT_STATIC "Build CBot as static libary" OFF) @@ -187,7 +206,7 @@ endif() # Clipboard support ## 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) endif() - add_subdirectory(${GTEST_SRC_DIR} bin/gtest) + add_subdirectory(${GTEST_SRC_DIR} lib/gtest) # Google Mock library 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") set(GMOCK_SRC_DIR ${colobot_SOURCE_DIR}/lib/gmock) 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() # Tests targets enable_testing() - add_subdirectory(test bin/test) + add_subdirectory(test) endif() @@ -271,7 +290,13 @@ else() endif() # Subdirectory with sources -add_subdirectory(src bin) +add_subdirectory(src) + +add_subdirectory(po) + +if(${DESKTOP}) + add_subdirectory(desktop) +endif() ## diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index 96ec5aef..00000000 --- a/bin/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# Ignore everything -* - -# But not these files... -!.gitignore -!README.txt diff --git a/bin/README.txt b/bin/README.txt deleted file mode 100644 index c63a6ee8..00000000 --- a/bin/README.txt +++ /dev/null @@ -1 +0,0 @@ -Target directory for binary objects: colobot.exe and CBot/libCBot.dll diff --git a/src/desktop/.gitignore b/desktop/.gitignore similarity index 100% rename from src/desktop/.gitignore rename to desktop/.gitignore diff --git a/src/desktop/CMakeLists.txt b/desktop/CMakeLists.txt similarity index 100% rename from src/desktop/CMakeLists.txt rename to desktop/CMakeLists.txt diff --git a/src/desktop/colobot.desktop.in b/desktop/colobot.desktop.in similarity index 100% rename from src/desktop/colobot.desktop.in rename to desktop/colobot.desktop.in diff --git a/src/desktop/colobot.ini b/desktop/colobot.ini similarity index 100% rename from src/desktop/colobot.ini rename to desktop/colobot.ini diff --git a/src/desktop/colobot.pod b/desktop/colobot.pod similarity index 100% rename from src/desktop/colobot.pod rename to desktop/colobot.pod diff --git a/src/desktop/colobot.svg b/desktop/colobot.svg similarity index 100% rename from src/desktop/colobot.svg rename to desktop/colobot.svg diff --git a/src/desktop/create_desktop_file.sh b/desktop/create_desktop_file.sh similarity index 100% rename from src/desktop/create_desktop_file.sh rename to desktop/create_desktop_file.sh diff --git a/src/desktop/po/colobot-desktop.pot b/desktop/po/colobot-desktop.pot similarity index 100% rename from src/desktop/po/colobot-desktop.pot rename to desktop/po/colobot-desktop.pot diff --git a/src/desktop/po/fr.po b/desktop/po/fr.po similarity index 100% rename from src/desktop/po/fr.po rename to desktop/po/fr.po diff --git a/src/desktop/po4a.cfg b/desktop/po4a.cfg similarity index 100% rename from src/desktop/po4a.cfg rename to desktop/po4a.cfg diff --git a/src/po/CMakeLists.txt b/po/CMakeLists.txt similarity index 63% rename from src/po/CMakeLists.txt rename to po/CMakeLists.txt index 85b401c8..22393f9e 100644 --- a/src/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -5,8 +5,8 @@ set(_potFile colobot.pot) find_program(XGETTEXT_CMD xgettext) add_custom_command(OUTPUT ${_potFile} - COMMAND ${XGETTEXT_CMD} ../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/app/app.cpp --output=${_potFile} + COMMAND ${XGETTEXT_CMD} ${colobot_SOURCE_DIR}/src/common/restext.cpp --output=${_potFile} --join-existing --extract-all --no-location WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Extract translatable messages to ${_potFile}" diff --git a/src/po/colobot.pot b/po/colobot.pot similarity index 100% rename from src/po/colobot.pot rename to po/colobot.pot diff --git a/src/po/de.po b/po/de.po similarity index 100% rename from src/po/de.po rename to po/de.po diff --git a/src/po/fr.po b/po/fr.po similarity index 100% rename from src/po/fr.po rename to po/fr.po diff --git a/src/po/pl.po b/po/pl.po similarity index 100% rename from src/po/pl.po rename to po/pl.po diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8493fe80..7c02aa19 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,12 +8,8 @@ set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG}) add_subdirectory(CBot) -add_subdirectory(tools) - -add_subdirectory(po) - -if(${DESKTOP}) - add_subdirectory(desktop) +if(${TOOLS}) + add_subdirectory(tools) endif() diff --git a/src/common/profile.cpp b/src/common/profile.cpp index c6af6ccd..77c70c34 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -47,11 +47,10 @@ bool CProfile::InitCurrentDirectory() { try { - // TODO: NDEBUG should be replaced with something like BUILD_TYPE == "DEBUG"/"RELEASE" - #ifdef NDEBUG - bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); - #else + #if DEV_BUILD bp::ini_parser::read_ini("colobot.ini", m_propertyTree); + #else + bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); #endif } catch (std::exception & e) @@ -68,10 +67,10 @@ bool CProfile::SaveCurrentDirectory() { try { - #ifdef NDEBUG - bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); - #else + #if DEV_BUILD bp::ini_parser::write_ini("colobot.ini", m_propertyTree); + #else + bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); #endif } catch (std::exception & e) diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp index 295b3dae..8694c7ad 100644 --- a/src/graphics/engine/lightman.cpp +++ b/src/graphics/engine/lightman.cpp @@ -112,7 +112,7 @@ void CLightManager::DebugDumpLights() continue; int deviceLight = -1; - for (int j = 0; j < m_lightMap.size(); ++j) + for (int j = 0; j < static_cast( m_lightMap.size() ); ++j) { if (m_lightMap[j] == i) { diff --git a/src/graphics/engine/test/CMakeLists.txt b/src/graphics/engine/test/CMakeLists.txt deleted file mode 100644 index 134ed2ae..00000000 --- a/src/graphics/engine/test/CMakeLists.txt +++ /dev/null @@ -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) - diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 7eaa3f62..b58e5f83 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -669,11 +669,13 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) m_showPos = false; m_selectInsect = false; m_showSoluce = false; - #ifdef NDEBUG - m_showAll = false; - #else + + #if DEV_BUILD m_showAll = true; // for development + #else + m_showAll = false; #endif + m_cheatRadar = false; m_fixScene = false; m_trainerPilot = false; diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 04efea7f..525e5df2 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -192,7 +192,7 @@ class CRobotMain : public CSingleton { public: CRobotMain(CApplication* app, bool loadProfile); - ~CRobotMain(); + virtual ~CRobotMain(); Gfx::CCamera* GetCamera(); Gfx::CTerrain* GetTerrain(); diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 3a31883b..defff84c 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -175,12 +175,12 @@ CMainDialog::CMainDialog() m_sceneDir = "levels"; - // TODO: replace NDEBUG with something like BUILD_TYPE == "DEBUG"/"RELEASE" - #ifdef NDEBUG - m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation(); - #else + #if DEV_BUILD m_savegameDir = "savegame"; + #else + m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation(); #endif + m_publicDir = "program"; m_userDir = "user"; m_filesDir = m_savegameDir; diff --git a/test/unit/app/app_test.cpp b/test/unit/app/app_test.cpp index 8c1e8997..b517d7d7 100644 --- a/test/unit/app/app_test.cpp +++ b/test/unit/app/app_test.cpp @@ -10,8 +10,6 @@ #include "app/system_mock.h" -#include "common/logger.h" - #include using testing::_; @@ -57,7 +55,6 @@ protected: long long relTimeReal, long long absTimeReal); protected: - CLogger logger; CApplicationWrapper* app; CSystemUtilsMock* systemUtils; diff --git a/src/graphics/engine/test/modelfile_test.cpp b/test/unit/graphics/engine/modelfile_test.cpp similarity index 74% rename from src/graphics/engine/test/modelfile_test.cpp rename to test/unit/graphics/engine/modelfile_test.cpp index 1ca7f0a2..0598e849 100644 --- a/src/graphics/engine/test/modelfile_test.cpp +++ b/test/unit/graphics/engine/modelfile_test.cpp @@ -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 "math/func.h" #include @@ -63,17 +46,17 @@ void Init() { TRIANGLE_1.p1 = Gfx::VertexTex2(Math::Vector(-12.4099, 10.0016, -2.54558), - Math::Vector(1, 0, 1.87319e-07), - Math::Point(0.970703, 0.751953), - Math::Point(0, 0)); + Math::Vector(1, 0, 1.87319e-07), + Math::Point(0.970703, 0.751953), + Math::Point(0, 0)); TRIANGLE_1.p2 = Gfx::VertexTex2(Math::Vector(-12.4099, 10.0016, 2.54558), - Math::Vector(1, 0, 1.87319e-07), - Math::Point(0.998047, 0.751953), - Math::Point(0, 0)); + Math::Vector(1, 0, 1.87319e-07), + Math::Point(0.998047, 0.751953), + Math::Point(0, 0)); TRIANGLE_1.p3 = Gfx::VertexTex2(Math::Vector(-12.4099, 4.00165, -2.54558), - Math::Vector(1, 0, 1.87319e-07), - Math::Point(0.970703, 0.998047), - Math::Point(0, 0)); + Math::Vector(1, 0, 1.87319e-07), + Math::Point(0.970703, 0.998047), + Math::Point(0, 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.specular = Gfx::Color(0, 0, 0, 0); @@ -83,17 +66,17 @@ void Init() TRIANGLE_1.state = 1024; TRIANGLE_2.p1 = Gfx::VertexTex2(Math::Vector(-19, -1, 4), - Math::Vector(-1, 0, 0), - Math::Point(0.248047, 0.123047), - Math::Point(0.905224, 0.52067)); + Math::Vector(-1, 0, 0), + Math::Point(0.248047, 0.123047), + Math::Point(0.905224, 0.52067)); TRIANGLE_2.p2 = Gfx::VertexTex2(Math::Vector(-19, 4, 4), - Math::Vector(-1, 0, 0), - Math::Point(0.248047, 0.00195312), - Math::Point(0.905224, 0.614223)); + Math::Vector(-1, 0, 0), + Math::Point(0.248047, 0.00195312), + Math::Point(0.905224, 0.614223)); TRIANGLE_2.p3 = Gfx::VertexTex2(Math::Vector(-19, 4, -4), - Math::Vector(-1, 0, 0), - Math::Point(0.00195312, 0.00195312), - Math::Point(0.0947756, 0.614223)); + Math::Vector(-1, 0, 0), + Math::Point(0.00195312, 0.00195312), + Math::Point(0.0947756, 0.614223)); 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.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()[1], TRIANGLE_2)); } - -int main(int argc, char **argv) -{ - CLogger logger; - - Init(); - - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - diff --git a/test/unit/main.cpp b/test/unit/main.cpp index e978630d..7d08f58b 100644 --- a/test/unit/main.cpp +++ b/test/unit/main.cpp @@ -14,10 +14,14 @@ // * 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 "gtest/gtest.h" +#include "common/logger.h" + +#include int main(int argc, char* argv[]) { + CLogger logger; + ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/test/unit/math/func_test.cpp b/test/unit/math/func_test.cpp index 00a564b1..57f1347d 100644 --- a/test/unit/math/func_test.cpp +++ b/test/unit/math/func_test.cpp @@ -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. */ #include "math/func.h" -#include "gtest/gtest.h" +#include TEST(IsPowerOfTwo, TestDifferentValues) diff --git a/test/unit/math/geometry_test.cpp b/test/unit/math/geometry_test.cpp index 7c3e26a2..581ef892 100644 --- a/test/unit/math/geometry_test.cpp +++ b/test/unit/math/geometry_test.cpp @@ -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 */ #include "math/func.h" #include "math/geometry.h" -#include "gtest/gtest.h" +#include const float TEST_TOLERANCE = 1e-5; diff --git a/test/unit/math/matrix_test.cpp b/test/unit/math/matrix_test.cpp index 5f5c3af0..7693a85f 100644 --- a/test/unit/math/matrix_test.cpp +++ b/test/unit/math/matrix_test.cpp @@ -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 @@ -24,7 +8,7 @@ #include "math/func.h" #include "math/matrix.h" -#include "gtest/gtest.h" +#include const float TEST_TOLERANCE = 1e-6; diff --git a/test/unit/math/vector_test.cpp b/test/unit/math/vector_test.cpp index 41bac74a..6fe30be3 100644 --- a/test/unit/math/vector_test.cpp +++ b/test/unit/math/vector_test.cpp @@ -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 @@ -24,7 +8,7 @@ #include "math/func.h" #include "math/vector.h" -#include "gtest/gtest.h" +#include const float TEST_TOLERANCE = 1e-6; diff --git a/test/unit/ui/edit_test.cpp b/test/unit/ui/edit_test.cpp index d4c36eb7..21af00f1 100644 --- a/test/unit/ui/edit_test.cpp +++ b/test/unit/ui/edit_test.cpp @@ -1,10 +1,13 @@ #include "app/app.h" + #include "ui/edit.h" + #include "mocks/text_mock.h" +#include + #include #include -#include class CEditTest : public testing::Test {