ソースを参照

macro and config refactor proposal 1

AzaezelX 2 年 前
コミット
e55d71f6ee

+ 3 - 77
CMakeLists.txt

@@ -1,10 +1,12 @@
+include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_macros.cmake")
+include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_configs.cmake")
 cmake_minimum_required (VERSION 3.10.2)
 set (CMAKE_CXX_STANDARD 17)
 
 # Ensure multi-core compilation is enabled for everything
 add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
 
-project(Torque3D)
+project(${TORQUE_APP_NAME})
 
 # An application name must be set first
 set(TORQUE_APP_NAME "" CACHE STRING "the app name")
@@ -39,56 +41,6 @@ else()
     endif()
 endif()
 
-option(TORQUE_MULTITHREAD "Multi Threading" ON)
-mark_as_advanced(TORQUE_MULTITHREAD)
-
-option(TORQUE_POSIX_PATH_CASE_INSENSITIVE "POSIX Pathing Case Insensitivity" ON)
-mark_as_advanced(TORQUE_POSIX_PATH_CASE_INSENSITIVE)
-
-option(TORQUE_ZIP_PATH_CASE_INSENSITIVE "ZIP Pathing Case Insensitivity" ON)
-mark_as_advanced(TORQUE_ZIP_PATH_CASE_INSENSITIVE)
-
-option(TORQUE_DISABLE_MEMORY_MANAGER "Disable memory manager" ON)
-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_DISABLE_FIND_ROOT_WITHIN_ZIP "Disable reading root path from zip. Zips will be mounted in-place with file name as directory name." ON)
-mark_as_advanced(TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP)
-
-option(TORQUE_ZIP_DISK_LAYOUT "All zips must be placed in the executable directory and contain full paths to the files." OFF)
-mark_as_advanced(TORQUE_ZIP_DISK_LAYOUT)
-
-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)
 
 if(NOT TORQUE_SCRIPT_EXTENSION)
     set(TORQUE_SCRIPT_EXTENSION "tscript" CACHE STRING "The default script extension to use for TorqueScript files")
@@ -98,29 +50,6 @@ mark_as_advanced(TORQUE_SCRIPT_EXTENSION)
 set(TORQUE_MODULE_USER_PATH "" CACHE PATH "Additional search path for modules aside from the default Tools/CMake/modules.")
 mark_as_advanced(TORQUE_MODULE_USER_PATH)
 
-option(TORQUE_USE_ZENITY "use the Zenity backend for NFD" OFF)
-mark_as_advanced(TORQUE_USE_ZENITY)
-
-option(TORQUE_SHOW_LEGACY_FILE_FIELDS "If on, shows legacy direct file path fields in the inspector." OFF)
-mark_as_advanced(TORQUE_SHOW_LEGACY_FILE_FIELDS)
-
-option(TORQUE_SFX_VORBIS "Vorbis Sound" ON)
-mark_as_advanced(TORQUE_SFX_VORBIS)
-
-option(TORQUE_THEORA "Theora Video Support" ON)
-mark_as_advanced(TORQUE_THEORA)
-
-option(TORQUE_ADVANCED_LIGHTING "Advanced Lighting" ON)
-mark_as_advanced(TORQUE_ADVANCED_LIGHTING)
-
-option(TORQUE_BASIC_LIGHTING "Basic Lighting" ON)
-mark_as_advanced(TORQUE_APP_PASSWORD)
-
-option(TORQUE_DYNAMIC_LIBRARY "Whether or not to build Torque as a dynamic library." OFF)
-mark_as_advanced(TORQUE_DYNAMIC_LIBRARY)
-
-set(TORQUE_APP_PASSWORD "changeme" CACHE STRING "zip file password")
-
 if(WIN32)
 	option(TORQUE_OPENGL "Allow OpenGL render" ON)
 else()
@@ -131,9 +60,6 @@ if(WIN32)
 	option(TORQUE_D3D11 "Allow Direct3D 11 render" ON)
 endif()
 
-include("${CMAKE_SOURCE_DIR}/Tools/CMake/basics.cmake")
-setupVersionNumbers()
-
 # Install Torque template
 if(NOT TORQUE_TEMPLATE)
     set(TORQUE_TEMPLATE "BaseGame" CACHE STRING "the template to use")

+ 0 - 32
Tools/CMake/CMakeLists.txt

@@ -1,32 +0,0 @@
-# -----------------------------------------------------------------------------
-# 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.
-# -----------------------------------------------------------------------------
-
-cmake_minimum_required(VERSION 3.12)
-
-include(basics.cmake)
-
-setupVersionNumbers()
-
-# the main engine, should come last
-include(torque3d.cmake)
-
-#setupPackaging()

