diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..77057ec73 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.8.3) + +set(TORQUE_APP_NAME "" CACHE STRING "the app name") + +if("${TORQUE_APP_NAME}" STREQUAL "") + message(FATAL_ERROR "Please set TORQUE_APP_NAME first") +endif() + +project(${TORQUE_APP_NAME}) + +add_subdirectory(Tools/CMake) \ No newline at end of file diff --git a/My Projects/readme.txt b/My Projects/readme.txt index 299a8f786..9663bd6e3 100644 --- a/My Projects/readme.txt +++ b/My Projects/readme.txt @@ -1 +1 @@ -The Torque Toolbox places your projects here. +your projects will go in this folder \ No newline at end of file diff --git a/Templates/Empty/game/main.cs.in b/Templates/Empty/game/main.cs.in new file mode 100644 index 000000000..db8436e7d --- /dev/null +++ b/Templates/Empty/game/main.cs.in @@ -0,0 +1,280 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +// Set the name of our application +$appName = "@TORQUE_APP_NAME@"; + +// The directory it is run from +$defaultGame = "scripts"; + +// Set profile directory +$Pref::Video::ProfilePath = "core/profile"; + +function createCanvas(%windowTitle) +{ + if ($isDedicated) + { + GFXInit::createNullDevice(); + return true; + } + + // Create the Canvas + %foo = new GuiCanvas(Canvas); + + // Set the window title + if (isObject(Canvas)) + Canvas.setWindowTitle(getEngineName() @ " - " @ $appName); + + return true; +} + +// Display the optional commandline arguements +$displayHelp = false; + +// Use these to record and play back crashes +//saveJournal("editorOnFileQuitCrash.jrn"); +//playJournal("editorOnFileQuitCrash.jrn", false); + +//------------------------------------------------------------------------------ +// Check if a script file exists, compiled or not. +function isScriptFile(%path) +{ + if( isFile(%path @ ".dso") || isFile(%path) ) + return true; + + return false; +} + +//------------------------------------------------------------------------------ +// Process command line arguments +exec("core/parseArgs.cs"); + +$isDedicated = false; +$dirCount = 2; +$userDirs = $defaultGame @ ";art;levels"; + +// load tools scripts if we're a tool build +if (isToolBuild()) + $userDirs = "tools;" @ $userDirs; + + +// Parse the executable arguments with the standard +// function from core/main.cs +defaultParseArgs(); + + +if($dirCount == 0) { + $userDirs = $defaultGame; + $dirCount = 1; +} + +//----------------------------------------------------------------------------- +// Display a splash window immediately to improve app responsiveness before +// engine is initialized and main window created +if (!$isDedicated) + displaySplashWindow(); + + +//----------------------------------------------------------------------------- +// The displayHelp, onStart, onExit and parseArgs function are overriden +// by mod packages to get hooked into initialization and cleanup. + +function onStart() +{ + // Default startup function +} + +function onExit() +{ + // OnExit is called directly from C++ code, whereas onStart is + // invoked at the end of this file. +} + +function parseArgs() +{ + // Here for mod override, the arguments have already + // been parsed. +} + +function compileFiles(%pattern) +{ + %path = filePath(%pattern); + + %saveDSO = $Scripts::OverrideDSOPath; + %saveIgnore = $Scripts::ignoreDSOs; + + $Scripts::OverrideDSOPath = %path; + $Scripts::ignoreDSOs = false; + %mainCsFile = makeFullPath("main.cs"); + + for (%file = findFirstFileMultiExpr(%pattern); %file !$= ""; %file = findNextFileMultiExpr(%pattern)) + { + // we don't want to try and compile the primary main.cs + if(%mainCsFile !$= %file) + compile(%file, true); + } + + $Scripts::OverrideDSOPath = %saveDSO; + $Scripts::ignoreDSOs = %saveIgnore; + +} + +if($compileAll) +{ + echo(" --- Compiling all files ---"); + compileFiles("*.cs"); + compileFiles("*.gui"); + compileFiles("*.ts"); + echo(" --- Exiting after compile ---"); + quit(); +} + +if($compileTools) +{ + echo(" --- Compiling tools scritps ---"); + compileFiles("tools/*.cs"); + compileFiles("tools/*.gui"); + compileFiles("tools/*.ts"); + echo(" --- Exiting after compile ---"); + quit(); +} + +package Help { + function onExit() { + // Override onExit when displaying help + } +}; + +function displayHelp() { + activatePackage(Help); + + // Notes on logmode: console logging is written to console.log. + // -log 0 disables console logging. + // -log 1 appends to existing logfile; it also closes the file + // (flushing the write buffer) after every write. + // -log 2 overwrites any existing logfile; it also only closes + // the logfile when the application shuts down. (default) + + error( + "Torque Demo command line options:\n"@ + " -log Logging behavior; see main.cs comments for details\n"@ + " -game Reset list of mods to only contain \n"@ + " Works like the -game argument\n"@ + " -dir Add to list of directories\n"@ + " -console Open a separate console\n"@ + " -show Deprecated\n"@ + " -jSave Record a journal\n"@ + " -jPlay Play back a journal\n"@ + " -jDebug Play back a journal and issue an int3 at the end\n"@ + " -help Display this help message\n" + ); +} + + +//-------------------------------------------------------------------------- + +// Default to a new logfile each session. +if( !$logModeSpecified ) +{ + if( $platform !$= "xbox" && $platform !$= "xenon" ) + setLogMode(6); +} + +// Get the first dir on the list, which will be the last to be applied... this +// does not modify the list. +nextToken($userDirs, currentMod, ";"); + +// Execute startup scripts for each mod, starting at base and working up +function loadDir(%dir) +{ + pushback($userDirs, %dir, ";"); + + if (isScriptFile(%dir @ "/main.cs")) + exec(%dir @ "/main.cs"); +} + +echo("--------- Loading DIRS ---------"); +function loadDirs(%dirPath) +{ + %dirPath = nextToken(%dirPath, token, ";"); + if (%dirPath !$= "") + loadDirs(%dirPath); + + if(exec(%token @ "/main.cs") != true) + { + error("Error: Unable to find specified directory: " @ %token ); + $dirCount--; + } +} +loadDirs($userDirs); +echo(""); + +if($dirCount == 0) { + enableWinConsole(true); + error("Error: Unable to load any specified directories"); + quit(); +} +// Parse the command line arguments +echo("--------- Parsing Arguments ---------"); +parseArgs(); + +// Either display the help message or startup the app. +if ($displayHelp) { + enableWinConsole(true); + displayHelp(); + quit(); +} +else { + onStart(); + echo("Engine initialized..."); + + // Auto-load on the 360 + if( $platform $= "xenon" ) + { + %mission = "levels/Empty Terrain.mis"; + + echo("Xbox360 Autoloading level: '" @ %mission @ "'"); + + + if ($pref::HostMultiPlayer) + %serverType = "MultiPlayer"; + else + %serverType = "SinglePlayer"; + + createAndConnectToLocalServer( %serverType, %mission ); + } +} + +// Display an error message for unused arguments +for ($i = 1; $i < $Game::argc; $i++) { + if (!$argUsed[$i]) + error("Error: Unknown command line argument: " @ $Game::argv[$i]); +} + +// Automatically start up the appropriate eidtor, if any +if ($startWorldEditor) { + Canvas.setCursor("DefaultCursor"); + Canvas.setContent(EditorChooseLevelGui); +} else if ($startGUIEditor) { + Canvas.setCursor("DefaultCursor"); + Canvas.setContent(EditorChooseGUI); +} diff --git a/Templates/Full/game/main.cs.in b/Templates/Full/game/main.cs.in new file mode 100644 index 000000000..db8436e7d --- /dev/null +++ b/Templates/Full/game/main.cs.in @@ -0,0 +1,280 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +// Set the name of our application +$appName = "@TORQUE_APP_NAME@"; + +// The directory it is run from +$defaultGame = "scripts"; + +// Set profile directory +$Pref::Video::ProfilePath = "core/profile"; + +function createCanvas(%windowTitle) +{ + if ($isDedicated) + { + GFXInit::createNullDevice(); + return true; + } + + // Create the Canvas + %foo = new GuiCanvas(Canvas); + + // Set the window title + if (isObject(Canvas)) + Canvas.setWindowTitle(getEngineName() @ " - " @ $appName); + + return true; +} + +// Display the optional commandline arguements +$displayHelp = false; + +// Use these to record and play back crashes +//saveJournal("editorOnFileQuitCrash.jrn"); +//playJournal("editorOnFileQuitCrash.jrn", false); + +//------------------------------------------------------------------------------ +// Check if a script file exists, compiled or not. +function isScriptFile(%path) +{ + if( isFile(%path @ ".dso") || isFile(%path) ) + return true; + + return false; +} + +//------------------------------------------------------------------------------ +// Process command line arguments +exec("core/parseArgs.cs"); + +$isDedicated = false; +$dirCount = 2; +$userDirs = $defaultGame @ ";art;levels"; + +// load tools scripts if we're a tool build +if (isToolBuild()) + $userDirs = "tools;" @ $userDirs; + + +// Parse the executable arguments with the standard +// function from core/main.cs +defaultParseArgs(); + + +if($dirCount == 0) { + $userDirs = $defaultGame; + $dirCount = 1; +} + +//----------------------------------------------------------------------------- +// Display a splash window immediately to improve app responsiveness before +// engine is initialized and main window created +if (!$isDedicated) + displaySplashWindow(); + + +//----------------------------------------------------------------------------- +// The displayHelp, onStart, onExit and parseArgs function are overriden +// by mod packages to get hooked into initialization and cleanup. + +function onStart() +{ + // Default startup function +} + +function onExit() +{ + // OnExit is called directly from C++ code, whereas onStart is + // invoked at the end of this file. +} + +function parseArgs() +{ + // Here for mod override, the arguments have already + // been parsed. +} + +function compileFiles(%pattern) +{ + %path = filePath(%pattern); + + %saveDSO = $Scripts::OverrideDSOPath; + %saveIgnore = $Scripts::ignoreDSOs; + + $Scripts::OverrideDSOPath = %path; + $Scripts::ignoreDSOs = false; + %mainCsFile = makeFullPath("main.cs"); + + for (%file = findFirstFileMultiExpr(%pattern); %file !$= ""; %file = findNextFileMultiExpr(%pattern)) + { + // we don't want to try and compile the primary main.cs + if(%mainCsFile !$= %file) + compile(%file, true); + } + + $Scripts::OverrideDSOPath = %saveDSO; + $Scripts::ignoreDSOs = %saveIgnore; + +} + +if($compileAll) +{ + echo(" --- Compiling all files ---"); + compileFiles("*.cs"); + compileFiles("*.gui"); + compileFiles("*.ts"); + echo(" --- Exiting after compile ---"); + quit(); +} + +if($compileTools) +{ + echo(" --- Compiling tools scritps ---"); + compileFiles("tools/*.cs"); + compileFiles("tools/*.gui"); + compileFiles("tools/*.ts"); + echo(" --- Exiting after compile ---"); + quit(); +} + +package Help { + function onExit() { + // Override onExit when displaying help + } +}; + +function displayHelp() { + activatePackage(Help); + + // Notes on logmode: console logging is written to console.log. + // -log 0 disables console logging. + // -log 1 appends to existing logfile; it also closes the file + // (flushing the write buffer) after every write. + // -log 2 overwrites any existing logfile; it also only closes + // the logfile when the application shuts down. (default) + + error( + "Torque Demo command line options:\n"@ + " -log Logging behavior; see main.cs comments for details\n"@ + " -game Reset list of mods to only contain \n"@ + " Works like the -game argument\n"@ + " -dir Add to list of directories\n"@ + " -console Open a separate console\n"@ + " -show Deprecated\n"@ + " -jSave Record a journal\n"@ + " -jPlay Play back a journal\n"@ + " -jDebug Play back a journal and issue an int3 at the end\n"@ + " -help Display this help message\n" + ); +} + + +//-------------------------------------------------------------------------- + +// Default to a new logfile each session. +if( !$logModeSpecified ) +{ + if( $platform !$= "xbox" && $platform !$= "xenon" ) + setLogMode(6); +} + +// Get the first dir on the list, which will be the last to be applied... this +// does not modify the list. +nextToken($userDirs, currentMod, ";"); + +// Execute startup scripts for each mod, starting at base and working up +function loadDir(%dir) +{ + pushback($userDirs, %dir, ";"); + + if (isScriptFile(%dir @ "/main.cs")) + exec(%dir @ "/main.cs"); +} + +echo("--------- Loading DIRS ---------"); +function loadDirs(%dirPath) +{ + %dirPath = nextToken(%dirPath, token, ";"); + if (%dirPath !$= "") + loadDirs(%dirPath); + + if(exec(%token @ "/main.cs") != true) + { + error("Error: Unable to find specified directory: " @ %token ); + $dirCount--; + } +} +loadDirs($userDirs); +echo(""); + +if($dirCount == 0) { + enableWinConsole(true); + error("Error: Unable to load any specified directories"); + quit(); +} +// Parse the command line arguments +echo("--------- Parsing Arguments ---------"); +parseArgs(); + +// Either display the help message or startup the app. +if ($displayHelp) { + enableWinConsole(true); + displayHelp(); + quit(); +} +else { + onStart(); + echo("Engine initialized..."); + + // Auto-load on the 360 + if( $platform $= "xenon" ) + { + %mission = "levels/Empty Terrain.mis"; + + echo("Xbox360 Autoloading level: '" @ %mission @ "'"); + + + if ($pref::HostMultiPlayer) + %serverType = "MultiPlayer"; + else + %serverType = "SinglePlayer"; + + createAndConnectToLocalServer( %serverType, %mission ); + } +} + +// Display an error message for unused arguments +for ($i = 1; $i < $Game::argc; $i++) { + if (!$argUsed[$i]) + error("Error: Unknown command line argument: " @ $Game::argv[$i]); +} + +// Automatically start up the appropriate eidtor, if any +if ($startWorldEditor) { + Canvas.setCursor("DefaultCursor"); + Canvas.setContent(EditorChooseLevelGui); +} else if ($startGUIEditor) { + Canvas.setCursor("DefaultCursor"); + Canvas.setContent(EditorChooseGUI); +} diff --git a/Tools/CMake/CMakeLists.txt b/Tools/CMake/CMakeLists.txt new file mode 100644 index 000000000..950d8cf99 --- /dev/null +++ b/Tools/CMake/CMakeLists.txt @@ -0,0 +1,28 @@ +include(basics.cmake) + +setupVersionNumbers() + +#the libs +include(lmng.cmake) +include(lpng.cmake) +include(lungif.cmake) +include(zlib.cmake) +include(ljpeg.cmake) +include(tinyxml.cmake) +include(opcode.cmake) +include(squish.cmake) +include(collada.cmake) +include(pcre.cmake) +include(convexDecomp.cmake) +if(TORQUE_SFX_VORBIS) + include(libvorbis.cmake) + include(libogg.cmake) +endif() +if(TORQUE_THEORA) + include(libtheora.cmake) +endif() + +# the main engine, should come last +include(torque3d.cmake) + +#setupPackaging() \ No newline at end of file diff --git a/Tools/CMake/app-debug-win.bat.in b/Tools/CMake/app-debug-win.bat.in new file mode 100644 index 000000000..8885f2e5b --- /dev/null +++ b/Tools/CMake/app-debug-win.bat.in @@ -0,0 +1,15 @@ +:: little debug helper script that helps you starting Torque3D with command line arguments. + +:: possible args: +:: -log +:: -console +:: -level +:: -worldeditor +:: -guieditor +:: -help + +:: as example, we just show the console +"@PROJECT_NAME@.exe" -console + +:: or load a level and open the editor: +:: "@PROJECT_NAME@.exe" -console -level mylevel.mis -worldeditor diff --git a/Tools/CMake/basics.cmake b/Tools/CMake/basics.cmake new file mode 100644 index 000000000..3faf03e6c --- /dev/null +++ b/Tools/CMake/basics.cmake @@ -0,0 +1,237 @@ +project("Torque3DEngine") + +set(TORQUE_TEMPLATE "Full" CACHE STRING "the template to use") + +set(projectDir "${CMAKE_SOURCE_DIR}/My Projects/${TORQUE_APP_NAME}") +set(projectOutDir "${projectDir}/game") +set(projectSrcDir "${projectDir}/source") +set(libDir "${CMAKE_SOURCE_DIR}/Engine/lib") +set(srcDir "${CMAKE_SOURCE_DIR}/Engine/source") +set(cmakeDir "${CMAKE_SOURCE_DIR}/Tools/CMake") + + +# hide some things +mark_as_advanced(CMAKE_INSTALL_PREFIX) +mark_as_advanced(CMAKE_CONFIGURATION_TYPES) + +# output folders +#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${projectOutDir}/game) +#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${projectOutDir}/game) +#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${projectOutDir}/game) + +# finds and adds sources files in a folder +macro(addPath dir) + set(tmpa "") + file(GLOB tmpa + ${dir}/*.cpp + ${dir}/*.c + ${dir}/*.cc + ${dir}/*.h) + LIST(APPEND ${PROJECT_NAME}_files "${tmpa}") + LIST(APPEND ${PROJECT_NAME}_paths "${dir}") + #message(STATUS "addPath ${PROJECT_NAME} : ${tmpa}") + #set(t "${${t}};${tmpa}") +endmacro() + +# adds a file to the sources +macro(addFile filename) + LIST(APPEND ${PROJECT_NAME}_files "${filename}") + #message(STATUS "addFile ${PROJECT_NAME} : ${filename}") +endmacro() + +# finds and adds sources files in a folder recursively +macro(addPathRec dir) + set(tmpa "") + file(GLOB_RECURSE tmpa + ${dir}/*.cpp + ${dir}/*.c + ${dir}/*.cc + ${dir}/*.h) + LIST(APPEND ${PROJECT_NAME}_files "${tmpa}") + LIST(APPEND ${PROJECT_NAME}_paths "${dir}") + #message(STATUS "addPathRec ${PROJECT_NAME} : ${tmpa}") +endmacro() + +# adds a definition +macro(addDef def) + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS "${def}") +endmacro() +# adds a definition +macro(addDebugDef def) + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG "${def}") +endmacro() + +# adds an include path +macro(addInclude incPath) + #message(STATUS "${PROJECT_NAME} : add include path : ${incPath}") + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${incPath}") +endmacro() + +# adds a library to link against +macro(addLib lib) + #message(STATUS "${PROJECT_NAME} : add lib : ${lib}") + target_link_libraries(${PROJECT_NAME} "${lib}") +endmacro() + +# adds a path to search for libs +macro(addLibPath dir) + link_directories(${dir}) +endmacro() + +# creates a proper filter for VS +macro(generateFilters relDir) + foreach(f ${${PROJECT_NAME}_files}) + # Get the path of the file relative to ${DIRECTORY}, + # then alter it (not compulsory) + file(RELATIVE_PATH SRCGR ${relDir} ${f}) + set(SRCGR "${PROJECT_NAME}/${SRCGR}") + # Extract the folder, ie remove the filename part + string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR}) + # do not have any ../ dirs + string(REPLACE "../" "" SRCGR ${SRCGR}) + # Source_group expects \\ (double antislash), not / (slash) + string(REPLACE / \\ SRCGR ${SRCGR}) + #STRING(REPLACE "//" "/" SRCGR ${SRCGR}) + #message(STATUS "FILE: ${f} -> ${SRCGR}") + source_group("${SRCGR}" FILES ${f}) + endforeach() +endmacro() + +# creates a proper filter for VS +macro(generateFiltersSpecial relDir) + foreach(f ${${PROJECT_NAME}_files}) + # Get the path of the file relative to ${DIRECTORY}, + # then alter it (not compulsory) + file(RELATIVE_PATH SRCGR ${relDir} ${f}) + set(SRCGR "torque3d/${SRCGR}") + # Extract the folder, ie remove the filename part + string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR}) + # do not have any ../ dirs + string(REPLACE "../" "" SRCGR ${SRCGR}) + IF("${SRCGR}" MATCHES "^torque3d/My Projects/.*$") + string(REPLACE "torque3d/My Projects/${PROJECT_NAME}/" "" SRCGR ${SRCGR}) + string(REPLACE "/source" "" SRCGR ${SRCGR}) + endif() + # Source_group expects \\ (double antislash), not / (slash) + string(REPLACE / \\ SRCGR ${SRCGR}) + #STRING(REPLACE "//" "/" SRCGR ${SRCGR}) + IF(EXISTS "${f}" AND NOT IS_DIRECTORY "${f}") + #message(STATUS "FILE: ${f} -> ${SRCGR}") + source_group("${SRCGR}" FILES ${f}) + endif() + endforeach() +endmacro() +# macro to add a static library +macro(addStaticLib) + # more paths? + if(${ARGC} GREATER 0) + foreach(dir ${ARGV0}) + addPath("${dir}") + endforeach() + endif() + # now inspect the paths we got + set(firstDir "") + foreach(dir ${${PROJECT_NAME}_paths}) + if("${firstDir}" STREQUAL "") + set(firstDir "${dir}") + endif() + endforeach() + generateFilters("${firstDir}") + if(TORQUE_STATIC) + add_library("${PROJECT_NAME}" STATIC ${${PROJECT_NAME}_files}) + else() + add_library("${PROJECT_NAME}" SHARED ${${PROJECT_NAME}_files}) + endif() + # omg - only use the first folder ... otehrwise we get lots of header name collisions + #foreach(dir ${${PROJECT_NAME}_paths}) + addInclude("${firstDir}") + #endforeach() +endmacro() + +# macro to add an executable +macro(addExecutable) + # now inspect the paths we got + set(firstDir "") + foreach(dir ${${PROJECT_NAME}_paths}) + if("${firstDir}" STREQUAL "") + set(firstDir "${dir}") + endif() + endforeach() + generateFiltersSpecial("${firstDir}") + add_executable("${PROJECT_NAME}" WIN32 ${${PROJECT_NAME}_files}) + # omg - only use the first folder ... otehrwise we get lots of header name collisions + addInclude("${firstDir}") +endmacro() + +macro(setupVersionNumbers) + set(TORQUE_APP_VERSION_MAYOR 1 CACHE INTEGER "") + set(TORQUE_APP_VERSION_MINOR 0 CACHE INTEGER "") + set(TORQUE_APP_VERSION_PATCH 0 CACHE INTEGER "") + set(TORQUE_APP_VERSION_TWEAK 0 CACHE INTEGER "") + mark_as_advanced(TORQUE_APP_VERSION_TWEAK) + MATH(EXPR TORQUE_APP_VERSION "${TORQUE_APP_VERSION_MAYOR} * 1000 + ${TORQUE_APP_VERSION_MINOR} * 100 + ${TORQUE_APP_VERSION_PATCH} * 10 + ${TORQUE_APP_VERSION_TWEAK}") + set(TORQUE_APP_VERSION_STRING "${TORQUE_APP_VERSION_MAYOR}.${TORQUE_APP_VERSION_MINOR}.${TORQUE_APP_VERSION_PATCH}.${TORQUE_APP_VERSION_TWEAK}") + #message(STATUS "version numbers: ${TORQUE_APP_VERSION} / ${TORQUE_APP_VERSION_STRING}") +endmacro() + +macro(setupPackaging) + INCLUDE(CPack) + # only enable zips for now + set(CPACK_BINARY_NSIS OFF CACHE INTERNAL "" FORCE) + set(CPACK_BINARY_ZIP ON CACHE INTERNAL "" FORCE) + set(CPACK_SOURCE_ZIP OFF CACHE INTERNAL "" FORCE) + SET(CPACK_GENERATOR "ZIP") + SET(CPACK_PACKAGE_VENDOR "${PROJECT_NAME}") + SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}") + SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1) + SET(CPACK_OUTPUT_FILE_PREFIX "${projectDir}/packages/${PROJECT_NAME}") + SET(CPACK_PACKAGE_INSTALL_DIRECTORY "") + #SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt") + #SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") + SET(CPACK_PACKAGE_VERSION_MAJOR "${TORQUE_APP_VERSION_MAYOR}") + SET(CPACK_PACKAGE_VERSION_MINOR "${TORQUE_APP_VERSION_MINOR}") + SET(CPACK_PACKAGE_VERSION_PATCH "${TORQUE_APP_VERSION_PATCH}") + #SET(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}") + SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${TORQUE_APP_VERSION_STRING}") + #SET(CPACK_SOURCE_STRIP_FILES "") +endmacro() +# always static for now +set(TORQUE_STATIC ON) +#option(TORQUE_STATIC "enables or disable static" OFF) + +if(WIN32) + # default disabled warnings: 4018;4100;4121;4127;4130;4244;4245;4389;4511;4512;4800; + set(TORQUE_CXX_FLAGS "/MP /O2 /Ob2 /Oi /Ot /Oy /GT /Zi /W4 /nologo /GF /EHsc /GS- /Gy- /Qpar- /arch:SSE2 /fp:fast /fp:except- /GR /Zc:wchar_t-" CACHE TYPE STRING) + mark_as_advanced(TORQUE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORQUE_CXX_FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}") + #set(CMAKE_EXE_LINKER_FLAGS "/OPT:NOREF") + #set(STATIC_LIBRARY_FLAGS "/OPT:NOREF") + + # Force static runtime libraries + if(TORQUE_STATIC) + FOREACH(flag + CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_DEBUG_INIT + CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_DEBUG_INIT) + STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}") + SET("${flag}" "${${flag}} /EHsc") + ENDFOREACH() + endif() +endif() + + +# fix the debug/release subfolders on windows +if(MSVC) + FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) + # Go uppercase (DEBUG, RELEASE...) + STRING(TOUPPER "${CONF}" CONF) + #SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${projectOutDir}") + SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${projectOutDir}") + ENDFOREACH() +endif() diff --git a/Tools/CMake/cleanup-win.bat.in b/Tools/CMake/cleanup-win.bat.in new file mode 100644 index 000000000..0e9906dd8 --- /dev/null +++ b/Tools/CMake/cleanup-win.bat.in @@ -0,0 +1,47 @@ +@ECHO off + +:: Delete procedural shaders +echo shaders +del /q /a:-R shaders\procedural\*.* +:: Delete dumped shader disassembly files +for /R %%a IN (*._dis.txt) do IF EXIST "%%a._dis.txt" del "%%a._dis.txt" + +:: Delete fonts +echo fonts +del /q /a:-R core\fonts\*.* + +:: CEF cache +echo browser cache +del /q /a:-R cache + + +:: the cached meshes and alike +echo meshes and alike +for /R %%a IN (*.dae) do IF EXIST "%%~pna.cached.dts" del "%%~pna.cached.dts" +for /R %%a IN (*.imposter*.dds) do del "%%a" + +:: the torque script compilations +echo compiled script +for /R %%a IN (*.cs) do IF EXIST "%%a.dso" del "%%a.dso" +for /R %%a IN (*.cs) do IF EXIST "%%a.edso" del "%%a.edso" +for /R %%a IN (*.gui) do IF EXIST "%%a.dso" del "%%a.dso" +for /R %%a IN (*.gui) do IF EXIST "%%a.edso" del "%%a.edso" +for /R %%a IN (*.ts) do IF EXIST "%%a.dso" del "%%a.dso" +for /R %%a IN (*.ts) do IF EXIST "%%a.edso" del "%%a.edso" + +:: the user settings and alike +echo settings +IF EXIST "prefs.cs" del /s prefs.cs +IF EXIST "core\prefs.cs" del /s core\prefs.cs +::IF EXIST "scripts\client\prefs.cs" del /s scripts\client\prefs.cs +IF EXIST "scripts\server\banlist.cs" del /s scripts\server\banlist.cs +IF EXIST "scripts\server\prefs.cs" del /s scripts\server\prefs.cs +IF EXIST "client\config.cs" del /s client\config.cs +IF EXIST "config.cs" del /s config.cs +IF EXIST "tools\settings.xml" del /s tools\settings.xml +IF EXIST "banlist.cs" del /s banlist.cs + +:: logs +echo logs +IF EXIST "torque3d.log" del /s torque3d.log +echo DONE! \ No newline at end of file diff --git a/Tools/CMake/collada.cmake b/Tools/CMake/collada.cmake new file mode 100644 index 000000000..a875643d8 --- /dev/null +++ b/Tools/CMake/collada.cmake @@ -0,0 +1,17 @@ +project(collada) + +addPath("${libDir}/collada/src/1.4/dom") +addPath("${libDir}/collada/src/dae") +addPath("${libDir}/collada/src/modules/LIBXMLPlugin") +addPath("${libDir}/collada/src/modules/stdErrPlugin") +addPath("${libDir}/collada/src/modules/STLDatabase") + +addStaticLib() + +addDef(DOM_INCLUDE_TINYXML) +addDef(PCRE_STATIC) + +addInclude(${libDir}/collada/include) +addInclude(${libDir}/collada/include/1.4) +addInclude(${libDir}/pcre) +addInclude(${libDir}/tinyxml) diff --git a/Tools/CMake/convexDecomp.cmake b/Tools/CMake/convexDecomp.cmake new file mode 100644 index 000000000..eb98a6144 --- /dev/null +++ b/Tools/CMake/convexDecomp.cmake @@ -0,0 +1,3 @@ +project(convexDecomp) + +addStaticLib("${libDir}/convexDecomp") diff --git a/Tools/CMake/libogg.cmake b/Tools/CMake/libogg.cmake new file mode 100644 index 000000000..fc83fd957 --- /dev/null +++ b/Tools/CMake/libogg.cmake @@ -0,0 +1,7 @@ +project(libogg) + +addPathRec("${libDir}/libogg") + +addStaticLib() + +addInclude(${libDir}/libogg/include) diff --git a/Tools/CMake/libtheora.cmake b/Tools/CMake/libtheora.cmake new file mode 100644 index 000000000..0e6dda65d --- /dev/null +++ b/Tools/CMake/libtheora.cmake @@ -0,0 +1,10 @@ +project(libtheora) + +addPathRec("${libDir}/libtheora") + +addStaticLib() + +addDef(TORQUE_OGGTHEORA) +addDef(TORQUE_OGGVORIBS) +addInclude(${libDir}/libogg/include) +addInclude(${libDir}/libtheora/include) diff --git a/Tools/CMake/libvorbis.cmake b/Tools/CMake/libvorbis.cmake new file mode 100644 index 000000000..9f1e2eb4a --- /dev/null +++ b/Tools/CMake/libvorbis.cmake @@ -0,0 +1,9 @@ +project(libvorbis) + +addPathRec("${libDir}/libvorbis") + +addStaticLib() + +addDef(TORQUE_OGGVORBIS) +addInclude(${libDir}/libvorbis/include) +addInclude(${libDir}/libogg/include) diff --git a/Tools/CMake/ljpeg.cmake b/Tools/CMake/ljpeg.cmake new file mode 100644 index 000000000..d518cb504 --- /dev/null +++ b/Tools/CMake/ljpeg.cmake @@ -0,0 +1,3 @@ +project(ljpeg) + +addStaticLib("${libDir}/ljpeg") diff --git a/Tools/CMake/lmng.cmake b/Tools/CMake/lmng.cmake new file mode 100644 index 000000000..27da5444f --- /dev/null +++ b/Tools/CMake/lmng.cmake @@ -0,0 +1,9 @@ +project(lmng) + +addStaticLib("${libDir}/${PROJECT_NAME}") + +addDef(MNG_OPTIMIZE_OBJCLEANUP) + +addInclude(${libDir}/lpng) +addInclude(${libDir}/zlib) +addInclude(${libDir}/ljpeg) diff --git a/Tools/CMake/lpng.cmake b/Tools/CMake/lpng.cmake new file mode 100644 index 000000000..0dbb15501 --- /dev/null +++ b/Tools/CMake/lpng.cmake @@ -0,0 +1,7 @@ +project(lpng) + +addStaticLib("${libDir}/${PROJECT_NAME}") + +# addDef(PNG_NO_ASSEMBLER_CODE) + +addInclude(${libDir}/zlib) diff --git a/Tools/CMake/lungif.cmake b/Tools/CMake/lungif.cmake new file mode 100644 index 000000000..2ede4dd3a --- /dev/null +++ b/Tools/CMake/lungif.cmake @@ -0,0 +1,5 @@ +project(lungif) + +addStaticLib("${libDir}/${PROJECT_NAME}") + +addDef(_GBA_NO_FILEIO) diff --git a/Tools/CMake/opcode.cmake b/Tools/CMake/opcode.cmake new file mode 100644 index 000000000..df94b0c7f --- /dev/null +++ b/Tools/CMake/opcode.cmake @@ -0,0 +1,9 @@ +project(opcode) + +addPath("${libDir}/${PROJECT_NAME}") +addPath("${libDir}/${PROJECT_NAME}/Ice") + +addStaticLib() + +addDef(TORQUE_OPCODE) +addDef(ICE_NO_DLL) diff --git a/Tools/CMake/pcre.cmake b/Tools/CMake/pcre.cmake new file mode 100644 index 000000000..0f86b50b2 --- /dev/null +++ b/Tools/CMake/pcre.cmake @@ -0,0 +1,8 @@ +project(pcre) + +addStaticLib("${libDir}/pcre") + +addDef(PCRE_STATIC) +addDef(HAVE_CONFIG_H) + +set_property(TARGET pcre PROPERTY COMPILE_FLAGS /TP) #/TP = compile as C++ diff --git a/Tools/CMake/squish.cmake b/Tools/CMake/squish.cmake new file mode 100644 index 000000000..acc3332bc --- /dev/null +++ b/Tools/CMake/squish.cmake @@ -0,0 +1,3 @@ +project(squish) + +addStaticLib("${libDir}/${PROJECT_NAME}") diff --git a/Tools/CMake/template.cmake b/Tools/CMake/template.cmake new file mode 100644 index 000000000..8040cddb0 --- /dev/null +++ b/Tools/CMake/template.cmake @@ -0,0 +1,21 @@ +# this is a template file that should help you write a new cmake build script for a new library + + +# 1st thing: the project name +project(pcre) + +# 2nd: add the paths where the source code is + +addPath("${libDir}/pcre") +addPathRec("${libDir}/pcre") + +# 3rd: add addStaticLib() +addStaticLib() + +# then add definitions +addDef(PCRE_STATIC) +addDef(HAVE_CONFIG_H) + +# and maybe more include paths +addInclude(${libDir}/libvorbis/include) +addInclude(${libDir}/libogg/include) diff --git a/Tools/CMake/template.torsion.in b/Tools/CMake/template.torsion.in new file mode 100644 index 000000000..f832ad13b --- /dev/null +++ b/Tools/CMake/template.torsion.in @@ -0,0 +1,39 @@ + +@TORQUE_APP_NAME@ + +main.cs +dbgSetParameters( #port#, "#password#", true ); + +core +scripts +art +levels +shaders +tools + +cs; gui + + +Release +@TORQUE_APP_NAME@.exe + +true +true +true +false + + +Debug +@TORQUE_APP_NAME@.exe + +true +true +true +false + + + +@TORQUE_APP_NAME@ +HEAD +true + diff --git a/Tools/CMake/tinyxml.cmake b/Tools/CMake/tinyxml.cmake new file mode 100644 index 000000000..c17dfbba1 --- /dev/null +++ b/Tools/CMake/tinyxml.cmake @@ -0,0 +1,3 @@ +project(tinyxml) + +addStaticLib("${libDir}/${PROJECT_NAME}") diff --git a/Tools/CMake/torque-win.rc.in b/Tools/CMake/torque-win.rc.in new file mode 100644 index 000000000..c73a0aaac --- /dev/null +++ b/Tools/CMake/torque-win.rc.in @@ -0,0 +1,123 @@ +//Microsoft Developer Studio generated resource script. +// +#define IDI_ICON1 103 +#define IDI_ICON2 107 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 108 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "windows.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON1 ICON DISCARDABLE "torque.ico" +IDI_ICON2 ICON DISCARDABLE "torque.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""windows.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @TORQUE_APP_VERSION_MAYOR@,@TORQUE_APP_VERSION_MINOR@,@TORQUE_APP_VERSION_PATCH@,@TORQUE_APP_VERSION_TWEAK@ + PRODUCTVERSION @TORQUE_APP_VERSION_MAYOR@,@TORQUE_APP_VERSION_MINOR@,@TORQUE_APP_VERSION_PATCH@,@TORQUE_APP_VERSION_TWEAK@ + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "@PROJECT_NAME@" + VALUE "FileDescription", "@PROJECT_NAME@" + VALUE "FileVersion", "@TORQUE_APP_VERSION_STRING@" + VALUE "InternalName", "@PROJECT_NAME@" + VALUE "LegalCopyright", "Copyright (C) 2014" + VALUE "OriginalFilename", "@PROJECT_NAME@" + VALUE "ProductName", "@PROJECT_NAME@" + VALUE "ProductVersion", "@TORQUE_APP_VERSION_STRING@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/Tools/CMake/torque.ico b/Tools/CMake/torque.ico new file mode 100644 index 000000000..22ac1a3d1 Binary files /dev/null and b/Tools/CMake/torque.ico differ diff --git a/Tools/CMake/torque3d.cmake b/Tools/CMake/torque3d.cmake new file mode 100644 index 000000000..06845ee22 --- /dev/null +++ b/Tools/CMake/torque3d.cmake @@ -0,0 +1,457 @@ +project(${TORQUE_APP_NAME}) + +# TODO: fmod support + +############################################################################### +# modules +############################################################################### +option(TORQUE_SFX_VORBIS "Vorbis Sound" ON) +mark_as_advanced(TORQUE_SFX_VORBIS) +option(TORQUE_ADVANCED_LIGHTING "Advanced Lighting" ON) +mark_as_advanced(TORQUE_ADVANCED_LIGHTING) +option(TORQUE_BASIC_LIGHTING "Basic Lighting" ON) +mark_as_advanced(TORQUE_BASIC_LIGHTING) +option(TORQUE_THEORA "Theora Video Support" ON) +mark_as_advanced(TORQUE_THEORA) +option(TORQUE_SFX_DirectX "DirectX Sound" ON) +mark_as_advanced(TORQUE_SFX_DirectX) +option(TORQUE_SFX_OPENAL "OpenAL Sound" ON) +mark_as_advanced(TORQUE_SFX_OPENAL) +option(TORQUE_HIFI "HIFI? support" OFF) +mark_as_advanced(TORQUE_HIFI) +option(TORQUE_EXTENDED_MOVE "Extended move support" OFF) +mark_as_advanced(TORQUE_EXTENDED_MOVE) + +############################################################################### +# options +############################################################################### +option(TORQUE_MULTITHREAD "Multi Threading" ON) +mark_as_advanced(TORQUE_MULTITHREAD) + +option(TORQUE_DISABLE_MEMORY_MANAGER "Disable memory manager" OFF) +mark_as_advanced(TORQUE_DISABLE_MEMORY_MANAGER) + +option(TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM "Disable virtual mount system" OFF) +mark_as_advanced(TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM) + +option(TORQUE_PLAYER "Playback only?" OFF) +mark_as_advanced(TORQUE_PLAYER) + +option(TORQUE_TOOLS "Enable or disable the tools" ON) +mark_as_advanced(TORQUE_TOOLS) + +option(TORQUE_ENABLE_PROFILER "Enable or disable the profiler" OFF) +mark_as_advanced(TORQUE_ENABLE_PROFILER) + +option(TORQUE_DEBUG "T3D Debug mode" OFF) +mark_as_advanced(TORQUE_DEBUG) + +option(TORQUE_SHIPPING "T3D Shipping build?" OFF) +mark_as_advanced(TORQUE_SHIPPING) + +option(TORQUE_DEBUG_NET "debug network" OFF) +mark_as_advanced(TORQUE_DEBUG_NET) + +option(TORQUE_DEBUG_NET_MOVES "debug network moves" OFF) +mark_as_advanced(TORQUE_DEBUG_NET_MOVES) + +option(TORQUE_ENABLE_ASSERTS "enables or disable asserts" OFF) +mark_as_advanced(TORQUE_ENABLE_ASSERTS) + +option(TORQUE_DEBUG_GFX_MODE "triggers graphics debug mode" OFF) +mark_as_advanced(TORQUE_DEBUG_GFX_MODE) + +#option(DEBUG_SPEW "more debug" OFF) +set(TORQUE_NO_DSO_GENERATION ON) + +# warning C4800: 'XXX' : forcing value to bool 'true' or 'false' (performance warning) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4800") +# warning C4018: '<' : signed/unsigned mismatch +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4018") +# warning C4244: 'initializing' : conversion from 'XXX' to 'XXX', possible loss of data +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4244") + +if(WIN32) + link_directories($ENV{DXSDK_DIR}/Lib/x86) +endif() + +############################################################################### +# Always enabled paths first +############################################################################### +addPath("${srcDir}/") # must come first :) +addPathRec("${srcDir}/app") +addPath("${srcDir}/sfx/media") +addPath("${srcDir}/sfx/null") +addPath("${srcDir}/sfx") +addPath("${srcDir}/component") +addPath("${srcDir}/component/interfaces") +addPath("${srcDir}/console") +addPath("${srcDir}/core") +addPath("${srcDir}/core/stream") +addPath("${srcDir}/core/strings") +addPath("${srcDir}/core/util") +addPath("${srcDir}/core/util/test") +addPath("${srcDir}/core/util/journal") +addPath("${srcDir}/core/util/journal/test") +addPath("${srcDir}/core/util/zip") +addPath("${srcDir}/core/util/zip/unitTests") +addPath("${srcDir}/core/util/zip/compressors") +addPath("${srcDir}/i18n") +addPath("${srcDir}/sim") +#addPath("${srcDir}/unit/tests") +addPath("${srcDir}/unit") +addPath("${srcDir}/util") +addPath("${srcDir}/windowManager") +addPath("${srcDir}/windowManager/torque") +addPath("${srcDir}/windowManager/test") +addPath("${srcDir}/math") +addPath("${srcDir}/math/util") +addPath("${srcDir}/math/test") +addPath("${srcDir}/platform") +addPath("${srcDir}/cinterface") +addPath("${srcDir}/platform/nativeDialogs") +addPath("${srcDir}/platform/menus") +addPath("${srcDir}/platform/test") +addPath("${srcDir}/platform/threads") +addPath("${srcDir}/platform/async") +addPath("${srcDir}/platform/input") +addPath("${srcDir}/platform/output") +addPath("${srcDir}/app") +addPath("${srcDir}/app/net") +addPath("${srcDir}/util/messaging") +addPath("${srcDir}/gfx/Null") +addPath("${srcDir}/gfx/test") +addPath("${srcDir}/gfx/bitmap") +addPath("${srcDir}/gfx/bitmap/loaders") +addPath("${srcDir}/gfx/util") +addPath("${srcDir}/gfx/video") +addPath("${srcDir}/gfx") +addPath("${srcDir}/shaderGen") +addPath("${srcDir}/gfx/sim") +addPath("${srcDir}/gui/buttons") +addPath("${srcDir}/gui/containers") +addPath("${srcDir}/gui/controls") +addPath("${srcDir}/gui/core") +addPath("${srcDir}/gui/game") +addPath("${srcDir}/gui/shiny") +addPath("${srcDir}/gui/utility") +addPath("${srcDir}/gui") +addPath("${srcDir}/collision") +addPath("${srcDir}/materials") +addPath("${srcDir}/lighting") +addPath("${srcDir}/lighting/common") +addPath("${srcDir}/renderInstance") +addPath("${srcDir}/scene") +addPath("${srcDir}/scene/culling") +addPath("${srcDir}/scene/zones") +addPath("${srcDir}/scene/mixin") +addPath("${srcDir}/shaderGen") +addPath("${srcDir}/terrain") +addPath("${srcDir}/environment") +addPath("${srcDir}/forest") +addPath("${srcDir}/forest/ts") +addPath("${srcDir}/ts") +addPath("${srcDir}/ts/arch") +addPath("${srcDir}/physics") +addPath("${srcDir}/gui/3d") +addPath("${srcDir}/postFx") +addPath("${srcDir}/T3D") +addPath("${srcDir}/T3D/examples") +addPath("${srcDir}/T3D/fps") +addPath("${srcDir}/T3D/fx") +addPath("${srcDir}/T3D/vehicles") +addPath("${srcDir}/T3D/physics") +addPath("${srcDir}/T3D/decal") +addPath("${srcDir}/T3D/sfx") +addPath("${srcDir}/T3D/gameBase") +addPath("${srcDir}/T3D/turret") +addPath("${srcDir}/main/") +addPathRec("${srcDir}/ts/collada") +addPathRec("${srcDir}/ts/loader") +addPathRec("${projectSrcDir}") + +############################################################################### +# modular paths +############################################################################### +# lighting +if(TORQUE_ADVANCED_LIGHTING) + addPath("${srcDir}/lighting/advanced") + addPathRec("${srcDir}/lighting/shadowMap") + addPathRec("${srcDir}/lighting/advanced/hlsl") + #addPathRec("${srcDir}/lighting/advanced/glsl") +endif() +if(TORQUE_BASIC_LIGHTING) + addPathRec("${srcDir}/lighting/basic") + addPathRec("${srcDir}/lighting/shadowMap") +endif() + +# DirectX Sound +if(TORQUE_SFX_DirectX) + addPathRec("${srcDir}/sfx/dsound") + addPathRec("${srcDir}/sfx/xaudio") +endif() + +# OpenAL +if(TORQUE_SFX_OPENAL) + addPath("${srcDir}/sfx/openal") + #addPath("${srcDir}/sfx/openal/mac") + addPath("${srcDir}/sfx/openal/win32") +endif() + +# Theora +if(TORQUE_THEORA) + addPath("${srcDir}/core/ogg") + addPath("${srcDir}/gfx/video") + addPath("${srcDir}/gui/theora") +endif() + +# Include tools for non-tool builds (or define player if a tool build) +if(TORQUE_TOOLS) + addPath("${srcDir}/gui/worldEditor") + addPath("${srcDir}/environment/editors") + addPath("${srcDir}/forest/editor") + addPath("${srcDir}/gui/editor") + addPath("${srcDir}/gui/editor/inspector") +endif() + +if(TORQUE_HIFI) + addPath("${srcDir}/T3D/gameBase/hifi") +endif() + +if(TORQUE_EXTENDED_MOVE) + addPath("${srcDir}/T3D/gameBase/extended") +else() + addPath("${srcDir}/T3D/gameBase/std") +endif() + +############################################################################### +# platform specific things +############################################################################### +if(WIN32) + addPath("${srcDir}/platformWin32") + addPath("${srcDir}/platformWin32/nativeDialogs") + addPath("${srcDir}/platformWin32/menus") + addPath("${srcDir}/platformWin32/threads") + addPath("${srcDir}/platformWin32/videoInfo") + addPath("${srcDir}/platformWin32/minidump") + addPath("${srcDir}/windowManager/win32") + #addPath("${srcDir}/gfx/D3D8") + addPath("${srcDir}/gfx/D3D") + addPath("${srcDir}/gfx/D3D9") + addPath("${srcDir}/gfx/D3D9/pc") + addPath("${srcDir}/shaderGen/HLSL") + addPath("${srcDir}/terrain/hlsl") + addPath("${srcDir}/forest/hlsl") + # add windows rc file for the icon + addFile("${projectSrcDir}/torque.rc") +endif() + +if(APPLE) + addPath("${srcDir}/platformMac") + addPath("${srcDir}/platformMac/menus") + addPath("${srcDir}/platformPOSIX") + addPath("${srcDir}/windowManager/mac") + addPath("${srcDir}/gfx/gl") + addPath("${srcDir}/gfx/gl/ggl") + addPath("${srcDir}/gfx/gl/ggl/mac") + addPath("${srcDir}/gfx/gl/ggl/generated") + addPath("${srcDir}/shaderGen/GLSL") + addPath("${srcDir}/terrain/glsl") + addPath("${srcDir}/forest/glsl") +endif() + +if(XBOX360) + addPath("${srcDir}/platformXbox") + addPath("${srcDir}/platformXbox/threads") + addPath("${srcDir}/windowManager/360") + addPath("${srcDir}/gfx/D3D9") + addPath("${srcDir}/gfx/D3D9/360") + addPath("${srcDir}/shaderGen/HLSL") + addPath("${srcDir}/shaderGen/360") + addPath("${srcDir}/ts/arch/360") + addPath("${srcDir}/terrain/hlsl") + addPath("${srcDir}/forest/hlsl") +endif() + +if(PS3) + addPath("${srcDir}/platformPS3") + addPath("${srcDir}/platformPS3/threads") + addPath("${srcDir}/windowManager/ps3") + addPath("${srcDir}/gfx/gl") + addPath("${srcDir}/gfx/gl/ggl") + addPath("${srcDir}/gfx/gl/ggl/ps3") + addPath("${srcDir}/gfx/gl/ggl/generated") + addPath("${srcDir}/shaderGen/GLSL") + addPath("${srcDir}/ts/arch/ps3") + addPath("${srcDir}/terrain/glsl") + addPath("${srcDir}/forest/glsl") +endif() + +if(UNIX) + # linux_dedicated + addPath("${srcDir}/windowManager/dedicated") + # linux + addPath("${srcDir}/platformX86UNIX") + addPath("${srcDir}/platformX86UNIX/threads") + addPath("${srcDir}/platformPOSIX") + addPath("${srcDir}/gfx/gl") + addPath("${srcDir}/gfx/gl/ggl") + addPath("${srcDir}/gfx/gl/ggl/x11") # This one is not yet implemented! + addPath("${srcDir}/gfx/gl/ggl/generated") + addPath("${srcDir}/shaderGen/GLSL") + addPath("${srcDir}/terrain/glsl") + addPath("${srcDir}/forest/glsl") +endif() + +############################################################################### +############################################################################### +addExecutable() +############################################################################### +############################################################################### + +# configure the relevant files only once +if(NOT EXISTS "${projectSrcDir}/torqueConfig.h") + message(STATUS "writing ${projectSrcDir}/torqueConfig.h") + CONFIGURE_FILE("${cmakeDir}/torqueConfig.h.in" "${projectSrcDir}/torqueConfig.h") +endif() +if(NOT EXISTS "${projectSrcDir}/torque.ico") + CONFIGURE_FILE("${cmakeDir}/torque.ico" "${projectSrcDir}/torque.ico" COPYONLY) +endif() +if(NOT EXISTS "${projectOutDir}/${PROJECT_NAME}.torsion") + CONFIGURE_FILE("${cmakeDir}/template.torsion.in" "${projectOutDir}/${PROJECT_NAME}.torsion") +endif() +if(EXISTS "${CMAKE_SOURCE_DIR}/Templates/${TORQUE_TEMPLATE}/game/main.cs.in" AND NOT EXISTS "${projectOutDir}/main.cs") + CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/Templates/${TORQUE_TEMPLATE}/game/main.cs.in" "${projectOutDir}/main.cs") +endif() +if(WIN32) + if(NOT EXISTS "${projectSrcDir}/torque.rc") + CONFIGURE_FILE("${cmakeDir}/torque-win.rc.in" "${projectSrcDir}/torque.rc") + endif() + if(NOT EXISTS "${projectOutDir}/${PROJECT_NAME}-debug.bat") + CONFIGURE_FILE("${cmakeDir}/app-debug-win.bat.in" "${projectOutDir}/${PROJECT_NAME}-debug.bat") + endif() + if(NOT EXISTS "${projectOutDir}/cleanup.bat") + CONFIGURE_FILE("${cmakeDir}/cleanup-win.bat.in" "${projectOutDir}/cleanup.bat") + endif() +endif() + +############################################################################### +# Common Libraries +############################################################################### +addLib(lmng) +addLib(lpng) +addLib(lungif) +addLib(ljpeg) +addLib(zlib) +addLib(tinyxml) +addLib(opcode) +addLib(squish) +addLib(collada) +addLib(pcre) +addLib(convexDecomp) + +if(WIN32) + # copy pasted from T3D build system, some might not be needed + set(TORQUE_EXTERNAL_LIBS "COMCTL32.LIB;COMDLG32.LIB;USER32.LIB;ADVAPI32.LIB;GDI32.LIB;WINMM.LIB;WSOCK32.LIB;vfw32.lib;Imm32.lib;d3d9.lib;d3dx9.lib;DxErr.lib;ole32.lib;shell32.lib;oleaut32.lib;version.lib" CACHE STRING "external libs to link against") + mark_as_advanced(TORQUE_EXTERNAL_LIBS) + addLib("${TORQUE_EXTERNAL_LIBS}") +endif() + +############################################################################### +# Always enabled Definitions +############################################################################### +addDebugDef(TORQUE_DEBUG) +addDebugDef(TORQUE_ENABLE_ASSERTS) +addDebugDef(TORQUE_DEBUG_GFX_MODE) + +addDef(TORQUE_SHADERGEN) +addDef(INITGUID) +addDef(NTORQUE_SHARED) +addDef(UNICODE) +addDef(_UNICODE) # for VS +addDef(TORQUE_UNICODE) +#addDef(TORQUE_SHARED) # not used anymore as the game is the executable directly +addDef(LTC_NO_PROTOTYPES) # for libTomCrypt +addDef(BAN_OPCODE_AUTOLINK) +addDef(ICE_NO_DLL) +addDef(TORQUE_OPCODE) +addDef(TORQUE_COLLADA) +addDef(DOM_INCLUDE_TINYXML) +addDef(PCRE_STATIC) +addDef(_CRT_SECURE_NO_WARNINGS) +addDef(_CRT_SECURE_NO_DEPRECATE) + + +############################################################################### +# Modules +############################################################################### +if(TORQUE_SFX_DirectX) + addLib(x3daudio.lib) +endif() + +if(TORQUE_ADVANCED_LIGHTING) + addDef(TORQUE_ADVANCED_LIGHTING) +endif() +if(TORQUE_BASIC_LIGHTING) + addDef(TORQUE_BASIC_LIGHTING) +endif() + +if(TORQUE_SFX_OPENAL) + addInclude("${libDir}/openal/win32") +endif() + +if(TORQUE_SFX_VORBIS) + addInclude(${libDir}/libvorbis/include) + addDef(TORQUE_OGGVORBIS) + addLib(libvorbis) + addLib(libogg) +endif() + +if(TORQUE_THEORA) + addDef(TORQUE_OGGTHEORA) + addDef(TORQUE_OGGVORIBS) + addInclude(${libDir}/libtheora/include) + addLib(libtheora) +endif() + +if(TORQUE_HIFI) + addDef(TORQUE_HIFI_NET) +endif() +if(TORQUE_EXTENDED_MOVE) + addDef(TORQUE_EXTENDED_MOVE) +endif() + +############################################################################### +# Include Paths +############################################################################### +addInclude("${projectSrcDir}") +addInclude("${srcDir}/") +addInclude("${libDir}/lmpg") +addInclude("${libDir}/lpng") +addInclude("${libDir}/ljpeg") +addInclude("${libDir}/lungif") +addInclude("${libDir}/zlib") +addInclude("${libDir}/") # for tinyxml +addInclude("${libDir}/tinyxml") +addInclude("${libDir}/squish") +addInclude("${libDir}/convexDecomp") +addInclude("${libDir}/libogg/include") +addInclude("${libDir}/opcode") +addInclude("${libDir}/collada/include") +addInclude("${libDir}/collada/include/1.4") + +# external things +if(WIN32) + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES $ENV{DXSDK_DIR}/Include) +endif() + +############################################################################### +# Installation +############################################################################### +INSTALL(DIRECTORY "${CMAKE_SOURCE_DIR}/Templates/${TORQUE_TEMPLATE}/game" DESTINATION "${projectDir}") +if(WIN32) + INSTALL(FILES "${CMAKE_SOURCE_DIR}/Templates/${TORQUE_TEMPLATE}/cleanShaders.bat" DESTINATION "${projectDir}") + INSTALL(FILES "${CMAKE_SOURCE_DIR}/Templates/${TORQUE_TEMPLATE}/DeleteCachedDTSs.bat" DESTINATION "${projectDir}") + INSTALL(FILES "${CMAKE_SOURCE_DIR}/Templates/${TORQUE_TEMPLATE}/DeleteDSOs.bat" DESTINATION "${projectDir}") + INSTALL(FILES "${CMAKE_SOURCE_DIR}/Templates/${TORQUE_TEMPLATE}/DeletePrefs.bat" DESTINATION "${projectDir}") +endif() diff --git a/Tools/CMake/torqueConfig.h.in b/Tools/CMake/torqueConfig.h.in new file mode 100644 index 000000000..9acb419df --- /dev/null +++ b/Tools/CMake/torqueConfig.h.in @@ -0,0 +1,208 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +#pragma once + +//----------------------------------------------------------------------------- +//Hi, and welcome to the Torque Config file. +// +//This file is a central reference for the various configuration flags that +//you'll be using when controlling what sort of a Torque build you have. In +//general, the information here is global for your entire codebase, applying +//not only to your game proper, but also to all of your tools. + +/// What's the name of your application? Used in a variety of places. +#define TORQUE_APP_NAME "@TORQUE_APP_NAME@" + +/// What version of the application specific source code is this? +/// +/// Version number is major * 1000 + minor * 100 + revision * 10. +#define TORQUE_APP_VERSION @TORQUE_APP_VERSION@ + +/// Human readable application version string. +#define TORQUE_APP_VERSION_STRING "@TORQUE_APP_VERSION_STRING@" + +/// Define me if you want to enable multithreading support. +#cmakedefine TORQUE_MULTITHREAD + +/// Define me if you want to disable Torque memory manager. +#cmakedefine TORQUE_DISABLE_MEMORY_MANAGER + +/// Define me if you want to disable the virtual mount system. +#cmakedefine TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM + +/// Define me if you want to disable looking for the root of a given path +/// within a zip file. This means that the zip file name itself must be +/// the root of the path. Requires the virtual mount system to be active. +#cmakedefine TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP + +//Uncomment this define if you want to use the alternative zip support where you can +//define your directories and files inside the zip just like you would on disk +//instead of the default zip support that treats the zip as an extra directory. +#cmakedefine TORQUE_ZIP_DISK_LAYOUT + +/// Define me if you don't want Torque to compile dso's +#cmakedefine TORQUE_NO_DSO_GENERATION + +// Define me if this build is a tools build +#cmakedefine TORQUE_PLAYER +#cmakedefine TORQUE_TOOLS + +/// Define me if you want to enable the profiler. +/// See also the TORQUE_SHIPPING block below +#cmakedefine TORQUE_ENABLE_PROFILER + +/// Define me to enable debug mode; enables a great number of additional +/// sanity checks, as well as making AssertFatal and AssertWarn do something. +/// This is usually defined by the build target. + +// TORQUE_DEBUG is now set dynamically and not here anymore +// #cmakedefine TORQUE_DEBUG + +#cmakedefine DEBUG_SPEW +#cmakedefine TORQUE_DEBUG_GFX_MODE + +/// Define me if this is a shipping build; if defined I will instruct Torque +/// to batten down some hatches and generally be more "final game" oriented. +/// Notably this disables a liberal resource manager file searching, and +/// console help strings. +#cmakedefine TORQUE_SHIPPING + +/// Define me to enable a variety of network debugging aids. +/// +/// - NetConnection packet logging. +/// - DebugChecksum guards to detect mismatched pack/unpacks. +/// - Detection of invalid destination ghosts. +/// +#cmakedefine TORQUE_DEBUG_NET + +/// Define me to enable detailed console logging of net moves. +#cmakedefine TORQUE_DEBUG_NET_MOVES + +/// Enable this define to change the default Net::MaxPacketDataSize +/// Do this at your own risk since it has the potential to cause packets +/// to be split up by old routers and Torque does not have a mechanism to +/// stitch split packets back together. Using this define can be very useful +/// in controlled network hardware environments (like a LAN) or for singleplayer +/// games (like BArricade and its large paths) +//#define MAXPACKETSIZE 1500 + +/// Modify me to enable metric gathering code in the renderers. +/// +/// 0 does nothing; higher numbers enable higher levels of metric gathering. +//#define TORQUE_GATHER_METRICS 0 + +/// Define me if you want to enable debug guards in the memory manager. +/// +/// Debug guards are known values placed before and after every block of +/// allocated memory. They are checked periodically by Memory::validate(), +/// and if they are modified (indicating an access to memory the app doesn't +/// "own"), an error is flagged (ie, you'll see a crash in the memory +/// manager's validate code). Using this and a debugger, you can track down +/// memory corruption issues quickly. +//#define TORQUE_DEBUG_GUARD + +/// Define me if you want to enable instanced-static behavior +//#define TORQUE_ENABLE_THREAD_STATICS + +/// Define me if you want to gather static-usage metrics +//#define TORQUE_ENABLE_THREAD_STATIC_METRICS + +/// Define me if you want to enable debug guards on the FrameAllocator. +/// +/// This is similar to the above memory manager guards, but applies only to the +/// fast FrameAllocator temporary pool memory allocations. The guards are only +/// checked when the FrameAllocator frees memory (when it's water mark changes). +/// This is most useful for detecting buffer overruns when using FrameTemp<> . +/// A buffer overrun in the FrameAllocator is unlikely to cause a crash, but may +/// still result in unexpected behavior, if other FrameTemp's are stomped. +//#define FRAMEALLOCATOR_DEBUG_GUARD + +/// This #define is used by the FrameAllocator to set the size of the frame. +/// +/// It was previously set to 3MB but I've increased it to 16MB due to the +/// FrameAllocator being used as temporary storage for bitmaps in the D3D9 +/// texture manager. +#define TORQUE_FRAME_SIZE 16 << 20 + +// Finally, we define some dependent #defines. This enables some subsidiary +// functionality to get automatically turned on in certain configurations. + +#ifdef TORQUE_DEBUG + + #define TORQUE_GATHER_METRICS 0 + #define TORQUE_ENABLE_PROFILE_PATH + #ifndef TORQUE_DEBUG_GUARD + #define TORQUE_DEBUG_GUARD + #endif + #ifndef TORQUE_NET_STATS + #define TORQUE_NET_STATS + #endif + + // Enables the C++ assert macros AssertFatal, AssertWarn, etc. + #ifndef TORQUE_ENABLE_ASSERTS + #define TORQUE_ENABLE_ASSERTS + #endif + +#endif + +#ifdef TORQUE_RELEASE + // If it's not DEBUG, it's a RELEASE build, put appropriate things here. +#endif + +#ifdef TORQUE_SHIPPING + + // TORQUE_SHIPPING flags here. + +#else + + // Enable the profiler by default, if we're not doing a shipping build. + #define TORQUE_ENABLE_PROFILER + + // Enable the TorqueScript assert() instruction if not shipping. + #define TORQUE_ENABLE_SCRIPTASSERTS + + // We also enable GFX debug events for use in Pix and other graphics + // debugging tools. + #define TORQUE_ENABLE_GFXDEBUGEVENTS + +#endif + +#ifdef TORQUE_TOOLS +# define TORQUE_INSTANCE_EXCLUSION "TorqueToolsTest" +#else +# define TORQUE_INSTANCE_EXCLUSION "TorqueTest" +#endif + +// Someday, it might make sense to do some pragma magic here so we error +// on inconsistent flags. + +// The Xbox360 has it's own profiling tools, the Torque Profiler should not be used +#ifdef TORQUE_OS_XENON +# ifdef TORQUE_ENABLE_PROFILER +# undef TORQUE_ENABLE_PROFILER +# endif +# +# ifdef TORQUE_ENABLE_PROFILE_PATH +# undef TORQUE_ENABLE_PROFILE_PATH +#endif +#endif diff --git a/Tools/CMake/zlib.cmake b/Tools/CMake/zlib.cmake new file mode 100644 index 000000000..6df47de04 --- /dev/null +++ b/Tools/CMake/zlib.cmake @@ -0,0 +1,3 @@ +project(zlib) + +addStaticLib("${libDir}/${PROJECT_NAME}")