[Orxonox-commit 3124] r7818 - in code/trunk: cmake cmake/tools doc/api src
rgrieder at orxonox.net
rgrieder at orxonox.net
Sun Dec 26 21:07:43 CET 2010
Author: rgrieder
Date: 2010-12-26 21:07:43 +0100 (Sun, 26 Dec 2010)
New Revision: 7818
Modified:
code/trunk/cmake/CompilerConfigMSVC.cmake
code/trunk/cmake/PackageConfigMSVC.cmake
code/trunk/cmake/tools/SourceFileUtilities.cmake
code/trunk/cmake/tools/TargetUtilities.cmake
code/trunk/doc/api/doxy.config.in
code/trunk/src/CMakeLists.txt
code/trunk/src/OrxonoxConfig.cmake
code/trunk/src/OrxonoxConfig.h.in
code/trunk/src/SpecialConfig.h.in
Log:
Merged changes related to Visual Leak Detector and source file handling from sandbox QT to trunk.
Modified: code/trunk/cmake/CompilerConfigMSVC.cmake
===================================================================
--- code/trunk/cmake/CompilerConfigMSVC.cmake 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/cmake/CompilerConfigMSVC.cmake 2010-12-26 20:07:43 UTC (rev 7818)
@@ -35,17 +35,6 @@
######################## Options ########################
-# Currently VLD has a problem with MSVC9 although it actually is supported
-IF(MSVC80)
- OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" off)
-ENDIF()
-# Make sure the value is "on" or "off" for vld.ini
-IF(VISUAL_LEAK_DETECTOR_ENABLE)
- SET(VISUAL_LEAK_DETECTOR_ENABLE on)
-ELSE()
- SET(VISUAL_LEAK_DETECTOR_ENABLE off)
-ENDIF()
-
# Orxonox only supports MSVC 8 and above, which gets asserted above
SET(PCH_COMPILER_SUPPORT TRUE)
@@ -158,6 +147,8 @@
# Use Link time code generation for Release config if ORXONOX_RELEASE is defined
IF(ORXONOX_RELEASE)
ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF -LTCG" ReleaseAll CACHE)
+ # Static linker flags have to be added manually to a target
+ SET(ORXONOX_STATIC_LINKER_FLAGS "/LTCG")
ELSE()
ADD_LINKER_FLAGS("-INCREMENTAL:YES" RelWithDebInfo CACHE)
ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF" Release MinSizeRel CACHE)
Modified: code/trunk/cmake/PackageConfigMSVC.cmake
===================================================================
--- code/trunk/cmake/PackageConfigMSVC.cmake 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/cmake/PackageConfigMSVC.cmake 2010-12-26 20:07:43 UTC (rev 7818)
@@ -56,10 +56,4 @@
SET(TCL_LIBRARY ${DEP_LIBRARY_DIR}/tcl85.lib CACHE FILEPATH "")
SET(ZLIB_LIBRARY ${DEP_LIBRARY_DIR}/zdll.lib CACHE FILEPATH "")
- # Visual Leak Detector
- SET(VLD_INCLUDE_DIR ${DEP_INCLUDE_DIR}/vld CACHE PATH "")
- SET(VLD_LIBRARY_DIR ${DEP_LIBRARY_DIR} CACHE PATH "")
- LINK_DIRECTORIES(${VLD_LIBRARY_DIR}) # Used for auto-linking
- MARK_AS_ADVANCED(VLD_INCLUDE_DIR VLD_LIBRARY_DIR)
-
ENDIF(MSVC)
Modified: code/trunk/cmake/tools/SourceFileUtilities.cmake
===================================================================
--- code/trunk/cmake/tools/SourceFileUtilities.cmake 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/cmake/tools/SourceFileUtilities.cmake 2010-12-26 20:07:43 UTC (rev 7818)
@@ -33,54 +33,18 @@
#
FUNCTION(PREPARE_SOURCE_FILES)
- SET(_fullpath_sources)
+ SET(_source_files)
FOREACH(_file ${ARGN})
- IF(_file STREQUAL "COMPILATION_BEGIN")
- SET(_compile TRUE)
- # Next file is the name of the compilation
- SET(_get_name TRUE)
- ELSEIF(_get_name)
- SET(_get_name FALSE)
- SET(_compilation_name ${_file})
- ELSEIF(_file STREQUAL "COMPILATION_END")
- IF(NOT _compilation_name)
- MESSAGE(FATAL_ERROR "No name provided for source file compilation")
- ENDIF()
- IF(NOT DISABLE_COMPILATIONS)
- SET(_compilation_file ${CMAKE_CURRENT_BINARY_DIR}/${_compilation_name})
- SET(_include_string)
- FOREACH(_file2 ${_compilation})
- SET(_include_string "${_include_string}#include \"${_file2}\"\n")
- ENDFOREACH(_file2)
- IF(EXISTS ${_compilation_file})
- FILE(READ ${_compilation_file} _include_string_file)
- ENDIF()
- IF(NOT _include_string STREQUAL "${_include_string_file}")
- FILE(WRITE ${_compilation_file} "${_include_string}")
- ENDIF()
- LIST(APPEND _fullpath_sources ${_compilation_file})
- # MSVC hack that excludes the compilations from the intellisense database
- # (There is a bug with the "-" instead of "/". Only works for "Zm#" argument)
- # 2nd Note: Exploiting this results in a strange separation of the compilation
- # file, causing the compiler not to use multi processing --> slower compiling.
- #IF(MSVC)
- # SET_SOURCE_FILES_PROPERTIES(${_compilation_file} PROPERTIES COMPILE_FLAGS "-Zm1000")
- #ENDIF()
- ENDIF()
- SET(_compilation_name)
- SET(_compilation)
- SET(_compile FALSE)
+ IF(_file MATCHES "^(COMPILATION_BEGIN|COMPILATION_END)$")
+ # Append keywords verbatim
+ LIST(APPEND _source_files ${_file})
ELSE()
- # Prefix the full path
- GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
- LIST(APPEND _fullpath_sources ${_filepath})
- IF(_compile AND NOT DISABLE_COMPILATIONS)
- LIST(APPEND _compilation ${_filepath})
- LIST(APPEND _fullpath_sources "H")
- ENDIF()
+ # Store file with path relative to the root source directory
+ FILE(RELATIVE_PATH _file_rel ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
+ LIST(APPEND _source_files ./${_file_rel})
ENDIF()
ENDFOREACH(_file)
- SET(_fullpath_sources ${_fullpath_sources} PARENT_SCOPE)
+ SET(_source_files ${_source_files} PARENT_SCOPE)
ENDFUNCTION(PREPARE_SOURCE_FILES)
@@ -88,7 +52,7 @@
FUNCTION(ADD_SOURCE_FILES _varname)
PREPARE_SOURCE_FILES(${ARGN})
# Write into the cache to avoid variable scoping in subdirs
- SET(${_varname} ${${_varname}} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
+ SET(${_varname} ${${_varname}} ${_source_files} CACHE INTERNAL "Do not edit")
ENDFUNCTION(ADD_SOURCE_FILES)
@@ -96,7 +60,7 @@
FUNCTION(SET_SOURCE_FILES _varname)
PREPARE_SOURCE_FILES(${ARGN})
# Write into the cache to avoid variable scoping in subdirs
- SET(${_varname} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
+ SET(${_varname} ${_source_files} CACHE INTERNAL "Do not edit")
ENDFUNCTION(SET_SOURCE_FILES)
@@ -112,7 +76,7 @@
FOREACH(_file ${ARGN})
GET_SOURCE_FILE_PROPERTY(_full_filepath ${_file} LOCATION)
FILE(RELATIVE_PATH _relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${_full_filepath})
- IF(NOT _relative_path MATCHES "^\\.\\.")
+ IF(NOT _relative_path MATCHES "^\\.\\./") # Has "../" at the beginning
GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
SOURCE_GROUP("Source\\${_group_path}" FILES ${_file})
Modified: code/trunk/cmake/tools/TargetUtilities.cmake
===================================================================
--- code/trunk/cmake/tools/TargetUtilities.cmake 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/cmake/tools/TargetUtilities.cmake 2010-12-26 20:07:43 UTC (rev 7818)
@@ -89,15 +89,65 @@
PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
-
- # Workaround: Source file properties get lost when leaving a subdirectory
- # Therefore an "H" after a file means we have to set it as HEADER_FILE_ONLY
+ # Process source files with support for compilations
+ # Note: All file paths are relative to the root source directory, even the
+ # name of the compilation file.
+ SET(_${_target_name}_source_files)
+ SET(_get_compilation_file FALSE)
+ SET(_add_to_compilation FALSE)
FOREACH(_file ${_arg_SOURCE_FILES})
- IF(_file STREQUAL "H")
- SET_SOURCE_FILES_PROPERTIES(${_last_file} PROPERTIES HEADER_FILE_ONLY TRUE)
+ IF(_file STREQUAL "COMPILATION_BEGIN")
+ # Next file is the name of the compilation
+ SET(_get_compilation_file TRUE)
+ ELSEIF(_file STREQUAL "COMPILATION_END")
+ IF(NOT _compilation_file)
+ MESSAGE(FATAL_ERROR "No name provided for source file compilation")
+ ENDIF()
+ IF(NOT _compilation_include_string)
+ MESSAGE(STATUS "Warning: Empty source file compilation!")
+ ENDIF()
+ IF(NOT DISABLE_COMPILATIONS)
+ IF(EXISTS ${_compilation_file})
+ FILE(READ ${_compilation_file} _include_string_file)
+ ENDIF()
+ IF(NOT _compilation_include_string STREQUAL "${_include_string_file}")
+ FILE(WRITE ${_compilation_file} "${_compilation_include_string}")
+ ENDIF()
+ LIST(APPEND _${_target_name}_source_files ${_compilation_file})
+ ENDIF()
+ SET(_add_to_compilation FALSE)
+ ELSEIF(_get_compilation_file)
+ SET(_compilation_file ${CMAKE_BINARY_DIR}/${_file})
+ SET(_get_compilation_file FALSE)
+ SET(_add_to_compilation TRUE)
+ SET(_compilation_include_string)
ELSE()
- SET(_last_file ${_file})
+ # Default, add source file
+
+ # Prepare relative paths
+ IF(NOT _file MATCHES "^(.\\:|\\/)")
+ # Path can be relative to the current source directory if the file was
+ # not added with the source file macros. Otherwise there is a "./" at
+ # the beginning of each file and the filename is relative
+ # to the CMAKE_SOURCE_DIR
+ STRING(REGEX REPLACE "^\\.\\/(.+)$" "\\1" _temp ${_file})
+ IF(NOT ${_temp} STREQUAL ${_file})
+ SET(_file ${CMAKE_SOURCE_DIR}/${_temp})
+ ELSE()
+ SET(_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
+ ENDIF()
+ ENDIF()
+
LIST(APPEND _${_target_name}_source_files ${_file})
+
+ # Handle compilations
+ IF(_add_to_compilation AND NOT DISABLE_COMPILATIONS)
+ IF(_file MATCHES "\\.(c|cc|cpp|cxx)$")
+ SET(_compilation_include_string "${_compilation_include_string}#include \"${_file}\"\n")
+ ENDIF()
+ # Don't compile these files, even if they are source files
+ SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
+ ENDIF()
ENDIF()
ENDFOREACH(_file)
@@ -171,7 +221,7 @@
# Don't compile header files
FOREACH(_file ${_${_target_name}_files})
- IF(NOT _file MATCHES "\\.(c|cc|cpp)")
+ IF(NOT _file MATCHES "\\.(c|cc|cpp|cxx)$")
SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
ENDIF()
ENDFOREACH(_file)
@@ -218,6 +268,11 @@
SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE STRING "" FORCE)
ENDIF()
+ # Static library flags are not globally available
+ IF(ORXONOX_STATIC_LINKER_FLAGS)
+ SET_TARGET_PROPERTIES(${_target_name} PROPERTIES STATIC_LIBRARY_FLAGS ${ORXONOX_STATIC_LINKER_FLAGS})
+ ENDIF()
+
# LINK_LIBRARIES
IF(_arg_LINK_LIBRARIES)
TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBRARIES})
Modified: code/trunk/doc/api/doxy.config.in
===================================================================
--- code/trunk/doc/api/doxy.config.in 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/doc/api/doxy.config.in 2010-12-26 20:07:43 UTC (rev 7818)
@@ -608,8 +608,8 @@
FILE_PATTERNS = *.cpp \
*.cc \
+ *.c \
*.h \
- *.hh \
*.hpp \
*.dox
Modified: code/trunk/src/CMakeLists.txt
===================================================================
--- code/trunk/src/CMakeLists.txt 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/src/CMakeLists.txt 2010-12-26 20:07:43 UTC (rev 7818)
@@ -83,7 +83,6 @@
${TCL_INCLUDE_PATH}
${DIRECTX_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
- ${VLD_INCLUDE_DIR}
# All includes in "externals" should be prefixed with the path
# relative to "external" to avoid conflicts
@@ -122,6 +121,8 @@
################## Executable ###################
+SET_SOURCE_FILES(ORXONOX_MAIN_SRC_FILES Orxonox.cc)
+
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/libraries
${CMAKE_CURRENT_SOURCE_DIR}/orxonox
@@ -138,7 +139,7 @@
LINK_LIBRARIES
orxonox
SOURCE_FILES
- Orxonox.cc
+ ${ORXONOX_MAIN_SRC_FILES}
OUTPUT_NAME orxonox
)
# Main executable should depend on all modules
Modified: code/trunk/src/OrxonoxConfig.cmake
===================================================================
--- code/trunk/src/OrxonoxConfig.cmake 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/src/OrxonoxConfig.cmake 2010-12-26 20:07:43 UTC (rev 7818)
@@ -78,6 +78,22 @@
INCLUDE(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX(iso646.h HAVE_ISO646_H)
+IF(MSVC)
+ # Check whether we can use Visual Leak Detector
+ FIND_FILE(VLD_DLL vld_x86.dll)
+ IF(VLD_DLL)
+ SET(HAVE_VLD TRUE)
+ OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" off)
+ # Make sure the value is "on" or "off" for vld.ini
+ IF(VISUAL_LEAK_DETECTOR_ENABLE)
+ SET(VISUAL_LEAK_DETECTOR_ENABLE on)
+ ELSE()
+ SET(VISUAL_LEAK_DETECTOR_ENABLE off)
+ ENDIF()
+ ENDIF()
+ MARK_AS_ADVANCED(VLD_DLL)
+ENDIF()
+
############## Configured Headers ###############
SET(GENERATED_FILE_COMMENT
Modified: code/trunk/src/OrxonoxConfig.h.in
===================================================================
--- code/trunk/src/OrxonoxConfig.h.in 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/src/OrxonoxConfig.h.in 2010-12-26 20:07:43 UTC (rev 7818)
@@ -178,9 +178,17 @@
#endif
*/
-// Always include the memory leak detector for MSVC except for actual releases
-// Note: Although officially supported, VLD does not work with MSVC 9
-#if defined(ORXONOX_COMPILER_MSVC) && _MSC_VER < 1500 && !defined(ORXONOX_RELEASE)
+// Include memory leak detector if available and not building actual release
+#cmakedefine HAVE_VLD
+#if defined(HAVE_VLD) && !defined(ORXONOX_RELEASE)
+typedef uint32_t UINT32;
+typedef wchar_t WCHAR;
+struct HINSTANCE__;
+typedef struct HINSTANCE__* HINSTANCE;
+typedef HINSTANCE HMODULE;
+# ifndef NULL
+# define NULL 0
+# endif
# include <vld.h>
#endif
Modified: code/trunk/src/SpecialConfig.h.in
===================================================================
--- code/trunk/src/SpecialConfig.h.in 2010-12-26 16:26:58 UTC (rev 7817)
+++ code/trunk/src/SpecialConfig.h.in 2010-12-26 20:07:43 UTC (rev 7818)
@@ -51,7 +51,7 @@
#cmakedefine DBGHELP_FOUND ///< If DbgHelp was found on windows
-#cmakedefine ORXONOX_USE_WINMAIN ///< Using MSVC or XCode IDE
+#cmakedefine ORXONOX_USE_WINMAIN ///< Whether or not the console window is started as well
// Handle default ConfigValues
namespace orxonox { namespace specialConfig
More information about the Orxonox-commit
mailing list