+ 0 - 48
Tools/CMake/basics.cmake

@@ -1,48 +0,0 @@
-# -----------------------------------------------------------------------------
-# 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.
-# -----------------------------------------------------------------------------
-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}")
-endmacro()
-
-function(installTemplate templateName)
-  message("Prepare Template(${templateName}) install...")
-
-  add_subdirectory("${CMAKE_SOURCE_DIR}/Templates/${templateName}")
-endfunction()
-
-MACRO(SUBDIRLIST result curdir)
-  FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
-  SET(dirlist "")
-  FOREACH(child ${children})
-    IF(IS_DIRECTORY ${curdir}/${child})
-      LIST(APPEND dirlist ${child})
-    ENDIF()
-  ENDFOREACH()
-  SET(${result} ${dirlist})
-ENDMACRO()

+ 1 - 0
Tools/CMake/modules/openal.cmake

@@ -20,6 +20,7 @@ if(TORQUE_SFX_OPENAL)
 
   # Since OpenAL lives elsewhere we need to ensure it is known to Torque when providing a link to it
   set(ALSOFT_EXAMPLES OFF CACHE BOOL "OpenAL Examples" FORCE)
+  set(ALSOFT_UTILS OFF CACHE BOOL "OpenAL Utilities" FORCE)
   set(ALSOFT_UPDATE_BUILD_VERSION OFF CACHE BOOL "Update build Version" UPDATE)
   
   add_subdirectory("${CMAKE_SOURCE_DIR}/Engine/lib/openal-soft" ${CMAKE_BINARY_DIR}/temp/openal-soft EXCLUDE_FROM_ALL)

+ 96 - 0
Tools/CMake/torque_configs.cmake

@@ -0,0 +1,96 @@
+#general
+advanced_option(TORQUE_MULTITHREAD "Multi Threading" ON)
+advanced_option(TORQUE_DISABLE_MEMORY_MANAGER "Disable memory manager" ON)
+#fileIO
+set(TORQUE_APP_PASSWORD "changeme" CACHE STRING "zip file password")
+advanced_option(TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM "Disable virtual mount system" OFF)
+advanced_option(TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP "Disable reading root path from zip. Zips will be mounted in-place with file name as directory name." ON)
+advanced_option(TORQUE_ZIP_DISK_LAYOUT "All zips must be placed in the executable directory and contain full paths to the files." OFF)
+advanced_option(TORQUE_POSIX_PATH_CASE_INSENSITIVE "POSIX Pathing Case Insensitivity" ON)
+advanced_option(TORQUE_ZIP_PATH_CASE_INSENSITIVE "ZIP Pathing Case Insensitivity" ON)
+advanced_option(TORQUE_USE_ZENITY "use the Zenity backend for NFD" OFF)
+#sound
+advanced_option(TORQUE_SFX_VORBIS "Vorbis Sound" ON)
+advanced_option(TORQUE_THEORA "Theora Video Support" ON)
+advanced_option(TORQUE_SFX_OPENAL "OpenAL Sound" ON)
+#gfx
+advanced_option(TORQUE_DEBUG_GFX_MODE "triggers graphics debug mode" OFF)
+advanced_option(TORQUE_ADVANCED_LIGHTING "Advanced Lighting" ON)
+advanced_option(TORQUE_BASIC_LIGHTING "Basic Lighting" ON)
+#mode
+advanced_option(TORQUE_NO_DSO_GENERATION "skip storing compiled scripts" ON)
+advanced_option(TORQUE_DYNAMIC_LIBRARY "Whether or not to build Torque as a dynamic library." OFF)
+advanced_option(TORQUE_PLAYER "Playback only?" OFF)
+advanced_option(TORQUE_DEBUG "T3D Debug mode" OFF)
+#option(DEBUG_SPEW "more debug" OFF)
+advanced_option(TORQUE_SHIPPING "T3D Shipping build?" OFF)
+#tools
+advanced_option(TORQUE_DEBUG_NET "debug network" OFF)
+advanced_option(TORQUE_DEBUG_NET_MOVES "debug network moves" OFF)
+advanced_option(TORQUE_ENABLE_ASSERTS "enables or disable asserts" OFF)
+advanced_option(TORQUE_TOOLS "Enable or disable the tools" ON)
+advanced_option(TORQUE_ENABLE_PROFILER "Enable or disable the profiler" OFF)
+advanced_option(TORQUE_SHOW_LEGACY_FILE_FIELDS "If on, shows legacy direct file path fields in the inspector." OFF)
+
+setupVersionNumbers()
+
+if(TORQUE_SFX_OPENAL)
+    advanced_option(ALSOFT_EAX "Enable legacy EAX extensions" ${WIN32})
+    advanced_option(ALSOFT_INSTALL_EXAMPLES "Install example programs (alplay, alstream, ...)" ON)
+    advanced_option(ALSOFT_INSTALL_UTILS "Install utility programs (openal-info, alsoft-config, ...)" ON)
+    advanced_option(ALSOFT_UPDATE_BUILD_VERSION "Update git build version info" ON)
+    mark_as_advanced(ALSOFT_REQUIRE_OBOE)
+    mark_as_advanced(ALSOFT_REQUIRE_PIPEWIRE)
+    mark_as_advanced(ALSOFT_REQUIRE_RTKIT)
+    mark_as_advanced(ALSOFT_REQUIRE_SSE3)
+    #Hide some unnecessary fields as advanced
+    mark_as_advanced(ALSOFT_INSTALL_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_INSTALL_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)
+    mark_as_advanced(ALSOFT_EMBED_HRTF_DATA)
+    mark_as_advanced(ALSOFT_EXAMPLES)
+    mark_as_advanced(ALSOFT_INSTALL_HRTF_DATA)
+    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)
+    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()

