Browse Source

Rename Urho3D-CMake-common.cmake module to UrhoCommon.cmake.
To be consistent with the other modules. Drop the '3D' simply because it sticks out in 'Urho3DCommon'.

Yao Wei Tjong 姚伟忠 9 years ago
parent
commit
f32cbb72b0

+ 419 - 435
CMake/Modules/Urho3D-CMake-common.cmake → CMake/Modules/UrhoCommon.cmake

@@ -521,7 +521,7 @@ else ()
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
     if (NOT ANDROID)    # Most of the flags are already setup in android.toolchain.cmake module
     if (NOT ANDROID)    # Most of the flags are already setup in android.toolchain.cmake module
         if (ARM AND CMAKE_SYSTEM_NAME STREQUAL Linux)
         if (ARM AND CMAKE_SYSTEM_NAME STREQUAL Linux)
-            # Common compiler flags for aarch64-linux-gnu and arm-linux-gnueabihf, we do not support Windows on arm for now
+            # Common compiler flags for aarch64-linux-gnu and arm-linux-gnueabihf, we do not support ARM on Windows for now
             set (ARM_CFLAGS "${ARM_CFLAGS} -fsigned-char -pipe")
             set (ARM_CFLAGS "${ARM_CFLAGS} -fsigned-char -pipe")
             if (NOT URHO3D_64BIT)
             if (NOT URHO3D_64BIT)
                 # We only support armhf distros, so turn on hard-float by default
                 # We only support armhf distros, so turn on hard-float by default
@@ -712,39 +712,33 @@ if (URHO3D_LUAJIT)
         set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-E")
         set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-E")
     endif ()
     endif ()
 endif ()
 endif ()
+# Trim the leading white space in the compiler/linker flags, if any
+foreach (TYPE C CXX EXE_LINKER SHARED_LINKER)
+    string (REGEX REPLACE "^ +" "" CMAKE_${TYPE}_FLAGS "${CMAKE_${TYPE}_FLAGS}")
+endforeach ()
 
 
-# Macro for setting common output directories
 include (CMakeParseArguments)
 include (CMakeParseArguments)
-macro (set_output_directories OUTPUT_PATH)
-    cmake_parse_arguments (ARG LOCAL "" "" ${ARGN})
-    if (ARG_LOCAL)
-        unset (SCOPE)
-        unset (OUTPUT_DIRECTORY_PROPERTIES)
-    else ()
-        set (SCOPE CMAKE_)
-    endif ()
-    foreach (TYPE ${ARG_UNPARSED_ARGUMENTS})
-        set (${SCOPE}${TYPE}_OUTPUT_DIRECTORY ${OUTPUT_PATH})
-        list (APPEND OUTPUT_DIRECTORY_PROPERTIES ${TYPE}_OUTPUT_DIRECTORY ${${TYPE}_OUTPUT_DIRECTORY})
-        foreach (CONFIG ${CMAKE_CONFIGURATION_TYPES})
-            string (TOUPPER ${CONFIG} CONFIG)
-            set (${SCOPE}${TYPE}_OUTPUT_DIRECTORY_${CONFIG} ${OUTPUT_PATH})
-            list (APPEND OUTPUT_DIRECTORY_PROPERTIES ${TYPE}_OUTPUT_DIRECTORY_${CONFIG} ${${TYPE}_OUTPUT_DIRECTORY_${CONFIG}})
-        endforeach ()
-        if (TYPE STREQUAL RUNTIME AND NOT ${OUTPUT_PATH} STREQUAL .)
-            file (RELATIVE_PATH REL_OUTPUT_PATH ${CMAKE_BINARY_DIR} ${OUTPUT_PATH})
-            set (DEST_RUNTIME_DIR ${REL_OUTPUT_PATH})
-        endif ()
-    endforeach ()
-    if (ARG_LOCAL)
-        list (APPEND TARGET_PROPERTIES ${OUTPUT_DIRECTORY_PROPERTIES})
+
+# Macro for adjusting target output name by dropping _suffix from the target name
+macro (adjust_target_name)
+    if (TARGET_NAME MATCHES _.*$)
+        string (REGEX REPLACE _.*$ "" OUTPUT_NAME ${TARGET_NAME})
+        set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
-# Set common binary output directory for all platforms if not already set (note that this module can be included in an external project which already has DEST_RUNTIME_DIR preset)
-if (NOT DEST_RUNTIME_DIR)
-    set_output_directories (${CMAKE_BINARY_DIR}/bin RUNTIME PDB)
-endif ()
+# Macro for checking the SOURCE_FILES variable is properly initialized
+macro (check_source_files)
+    if (NOT SOURCE_FILES)
+        message (FATAL_ERROR "Could not configure and generate the project file because no source files have been defined yet. "
+            "You can define the source files explicitly by setting the SOURCE_FILES variable in your CMakeLists.txt; or "
+            "by calling the define_source_files() macro which would by default glob all the C++ source files found in the same scope of "
+            "CMakeLists.txt where the macro is being called and the macro would set the SOURCE_FILES variable automatically. "
+            "If your source files are not located in the same directory as the CMakeLists.txt or your source files are "
+            "more than just C++ language then you probably have to pass in extra arguments when calling the macro in order to make it works. "
+            "See the define_source_files() macro definition in the CMake/Modules/UrhoCommon.cmake for more detail.")
+    endif ()
+endmacro ()
 
 
 # Macro for setting symbolic link on platform that supports it
 # Macro for setting symbolic link on platform that supports it
 macro (create_symlink SOURCE DESTINATION)
 macro (create_symlink SOURCE DESTINATION)
