Changeset 7805
- Timestamp:
- Dec 25, 2010, 11:58:25 PM (14 years ago)
- Location:
- code/forks/sandbox_qt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/forks/sandbox_qt/cmake/tools/SourceFileUtilities.cmake
r7415 r7805 34 34 35 35 FUNCTION(PREPARE_SOURCE_FILES) 36 SET(_ fullpath_sources)36 SET(_source_files) 37 37 FOREACH(_file ${ARGN}) 38 IF(_file STREQUAL "COMPILATION_BEGIN") 39 SET(_compile TRUE) 40 # Next file is the name of the compilation 41 SET(_get_name TRUE) 42 ELSEIF(_get_name) 43 SET(_get_name FALSE) 44 SET(_compilation_name ${_file}) 45 ELSEIF(_file STREQUAL "COMPILATION_END") 46 IF(NOT _compilation_name) 47 MESSAGE(FATAL_ERROR "No name provided for source file compilation") 48 ENDIF() 49 IF(NOT DISABLE_COMPILATIONS) 50 SET(_compilation_file ${CMAKE_CURRENT_BINARY_DIR}/${_compilation_name}) 51 SET(_include_string) 52 FOREACH(_file2 ${_compilation}) 53 SET(_include_string "${_include_string}#include \"${_file2}\"\n") 54 ENDFOREACH(_file2) 55 IF(EXISTS ${_compilation_file}) 56 FILE(READ ${_compilation_file} _include_string_file) 57 ENDIF() 58 IF(NOT _include_string STREQUAL "${_include_string_file}") 59 FILE(WRITE ${_compilation_file} "${_include_string}") 60 ENDIF() 61 LIST(APPEND _fullpath_sources ${_compilation_file}) 62 # MSVC hack that excludes the compilations from the intellisense database 63 # (There is a bug with the "-" instead of "/". Only works for "Zm#" argument) 64 # 2nd Note: Exploiting this results in a strange separation of the compilation 65 # file, causing the compiler not to use multi processing --> slower compiling. 66 #IF(MSVC) 67 # SET_SOURCE_FILES_PROPERTIES(${_compilation_file} PROPERTIES COMPILE_FLAGS "-Zm1000") 68 #ENDIF() 69 ENDIF() 70 SET(_compilation_name) 71 SET(_compilation) 72 SET(_compile FALSE) 38 IF(_file MATCHES "^(COMPILATION_BEGIN|COMPILATION_END|QT)$") 39 # Append keywords verbatim 40 LIST(APPEND _source_files ${_file}) 73 41 ELSE() 74 # Prefix the full path 75 GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION) 76 LIST(APPEND _fullpath_sources ${_filepath}) 77 IF(_compile AND NOT DISABLE_COMPILATIONS) 78 LIST(APPEND _compilation ${_filepath}) 79 LIST(APPEND _fullpath_sources "H") 80 ENDIF() 42 # Store file with path relative to the root source directory 43 FILE(RELATIVE_PATH _file_rel ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) 44 LIST(APPEND _source_files ${_file_rel}) 81 45 ENDIF() 82 46 ENDFOREACH(_file) 83 SET(_ fullpath_sources ${_fullpath_sources} PARENT_SCOPE)47 SET(_source_files ${_source_files} PARENT_SCOPE) 84 48 ENDFUNCTION(PREPARE_SOURCE_FILES) 85 49 … … 89 53 PREPARE_SOURCE_FILES(${ARGN}) 90 54 # Write into the cache to avoid variable scoping in subdirs 91 SET(${_varname} ${${_varname}} ${_ fullpath_sources} CACHE INTERNAL "Do not edit")55 SET(${_varname} ${${_varname}} ${_source_files} CACHE INTERNAL "Do not edit") 92 56 ENDFUNCTION(ADD_SOURCE_FILES) 93 57 … … 97 61 PREPARE_SOURCE_FILES(${ARGN}) 98 62 # Write into the cache to avoid variable scoping in subdirs 99 SET(${_varname} ${_ fullpath_sources} CACHE INTERNAL "Do not edit")63 SET(${_varname} ${_source_files} CACHE INTERNAL "Do not edit") 100 64 ENDFUNCTION(SET_SOURCE_FILES) 101 65 … … 113 77 GET_SOURCE_FILE_PROPERTY(_full_filepath ${_file} LOCATION) 114 78 FILE(RELATIVE_PATH _relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${_full_filepath}) 115 IF(NOT _relative_path MATCHES "^\\.\\. ")79 IF(NOT _relative_path MATCHES "^\\.\\./") # Has "../" at the beginning 116 80 GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH) 117 81 STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}") -
code/forks/sandbox_qt/cmake/tools/TargetUtilities.cmake
r7421 r7805 48 48 # PCH_EXCLUDE: Source files to be excluded from PCH support 49 49 # OUTPUT_NAME: If you want a different name than the target name 50 # QT_MOC_FILES: List of files to be processed by Qt MOC51 # QT_UIC_FILES: List of files to be processed by Qt UIC52 50 # Note: 53 51 # This function also installs the target! … … 85 83 SET(_list_names LINK_LIBRARIES VERSION SOURCE_FILES 86 84 DEFINE_SYMBOL PCH_FILE PCH_EXCLUDE 87 OUTPUT_NAME QT_MOC_FILES QT_UIC_FILES)85 OUTPUT_NAME) 88 86 89 87 PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN}) 90 88 91 89 92 # Workaround: Source file properties get lost when leaving a subdirectory 93 # Therefore an "H" after a file means we have to set it as HEADER_FILE_ONLY 90 # Process source files with support for compilations and QT special files 91 # Note: All file paths are relative to the root source directory, even the 92 # name of the compilation file. 93 SET(_${_target_name}_source_files) 94 SET(_get_compilation_file FALSE) 95 SET(_add_to_compilation FALSE) 96 SET(_compile_qt_next FALSE) 94 97 FOREACH(_file ${_arg_SOURCE_FILES}) 95 IF(_file STREQUAL "H") 96 SET_SOURCE_FILES_PROPERTIES(${_last_file} PROPERTIES HEADER_FILE_ONLY TRUE) 98 IF(_file STREQUAL "COMPILATION_BEGIN") 99 # Next file is the name of the compilation 100 SET(_get_compilation_file TRUE) 101 ELSEIF(_file STREQUAL "COMPILATION_END") 102 IF(NOT _compilation_file) 103 MESSAGE(FATAL_ERROR "No name provided for source file compilation") 104 ENDIF() 105 IF(NOT _compilation_include_string) 106 MESSAGE(STATUS "Warning: Empty source file compilation!") 107 ENDIF() 108 IF(NOT DISABLE_COMPILATIONS) 109 IF(EXISTS ${_compilation_file}) 110 FILE(READ ${_compilation_file} _include_string_file) 111 ENDIF() 112 IF(NOT _compilation_include_string STREQUAL "${_include_string_file}") 113 FILE(WRITE ${_compilation_file} "${_compilation_include_string}") 114 ENDIF() 115 LIST(APPEND _${_target_name}_source_files ${_compilation_file}) 116 ENDIF() 117 SET(_add_to_compilation FALSE) 118 ELSEIF(_get_compilation_file) 119 SET(_compilation_file ${CMAKE_BINARY_DIR}/${_file}) 120 SET(_get_compilation_file FALSE) 121 SET(_add_to_compilation TRUE) 122 SET(_compilation_include_string) 123 ELSEIF(_file STREQUAL "QT") 124 SET(_compile_qt_next TRUE) 97 125 ELSE() 98 SET(_last_file ${_file}) 126 # Default, add source file 127 SET(_file ${CMAKE_SOURCE_DIR}/${_file}) 99 128 LIST(APPEND _${_target_name}_source_files ${_file}) 129 130 # Handle compilations 131 IF(_add_to_compilation AND NOT DISABLE_COMPILATIONS) 132 IF(_file MATCHES "\\.(c|cc|cpp|cxx)$") 133 SET(_compilation_include_string "${_compilation_include_string}#include \"${_file}\"\n") 134 ENDIF() 135 # Don't compile these files, even if they are source files 136 SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE) 137 ENDIF() 138 139 # Handle Qt MOC and UI files 140 IF(_compile_qt_next) 141 GET_FILENAME_COMPONENT(_ext ${_file} EXT) 142 IF(_ext STREQUAL ".ui") 143 QT4_WRAP_UI(_${_target_name}_source_files ${_file}) 144 ELSEIF(_ext STREQUAL ".qrc") 145 QT4_ADD_RESOURCES(_${_target_name}_source_files ${_file}) 146 ELSEIF(_ext MATCHES "^\\.(h|hpp|hxx)$") 147 QT4_WRAP_CPP(_${_target_name}_source_files ${_file}) 148 ENDIF() 149 SET(_compile_qt_next FALSE) 150 ENDIF() 100 151 ENDIF() 101 152 ENDFOREACH(_file) … … 106 157 ENDIF() 107 158 108 # Combine source , header and QT designer files159 # Combine source and header files 109 160 SET(_${_target_name}_files 110 161 ${_${_target_name}_header_files} 111 162 ${_${_target_name}_source_files} 112 ${_arg_QT_UIC_FILES}113 163 ) 114 164 # Remove potential duplicates 115 165 LIST(REMOVE_DUPLICATES _${_target_name}_files) 116 117 # QT MOC and UIC preprocessing118 IF(_arg_QT_MOC_FILES)119 QT4_WRAP_CPP(_${_target_name}_files ${_arg_QT_MOC_FILES})120 ENDIF()121 IF(_arg_QT_UIC_FILES)122 QT4_WRAP_UI(_${_target_name}_files ${_arg_QT_UIC_FILES})123 ENDIF()124 166 125 167 # First part (pre target) of precompiled header files … … 174 216 # Don't compile header files 175 217 FOREACH(_file ${_${_target_name}_files}) 176 IF(NOT _file MATCHES "\\.(c|cc|cpp )")218 IF(NOT _file MATCHES "\\.(c|cc|cpp|cxx)$") 177 219 SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE) 178 220 ENDIF() -
code/forks/sandbox_qt/src/CMakeLists.txt
r7423 r7805 80 80 ################## Executable ################### 81 81 82 SET_SOURCE_FILES(ORXONOX_MAIN_SRC_FILES Orxonox.cc) 83 82 84 INCLUDE_DIRECTORIES( 83 85 ${CMAKE_CURRENT_SOURCE_DIR}/libraries … … 97 99 orxonox 98 100 SOURCE_FILES 99 Orxonox.cc101 ${ORXONOX_MAIN_SRC_FILES} 100 102 OUTPUT_NAME orxonox 101 103 ) -
code/forks/sandbox_qt/src/orxonox/CMakeLists.txt
r7430 r7805 20 20 INCLUDE_DIRECTORIES( 21 21 ${CMAKE_SOURCE_DIR}/src/libraries 22 ${CMAKE_CURRENT_SOURCE_DIR} 22 # Make Qt UIC generated header files visible 23 ${CMAKE_CURRENT_BINARY_DIR} 23 24 ) 24 25 25 26 SET_SOURCE_FILES(ORXONOX_SRC_FILES 26 27 Main.cc 27 MainWindow.cc 28 29 QT MainWindow.h MainWindow.cc 30 QT MainWindow.ui 28 31 ) 29 32 … … 31 34 32 35 ORXONOX_ADD_LIBRARY(orxonox 33 FIND_HEADER_FILES34 QT_MOC_FILES35 MainWindow.h36 QT_UIC_FILES37 MainWindow.ui38 36 LINK_LIBRARIES 39 37 ${QT_QTCORE_LIBRARY}
Note: See TracChangeset
for help on using the changeset viewer.