+ 126 - 0
Tools/CMake/torque_macros.cmake

@@ -0,0 +1,126 @@
+# -----------------------------------------------------------------------------
+# 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.
+# -----------------------------------------------------------------------------
+################# Helper Functions ###################
+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}")
+endmacro()
+
+function(installTemplate templateName)
+  message("Prepare Template(${templateName}) install...")
+
+  add_subdirectory("${CMAKE_SOURCE_DIR}/Templates/${templateName}")
+endfunction()
+
+MACRO(SUBDIRLIST result curdir)
+  FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
+  SET(dirlist "")
+  FOREACH(child ${children})
+    IF(IS_DIRECTORY ${curdir}/${child})
+      LIST(APPEND dirlist ${child})
+    ENDIF()
+  ENDFOREACH()
+  SET(${result} ${dirlist})
+ENDMACRO()
+
+# Helper function to add a directory to the TORQUE_SOURCE_FILES variable. It automatically searches for .cpp and .h files in the
+# specified directory then adds them to the TORQUE_SOURCE_FILES variable.
+macro (torqueAddSourceDirectories)
+  foreach(ARGUMENT ${ARGV})
+    file(GLOB SCANNED_SOURCE_FILES "${ARGUMENT}/*.cpp")
+    file(GLOB SCANNED_INCLUDE_FILES "${ARGUMENT}/*.h")
+
+    if (APPLE)
+      file(GLOB SCANNED_MAC_FILES "${ARGUMENT}/*.mm")
+    endif (APPLE)
+
+    # Set in both current and parent scope so this macro can be used from loaded modules
+    set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} ${SCANNED_SOURCE_FILES} ${SCANNED_INCLUDE_FILES} ${SCANNED_MAC_FILES})
+    set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} PARENT_SCOPE)
+  endforeach()
+endmacro (torqueAddSourceDirectories)
+
+################# Set Conditional Engine Defines ###################
+macro (forwardDef flag)
+    if (${flag})
+        set(TORQUE_COMPILE_DEFINITIONS ${TORQUE_COMPILE_DEFINITIONS} ${flag})
+    endif()
+endmacro(forwardDef)
+
+macro (advanced_option flag description state)
+    option(${flag} ${description} ${state})
+    mark_as_advanced(${flag})
+endmacro(advanced_option)
+################# additional preprocessor defines ###################
+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 $<$<CONFIG:${config}>:${def}>)
+        endif()
+    else()
+        if("${config}" STREQUAL "")
+            list(APPEND ${PROJECT_NAME}_defs_ ${def})
+        else()
+            list(APPEND ${PROJECT_NAME}_defs_ $<$<CONFIG:${config}>:${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, <more build configurations>
+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 must come *after* target_compile_definitions
+macro(append_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_}")
+    else()
+        #message(STATUS "NO ${PROJECT_NAME}_defs_ defined!")
+    endif()    
+endmacro()
+
+################# file filtering ###################
+macro (filterOut)
+  foreach(ARGUMENT ${ARGV})
+    list(REMOVE_ITEM TORQUE_SOURCE_FILES "${CMAKE_SOURCE_DIR}/Engine/source/${ARGUMENT}")
+  endforeach()
+endmacro (filterOut)