@@ -792,6 +786,168 @@ macro (create_symlink SOURCE DESTINATION)
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
+# *** THIS IS A DEPRECATED MACRO ***
+# Macro for defining external library dependencies
+# The purpose of this macro is emulate CMake to set the external library dependencies transitively
+# It works for both targets setup within Urho3D project and downstream projects that uses Urho3D as external static/shared library
+# *** THIS IS A DEPRECATED MACRO ***
+macro (define_dependency_libs TARGET)
+    # ThirdParty/SDL external dependency
+    if (${TARGET} MATCHES SDL|Urho3D)
+        if (WIN32)
+            list (APPEND LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
+        elseif (APPLE)
+            list (APPEND LIBS iconv)
+        elseif (ANDROID)
+            list (APPEND LIBS dl log android)
+        else ()
+            # Linux
+            if (NOT WEB)
+                list (APPEND LIBS dl m rt)
+            endif ()
+            if (RPI)
+                list (APPEND ABSOLUTE_PATH_LIBS ${VIDEOCORE_LIBRARIES})
+            endif ()
+        endif ()
+    endif ()
+
+    # ThirdParty/kNet & ThirdParty/Civetweb external dependency
+    if (${TARGET} MATCHES Civetweb|kNet|Urho3D)
+        if (WIN32)
+            list (APPEND LIBS ws2_32)
+        endif ()
+    endif ()
+
+    # Urho3D/LuaJIT external dependency
+    if (URHO3D_LUAJIT AND ${TARGET} MATCHES LuaJIT|Urho3D)
+        if (NOT WIN32 AND NOT WEB)
+            list (APPEND LIBS dl m)
+        endif ()
+    endif ()
+
+    # Urho3D external dependency
+    if (${TARGET} STREQUAL Urho3D)
+        # Core
+        if (WIN32)
+            list (APPEND LIBS winmm)
+            if (URHO3D_MINIDUMPS)
+                list (APPEND LIBS dbghelp)
+            endif ()
+        elseif (APPLE)
+            if (IOS OR TVOS)
+                list (APPEND LIBS "-framework AudioToolbox" "-framework AVFoundation" "-framework CoreAudio" "-framework CoreGraphics" "-framework CoreMotion" "-framework Foundation" "-framework GameController" "-framework OpenGLES" "-framework QuartzCore" "-framework UIKit")
+            else ()
+                list (APPEND LIBS "-framework AudioToolbox" "-framework Carbon" "-framework Cocoa" "-framework CoreAudio" "-framework CoreServices" "-framework CoreVideo" "-framework ForceFeedback" "-framework IOKit" "-framework OpenGL")
+            endif ()
+        endif ()
+
+        # Graphics
+        if (URHO3D_OPENGL)
+            if (APPLE)
+                # Do nothing
+            elseif (WIN32)
+                list (APPEND LIBS opengl32)
+            elseif (ANDROID OR ARM)
+                list (APPEND LIBS GLESv1_CM GLESv2)
+            else ()
+                list (APPEND LIBS GL)
+            endif ()
+        elseif (DIRECT3D_LIBRARIES)
+            list (APPEND LIBS ${DIRECT3D_LIBRARIES})
+        endif ()
+
+        # Database
+        if (URHO3D_DATABASE_ODBC)
+            list (APPEND LIBS ${ODBC_LIBRARIES})
+        endif ()
+
+        # This variable value can either be 'Urho3D' target or an absolute path to an actual static/shared Urho3D library or empty (if we are building the library itself)
+        # The former would cause CMake not only to link against the Urho3D library but also to add a dependency to Urho3D target
+        if (URHO3D_LIBRARIES)
+            if (WIN32 AND URHO3D_LIBRARIES_DBG AND URHO3D_LIBRARIES_REL AND TARGET ${TARGET_NAME})
+                # Special handling when both debug and release libraries are found
+                target_link_libraries (${TARGET_NAME} debug ${URHO3D_LIBRARIES_DBG} optimized ${URHO3D_LIBRARIES_REL})
+            else ()
+                if (TARGET ${TARGET}_universal)
+                    add_dependencies (${TARGET_NAME} ${TARGET}_universal)
+                endif ()
+                list (APPEND ABSOLUTE_PATH_LIBS ${URHO3D_LIBRARIES})
+            endif ()
+        endif ()
+    endif ()
+endmacro ()
+
+# Macro for defining source files with optional arguments as follows:
+#  GLOB_CPP_PATTERNS <list> - Use the provided globbing patterns for CPP_FILES instead of the default *.cpp
+#  GLOB_H_PATTERNS <list> - Use the provided globbing patterns for H_FILES instead of the default *.h
+#  EXCLUDE_PATTERNS <list> - Use the provided patterns for excluding matched source files
+#  EXTRA_CPP_FILES <list> - Include the provided list of files into CPP_FILES result
+#  EXTRA_H_FILES <list> - Include the provided list of files into H_FILES result
+#  PCH <list> - Enable precompiled header support on the defined source files using the specified header file, the list is "<path/to/header> [C++|C]"
+#  PARENT_SCOPE - Glob source files in current directory but set the result in parent-scope's variable ${DIR}_CPP_FILES and ${DIR}_H_FILES instead
+#  RECURSE - Option to glob recursively
+#  GROUP - Option to group source files based on its relative path to the corresponding parent directory (only works when PARENT_SCOPE option is not in use)
+macro (define_source_files)
+    # Source files are defined by globbing source files in current source directory and also by including the extra source files if provided
+    cmake_parse_arguments (ARG "PARENT_SCOPE;RECURSE;GROUP" "" "PCH;EXTRA_CPP_FILES;EXTRA_H_FILES;GLOB_CPP_PATTERNS;GLOB_H_PATTERNS;EXCLUDE_PATTERNS" ${ARGN})
+    if (NOT ARG_GLOB_CPP_PATTERNS)
+        set (ARG_GLOB_CPP_PATTERNS *.cpp)    # Default glob pattern
+    endif ()
+    if (NOT ARG_GLOB_H_PATTERNS)
+        set (ARG_GLOB_H_PATTERNS *.h)
+    endif ()
+    if (ARG_RECURSE)
+        set (ARG_RECURSE _RECURSE)
+    else ()
+        unset (ARG_RECURSE)
+    endif ()
+    file (GLOB${ARG_RECURSE} CPP_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${ARG_GLOB_CPP_PATTERNS})
+    file (GLOB${ARG_RECURSE} H_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${ARG_GLOB_H_PATTERNS})
+    if (ARG_EXCLUDE_PATTERNS)
+        set (CPP_FILES_WITH_SENTINEL ";${CPP_FILES};")  # Stringify the lists
+        set (H_FILES_WITH_SENTINEL ";${H_FILES};")
+        foreach (PATTERN ${ARG_EXCLUDE_PATTERNS})
+            foreach (LOOP RANGE 1)
+                string (REGEX REPLACE ";${PATTERN};" ";;" CPP_FILES_WITH_SENTINEL "${CPP_FILES_WITH_SENTINEL}")
+                string (REGEX REPLACE ";${PATTERN};" ";;" H_FILES_WITH_SENTINEL "${H_FILES_WITH_SENTINEL}")
+            endforeach ()
+        endforeach ()
+        set (CPP_FILES ${CPP_FILES_WITH_SENTINEL})      # Convert strings back to lists, extra sentinels are harmless
+        set (H_FILES ${H_FILES_WITH_SENTINEL})
+    endif ()
+    list (APPEND CPP_FILES ${ARG_EXTRA_CPP_FILES})
+    list (APPEND H_FILES ${ARG_EXTRA_H_FILES})
+    set (SOURCE_FILES ${CPP_FILES} ${H_FILES})
+
+    # Optionally enable PCH
+    if (ARG_PCH)
+        enable_pch (${ARG_PCH})
+    endif ()
+
+    # Optionally accumulate source files at parent scope
+    if (ARG_PARENT_SCOPE)
+        get_filename_component (NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+        set (${NAME}_CPP_FILES ${CPP_FILES} PARENT_SCOPE)
+        set (${NAME}_H_FILES ${H_FILES} PARENT_SCOPE)
+    # Optionally put source files into further sub-group (only works when PARENT_SCOPE option is not in use)
+    elseif (ARG_GROUP)
+        foreach (CPP_FILE ${CPP_FILES})
+            get_filename_component (PATH ${CPP_FILE} PATH)
+            if (PATH)
+                string (REPLACE / \\ PATH ${PATH})
+                source_group ("Source Files\\${PATH}" FILES ${CPP_FILE})
+            endif ()
+        endforeach ()
+        foreach (H_FILE ${H_FILES})
+            get_filename_component (PATH ${H_FILE} PATH)
+            if (PATH)
+                string (REPLACE / \\ PATH ${PATH})
+                source_group ("Header Files\\${PATH}" FILES ${H_FILE})
+            endif ()
+        endforeach ()
+    endif ()
+endmacro ()
+
 include (GenerateExportHeader)
 include (GenerateExportHeader)
 
 
 # Macro for precompiling header (On MSVC, the dummy C++ or C implementation file for precompiling the header file would be generated if not already exists)
 # Macro for precompiling header (On MSVC, the dummy C++ or C implementation file for precompiling the header file would be generated if not already exists)
@@ -960,112 +1116,153 @@ macro (enable_pch HEADER_PATHNAME)
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
-# Macro for setting up dependency lib for compilation and linking of a target
-macro (setup_target)
-    # Include directories
-    include_directories (${INCLUDE_DIRS})
-    # Link libraries
-    define_dependency_libs (${TARGET_NAME})
-    target_link_libraries (${TARGET_NAME} ${ABSOLUTE_PATH_LIBS} ${LIBS})
-    # Enable PCH if requested
-    if (${TARGET_NAME}_HEADER_PATHNAME)
-        enable_pch (${${TARGET_NAME}_HEADER_PATHNAME})
-    endif ()
-    # Set additional linker dependencies (only work for Makefile-based generator according to CMake documentation)
-    if (LINK_DEPENDS)
-        string (REPLACE ";" "\;" LINK_DEPENDS "${LINK_DEPENDS}")        # Stringify for string replacement
-        list (APPEND TARGET_PROPERTIES LINK_DEPENDS "${LINK_DEPENDS}")  # Stringify with semicolons already escaped
-        unset (LINK_DEPENDS)
-    endif ()
-    # Extra compiler flags for Xcode which are dynamically changed based on active arch in order to support Mach-O universal binary targets
-    # We don't add the ABI flag for Xcode because it automatically passes '-arch i386' compiler flag when targeting 32 bit which does the same thing as '-m32'
-    if (XCODE)
-        # Speed up build when in Debug configuration by building active arch only
-        list (FIND TARGET_PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH ATTRIBUTE_ALREADY_SET)
-        if (ATTRIBUTE_ALREADY_SET EQUAL -1)
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)
-        endif ()
-        if (NOT URHO3D_SSE)
-            # Nullify the Clang default so that it is consistent with GCC
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CFLAGS[arch=i386] "-mno-sse $(OTHER_CFLAGS)")
-            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=i386] "-mno-sse $(OTHER_CPLUSPLUSFLAGS)")
-        endif ()
-    endif ()
-    if (TARGET_PROPERTIES)
-        set_target_properties (${TARGET_NAME} PROPERTIES ${TARGET_PROPERTIES})
-        unset (TARGET_PROPERTIES)
+# Macro for finding file in Urho3D build tree or Urho3D SDK
+macro (find_Urho3D_file VAR NAME)
+    # Pass the arguments to the actual find command
+    cmake_parse_arguments (ARG "" "DOC;MSG_MODE" "HINTS;PATHS;PATH_SUFFIXES" ${ARGN})
+    find_file (${VAR} ${NAME} HINTS ${ARG_HINTS} PATHS ${ARG_PATHS} PATH_SUFFIXES ${ARG_PATH_SUFFIXES} DOC ${ARG_DOC} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
+    mark_as_advanced (${VAR})  # Hide it from cmake-gui in non-advanced mode
+    if (NOT ${VAR} AND ARG_MSG_MODE)
+        message (${ARG_MSG_MODE}
+            "Could not find ${VAR} file in the Urho3D build tree or Urho3D SDK. "
+            "Please reconfigure and rebuild your Urho3D build tree or reinstall the SDK for the correct target platform.")
     endif ()
     endif ()
+endmacro ()
 
 
-    # Workaround CMake/Xcode generator bug where it always appends '/build' path element to SYMROOT attribute and as such the items in Products are always rendered as red in the Xcode IDE as if they are not yet built
-    if (NOT DEFINED ENV{TRAVIS})
-        if (XCODE AND NOT CMAKE_PROJECT_NAME MATCHES ^Urho3D-ExternalProject-)
-            file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/build)
-            get_target_property (LOCATION ${TARGET_NAME} LOCATION)
-            string (REGEX REPLACE "^.*\\$\\(CONFIGURATION\\)" $(CONFIGURATION) SYMLINK ${LOCATION})
-            get_filename_component (DIRECTORY ${SYMLINK} PATH)
-            add_custom_command (TARGET ${TARGET_NAME} POST_BUILD
-                COMMAND mkdir -p ${DIRECTORY} && ln -sf $<TARGET_FILE:${TARGET_NAME}> ${DIRECTORY}/$<TARGET_FILE_NAME:${TARGET_NAME}>
-                WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/build)
+# Macro for finding tool in Urho3D build tree or Urho3D SDK
+macro (find_Urho3D_tool VAR NAME)
+    # Pass the arguments to the actual find command
+    cmake_parse_arguments (ARG "" "DOC;MSG_MODE" "HINTS;PATHS;PATH_SUFFIXES" ${ARGN})
+    find_program (${VAR} ${NAME} HINTS ${ARG_HINTS} PATHS ${ARG_PATHS} PATH_SUFFIXES ${ARG_PATH_SUFFIXES} DOC ${ARG_DOC} NO_DEFAULT_PATH)
+    mark_as_advanced (${VAR})  # Hide it from cmake-gui in non-advanced mode
+    if (NOT ${VAR})
+        set (${VAR} ${CMAKE_BINARY_DIR}/bin/tool/${NAME})
+        if (ARG_MSG_MODE AND NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
+            message (${ARG_MSG_MODE}
+                "Could not find ${VAR} tool in the Urho3D build tree or Urho3D SDK. Your project may not build successfully without this tool. "
+                "You may have to first rebuild the Urho3D in its build tree or reinstall Urho3D SDK to get this tool built or installed properly. "
+                "Alternatively, copy the ${VAR} executable manually into bin/tool subdirectory in your own project build tree.")
         endif ()
         endif ()
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
-# Macro for checking the SOURCE_FILES variable is properly initialized
-macro (check_source_files)
-    if (NOT SOURCE_FILES)
-        message (FATAL_ERROR "Could not configure and generate the project file because no source files have been defined yet. "
-            "You can define the source files explicitly by setting the SOURCE_FILES variable in your CMakeLists.txt; or "
-            "by calling the define_source_files() macro which would by default glob all the C++ source files found in the same scope of "
-            "CMakeLists.txt where the macro is being called and the macro would set the SOURCE_FILES variable automatically. "
-            "If your source files are not located in the same directory as the CMakeLists.txt or your source files are "
-            "more than just C++ language then you probably have to pass in extra arguments when calling the macro in order to make it works. "
-            "See the define_source_files() macro definition in the CMake/Modules/Urho3D-CMake-common.cmake for more detail.")
-    endif ()
-endmacro ()
+# Macro for setting up header files installation for the SDK and the build tree (only support subset of install command arguments)
+#  FILES <list> - File list to be installed
+#  DIRECTORY <list> - Directory list to be installed
+#  FILES_MATCHING - Option to perform file pattern matching on DIRECTORY list
+#  USE_FILE_SYMLINK - Option to use file symlinks on the matched files found in the DIRECTORY list
+#  BUILD_TREE_ONLY - Option to install the header files into the build tree only
+#  PATTERN <list> - Pattern list to be used in file pattern matching option
+#  BASE <value> - An absolute base path to be prepended to the destination path when installing to build tree, default to build tree
+#  DESTINATION <value> - A relative destination path to be installed to
+#  ACCUMULATE <value> - Accumulate the header files into the specified CMake variable, implies USE_FILE_SYMLINK when input list is a directory
+macro (install_header_files)
+    # Need to check if the destination variable is defined first because this macro could be called by downstream project that does not wish to install anything
+    if (DEST_INCLUDE_DIR)
+        # Parse the arguments for the underlying install command for the SDK
+        cmake_parse_arguments (ARG "FILES_MATCHING;USE_FILE_SYMLINK;BUILD_TREE_ONLY" "BASE;DESTINATION;ACCUMULATE" "FILES;DIRECTORY;PATTERN" ${ARGN})
+        unset (INSTALL_MATCHING)
+        if (ARG_FILES)
+            set (INSTALL_TYPE FILES)
+            set (INSTALL_SOURCES ${ARG_FILES})
+        elseif (ARG_DIRECTORY)
+            set (INSTALL_TYPE DIRECTORY)
+            set (INSTALL_SOURCES ${ARG_DIRECTORY})
+            if (ARG_FILES_MATCHING)
+                set (INSTALL_MATCHING FILES_MATCHING)
+                # Our macro supports PATTERN <list> but CMake's install command does not, so convert the list to: PATTERN <value1> PATTERN <value2> ...
+                foreach (PATTERN ${ARG_PATTERN})
+                    list (APPEND INSTALL_MATCHING PATTERN ${PATTERN})
+                endforeach ()
+            endif ()
+        else ()
+            message (FATAL_ERROR "Couldn't setup install command because the install type is not specified.")
+        endif ()
+        if (NOT ARG_DESTINATION)
+            message (FATAL_ERROR "Couldn't setup install command because the install destination is not specified.")
+        endif ()
+        if (NOT ARG_BUILD_TREE_ONLY AND NOT CMAKE_PROJECT_NAME MATCHES ^Urho3D-ExternalProject-)
+            install (${INSTALL_TYPE} ${INSTALL_SOURCES} DESTINATION ${ARG_DESTINATION} ${INSTALL_MATCHING})
+        endif ()
 
 
-# Macro for setting up a library target
-# Macro arguments:
-#  NODEPS - setup library target without defining Urho3D dependency libraries (applicable for downstream projects)
-#  STATIC/SHARED/MODULE/EXCLUDE_FROM_ALL - see CMake help on add_library() command
-# CMake variables:
-#  SOURCE_FILES - list of source files
-#  INCLUDE_DIRS - list of directories for include search path
-#  LIBS - list of dependent libraries that are built internally in the project
-#  ABSOLUTE_PATH_LIBS - list of dependent libraries that are external to the project
-#  LINK_DEPENDS - list of additional files on which a target binary depends for linking (Makefile-based generator only)
-#  TARGET_PROPERTIES - list of target properties
-macro (setup_library)
-    cmake_parse_arguments (ARG NODEPS "" "" ${ARGN})
-    check_source_files ()
-    add_library (${TARGET_NAME} ${ARG_UNPARSED_ARGUMENTS} ${SOURCE_FILES})
-    get_target_property (LIB_TYPE ${TARGET_NAME} TYPE)
-    if (NOT ARG_NODEPS AND NOT PROJECT_NAME STREQUAL Urho3D)
-        define_dependency_libs (Urho3D)
-    endif ()
-    if (XCODE AND LUAJIT_SHARED_LINKER_FLAGS_APPLE AND LIB_TYPE STREQUAL SHARED_LIBRARY)
-        list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_LDFLAGS[arch=x86_64] "${LUAJIT_SHARED_LINKER_FLAGS_APPLE} $(OTHER_LDFLAGS)")    # Xcode universal build linker flags when targeting 64-bit OSX with LuaJIT enabled
+        # Reparse the arguments for the create_symlink macro to "install" the header files in the build tree
+        if (NOT ARG_BASE)
+            set (ARG_BASE ${CMAKE_BINARY_DIR})  # Use build tree as base path
+        endif ()
+        foreach (INSTALL_SOURCE ${INSTALL_SOURCES})
+            if (NOT IS_ABSOLUTE ${INSTALL_SOURCE})
+                set (INSTALL_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/${INSTALL_SOURCE})
+            endif ()
+            if (INSTALL_SOURCE MATCHES /$)
+                # Source is a directory
+                if (ARG_USE_FILE_SYMLINK OR ARG_ACCUMULATE OR BASH_ON_WINDOWS)
+                    # Use file symlink for each individual files in the source directory
+                    if (IS_SYMLINK ${ARG_DESTINATION} AND NOT CMAKE_HOST_WIN32)
+                        execute_process (COMMAND ${CMAKE_COMMAND} -E remove ${ARG_DESTINATION})
+                    endif ()
+                    set (GLOBBING_EXPRESSION RELATIVE ${INSTALL_SOURCE})
+                    if (ARG_FILES_MATCHING)
+                        foreach (PATTERN ${ARG_PATTERN})
+                            list (APPEND GLOBBING_EXPRESSION ${INSTALL_SOURCE}${PATTERN})
+                        endforeach ()
+                    else ()
+                        list (APPEND GLOBBING_EXPRESSION ${INSTALL_SOURCE}*)
+                    endif ()
+                    file (GLOB_RECURSE NAMES ${GLOBBING_EXPRESSION})
+                    foreach (NAME ${NAMES})
+                        get_filename_component (PATH ${ARG_DESTINATION}/${NAME} PATH)
+                        # Recreate the source directory structure in the destination path
+                        if (NOT EXISTS ${ARG_BASE}/${PATH})
+                            file (MAKE_DIRECTORY ${ARG_BASE}/${PATH})
+                        endif ()
+                        create_symlink (${INSTALL_SOURCE}${NAME} ${ARG_DESTINATION}/${NAME} FALLBACK_TO_COPY)
+                        if (ARG_ACCUMULATE)
+                            list (APPEND ${ARG_ACCUMULATE} ${ARG_DESTINATION}/${NAME})
+                        endif ()
+                    endforeach ()
+                else ()
+                    # Use a single symlink pointing to the source directory
+                    if (NOT IS_SYMLINK ${ARG_DESTINATION} AND NOT CMAKE_HOST_WIN32)
+                        execute_process (COMMAND ${CMAKE_COMMAND} -E remove_directory ${ARG_DESTINATION})
+                    endif ()
+                    create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION} FALLBACK_TO_COPY)
+                endif ()
+            else ()
+                # Source is a file (it could also be actually a directory to be treated as a "file", i.e. for creating symlink pointing to the directory)
+                get_filename_component (NAME ${INSTALL_SOURCE} NAME)
+                create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION}/${NAME} FALLBACK_TO_COPY)
+                if (ARG_ACCUMULATE)
+                    list (APPEND ${ARG_ACCUMULATE} ${ARG_DESTINATION}/${NAME})
+                endif ()
+            endif ()
+        endforeach ()
     endif ()
     endif ()
