diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..10c06779 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required (VERSION 3.6.0) + +set(TORQUE_APP_NAME "Torque2D") + +project(${TORQUE_APP_NAME} +VERSION 4.0.0.0 +) + +add_subdirectory(tools/CMake) diff --git a/tools/CMake/CMakeLists.txt b/tools/CMake/CMakeLists.txt new file mode 100644 index 00000000..d495ac14 --- /dev/null +++ b/tools/CMake/CMakeLists.txt @@ -0,0 +1,8 @@ +include(basics.cmake) + +setupVersionNumbers() + +# the main engine, should come last +include(torque2d.cmake) + +#setupPackaging() \ No newline at end of file diff --git a/tools/CMake/Torque 2D.ico b/tools/CMake/Torque 2D.ico new file mode 100644 index 00000000..7e9d7fee Binary files /dev/null and b/tools/CMake/Torque 2D.ico differ diff --git a/tools/CMake/Torque 2D.rc.in b/tools/CMake/Torque 2D.rc.in new file mode 100644 index 00000000..4c842aa9 --- /dev/null +++ b/tools/CMake/Torque 2D.rc.in @@ -0,0 +1,110 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "windows.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_TORQUE2D ICON "Torque 2D.ico" + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 4,0,0,0 + PRODUCTVERSION 4,0,0,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Torque Game Engines" + VALUE "FileDescription", "Torque 2D: Rocket Edition" + VALUE "FileVersion", "4, 0, 0, 0" + VALUE "InternalName", "Torque 2D" + VALUE "LegalCopyright", "Copyright (c) 2021 Torque Game Engines" + VALUE "OriginalFilename", "Torque2D.exe" + VALUE "ProductName", "Torque 2D" + VALUE "ProductVersion", "4, 0, 0, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/tools/CMake/basics.cmake b/tools/CMake/basics.cmake new file mode 100644 index 00000000..0e31519b --- /dev/null +++ b/tools/CMake/basics.cmake @@ -0,0 +1,437 @@ +if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8 ) + set( TORQUE_CPU_X64 ON) +elseif( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4 ) + set (TORQUE_CPU_X32 ON) +endif() + +if(NOT TORQUE_APP_DIR) + set(TORQUE_APP_DIR "${CMAKE_SOURCE_DIR}") +endif() + +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) + +############################################################################### +### Source File Handling +############################################################################### + +# finds and adds sources files in a folder +macro(addPath dir) + set(tmp_files "") + set(glob_config GLOB) + if(${ARGC} GREATER 1 AND "${ARGV1}" STREQUAL "REC") + set(glob_config GLOB_RECURSE) + endif() + set(mac_files "") + if(APPLE) + set(mac_files ${dir}/*.mm ${dir}/*.m) + endif() + file(${glob_config} tmp_files + ${dir}/*.cpp + ${dir}/*.c + ${dir}/*.cc + ${dir}/*.h + #${dir}/*.neon.asm + #${dir}/*.asm + ${mac_files} + #${dir}/*.asm + ) + foreach(entry ${BLACKLIST}) + list(REMOVE_ITEM tmp_files ${dir}/${entry}) + endforeach() + LIST(APPEND ${PROJECT_NAME}_files "${tmp_files}") + LIST(APPEND ${PROJECT_NAME}_paths "${dir}") + #message(STATUS "addPath ${PROJECT_NAME} : ${tmp_files}") +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) + addPath("${dir}" "REC") +endmacro() + +############################################################################### +### Definition Handling +############################################################################### +macro(__addDef def config) + # two possibilities: a) target already known, so add it directly, or b) target not yet known, so add it to its cache + if(TARGET ${PROJECT_NAME}) + #message(STATUS "directly applying defs: ${PROJECT_NAME} with config ${config}: ${def}") + if("${config}" STREQUAL "") + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS ${def}) + else() + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS $<$:${def}>) + endif() + else() + if("${config}" STREQUAL "") + list(APPEND ${PROJECT_NAME}_defs_ ${def}) + else() + list(APPEND ${PROJECT_NAME}_defs_ $<$:${def}>) + endif() + #message(STATUS "added definition to cache: ${PROJECT_NAME}_defs_: ${${PROJECT_NAME}_defs_}") + endif() +endmacro() + +# adds a definition: argument 1: Nothing(for all), _DEBUG, _RELEASE, +macro(addDef def) + set(def_configs "") + if(${ARGC} GREATER 1) + foreach(config ${ARGN}) + __addDef(${def} ${config}) + endforeach() + else() + __addDef(${def} "") + endif() +endmacro() + +# this applies cached definitions onto the target +macro(_process_defs) + if(DEFINED ${PROJECT_NAME}_defs_) + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS ${${PROJECT_NAME}_defs_}) + #message(STATUS "applying defs to project ${PROJECT_NAME}: ${${PROJECT_NAME}_defs_}") + endif() +endmacro() + +############################################################################### +### Source Library Handling +############################################################################### +macro(addLibSrc libPath) + set(cached_project_name ${PROJECT_NAME}) + include(${libPath}) + project(${cached_project_name}) +endmacro() + +############################################################################### +### Linked Library Handling +############################################################################### +macro(addLib libs) + foreach(lib ${libs}) + # check if we can build it ourselfs + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}.cmake") + addLibSrc("${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}.cmake") + endif() + # then link against it + # two possibilities: a) target already known, so add it directly, or b) target not yet known, so add it to its cache + if(TARGET ${PROJECT_NAME}) + target_link_libraries(${PROJECT_NAME} "${lib}") + else() + list(APPEND ${PROJECT_NAME}_libs ${lib}) + endif() + endforeach() +endmacro() + +#addLibRelease will add to only release builds +macro(addLibRelease libs) + foreach(lib ${libs}) + # check if we can build it ourselfs + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}.cmake") + addLibSrc("${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}.cmake") + endif() + # then link against it + # two possibilities: a) target already known, so add it directly, or b) target not yet known, so add it to its cache + if(TARGET ${PROJECT_NAME}) + target_link_libraries(${PROJECT_NAME} optimized "${lib}") + else() + list(APPEND ${PROJECT_NAME}_libsRelease ${lib}) + endif() + endforeach() +endmacro() + +#addLibDebug will add to only debug builds +macro(addLibDebug libs) + foreach(lib ${libs}) + # check if we can build it ourselfs + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}.cmake") + addLibSrc("${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}.cmake") + endif() + # then link against it + # two possibilities: a) target already known, so add it directly, or b) target not yet known, so add it to its cache + if(TARGET ${PROJECT_NAME}) + target_link_libraries(${PROJECT_NAME} debug "${lib}") + else() + list(APPEND ${PROJECT_NAME}_libsDebug ${lib}) + endif() + endforeach() +endmacro() + +# this applies cached definitions onto the target +macro(_process_libs) + if(DEFINED ${PROJECT_NAME}_libs) + target_link_libraries(${PROJECT_NAME} "${${PROJECT_NAME}_libs}") + endif() + if(DEFINED ${PROJECT_NAME}_libsRelease) + target_link_libraries(${PROJECT_NAME} optimized "${${PROJECT_NAME}_libsRelease}") + endif() + if(DEFINED ${PROJECT_NAME}_libsDebug) + target_link_libraries(${PROJECT_NAME} debug "${${PROJECT_NAME}_libsDebug}") + endif() + +endmacro() + +# apple frameworks +macro(addFramework framework) + if (APPLE) + addLib("-framework ${framework}") + endif() +endmacro() + +############################################################################### +### Include Handling +############################################################################### +macro(addInclude incPath) + if(TARGET ${PROJECT_NAME}) + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${incPath}") + else() + list(APPEND ${PROJECT_NAME}_includes ${incPath}) + endif() +endmacro() + +# this applies cached definitions onto the target +macro(_process_includes) + if(DEFINED ${PROJECT_NAME}_includes) + set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${${PROJECT_NAME}_includes}") + endif() +endmacro() + +############################################################################### + +macro(_postTargetProcess) + _process_includes() + _process_defs() + _process_libs() +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 "torque2d/${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 "^torque2d/Projects/.*$") + string(REPLACE "torque2d/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(finishLibrary) + # 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}") + + # set per target compile flags + if(TORQUE_CXX_FLAGS_${PROJECT_NAME}) + set_source_files_properties(${${PROJECT_NAME}_files} PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS_${PROJECT_NAME}}") + else() + set_source_files_properties(${${PROJECT_NAME}_files} PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS_LIBS}") + endif() + + 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 ... otherwise we get lots of header name collisions + #foreach(dir ${${PROJECT_NAME}_paths}) + addInclude("${firstDir}") + #endforeach() + + _postTargetProcess() +endmacro() + +# macro to add an executable +macro(finishExecutable) + # now inspect the paths we got + set(firstDir "") + foreach(dir ${${PROJECT_NAME}_paths}) + if("${firstDir}" STREQUAL "") + set(firstDir "${dir}") + endif() + endforeach() + generateFiltersSpecial("${firstDir}") + + # set per target compile flags + if(TORQUE_CXX_FLAGS_${PROJECT_NAME}) + set_source_files_properties(${${PROJECT_NAME}_files} PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS_${PROJECT_NAME}}") + else() + set_source_files_properties(${${PROJECT_NAME}_files} PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS_EXECUTABLES}") + endif() + + if (APPLE) + set(ICON_FILE "${projectSrcDir}/torque.icns") + set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + add_executable("${PROJECT_NAME}" MACOSX_BUNDLE ${ICON_FILE} ${${PROJECT_NAME}_files}) + else() + add_executable("${PROJECT_NAME}" WIN32 ${${PROJECT_NAME}_files}) + endif() + addInclude("${firstDir}") + + _postTargetProcess() +endmacro() + +macro(setupVersionNumbers) + set(TORQUE_APP_VERSION_MAJOR 1 CACHE STRING "") + set(TORQUE_APP_VERSION_MINOR 0 CACHE STRING "") + set(TORQUE_APP_VERSION_PATCH 0 CACHE STRING "") + set(TORQUE_APP_VERSION_TWEAK 0 CACHE STRING "") + mark_as_advanced(TORQUE_APP_VERSION_TWEAK) + MATH(EXPR TORQUE_APP_VERSION "${TORQUE_APP_VERSION_MAJOR} * 1000 + ${TORQUE_APP_VERSION_MINOR} * 100 + ${TORQUE_APP_VERSION_PATCH} * 10 + ${TORQUE_APP_VERSION_TWEAK}") + set(TORQUE_APP_VERSION_STRING "${TORQUE_APP_VERSION_MAJOR}.${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 "${TORQUE_APP_DIR}/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_MAJOR}") + 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) + set(TORQUE_CXX_FLAGS_EXECUTABLES "/wd4800 /wd4100 /wd4127 /wd4127 /wd4512" CACHE STRING "") + mark_as_advanced(TORQUE_CXX_FLAGS_EXECUTABLES) + + set(TORQUE_CXX_FLAGS_LIBS "/W0" CACHE STRING "") + mark_as_advanced(TORQUE_CXX_FLAGS_LIBS) + + set(TORQUE_CXX_FLAGS_COMMON_DEFAULT "-DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS /MP /O2 /Ob2 /Oi /Ot /Oy /GT /Zi /W4 /nologo /GF /EHsc /GS- /Gy- /Qpar- /fp:precise /fp:except- /GR /Zc:wchar_t-" ) + if( TORQUE_CPU_X32 ) + set(TORQUE_CXX_FLAGS_COMMON_DEFAULT "${TORQUE_CXX_FLAGS_COMMON_DEFAULT}") + endif() + set(TORQUE_CXX_FLAGS_COMMON ${TORQUE_CXX_FLAGS_COMMON_DEFAULT} CACHE STRING "") + + mark_as_advanced(TORQUE_CXX_FLAGS_COMMON) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORQUE_CXX_FLAGS_COMMON}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "") + #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() +else() + # TODO: improve default settings on other platforms + set(TORQUE_CXX_FLAGS_EXECUTABLES "" CACHE STRING "") + mark_as_advanced(TORQUE_CXX_FLAGS_EXECUTABLES) + set(TORQUE_CXX_FLAGS_LIBS "" CACHE STRING "") + mark_as_advanced(TORQUE_CXX_FLAGS_LIBS) + set(TORQUE_CXX_FLAGS_COMMON "" CACHE 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}") +endif() + +if(UNIX AND NOT APPLE) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${TORQUE_APP_DIR}") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${TORQUE_APP_DIR}") + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TORQUE_APP_DIR}") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${TORQUE_APP_DIR}") +endif() + +if(APPLE) + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TORQUE_APP_DIR}") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${TORQUE_APP_DIR}") + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TORQUE_APP_DIR}") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${TORQUE_APP_DIR}") +endif() + +# fix the debug/release subfolders on windows +if(MSVC) + SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY" "${TORQUE_APP_DIR}") + FOREACH(CONF ${CMAKE_CONFIGURATION_TYPES}) + # Go uppercase (DEBUG, RELEASE...) + STRING(TOUPPER "${CONF}" CONF) + #SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${TORQUE_APP_DIR}") + SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${TORQUE_APP_DIR}") + ENDFOREACH() +endif() \ No newline at end of file diff --git a/tools/CMake/cleandso.bat.in b/tools/CMake/cleandso.bat.in new file mode 100644 index 00000000..fdaec0f0 --- /dev/null +++ b/tools/CMake/cleandso.bat.in @@ -0,0 +1 @@ +del /s *.dso \ No newline at end of file diff --git a/tools/CMake/libraries/libogg.cmake b/tools/CMake/libraries/libogg.cmake new file mode 100644 index 00000000..b5a7d092 --- /dev/null +++ b/tools/CMake/libraries/libogg.cmake @@ -0,0 +1,44 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) 2014 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. +# ----------------------------------------------------------------------------- + +project(libogg) + +include(CheckIncludeFiles) + +# Configure config_type.h +check_include_files(inttypes.h INCLUDE_INTTYPES_H) +check_include_files(stdint.h INCLUDE_STDINT_H) +check_include_files(sys/types.h INCLUDE_SYS_TYPES_H) + +set(SIZE16 int16_t) +set(USIZE16 uint16_t) +set(SIZE32 int32_t) +set(USIZE32 uint32_t) +set(SIZE64 int64_t) + +configure_file(${libDir}/libogg/include/ogg/config_types.h ${libDir}/libogg/include/ogg/config_types.h @ONLY) + +addPath("${libDir}/libogg" REC) + +addInclude(${libDir}/libogg/include) + +finishLibrary() diff --git a/tools/CMake/libraries/libvorbis.cmake b/tools/CMake/libraries/libvorbis.cmake new file mode 100644 index 00000000..4f79f203 --- /dev/null +++ b/tools/CMake/libraries/libvorbis.cmake @@ -0,0 +1,34 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) 2014 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. +# ----------------------------------------------------------------------------- + +project(libvorbis) + +set(BLACKLIST "tone.c") +addPathRec("${libDir}/libvorbis") +set(BLACKLIST "") + +addDef(TORQUE_OGGVORBIS) +addInclude(${libDir}/libvorbis/include) +addInclude(${libDir}/libogg/include) +addInclude(${libDir}/libvorbis/lib) + +finishLibrary() diff --git a/tools/CMake/libraries/ljpeg.cmake b/tools/CMake/libraries/ljpeg.cmake new file mode 100644 index 00000000..1f669a60 --- /dev/null +++ b/tools/CMake/libraries/ljpeg.cmake @@ -0,0 +1,29 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) 2014 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. +# ----------------------------------------------------------------------------- + +project(ljpeg) + +set(BLACKLIST "jmemansi.c" "jmemdos.c" "jmemmac.c" "jmemname.c" "jpegtran.c") +addPath("${libDir}/ljpeg") +set(BLACKLIST "") + +finishLibrary() diff --git a/tools/CMake/libraries/lpng.cmake b/tools/CMake/libraries/lpng.cmake new file mode 100644 index 00000000..44271904 --- /dev/null +++ b/tools/CMake/libraries/lpng.cmake @@ -0,0 +1,29 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) 2014 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. +# ----------------------------------------------------------------------------- + +project(lpng) + +# addDef(PNG_NO_ASSEMBLER_CODE) + +addInclude(${libDir}/zlib) + +finishLibrary("${libDir}/${PROJECT_NAME}") diff --git a/tools/CMake/libraries/zlib.cmake b/tools/CMake/libraries/zlib.cmake new file mode 100644 index 00000000..72a5df4c --- /dev/null +++ b/tools/CMake/libraries/zlib.cmake @@ -0,0 +1,25 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) 2014 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. +# ----------------------------------------------------------------------------- + +project(zlib) + +finishLibrary("${libDir}/${PROJECT_NAME}") diff --git a/tools/CMake/main.cs.in b/tools/CMake/main.cs.in new file mode 100644 index 00000000..ec4be312 --- /dev/null +++ b/tools/CMake/main.cs.in @@ -0,0 +1,89 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2013 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 random seed +setRandomSeed(); + +// Set log mode. +setLogMode(2); + +// Set profiler. +//profilerEnable( true ); + +// Controls whether the execution or script files or compiled DSOs are echoed to the console or not. +// Being able to turn this off means far less spam in the console during typical development. +setScriptExecEcho( false ); + +// Controls whether all script execution is traced (echoed) to the console or not. +trace( false ); + +// Sets whether to ignore compiled TorqueScript files (DSOs) or not. +$Scripts::ignoreDSOs = true; + +// The name of the company. Used to form the path to save preferences. Defaults to GarageGames +// if not specified. +// The name of the game. Used to form the path to save preferences. Defaults to C++ engine define TORQUE_GAME_NAME +// if not specified. +// Appending version string to avoid conflicts with existing versions and other versions. +setCompanyAndProduct("Torque Game Engines", "Torque2D" ); + +// Set module database information echo. +ModuleDatabase.EchoInfo = false; + +// Set asset database information echo. +AssetDatabase.EchoInfo = false; + +// Set the asset manager to ignore any auto-unload assets. +// This cases assets to stay in memory unless assets are purged. +AssetDatabase.IgnoreAutoUnload = true; + +// If you want your game to start directly instead of first starting the Project Manager, you can load it here. This is an example using the toybox. +//ModuleDatabase.scanModules( "./toybox" ); +//ModuleDatabase.LoadExplicit( "AppCore" ); + +// Starts the editor. +exec("./editor/main.cs"); + +//----------------------------------------------------------------------------- + +function onExit() +{ + // Unload the AppCore or EditorCore modules. + if(isObject(EditorManager)) + { + EditorManager.unloadGroup( "EditorGroup" ); + } + if(isObject(AppCore)) + { + ModuleDatabase.unloadExplicit( "AppCore" ); + } +} + +function androidBackButton(%val) +{ + if (%val) { + //Add code here for other options the back button can do like going back a screen. the quit should happen at your main menu. + + quit(); + } + +} diff --git a/tools/CMake/torque2d.cmake b/tools/CMake/torque2d.cmake new file mode 100644 index 00000000..cb7e771d --- /dev/null +++ b/tools/CMake/torque2d.cmake @@ -0,0 +1,362 @@ +project(${TORQUE_APP_NAME}) + +if(UNIX) + if(NOT CXX_FLAG32) + set(CXX_FLAG32 "") + endif() + #set(CXX_FLAG32 "-m32") #uncomment for build x32 on OSx64 + + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors -Wno-return-type-c-linkage -Wno-unused-local-typedef ${TORQUE_ADDITIONAL_LINKER_FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors -Wno-return-type-c-linkage -Wno-unused-local-typedef ${TORQUE_ADDITIONAL_LINKER_FLAGS}") + else() + # default compiler flags + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors -no-pie ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$$ORIGIN'") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_FLAG32} -Wundef -msse -pipe -Wfatal-errors ${TORQUE_ADDITIONAL_LINKER_FLAGS} -Wl,-rpath,'$$ORIGIN'") + + endif() + + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ") +endif() + +if(UNIX AND NOT APPLE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLINUX") +endif() + +# TODO: fmod support + +############################################################################### +# modules +############################################################################### + +option(TORQUE_SFX_VORBIS "Vorbis Sound" ON) +mark_as_advanced(TORQUE_SFX_VORBIS) +option(TORQUE_SFX_OPENAL "OpenAL Sound" ON) + +if(TORQUE_SFX_OPENAL) + #Hide some unnecessary fields as advanced + mark_as_advanced(ALSOFT_AMBDEC_PRESETS) + mark_as_advanced(ALSOFT_BACKEND_DSOUND) + mark_as_advanced(ALSOFT_BACKEND_MMDEVAPI) + mark_as_advanced(ALSOFT_BACKEND_WAVE) + mark_as_advanced(ALSOFT_BACKEND_WINMM) + mark_as_advanced(ALSOFT_CONFIG) + mark_as_advanced(ALSOFT_CPUEXT_SSE) + mark_as_advanced(ALSOFT_CPUEXT_SSE2) + mark_as_advanced(ALSOFT_CPUEXT_SSE3) + mark_as_advanced(ALSOFT_CPUEXT_SSE4_1) + mark_as_advanced(ALSOFT_DLOPEN) + set(ALSOFT_DLOPEN ON CACHE BOOL "Test for open Dll" FORCE) + mark_as_advanced(ALSOFT_EMBED_HRTF_DATA) + mark_as_advanced(ALSOFT_EXAMPLES) + mark_as_advanced(ALSOFT_HRTF_DEFS) + mark_as_advanced(ALSOFT_INSTALL) + mark_as_advanced(ALSOFT_NO_CONFIG_UTIL) + mark_as_advanced(ALSOFT_NO_UID_DEFS) + mark_as_advanced(ALSOFT_REQUIRE_ALSA) + mark_as_advanced(ALSOFT_REQUIRE_COREAUDIO) + mark_as_advanced(ALSOFT_REQUIRE_DSOUND) + mark_as_advanced(ALSOFT_REQUIRE_JACK) + mark_as_advanced(ALSOFT_REQUIRE_MMDEVAPI) + mark_as_advanced(ALSOFT_REQUIRE_NEON) + mark_as_advanced(ALSOFT_REQUIRE_OPENSL) + mark_as_advanced(ALSOFT_REQUIRE_OSS) + mark_as_advanced(ALSOFT_REQUIRE_PORTAUDIO) + mark_as_advanced(ALSOFT_REQUIRE_PULSEAUDIO) + mark_as_advanced(ALSOFT_REQUIRE_QSA) + mark_as_advanced(ALSOFT_REQUIRE_SNDIO) + mark_as_advanced(ALSOFT_REQUIRE_SOLARIS) + mark_as_advanced(ALSOFT_REQUIRE_SSE) + mark_as_advanced(ALSOFT_REQUIRE_SSE2) + mark_as_advanced(ALSOFT_REQUIRE_SSE4_1) + mark_as_advanced(ALSOFT_REQUIRE_WINMM) + mark_as_advanced(ALSOFT_TESTS) + mark_as_advanced(ALSOFT_UTILS) + mark_as_advanced(ALSOFT_WERROR) + mark_as_advanced(COREAUDIO_FRAMEWORK) + mark_as_advanced(CMAKE_DEBUG_POSTFIX) + mark_as_advanced(FORCE_STATIC_VCRT) + mark_as_advanced(ALSOFT_BACKEND_WASAPI) + mark_as_advanced(ALSOFT_BUILD_ROUTER) + mark_as_advanced(ALSOFT_REQUIRE_SDL2) + set(ALSOFT_REQUIRE_SDL2 OFF CACHE BOOL "T2D Does not have SDL" FORCE) + mark_as_advanced(ALSOFT_REQUIRE_WASAPI) + #the following is from openal-soft + mark_as_advanced(SDL2MAIN_LIBRARY) + mark_as_advanced(SDL2_CORE_LIBRARY) + mark_as_advanced(SDL2_INCLUDE_DIR) +endif() + +mark_as_advanced(TORQUE_SFX_OPENAL) + +############################################################################### +# options +############################################################################### +if(UNIX AND NOT APPLE) # handle single-configuration generator + set(TORQUE_BUILD_TYPE "Debug" CACHE STRING "Select one of Debug, Release and RelWithDebInfo") + set_property(CACHE TORQUE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo") + + set(TORQUE_ADDITIONAL_LINKER_FLAGS "" CACHE STRING "Additional linker flags") + mark_as_advanced(TORQUE_ADDITIONAL_LINKER_FLAGS) +endif() + +if(WIN32) + # 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") + +endif() + +# build types +if(UNIX AND NOT APPLE) # handle single-configuration generator + set(CMAKE_BUILD_TYPE ${TORQUE_BUILD_TYPE}) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(TORQUE_DEBUG TRUE) + elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + set(TORQUE_RELEASE TRUE) + elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + set(TORQUE_RELEASE TRUE) + else() + message(FATAL_ERROR "Please select Debug, Release or RelWithDebInfo for TORQUE_BUILD_TYPE") + endif() +endif() + +############################################################################### +# Always enabled paths first +############################################################################### +addPath("${srcDir}/") # must come first :) +addPath("${srcDir}/algorithm") +addPath("${srcDir}/assets") +addPath("${srcDir}/audio") +addPath("${srcDir}/bitmapFont") +addPathRec("${srcDir}/Box2D") +addPath("${srcDir}/collection") +addPath("${srcDir}/component") +addPath("${srcDir}/component/behaviors") +addPath("${srcDir}/console") +addPath("${srcDir}/debug") +addPath("${srcDir}/debug/remote") +addPath("${srcDir}/delegates") +addPath("${srcDir}/game") +addPath("${srcDir}/sfx") +set(BLACKLIST "bitmapPvr.cc" ) +addPath("${srcDir}/graphics") +if(WIN32) +set(BLACKLIST "") +endif() +addPath("${srcDir}/gui") +addPath("${srcDir}/gui/buttons") +addPath("${srcDir}/gui/containers") +addPath("${srcDir}/gui/editor") +addPath("${srcDir}/gui/language") +addPath("${srcDir}/input") +addPath("${srcDir}/io") +addPath("${srcDir}/io/resource") +addPath("${srcDir}/io/zip") +addPath("${srcDir}/math") +addPath("${srcDir}/memory") +addPath("${srcDir}/messaging") +addPath("${srcDir}/module") +addPath("${srcDir}/network") +addPath("${srcDir}/persistence") +addPath("${srcDir}/persistence/rapidjson/include/rapidjson") +addPath("${srcDir}/persistence/rapidjson/include/rapidjson/internal") +addPath("${srcDir}/persistence/taml") +addPath("${srcDir}/persistence/taml/binary") +addPath("${srcDir}/persistence/taml/json") +addPath("${srcDir}/persistence/taml/xml") +addPath("${srcDir}/persistence/tinyXML") +set(BLACKLIST "platformNet_Emscripten.cpp") +addPath("${srcDir}/platform") +set(BLACKLIST "") +addPath("${srcDir}/platform/menus") +addPath("${srcDir}/platform/nativeDialogs") +addPath("${srcDir}/platform/threads") +addPath("${srcDir}/sim") +addPath("${srcDir}/spine") +addPath("${srcDir}/string") +addPath("${srcDir}/testing") +addPath("${srcDir}/testing/tests") +addPath("${srcDir}/2d") +addPath("${srcDir}/2d/assets") +addPath("${srcDir}/2d/controllers") +addPath("${srcDir}/2d/controllers/core") +addPath("${srcDir}/2d/core") +addPath("${srcDir}/2d/experimental") +addPath("${srcDir}/2d/experimental/composites") +addPath("${srcDir}/2d/gui") +addPath("${srcDir}/2d/scene") +addPath("${srcDir}/2d/sceneobject") + +if(TORQUE_SFX_OPENAL) + if(WIN32) + option(AL_ALEXT_PROTOTYPES "Use Extended OpenAL options" ON) + addInclude("${libDir}/openal/win32") + endif() + if(UNIX AND NOT APPLE) + option(AL_ALEXT_PROTOTYPES "Use Extended OpenAL options" ON) + #addPath("${srcDir}/sfx/linux") + endif() + if(APPLE) + option(AL_ALEXT_PROTOTYPES "Use Extended OpenAL options" OFF) + addFramework("OpenAL") + endif() +endif() + +mark_as_advanced(AL_ALEXT_PROTOTYPES) +if(AL_ALEXT_PROTOTYPES) + addDef( "AL_ALEXT_PROTOTYPES" ) +endif() + +if(UNIX AND NOT APPLE) + #set(CMAKE_SIZEOF_VOID_P 4) #force 32 bit + set(ENV{CFLAGS} "${CXX_FLAG32} -g -O3") + if("${TORQUE_ADDITIONAL_LINKER_FLAGS}" STREQUAL "") + set(ENV{LDFLAGS} "${CXX_FLAG32}") + else() + set(ENV{LDFLAGS} "${CXX_FLAG32} ${TORQUE_ADDITIONAL_LINKER_FLAGS}") + endif() +endif() + +# Vorbis +addInclude(${libDir}/libvorbis/include) +addLib(libvorbis) +addInclude(${libDir}/libogg/include) +addLib(libogg) + +############################################################################### +# platform specific things +############################################################################### + +if(WIN32) + addPath("${srcDir}/platformWin32") + addPath("${srcDir}/platformWin32/nativeDialogs") + addPath("${srcDir}/platformWin32/menus") + addPath("${srcDir}/platformWin32/threads") + # add windows rc file for the icon + addFile("${cmakeDir}/Torque 2D.rc") +endif() + +if(APPLE) + addPath("${srcDir}/platformOSX") +endif() + +if(UNIX AND NOT APPLE) + addPath("${srcDir}/platformX86UNIX") +endif() + +############################################################################### +############################################################################### +finishExecutable() +############################################################################### +############################################################################### + +# Set Visual Studio startup project +if(MSVC) + set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TORQUE_APP_NAME}) + set_target_properties(${TORQUE_APP_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${TORQUE_APP_NAME}) +endif() + +if(NOT EXISTS "${TORQUE_APP_NAME}/Torque 2D.ico") + CONFIGURE_FILE("${cmakeDir}/Torque 2D.ico" "${TORQUE_APP_NAME}/Torque 2D.ico" COPYONLY) +endif() +if(WIN32) + if(NOT EXISTS "${projectSrcDir}/Torque 2D.rc") + CONFIGURE_FILE("${cmakeDir}/Torque 2D.rc.in" "${TORQUE_APP_NAME}/Torque 2D.rc") + endif() + if(NOT EXISTS "${projectSrcDir}/main.cs") + CONFIGURE_FILE("${cmakeDir}/main.cs.in" "${TORQUE_APP_NAME}/main.cs") + endif() + if(NOT EXISTS "${TORQUE_APP_NAME}/cleandso.bat") + CONFIGURE_FILE("${cmakeDir}/cleandso.bat.in" "${TORQUE_APP_NAME}/cleandso.bat") + endif() +endif() + +############################################################################### +# Common Libraries +############################################################################### +addLib(lpng) +addLib(ljpeg) +addLib(zlib) + +if (APPLE) + addFramework("Cocoa") + addFramework("OpenGL") + addFramework("CoreData") + addFramework("CoreFoundation") + addFramework("Foundation") + addFramework("AppKit") + addFramework("AVFoundation") + #set a few arch defaults + set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "OSX Architecture" FORCE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "OSX Deployment target" FORCE) +endif() + +if(WIN32) + set(TORQUE_EXTERNAL_LIBS "COMCTL32.LIB;COMDLG32.LIB;USER32.LIB;ADVAPI32.LIB;GDI32.LIB;RPCRT4.LIB;WINMM.LIB;WS2_32.LIB;vfw32.lib;Imm32.lib;shell32.lib;shlwapi.lib;ole32.lib" CACHE STRING "external libs to link against") + mark_as_advanced(TORQUE_EXTERNAL_LIBS) + addLib("${TORQUE_EXTERNAL_LIBS}") +endif() + +if(UNIX AND NOT APPLE) + # copy pasted from T3D build system, some might not be needed + set(TORQUE_EXTERNAL_LIBS "stdc++ m dl pthread rt X11 Xft SDL2main SDL2 openal" CACHE STRING "external libs to link against") + mark_as_advanced(TORQUE_EXTERNAL_LIBS) + + string(REPLACE " " ";" TORQUE_EXTERNAL_LIBS_LIST ${TORQUE_EXTERNAL_LIBS}) + addLib( "${TORQUE_EXTERNAL_LIBS_LIST}" ) +endif() + + +############################################################################### +# Always enabled Definitions +############################################################################### +addDef(TORQUE_DEBUG Debug) +addDef(TORQUE_DEBUG_GUARD) +addDef(TORQUE_NET_STATS) +addDef(_CRT_SECURE_NO_WARNINGS) +addDef(_CRT_SECURE_NO_DEPRECATE) +addDef(UNICODE) +addDef(_UNICODE) # for VS +addDef(TORQUE_UNICODE) +addDef(DEBUG=1) + +##TORQUE_DEBUG;TORQUE_DEBUG_GUARD;_CRT_SECURE_NO_DEPRECATE;UNICODE; + +if(UNIX AND NOT APPLE) + addDef(LINUX) +endif() + +############################################################################### +# Include Paths +############################################################################### +addInclude("${srcDir}/") +addInclude("${libDir}/") +addInclude("${libDir}/lpng") +addInclude("${libDir}/ljpeg") +addInclude("${libDir}/zlib") +addInclude("${libDir}/libogg/include") +addInclude("${srcDir}/persistence/rapidjson") +addInclude("${srcDir}/persistence/rapidjson/include") +addInclude("${srcDir}/testing/googleTest") +addInclude("${srcDir}/testing/googleTest/include") + +if(UNIX AND NOT APPLE) + addInclude("/usr/include/freetype2/freetype") + addInclude("/usr/include/freetype2") +endif() + +if(MSVC) + # Match projectGenerator naming for executables + set(OUTPUT_CONFIG DEBUG RELWITHDEBINFO) + set(OUTPUT_SUFFIX DEBUG OPTIMIZEDDEBUG) + foreach(INDEX RANGE 1) + list(GET OUTPUT_CONFIG ${INDEX} CONF) + list(GET OUTPUT_SUFFIX ${INDEX} SUFFIX) + set_property(TARGET ${PROJECT_NAME} PROPERTY OUTPUT_NAME_${CONF} ${PROJECT_NAME}_${SUFFIX}) + endforeach() +endif() +