[Orxonox-commit 890] r5613 - in code/branches/libraries: cmake src/orxonox
landauf at orxonox.net
landauf at orxonox.net
Mon Aug 10 16:44:05 CEST 2009
Author: landauf
Date: 2009-08-10 16:44:05 +0200 (Mon, 10 Aug 2009)
New Revision: 5613
Added:
code/branches/libraries/src/orxonox/Main.h
code/branches/libraries/src/orxonox/Orxonox.cc
Modified:
code/branches/libraries/cmake/TargetUtilities.cmake
code/branches/libraries/src/orxonox/CMakeLists.txt
code/branches/libraries/src/orxonox/Main.cc
code/branches/libraries/src/orxonox/OrxonoxPrereqs.h
Log:
replaced the old orxonox executable with an orxonox library. linked that library into the new orxonox executable which only contains one file (Orxonox.cc).
Modified: code/branches/libraries/cmake/TargetUtilities.cmake
===================================================================
--- code/branches/libraries/cmake/TargetUtilities.cmake 2009-08-10 13:30:37 UTC (rev 5612)
+++ code/branches/libraries/cmake/TargetUtilities.cmake 2009-08-10 14:44:05 UTC (rev 5613)
@@ -43,6 +43,7 @@
# TOLUA_FILES: Files with tolua interface
# PCH_FILE: Precompiled header file
# PCH_EXCLUDE: Source files to be excluded from PCH support
+ # OUTPUT_NAME: If you want a different name than the target name
# Note:
# This function also installs the target!
# Prerequisistes:
@@ -76,7 +77,7 @@
NO_DLL_INTERFACE NO_SOURCE_GROUPS ${_additional_switches}
PCH_NO_DEFAULT NO_INSTALL)
SET(_list_names LINK_LIBRARIES VERSION SOURCE_FILES DEFINE_SYMBOL
- TOLUA_FILES PCH_FILE PCH_EXCLUDE)
+ TOLUA_FILES PCH_FILE PCH_EXCLUDE OUTPUT_NAME)
PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
@@ -167,6 +168,11 @@
SET_TARGET_PROPERTIES(${_target_name} PROPERTIES VERSION ${ORXONOX_VERSION})
ENDIF()
+ # OUTPUT_NAME
+ IF(_arg_OUTPUT_NAME )
+ SET_TARGET_PROPERTIES(${_target_name} PROPERTIES OUTPUT_NAME ${_arg_OUTPUT_NAME})
+ ENDIF()
+
# Second part of precompiled header files
IF(PCH_COMPILER_SUPPORT AND PCH_ENABLE_${_target_name_upper} AND _arg_PCH_FILE)
PRECOMPILED_HEADER_FILES_POST_TARGET(${_target_name} ${_arg_PCH_FILE})
Modified: code/branches/libraries/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/CMakeLists.txt 2009-08-10 13:30:37 UTC (rev 5612)
+++ code/branches/libraries/src/orxonox/CMakeLists.txt 2009-08-10 14:44:05 UTC (rev 5613)
@@ -36,7 +36,7 @@
SET(ORXONOX_WIN32 WIN32)
ENDIF()
-ORXONOX_ADD_EXECUTABLE(orxonox
+ORXONOX_ADD_LIBRARY(orxonox
FIND_HEADER_FILES
TOLUA_FILES
LevelManager.h
@@ -44,10 +44,10 @@
objects/pickup/PickupInventory.h
objects/quest/QuestDescription.h
objects/quest/QuestManager.h
+ DEFINE_SYMBOL
+ "ORXONOX_SHARED_BUILD"
PCH_FILE
OrxonoxPrecompiledHeaders.h
- # When defined as WIN32 this removes the console window on Windows
- ${ORXONOX_WIN32}
LINK_LIBRARIES
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY} # Filesystem dependency
@@ -68,7 +68,18 @@
SOURCE_FILES ${ORXONOX_SRC_FILES}
)
-GET_TARGET_PROPERTY(_exec_loc orxonox LOCATION)
+ORXONOX_ADD_EXECUTABLE(orxonox-main
+ FIND_HEADER_FILES
+ # When defined as WIN32 this removes the console window on Windows
+ ${ORXONOX_WIN32}
+ LINK_LIBRARIES
+ orxonox
+ SOURCE_FILES
+ Orxonox.cc
+ OUTPUT_NAME orxonox
+)
+
+GET_TARGET_PROPERTY(_exec_loc orxonox-main LOCATION)
GET_FILENAME_COMPONENT(_exec_name ${_exec_loc} NAME)
SET(ORXONOX_EXECUTABLE_NAME ${_exec_name} CACHE INTERNAL "")
Modified: code/branches/libraries/src/orxonox/Main.cc
===================================================================
--- code/branches/libraries/src/orxonox/Main.cc 2009-08-10 13:30:37 UTC (rev 5612)
+++ code/branches/libraries/src/orxonox/Main.cc 2009-08-10 14:44:05 UTC (rev 5613)
@@ -26,27 +26,20 @@
* ...
*
*/
-
+
/**
@file
@brief
- Entry point of the program.
+ The main function of Orxonox.
*/
#include "OrxonoxPrereqs.h"
#include "SpecialConfig.h"
-#ifdef ORXONOX_USE_WINMAIN
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# endif
-#include <windows.h>
-#endif
-
-#include "util/Debug.h"
#include "util/Exception.h"
#include "core/CommandLine.h"
#include "core/Game.h"
+#include "Main.h"
SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
// Shortcuts for easy direct loading
@@ -55,27 +48,15 @@
SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
SetCommandLineSwitch(standalone).information("Start in standalone mode");
-/*
- at brief
- Main method. Game starts here (except for static initialisations).
-*/
-#ifdef ORXONOX_USE_WINMAIN
-INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
-#else
-int main(int argc, char** argv)
-#endif
+namespace orxonox
{
- using namespace orxonox;
-
- Game* game = 0;
- try
+ /**
+ @brief
+ Main method. Game starts here (except for static initialisations).
+ */
+ int main(const std::string& strCmdLine)
{
-#ifndef ORXONOX_USE_WINMAIN
- std::string strCmdLine;
- for (int i = 1; i < argc; ++i)
- strCmdLine += argv[i] + std::string(" ");
-#endif
- game = new Game(strCmdLine);
+ Game* game = new Game(strCmdLine);
game->setStateHierarchy(
"root"
@@ -107,22 +88,10 @@
Game::getInstance().requestStates("ioConsole");
else
Game::getInstance().requestStates("graphics, mainMenu");
- }
- catch (const std::exception& ex)
- {
- COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;
- COUT(0) << "Terminating program." << std::endl;
- return 1;
- }
- catch (...)
- {
- COUT(0) << "Orxonox failed to initialise: " << std::endl;
- COUT(0) << "Terminating program." << std::endl;
- return 1;
- }
- game->run();
- delete game;
+ game->run();
+ delete game;
- return 0;
+ return 0;
+ }
}
Added: code/branches/libraries/src/orxonox/Main.h
===================================================================
--- code/branches/libraries/src/orxonox/Main.h (rev 0)
+++ code/branches/libraries/src/orxonox/Main.h 2009-08-10 14:44:05 UTC (rev 5613)
@@ -0,0 +1,40 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Main_H__
+#define _Main_H__
+
+#include "OrxonoxPrereqs.h"
+
+namespace orxonox
+{
+ _OrxonoxExport int main(const std::string& strCmdLine);
+}
+
+#endif /* _Main_H__ */
Added: code/branches/libraries/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/libraries/src/orxonox/Orxonox.cc (rev 0)
+++ code/branches/libraries/src/orxonox/Orxonox.cc 2009-08-10 14:44:05 UTC (rev 5613)
@@ -0,0 +1,81 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Entry point of the program.
+*/
+
+#include "OrxonoxPrereqs.h"
+#include "SpecialConfig.h"
+
+#ifdef ORXONOX_USE_WINMAIN
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+#include <windows.h>
+#endif
+
+#include "util/Debug.h"
+#include "Main.h"
+
+/*
+ at brief
+ Main method. Game starts here (except for static initialisations).
+*/
+#ifdef ORXONOX_USE_WINMAIN
+INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
+#else
+int main(int argc, char** argv)
+#endif
+{
+ try
+ {
+#ifndef ORXONOX_USE_WINMAIN
+ std::string strCmdLine;
+ for (int i = 1; i < argc; ++i)
+ strCmdLine += argv[i] + std::string(" ");
+
+ return orxonox::main(strCmdLine);
+#endif
+ }
+ catch (const std::exception& ex)
+ {
+ COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;
+ COUT(0) << "Terminating program." << std::endl;
+ return 1;
+ }
+ catch (...)
+ {
+ COUT(0) << "Orxonox failed to initialise: " << std::endl;
+ COUT(0) << "Terminating program." << std::endl;
+ return 1;
+ }
+}
Modified: code/branches/libraries/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/libraries/src/orxonox/OrxonoxPrereqs.h 2009-08-10 13:30:37 UTC (rev 5612)
+++ code/branches/libraries/src/orxonox/OrxonoxPrereqs.h 2009-08-10 14:44:05 UTC (rev 5613)
@@ -39,8 +39,7 @@
//-----------------------------------------------------------------------
// Shared library settings
//-----------------------------------------------------------------------
-#define ORXONOX_NO_EXPORTS // This is an executable that needs no exports
-#if defined(ORXONOX_PLATFORM_WINDOWS) && !(defined(ORXONOX_STATIC_BUILD) || defined(ORXONOX_NO_EXPORTS))
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
# ifdef ORXONOX_SHARED_BUILD
# define _OrxonoxExport __declspec(dllexport)
# else
More information about the Orxonox-commit
mailing list