-    setup_target ()
+endmacro ()
 
 
-    # Setup the compiler flags for building shared library
-    if (LIB_TYPE STREQUAL SHARED_LIBRARY)
-        # Hide the symbols that are not explicitly marked for export
-        add_compiler_export_flags ()
+# Macro for setting common output directories
+macro (set_output_directories OUTPUT_PATH)
+    cmake_parse_arguments (ARG LOCAL "" "" ${ARGN})
+    if (ARG_LOCAL)
+        unset (SCOPE)
+        unset (OUTPUT_DIRECTORY_PROPERTIES)
+    else ()
+        set (SCOPE CMAKE_)
     endif ()
     endif ()
-
-    if (PROJECT_NAME STREQUAL Urho3D)
-        # Accumulate all the dependent static libraries that are used in building the Urho3D library itself
-        if (NOT ${TARGET_NAME} STREQUAL Urho3D AND LIB_TYPE STREQUAL STATIC_LIBRARY)
-            set (STATIC_LIBRARY_TARGETS ${STATIC_LIBRARY_TARGETS} ${TARGET_NAME} PARENT_SCOPE)
-            # When performing Xcode CI build suppress all the warnings for 3rd party libraries because there are just too many of them
-            if (XCODE AND DEFINED ENV{CI})
-                set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
-                set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
-            endif ()
+    foreach (TYPE ${ARG_UNPARSED_ARGUMENTS})
+        set (${SCOPE}${TYPE}_OUTPUT_DIRECTORY ${OUTPUT_PATH})
+        list (APPEND OUTPUT_DIRECTORY_PROPERTIES ${TYPE}_OUTPUT_DIRECTORY ${${TYPE}_OUTPUT_DIRECTORY})
+        foreach (CONFIG ${CMAKE_CONFIGURATION_TYPES})
+            string (TOUPPER ${CONFIG} CONFIG)
+            set (${SCOPE}${TYPE}_OUTPUT_DIRECTORY_${CONFIG} ${OUTPUT_PATH})
+            list (APPEND OUTPUT_DIRECTORY_PROPERTIES ${TYPE}_OUTPUT_DIRECTORY_${CONFIG} ${${TYPE}_OUTPUT_DIRECTORY_${CONFIG}})
+        endforeach ()
+        if (TYPE STREQUAL RUNTIME AND NOT ${OUTPUT_PATH} STREQUAL .)
+            file (RELATIVE_PATH REL_OUTPUT_PATH ${CMAKE_BINARY_DIR} ${OUTPUT_PATH})
+            set (DEST_RUNTIME_DIR ${REL_OUTPUT_PATH})
         endif ()
         endif ()
-    elseif (URHO3D_SCP_TO_TARGET)
-        add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND scp $<TARGET_FILE:${TARGET_NAME}> ${URHO3D_SCP_TO_TARGET} || exit 0
-            COMMENT "Scp-ing ${TARGET_NAME} library to target system")
+    endforeach ()
+    if (ARG_LOCAL)
+        list (APPEND TARGET_PROPERTIES ${OUTPUT_DIRECTORY_PROPERTIES})
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
@@ -1152,33 +1349,49 @@ macro (setup_executable)
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
-# Macro for finding file in Urho3D build tree or Urho3D SDK
-macro (find_Urho3D_file VAR NAME)
-    # Pass the arguments to the actual find command
-    cmake_parse_arguments (ARG "" "DOC;MSG_MODE" "HINTS;PATHS;PATH_SUFFIXES" ${ARGN})
-    find_file (${VAR} ${NAME} HINTS ${ARG_HINTS} PATHS ${ARG_PATHS} PATH_SUFFIXES ${ARG_PATH_SUFFIXES} DOC ${ARG_DOC} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
-    mark_as_advanced (${VAR})  # Hide it from cmake-gui in non-advanced mode
-    if (NOT ${VAR} AND ARG_MSG_MODE)
-        message (${ARG_MSG_MODE}
-            "Could not find ${VAR} file in the Urho3D build tree or Urho3D SDK. "
-            "Please reconfigure and rebuild your Urho3D build tree or reinstall the SDK for the correct target platform.")
+# Macro for setting up a library target
+# Macro arguments:
+#  NODEPS - setup library target without defining Urho3D dependency libraries (applicable for downstream projects)
+#  STATIC/SHARED/MODULE/EXCLUDE_FROM_ALL - see CMake help on add_library() command
+# CMake variables:
+#  SOURCE_FILES - list of source files
+#  INCLUDE_DIRS - list of directories for include search path
+#  LIBS - list of dependent libraries that are built internally in the project
+#  ABSOLUTE_PATH_LIBS - list of dependent libraries that are external to the project
+#  LINK_DEPENDS - list of additional files on which a target binary depends for linking (Makefile-based generator only)
+#  TARGET_PROPERTIES - list of target properties
+macro (setup_library)
+    cmake_parse_arguments (ARG NODEPS "" "" ${ARGN})
+    check_source_files ()
+    add_library (${TARGET_NAME} ${ARG_UNPARSED_ARGUMENTS} ${SOURCE_FILES})
+    get_target_property (LIB_TYPE ${TARGET_NAME} TYPE)
+    if (NOT ARG_NODEPS AND NOT PROJECT_NAME STREQUAL Urho3D)
+        define_dependency_libs (Urho3D)
     endif ()
     endif ()
-endmacro ()
+    if (XCODE AND LUAJIT_SHARED_LINKER_FLAGS_APPLE AND LIB_TYPE STREQUAL SHARED_LIBRARY)
+        list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_LDFLAGS[arch=x86_64] "${LUAJIT_SHARED_LINKER_FLAGS_APPLE} $(OTHER_LDFLAGS)")    # Xcode universal build linker flags when targeting 64-bit OSX with LuaJIT enabled
+    endif ()
+    setup_target ()
 
 
-# Macro for finding tool in Urho3D build tree or Urho3D SDK
-macro (find_Urho3D_tool VAR NAME)
-    # Pass the arguments to the actual find command
-    cmake_parse_arguments (ARG "" "DOC;MSG_MODE" "HINTS;PATHS;PATH_SUFFIXES" ${ARGN})
-    find_program (${VAR} ${NAME} HINTS ${ARG_HINTS} PATHS ${ARG_PATHS} PATH_SUFFIXES ${ARG_PATH_SUFFIXES} DOC ${ARG_DOC} NO_DEFAULT_PATH)
-    mark_as_advanced (${VAR})  # Hide it from cmake-gui in non-advanced mode
-    if (NOT ${VAR})
-        set (${VAR} ${CMAKE_BINARY_DIR}/bin/tool/${NAME})
-        if (ARG_MSG_MODE AND NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
-            message (${ARG_MSG_MODE}
-                "Could not find ${VAR} tool in the Urho3D build tree or Urho3D SDK. Your project may not build successfully without this tool. "
-                "You may have to first rebuild the Urho3D in its build tree or reinstall Urho3D SDK to get this tool built or installed properly. "
-                "Alternatively, copy the ${VAR} executable manually into bin/tool subdirectory in your own project build tree.")
+    # Setup the compiler flags for building shared library
+    if (LIB_TYPE STREQUAL SHARED_LIBRARY)
+        # Hide the symbols that are not explicitly marked for export
+        add_compiler_export_flags ()
+    endif ()
+
+    if (PROJECT_NAME STREQUAL Urho3D)
+        # Accumulate all the dependent static libraries that are used in building the Urho3D library itself
+        if (NOT ${TARGET_NAME} STREQUAL Urho3D AND LIB_TYPE STREQUAL STATIC_LIBRARY)
+            set (STATIC_LIBRARY_TARGETS ${STATIC_LIBRARY_TARGETS} ${TARGET_NAME} PARENT_SCOPE)
+            # When performing Xcode CI build suppress all the warnings for 3rd party libraries because there are just too many of them
+            if (XCODE AND DEFINED ENV{CI})
+                set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
+                set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
+            endif ()
         endif ()
         endif ()
+    elseif (URHO3D_SCP_TO_TARGET)
+        add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND scp $<TARGET_FILE:${TARGET_NAME}> ${URHO3D_SCP_TO_TARGET} || exit 0
+            COMMENT "Scp-ing ${TARGET_NAME} library to target system")
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
@@ -1425,17 +1638,59 @@ macro (setup_main_executable)
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
-# Macro for adjusting target output name by dropping _suffix from the target name
-macro (adjust_target_name)
-    if (TARGET_NAME MATCHES _.*$)
-        string (REGEX REPLACE _.*$ "" OUTPUT_NAME ${TARGET_NAME})
-        set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
-    endif ()
-endmacro ()
-
-# Macro for setting up a test case
-macro (setup_test)
-    if (URHO3D_TESTING)
+# Macro for setting up dependency lib for compilation and linking of a target
+macro (setup_target)
+    # Include directories
+    include_directories (${INCLUDE_DIRS})
+    # Link libraries
+    define_dependency_libs (${TARGET_NAME})
+    target_link_libraries (${TARGET_NAME} ${ABSOLUTE_PATH_LIBS} ${LIBS})
+    # Enable PCH if requested
+    if (${TARGET_NAME}_HEADER_PATHNAME)
+        enable_pch (${${TARGET_NAME}_HEADER_PATHNAME})
+    endif ()
+    # Set additional linker dependencies (only work for Makefile-based generator according to CMake documentation)
+    if (LINK_DEPENDS)
+        string (REPLACE ";" "\;" LINK_DEPENDS "${LINK_DEPENDS}")        # Stringify for string replacement
+        list (APPEND TARGET_PROPERTIES LINK_DEPENDS "${LINK_DEPENDS}")  # Stringify with semicolons already escaped
+        unset (LINK_DEPENDS)
+    endif ()
+    # Extra compiler flags for Xcode which are dynamically changed based on active arch in order to support Mach-O universal binary targets
+    # We don't add the ABI flag for Xcode because it automatically passes '-arch i386' compiler flag when targeting 32 bit which does the same thing as '-m32'
+    if (XCODE)
+        # Speed up build when in Debug configuration by building active arch only
+        list (FIND TARGET_PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH ATTRIBUTE_ALREADY_SET)
+        if (ATTRIBUTE_ALREADY_SET EQUAL -1)
+            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)
+        endif ()
+        if (NOT URHO3D_SSE)
+            # Nullify the Clang default so that it is consistent with GCC
+            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CFLAGS[arch=i386] "-mno-sse $(OTHER_CFLAGS)")
+            list (APPEND TARGET_PROPERTIES XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=i386] "-mno-sse $(OTHER_CPLUSPLUSFLAGS)")
+        endif ()
+    endif ()
+    if (TARGET_PROPERTIES)
+        set_target_properties (${TARGET_NAME} PROPERTIES ${TARGET_PROPERTIES})
+        unset (TARGET_PROPERTIES)
+    endif ()
+
+    # Workaround CMake/Xcode generator bug where it always appends '/build' path element to SYMROOT attribute and as such the items in Products are always rendered as red in the Xcode IDE as if they are not yet built
+    if (NOT DEFINED ENV{TRAVIS})
+        if (XCODE AND NOT CMAKE_PROJECT_NAME MATCHES ^Urho3D-ExternalProject-)
+            file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/build)
+            get_target_property (LOCATION ${TARGET_NAME} LOCATION)
+            string (REGEX REPLACE "^.*\\$\\(CONFIGURATION\\)" $(CONFIGURATION) SYMLINK ${LOCATION})
+            get_filename_component (DIRECTORY ${SYMLINK} PATH)
+            add_custom_command (TARGET ${TARGET_NAME} POST_BUILD
+                COMMAND mkdir -p ${DIRECTORY} && ln -sf $<TARGET_FILE:${TARGET_NAME}> ${DIRECTORY}/$<TARGET_FILE_NAME:${TARGET_NAME}>
+                WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/build)
+        endif ()
+    endif ()
+endmacro ()
+
+# Macro for setting up a test case
+macro (setup_test)
+    if (URHO3D_TESTING)
         cmake_parse_arguments (ARG "" NAME OPTIONS ${ARGN})
         cmake_parse_arguments (ARG "" NAME OPTIONS ${ARGN})
         if (NOT ARG_NAME)
         if (NOT ARG_NAME)
             set (ARG_NAME ${TARGET_NAME})
             set (ARG_NAME ${TARGET_NAME})
@@ -1458,282 +1713,11 @@ macro (setup_test)
     endif ()
     endif ()
 endmacro ()
 endmacro ()
 
 
-# *** THIS IS A DEPRECATED MACRO ***
-# Macro for defining external library dependencies
-# The purpose of this macro is emulate CMake to set the external library dependencies transitively
-# It works for both targets setup within Urho3D project and downstream projects that uses Urho3D as external static/shared library
-# *** THIS IS A DEPRECATED MACRO ***
-macro (define_dependency_libs TARGET)
-    # ThirdParty/SDL external dependency
-    if (${TARGET} MATCHES SDL|Urho3D)
-        if (WIN32)
-            list (APPEND LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
-        elseif (APPLE)
-            list (APPEND LIBS iconv)
-        elseif (ANDROID)
-            list (APPEND LIBS dl log android)
-        else ()
-            # Linux
-            if (NOT WEB)
-                list (APPEND LIBS dl m rt)
-            endif ()
-            if (RPI)
-                list (APPEND ABSOLUTE_PATH_LIBS ${VIDEOCORE_LIBRARIES})
-            endif ()
-        endif ()
-    endif ()
-
-    # ThirdParty/kNet & ThirdParty/Civetweb external dependency
-    if (${TARGET} MATCHES Civetweb|kNet|Urho3D)
-        if (WIN32)
-            list (APPEND LIBS ws2_32)
-        endif ()
-    endif ()
-
-    # Urho3D/LuaJIT external dependency
-    if (URHO3D_LUAJIT AND ${TARGET} MATCHES LuaJIT|Urho3D)
-        if (NOT WIN32 AND NOT WEB)
-            list (APPEND LIBS dl m)
-        endif ()
-    endif ()
-
-    # Urho3D external dependency
-    if (${TARGET} STREQUAL Urho3D)
-        # Core
-        if (WIN32)
-            list (APPEND LIBS winmm)
-            if (URHO3D_MINIDUMPS)
-                list (APPEND LIBS dbghelp)
-            endif ()
-        elseif (APPLE)
-            if (IOS OR TVOS)
-                list (APPEND LIBS "-framework AudioToolbox" "-framework AVFoundation" "-framework CoreAudio" "-framework CoreGraphics" "-framework CoreMotion" "-framework Foundation" "-framework GameController" "-framework OpenGLES" "-framework QuartzCore" "-framework UIKit")
-            else ()
-                list (APPEND LIBS "-framework AudioToolbox" "-framework Carbon" "-framework Cocoa" "-framework CoreAudio" "-framework CoreServices" "-framework CoreVideo" "-framework ForceFeedback" "-framework IOKit" "-framework OpenGL")
-            endif ()
-        endif ()
-
-        # Graphics
-        if (URHO3D_OPENGL)
-            if (APPLE)
-                # Do nothing
-            elseif (WIN32)
-                list (APPEND LIBS opengl32)
-            elseif (ANDROID OR ARM)
-                list (APPEND LIBS GLESv1_CM GLESv2)
-            else ()
-                list (APPEND LIBS GL)
-            endif ()
-        elseif (DIRECT3D_LIBRARIES)
-            list (APPEND LIBS ${DIRECT3D_LIBRARIES})
-        endif ()
-
-        # Database
-        if (URHO3D_DATABASE_ODBC)
-            list (APPEND LIBS ${ODBC_LIBRARIES})
-        endif ()
-
-        # This variable value can either be 'Urho3D' target or an absolute path to an actual static/shared Urho3D library or empty (if we are building the library itself)
-        # The former would cause CMake not only to link against the Urho3D library but also to add a dependency to Urho3D target
-        if (URHO3D_LIBRARIES)
-            if (WIN32 AND URHO3D_LIBRARIES_DBG AND URHO3D_LIBRARIES_REL AND TARGET ${TARGET_NAME})
-                # Special handling when both debug and release libraries are found
-                target_link_libraries (${TARGET_NAME} debug ${URHO3D_LIBRARIES_DBG} optimized ${URHO3D_LIBRARIES_REL})
-            else ()
-                if (TARGET ${TARGET}_universal)
-                    add_dependencies (${TARGET_NAME} ${TARGET}_universal)
-                endif ()
-                list (APPEND ABSOLUTE_PATH_LIBS ${URHO3D_LIBRARIES})
-            endif ()
-        endif ()
-    endif ()
-endmacro ()
-
-# Macro for sorting and removing duplicate values
-macro (remove_duplicate LIST_NAME)
-    if (${LIST_NAME})
-        list (SORT ${LIST_NAME})
-        list (REMOVE_DUPLICATES ${LIST_NAME})
-    endif ()
-endmacro ()
-
-# Macro for setting a list from another with option to sort and remove duplicate values
-macro (set_list TO_LIST FROM_LIST)
-    set (${TO_LIST} ${${FROM_LIST}})
-    if (${ARGN} STREQUAL REMOVE_DUPLICATE)
-        remove_duplicate (${TO_LIST})
-    endif ()
-endmacro ()
-
-# Macro for defining source files with optional arguments as follows:
-#  GLOB_CPP_PATTERNS <list> - Use the provided globbing patterns for CPP_FILES instead of the default *.cpp
-#  GLOB_H_PATTERNS <list> - Use the provided globbing patterns for H_FILES instead of the default *.h
-#  EXCLUDE_PATTERNS <list> - Use the provided patterns for excluding matched source files
-#  EXTRA_CPP_FILES <list> - Include the provided list of files into CPP_FILES result
-#  EXTRA_H_FILES <list> - Include the provided list of files into H_FILES result
-#  PCH <list> - Enable precompiled header support on the defined source files using the specified header file, the list is "<path/to/header> [C++|C]"
-#  PARENT_SCOPE - Glob source files in current directory but set the result in parent-scope's variable ${DIR}_CPP_FILES and ${DIR}_H_FILES instead
-#  RECURSE - Option to glob recursively
-#  GROUP - Option to group source files based on its relative path to the corresponding parent directory (only works when PARENT_SCOPE option is not in use)
-macro (define_source_files)
-    # Source files are defined by globbing source files in current source directory and also by including the extra source files if provided
-    cmake_parse_arguments (ARG "PARENT_SCOPE;RECURSE;GROUP" "" "PCH;EXTRA_CPP_FILES;EXTRA_H_FILES;GLOB_CPP_PATTERNS;GLOB_H_PATTERNS;EXCLUDE_PATTERNS" ${ARGN})
-    if (NOT ARG_GLOB_CPP_PATTERNS)
-        set (ARG_GLOB_CPP_PATTERNS *.cpp)    # Default glob pattern
-    endif ()
-    if (NOT ARG_GLOB_H_PATTERNS)
-        set (ARG_GLOB_H_PATTERNS *.h)
-    endif ()
-    if (ARG_RECURSE)
-        set (ARG_RECURSE _RECURSE)
-    else ()
-        unset (ARG_RECURSE)
-    endif ()
-    file (GLOB${ARG_RECURSE} CPP_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${ARG_GLOB_CPP_PATTERNS})
-    file (GLOB${ARG_RECURSE} H_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${ARG_GLOB_H_PATTERNS})
-    if (ARG_EXCLUDE_PATTERNS)
-        set (CPP_FILES_WITH_SENTINEL ";${CPP_FILES};")  # Stringify the lists
-        set (H_FILES_WITH_SENTINEL ";${H_FILES};")
-        foreach (PATTERN ${ARG_EXCLUDE_PATTERNS})
-            foreach (LOOP RANGE 1)
-                string (REGEX REPLACE ";${PATTERN};" ";;" CPP_FILES_WITH_SENTINEL "${CPP_FILES_WITH_SENTINEL}")
-                string (REGEX REPLACE ";${PATTERN};" ";;" H_FILES_WITH_SENTINEL "${H_FILES_WITH_SENTINEL}")
-            endforeach ()
-        endforeach ()
-        set (CPP_FILES ${CPP_FILES_WITH_SENTINEL})      # Convert strings back to lists, extra sentinels are harmless
-        set (H_FILES ${H_FILES_WITH_SENTINEL})
-    endif ()
-    list (APPEND CPP_FILES ${ARG_EXTRA_CPP_FILES})
-    list (APPEND H_FILES ${ARG_EXTRA_H_FILES})
-    set (SOURCE_FILES ${CPP_FILES} ${H_FILES})
-
-    # Optionally enable PCH
-    if (ARG_PCH)
-        enable_pch (${ARG_PCH})
-    endif ()
-
-    # Optionally accumulate source files at parent scope
-    if (ARG_PARENT_SCOPE)
-        get_filename_component (NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
-        set (${NAME}_CPP_FILES ${CPP_FILES} PARENT_SCOPE)
-        set (${NAME}_H_FILES ${H_FILES} PARENT_SCOPE)
-    # Optionally put source files into further sub-group (only works when PARENT_SCOPE option is not in use)
-    elseif (ARG_GROUP)
-        foreach (CPP_FILE ${CPP_FILES})
-            get_filename_component (PATH ${CPP_FILE} PATH)
-            if (PATH)
-                string (REPLACE / \\ PATH ${PATH})
-                source_group ("Source Files\\${PATH}" FILES ${CPP_FILE})
-            endif ()
-        endforeach ()
-        foreach (H_FILE ${H_FILES})
-            get_filename_component (PATH ${H_FILE} PATH)
-            if (PATH)
-                string (REPLACE / \\ PATH ${PATH})
-                source_group ("Header Files\\${PATH}" FILES ${H_FILE})
-            endif ()
-        endforeach ()
-    endif ()
-endmacro ()
-
-# Macro for setting up header files installation for the SDK and the build tree (only support subset of install command arguments)
-#  FILES <list> - File list to be installed
-#  DIRECTORY <list> - Directory list to be installed
-#  FILES_MATCHING - Option to perform file pattern matching on DIRECTORY list
-#  USE_FILE_SYMLINK - Option to use file symlinks on the matched files found in the DIRECTORY list
-#  BUILD_TREE_ONLY - Option to install the header files into the build tree only
-#  PATTERN <list> - Pattern list to be used in file pattern matching option
-#  BASE <value> - An absolute base path to be prepended to the destination path when installing to build tree, default to build tree
-#  DESTINATION <value> - A relative destination path to be installed to
-#  ACCUMULATE <value> - Accumulate the header files into the specified CMake variable, implies USE_FILE_SYMLINK when input list is a directory
-macro (install_header_files)
-    # Need to check if the destination variable is defined first because this macro could be called by downstream project that does not wish to install anything
-    if (DEST_INCLUDE_DIR)
-        # Parse the arguments for the underlying install command for the SDK
-        cmake_parse_arguments (ARG "FILES_MATCHING;USE_FILE_SYMLINK;BUILD_TREE_ONLY" "BASE;DESTINATION;ACCUMULATE" "FILES;DIRECTORY;PATTERN" ${ARGN})
-        unset (INSTALL_MATCHING)
-        if (ARG_FILES)
-            set (INSTALL_TYPE FILES)
-            set (INSTALL_SOURCES ${ARG_FILES})
-        elseif (ARG_DIRECTORY)
-            set (INSTALL_TYPE DIRECTORY)
-            set (INSTALL_SOURCES ${ARG_DIRECTORY})
-            if (ARG_FILES_MATCHING)
-                set (INSTALL_MATCHING FILES_MATCHING)
-                # Our macro supports PATTERN <list> but CMake's install command does not, so convert the list to: PATTERN <value1> PATTERN <value2> ...
-                foreach (PATTERN ${ARG_PATTERN})
-                    list (APPEND INSTALL_MATCHING PATTERN ${PATTERN})
-                endforeach ()
-            endif ()
-        else ()
-            message (FATAL_ERROR "Couldn't setup install command because the install type is not specified.")
-        endif ()
-        if (NOT ARG_DESTINATION)
-            message (FATAL_ERROR "Couldn't setup install command because the install destination is not specified.")
-        endif ()
-        if (NOT ARG_BUILD_TREE_ONLY AND NOT CMAKE_PROJECT_NAME MATCHES ^Urho3D-ExternalProject-)
-            install (${INSTALL_TYPE} ${INSTALL_SOURCES} DESTINATION ${ARG_DESTINATION} ${INSTALL_MATCHING})
-        endif ()
-
-        # Reparse the arguments for the create_symlink macro to "install" the header files in the build tree
-        if (NOT ARG_BASE)
-            set (ARG_BASE ${CMAKE_BINARY_DIR})  # Use build tree as base path
-        endif ()
-        foreach (INSTALL_SOURCE ${INSTALL_SOURCES})
-            if (NOT IS_ABSOLUTE ${INSTALL_SOURCE})
-                set (INSTALL_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/${INSTALL_SOURCE})
-            endif ()
-            if (INSTALL_SOURCE MATCHES /$)
-                # Source is a directory
-                if (ARG_USE_FILE_SYMLINK OR ARG_ACCUMULATE OR BASH_ON_WINDOWS)
-                    # Use file symlink for each individual files in the source directory
-                    if (IS_SYMLINK ${ARG_DESTINATION} AND NOT CMAKE_HOST_WIN32)
-                        execute_process (COMMAND ${CMAKE_COMMAND} -E remove ${ARG_DESTINATION})
-                    endif ()
-                    set (GLOBBING_EXPRESSION RELATIVE ${INSTALL_SOURCE})
-                    if (ARG_FILES_MATCHING)
-                        foreach (PATTERN ${ARG_PATTERN})
-                            list (APPEND GLOBBING_EXPRESSION ${INSTALL_SOURCE}${PATTERN})
-                        endforeach ()
-                    else ()
-                        list (APPEND GLOBBING_EXPRESSION ${INSTALL_SOURCE}*)
-                    endif ()
-                    file (GLOB_RECURSE NAMES ${GLOBBING_EXPRESSION})
-                    foreach (NAME ${NAMES})
-                        get_filename_component (PATH ${ARG_DESTINATION}/${NAME} PATH)
-                        # Recreate the source directory structure in the destination path
-                        if (NOT EXISTS ${ARG_BASE}/${PATH})
-                            file (MAKE_DIRECTORY ${ARG_BASE}/${PATH})
-                        endif ()
-                        create_symlink (${INSTALL_SOURCE}${NAME} ${ARG_DESTINATION}/${NAME} FALLBACK_TO_COPY)
-                        if (ARG_ACCUMULATE)
-                            list (APPEND ${ARG_ACCUMULATE} ${ARG_DESTINATION}/${NAME})
-                        endif ()
-                    endforeach ()
-                else ()
-                    # Use a single symlink pointing to the source directory
-                    if (NOT IS_SYMLINK ${ARG_DESTINATION} AND NOT CMAKE_HOST_WIN32)
-                        execute_process (COMMAND ${CMAKE_COMMAND} -E remove_directory ${ARG_DESTINATION})
-                    endif ()
-                    create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION} FALLBACK_TO_COPY)
-                endif ()
-            else ()
-                # Source is a file (it could also be actually a directory to be treated as a "file", i.e. for creating symlink pointing to the directory)
-                get_filename_component (NAME ${INSTALL_SOURCE} NAME)
-                create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION}/${NAME} FALLBACK_TO_COPY)
-                if (ARG_ACCUMULATE)
-                    list (APPEND ${ARG_ACCUMULATE} ${ARG_DESTINATION}/${NAME})
-                endif ()
-            endif ()
-        endforeach ()
-    endif ()
-endmacro ()
-
-# Trim the leading white space in the compiler flags, if any
-string (REGEX REPLACE "^ +" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
-string (REGEX REPLACE "^ +" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-
-# Set common project structure for some platforms
+# Set common project structure for all platforms
+if (NOT DEST_RUNTIME_DIR)
+    # Set common binary output directory if not already set (note that this module can be included in an external project which may already have DEST_RUNTIME_DIR preset)
+    set_output_directories (${CMAKE_BINARY_DIR}/bin RUNTIME PDB)
+endif ()
 if (ANDROID)
 if (ANDROID)
     # Enable Android ndk-gdb
     # Enable Android ndk-gdb
     if (ANDROID_NDK_GDB)
     if (ANDROID_NDK_GDB)

+ 4 - 4
CMakeLists.txt

@@ -20,7 +20,7 @@
 # THE SOFTWARE.
 # THE SOFTWARE.
 #
 #
 
 
-# Set CMake minimum version and CMake policy required by Urho3D-CMake-common module
+# Set CMake minimum version and CMake policy required by UrhoCommon module
 cmake_minimum_required (VERSION 3.2.3)
 cmake_minimum_required (VERSION 3.2.3)
 if (COMMAND cmake_policy)
 if (COMMAND cmake_policy)
     # Libraries linked via full path no longer produce linker search paths
     # Libraries linked via full path no longer produce linker search paths
@@ -39,8 +39,8 @@ project (Urho3D)
 # Set CMake modules search path
 # Set CMake modules search path
 set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
 set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
 
 
-# Include Urho3D CMake common module
-include (Urho3D-CMake-common)
+# Include UrhoCommon.cmake module after setting project name
+include (UrhoCommon)
 
 
 # Setup SDK install destinations
 # Setup SDK install destinations
 set (PATH_SUFFIX Urho3D)
 set (PATH_SUFFIX Urho3D)
@@ -69,7 +69,7 @@ set (DEST_LIBRARY_DIR lib${LIB_SUFFIX}/${PATH_SUFFIX})
 set (DEST_PKGCONFIG_DIR lib${LIB_SUFFIX}/pkgconfig)
 set (DEST_PKGCONFIG_DIR lib${LIB_SUFFIX}/pkgconfig)
 # Install application launcher scripts
 # Install application launcher scripts
 file (GLOB APP_SCRIPTS ${CMAKE_SOURCE_DIR}/bin/*${SCRIPT_EXT})
 file (GLOB APP_SCRIPTS ${CMAKE_SOURCE_DIR}/bin/*${SCRIPT_EXT})
-install (PROGRAMS ${APP_SCRIPTS} DESTINATION ${DEST_RUNTIME_DIR})   # DEST_RUNTIME_DIR variable is set by the set_output_directories() macro call in the Urho3D-CMake-common module
+install (PROGRAMS ${APP_SCRIPTS} DESTINATION ${DEST_RUNTIME_DIR})   # DEST_RUNTIME_DIR variable is set by the set_output_directories() macro call in the UrhoCommon module
 # Install resource directories required by applications built with Urho3D library
 # Install resource directories required by applications built with Urho3D library
 install (DIRECTORY ${CMAKE_SOURCE_DIR}/bin/Autoload ${CMAKE_SOURCE_DIR}/bin/CoreData ${CMAKE_SOURCE_DIR}/bin/Data DESTINATION ${DEST_SHARE_DIR}/Resources)
 install (DIRECTORY ${CMAKE_SOURCE_DIR}/bin/Autoload ${CMAKE_SOURCE_DIR}/bin/CoreData ${CMAKE_SOURCE_DIR}/bin/Data DESTINATION ${DEST_SHARE_DIR}/Resources)
 # Install CMake modules and toolchains provided by and for Urho3D
 # Install CMake modules and toolchains provided by and for Urho3D

+ 4 - 4
Docs/GettingStarted.dox

@@ -566,7 +566,7 @@ The physical project root directory is also the logical project source tree in C
 In your own project root directory, create a main CMakeLists.txt file and add the following lines: (replace MyProjectName and MyExecutableName with the actual names you want)
 In your own project root directory, create a main CMakeLists.txt file and add the following lines: (replace MyProjectName and MyExecutableName with the actual names you want)
 
 
 \code
 \code
-# Set CMake minimum version and CMake policy required by Urho3D-CMake-common module
+# Set CMake minimum version and CMake policy required by UrhoCommon module
 cmake_minimum_required (VERSION 3.2.3)
 cmake_minimum_required (VERSION 3.2.3)
 if (COMMAND cmake_policy)
 if (COMMAND cmake_policy)
     # Libraries linked via full path no longer produce linker search paths
     # Libraries linked via full path no longer produce linker search paths
@@ -585,8 +585,8 @@ project (MyProjectName)
 # Set CMake modules search path
 # Set CMake modules search path
 set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
 set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
 
 
-# Include Urho3D CMake common module
-include (Urho3D-CMake-common)
+# Include UrhoCommon.cmake module after setting project name
+include (UrhoCommon)
 
 
 # Define target name
 # Define target name
 set (TARGET_NAME MyExecutableName)
 set (TARGET_NAME MyExecutableName)
@@ -598,7 +598,7 @@ define_source_files ()
 setup_main_executable ()
 setup_main_executable ()
 \endcode
 \endcode
 
 
-The CMAKE_MODULE_PATH is setup so that CMake can find the Urho3D-specific CMake modules provided by Urho3D project inside your own project. The Urho3D-CMake-common.cmake is the module where all the reusable commands and macros are defined. It also gives your project cross-platform build capability similar to Urho3D project. It does this by automatically finding the required software library components specific for your target platform and configuring your project to use them together with the platform-specific compiler flags and definitions. It utilizes CMake-provided as well as Urho3D custom-made FindXXX modules to get the work done. So, it is important to get the CMAKE_MODULE_PATH setup correctly in your project early on.
+The CMAKE_MODULE_PATH is setup so that CMake can find the Urho3D-specific CMake modules provided by Urho3D project inside your own project. The UrhoCommon.cmake is the module where all the reusable commands and macros are defined. It also gives your project cross-platform build capability similar to Urho3D project. It does this by automatically finding the required software library components specific for your target platform and configuring your project to use them together with the platform-specific compiler flags and definitions. It utilizes CMake-provided as well as Urho3D custom-made FindXXX modules to get the work done. So, it is important to get the CMAKE_MODULE_PATH setup correctly in your project early on.
 
 
 Your own project naturally depends on Urho3D project, or to be more precise it depends on Urho3D library. The Urho3D library needs to be built first so that it can be found later by your own project. When using GCC/Clang or one of its derivatives, both Urho3D static and shared libraries could be potentially built/installed at a same location and coexist. In such cases the FindUrho3D.cmake module, the module responsible to find Urho3D software library component, has precedence to first find the static library type over over shared library type. However, you can use URHO3D_LIB_TYPE build option to override this precedence. When using MSVC compiler, both static and shared libraries could not be built/installed at a same location because both the static library and import library have a same file extension. However, for MSVC, it is possible to have both Release and Debug versions of either static or shared library type built/installed at a same location. In such cases the FindUrho3D.cmake module would automatically utilize both of Release and Debug versions as appropriate in your project for Release and Debug build configuration, respectively, without user intervention.
 Your own project naturally depends on Urho3D project, or to be more precise it depends on Urho3D library. The Urho3D library needs to be built first so that it can be found later by your own project. When using GCC/Clang or one of its derivatives, both Urho3D static and shared libraries could be potentially built/installed at a same location and coexist. In such cases the FindUrho3D.cmake module, the module responsible to find Urho3D software library component, has precedence to first find the static library type over over shared library type. However, you can use URHO3D_LIB_TYPE build option to override this precedence. When using MSVC compiler, both static and shared libraries could not be built/installed at a same location because both the static library and import library have a same file extension. However, for MSVC, it is possible to have both Release and Debug versions of either static or shared library type built/installed at a same location. In such cases the FindUrho3D.cmake module would automatically utilize both of Release and Debug versions as appropriate in your project for Release and Debug build configuration, respectively, without user intervention.
 
 

+ 3 - 3
Rakefile

@@ -712,7 +712,7 @@ def scaffolding dir, project = 'Scaffolding', target = 'Main'
   end
   end
   dir.gsub!(/\//, '\\') if ENV['OS']
   dir.gsub!(/\//, '\\') if ENV['OS']
   build_script = <<EOF
   build_script = <<EOF
-# Set CMake minimum version and CMake policy required by Urho3D-CMake-common module
+# Set CMake minimum version and CMake policy required by UrhoCommon module
 cmake_minimum_required (VERSION 3.2.3)
 cmake_minimum_required (VERSION 3.2.3)
 if (COMMAND cmake_policy)
 if (COMMAND cmake_policy)
     # Libraries linked via full path no longer produce linker search paths
     # Libraries linked via full path no longer produce linker search paths
@@ -731,8 +731,8 @@ project (#{project})
 # Set CMake modules search path
 # Set CMake modules search path
 set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
 set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
 
 
-# Include Urho3D CMake common module
-include (Urho3D-CMake-common)
+# Include UrhoCommon.cmake module after setting project name
+include (UrhoCommon)
 
 
 # Define target name
 # Define target name
 set (TARGET_NAME #{target})
 set (TARGET_NAME #{target})

+ 3 - 3
Source/Clang-Tools/CMakeLists.txt

@@ -27,7 +27,7 @@ if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # All Clang-tools must be natively built and output to bin/tool/clang subdir to differentiate them from the rest
     # All Clang-tools must be natively built and output to bin/tool/clang subdir to differentiate them from the rest
     set_output_directories (${CMAKE_BINARY_DIR}/bin/tool/clang RUNTIME PDB)
     set_output_directories (${CMAKE_BINARY_DIR}/bin/tool/clang RUNTIME PDB)
 else ()
 else ()
-    # Set CMake minimum version and CMake policy required by Urho3D-CMake-common module
+    # Set CMake minimum version and CMake policy required by UrhoCommon module
     cmake_minimum_required (VERSION 3.2.3)
     cmake_minimum_required (VERSION 3.2.3)
     if (COMMAND cmake_policy)
     if (COMMAND cmake_policy)
         # Libraries linked via full path no longer produce linker search paths
         # Libraries linked via full path no longer produce linker search paths
@@ -46,8 +46,8 @@ else ()
     # Set CMake modules search path
     # Set CMake modules search path
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
 
 
-    # Include Urho3D CMake common module
-    include (Urho3D-CMake-common)
+    # Include UrhoCommon.cmake module after setting project name
+    include (UrhoCommon)
 
 
     # Setup SDK-like include dir in the build tree for building the Clang-tools
     # Setup SDK-like include dir in the build tree for building the Clang-tools
     file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)
     file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DEST_INCLUDE_DIR}/ThirdParty)

+ 3 - 3
Source/ThirdParty/LuaJIT/CMakeLists.txt

@@ -24,7 +24,7 @@
 # The cross-compiling logic is ported to CMake as faithful as possible although currently Urho3D does not support all target archs supported by LuaJIT
 # The cross-compiling logic is ported to CMake as faithful as possible although currently Urho3D does not support all target archs supported by LuaJIT
 
 
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
-    # Set CMake minimum version and CMake policy required by Urho3D-CMake-common module
+    # Set CMake minimum version and CMake policy required by UrhoCommon module
     if (APPLE)
     if (APPLE)
         cmake_minimum_required (VERSION 3.4.1)
         cmake_minimum_required (VERSION 3.4.1)
     else ()
     else ()
@@ -47,8 +47,8 @@ if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Set CMake modules search path
     # Set CMake modules search path
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
 
 
-    # Include Urho3D CMake common module
-    include (Urho3D-CMake-common)
+    # Include UrhoCommon.cmake module after setting project name
+    include (UrhoCommon)
 
 
     # When performing Xcode CI build suppress all the warnings for 3rd party libraries because there are just too many of them
     # When performing Xcode CI build suppress all the warnings for 3rd party libraries because there are just too many of them
     if (XCODE AND DEFINED ENV{CI})
     if (XCODE AND DEFINED ENV{CI})

+ 3 - 3
Source/ThirdParty/LuaJIT/src/host/CMakeLists.txt

@@ -21,7 +21,7 @@
 #
 #
 
 
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
-    # Set CMake minimum version and CMake policy required by Urho3D-CMake-common module
+    # Set CMake minimum version and CMake policy required by UrhoCommon module
     if (APPLE)
     if (APPLE)
         cmake_minimum_required (VERSION 3.4.1)
         cmake_minimum_required (VERSION 3.4.1)
     else ()
     else ()
@@ -44,8 +44,8 @@ if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Set CMake modules search path
     # Set CMake modules search path
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
 
 
-    # Include Urho3D CMake common module
-    include (Urho3D-CMake-common)
+    # Include UrhoCommon.cmake module after setting project name
+    include (UrhoCommon)
 
 
     # Unescape the variables
     # Unescape the variables
     foreach (ESCAPED_VAR HOST_XCFLAGS TARGET_ARCH DASM_FLAGS DASM_ARCH)
     foreach (ESCAPED_VAR HOST_XCFLAGS TARGET_ARCH DASM_FLAGS DASM_ARCH)

+ 3 - 3
Source/ThirdParty/toluapp/src/bin/CMakeLists.txt

@@ -21,7 +21,7 @@
 #
 #
 
 
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
-    # Set CMake minimum version and CMake policy required by Urho3D-CMake-common module
+    # Set CMake minimum version and CMake policy required by UrhoCommon module
     cmake_minimum_required (VERSION 3.2.3)
     cmake_minimum_required (VERSION 3.2.3)
     if (COMMAND cmake_policy)
     if (COMMAND cmake_policy)
         # Libraries linked via full path no longer produce linker search paths
         # Libraries linked via full path no longer produce linker search paths
@@ -40,8 +40,8 @@ if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Set CMake modules search path
     # Set CMake modules search path
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
 
 
-    # Include Urho3D CMake common module
-    include (Urho3D-CMake-common)
+    # Include UrhoCommon.cmake module after setting project name
+    include (UrhoCommon)
 
 
     # When performing Xcode CI build suppress all the warnings for 3rd party libraries because there are just too many of them
     # When performing Xcode CI build suppress all the warnings for 3rd party libraries because there are just too many of them
     if (XCODE AND DEFINED ENV{CI})
     if (XCODE AND DEFINED ENV{CI})

+ 3 - 3
Source/Tools/PackageTool/CMakeLists.txt

@@ -21,7 +21,7 @@
 #
 #
 
 
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
 if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
-    # Set CMake minimum version and CMake policy required by Urho3D-CMake-common module
+    # Set CMake minimum version and CMake policy required by UrhoCommon module
     cmake_minimum_required (VERSION 3.2.3)
     cmake_minimum_required (VERSION 3.2.3)
     if (COMMAND cmake_policy)
     if (COMMAND cmake_policy)
         # Libraries linked via full path no longer produce linker search paths
         # Libraries linked via full path no longer produce linker search paths
@@ -40,8 +40,8 @@ if (NOT CMAKE_PROJECT_NAME STREQUAL Urho3D)
     # Set CMake modules search path
     # Set CMake modules search path
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
     set (CMAKE_MODULE_PATH ${BAKED_CMAKE_SOURCE_DIR}/CMake/Modules)
 
 
-    # Include Urho3D CMake common module
-    include (Urho3D-CMake-common)
+    # Include UrhoCommon.cmake module after setting project name
+    include (UrhoCommon)
 
 
     # Define additional source files
     # Define additional source files
     set (MINI_URHO_CPP_FILES
     set (MINI_URHO_CPP_FILES