|
|
@@ -388,22 +388,37 @@ set_output_directories (${CMAKE_BINARY_DIR}/Bin RUNTIME PDB)
|
|
|
# Macro for setting symbolic link on platform that supports it
|
|
|
macro (create_symlink SOURCE DESTINATION)
|
|
|
if (CMAKE_HOST_WIN32)
|
|
|
+ if (IS_DIRECTORY ${SOURCE})
|
|
|
+ set (SLASH_D /D)
|
|
|
+ else ()
|
|
|
+ unset (SLASH_D)
|
|
|
+ endif ()
|
|
|
if (URHO3D_MKLINK)
|
|
|
- if (NOT EXISTS ${DESTINATION})
|
|
|
- if (IS_DIRECTORY ${SOURCE})
|
|
|
- set (MKLINK_OPT /D)
|
|
|
- else ()
|
|
|
- unset (MKLINK_OPT)
|
|
|
- endif ()
|
|
|
- execute_process (COMMAND mklink ${MKLINK_OPT} "${DESTINATION}" "${SOURCE}")
|
|
|
+ if (NOT EXISTS ${DESTINATION})
|
|
|
+ execute_process (COMMAND mklink ${SLASH_D} ${DESTINATION} ${SOURCE})
|
|
|
endif ()
|
|
|
elseif (${ARGN} STREQUAL FALLBACK_TO_COPY)
|
|
|
- execute_process (COMMAND -E copy_if_different "${SOURCE}" "${DESTINATION}")
|
|
|
+ if (NOT IS_ABSOLUTE ${SOURCE})
|
|
|
+ get_filename_component (PATH ${DESTINATION} PATH)
|
|
|
+ set (SOURCE ${PATH}/${SOURCE})
|
|
|
+ endif ()
|
|
|
+ if (SLASH_D)
|
|
|
+ set (COMMAND COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE} ${DESTINATION})
|
|
|
+ else ()
|
|
|
+ set (COMMAND COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SOURCE} ${DESTINATION})
|
|
|
+ endif ()
|
|
|
+ if (TARGET ${TARGET_NAME})
|
|
|
+ # Fallback to copy everytime the target is built
|
|
|
+ add_custom_command (TARGET ${TARGET_NAME} POST_BUILD ${COMMAND} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
|
|
+ else ()
|
|
|
+ # Fallback to copy only one time
|
|
|
+ execute_process (${COMMAND})
|
|
|
+ endif ()
|
|
|
else ()
|
|
|
message (WARNING "Unable to create symbolic link on this host system, you may need to manually copy file/dir from \"${SOURCE}\" to \"${DESTINATION}\"")
|
|
|
endif ()
|
|
|
else ()
|
|
|
- execute_process (COMMAND ${CMAKE_COMMAND} -E create_symlink "${SOURCE}" "${DESTINATION}")
|
|
|
+ execute_process (COMMAND ${CMAKE_COMMAND} -E create_symlink ${SOURCE} ${DESTINATION})
|
|
|
endif ()
|
|
|
endmacro ()
|
|
|
|
|
|
@@ -430,11 +445,11 @@ if (ANDROID)
|
|
|
endif ()
|
|
|
# Create symbolic links in the build tree
|
|
|
foreach (I CoreData Data)
|
|
|
- create_symlink (../../Bin/${I} ${CMAKE_SOURCE_DIR}/Android/assets/${I})
|
|
|
+ create_symlink (../../Bin/${I} ${CMAKE_SOURCE_DIR}/Android/assets/${I} FALLBACK_TO_COPY)
|
|
|
endforeach ()
|
|
|
foreach (I AndroidManifest.xml build.xml src res assets jni)
|
|
|
- if (EXISTS ${CMAKE_SOURCE_DIR}/Android/${I})
|
|
|
- create_symlink (${CMAKE_SOURCE_DIR}/Android/${I} ${CMAKE_BINARY_DIR}/${I})
|
|
|
+ if (EXISTS ${CMAKE_SOURCE_DIR}/Android/${I} AND NOT EXISTS ${CMAKE_BINARY_DIR}/${I}) # No-ops when 'Android' is used as build tree
|
|
|
+ create_symlink (${CMAKE_SOURCE_DIR}/Android/${I} ${CMAKE_BINARY_DIR}/${I} FALLBACK_TO_COPY)
|
|
|
endif ()
|
|
|
endforeach ()
|
|
|
endif ()
|
|
|
@@ -854,7 +869,7 @@ endmacro ()
|
|
|
# PCH - Enable precompiled header on the defined source files
|
|
|
# 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
|
|
|
macro (define_source_files)
|
|
|
- # Parse extra arguments
|
|
|
+ # Parse the arguments
|
|
|
cmake_parse_arguments (ARG "PCH;PARENT_SCOPE" "GROUP" "EXTRA_CPP_FILES;EXTRA_H_FILES;GLOB_CPP_PATTERNS;GLOB_H_PATTERNS" ${ARGN})
|
|
|
|
|
|
# Source files are defined by globbing source files in current source directory and also by including the extra source files if provided
|
|
|
@@ -886,3 +901,69 @@ macro (define_source_files)
|
|
|
source_group ("Header Files\\${ARG_GROUP}" FILES ${H_FILES})
|
|
|
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
|
|
|
+# PATTERN <list> - Pattern list to be used in file pattern matching option
|
|
|
+# DESTINATION <value> - Destination to be installed to
|
|
|
+macro (install_header_files)
|
|
|
+ # Parse the arguments for the underlying install command
|
|
|
+ cmake_parse_arguments (ARG "FILES_MATCHING;USE_FILE_SYMLINK" "DESTINATION" "FILES;DIRECTORY;PATTERN" ${ARGN})
|
|
|
+ unset (INSTALL_MATCHING)
|
|
|
+ if (ARG_FILES)
|
|
|
+ set (INSTALL_TYPE FILES)
|
|
|
+ set (INSTALL_SOURCES ${ARG_FILES})
|
|
|
+ unset (INSTALL_PERMISSIONS)
|
|
|
+ elseif (ARG_DIRECTORY)
|
|
|
+ set (INSTALL_TYPE DIRECTORY)
|
|
|
+ set (INSTALL_SOURCES ${ARG_DIRECTORY})
|
|
|
+ set (INSTALL_PERMISSIONS ${DEST_PERMISSIONS})
|
|
|
+ if (ARG_FILES_MATCHING)
|
|
|
+ set (INSTALL_MATCHING FILES_MATCHING)
|
|
|
+ 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 ()
|
|
|
+ install (${INSTALL_TYPE} ${INSTALL_SOURCES} DESTINATION ${ARG_DESTINATION} ${INSTALL_PERMISSIONS} ${INSTALL_MATCHING})
|
|
|
+
|
|
|
+ # Reparse the arguments for the create_symlink macro to "install" the header files in the build tree
|
|
|
+ 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 /$)
|
|
|
+ if (ARG_USE_FILE_SYMLINK)
|
|
|
+ if (ARG_FILES_MATCHING)
|
|
|
+ set (GLOBBING_EXPRESSION RELATIVE ${INSTALL_SOURCE})
|
|
|
+ foreach (PATTERN ${ARG_PATTERN})
|
|
|
+ list (APPEND GLOBBING_EXPRESSION ${INSTALL_SOURCE}${PATTERN})
|
|
|
+ endforeach ()
|
|
|
+ else ()
|
|
|
+ set (GLOBBING_EXPRESSION ${INSTALL_SOURCE}*)
|
|
|
+ endif ()
|
|
|
+ file (GLOB_RECURSE NAMES ${GLOBBING_EXPRESSION})
|
|
|
+ foreach (NAME ${NAMES})
|
|
|
+ get_filename_component (PATH ${NAME} PATH)
|
|
|
+ if (PATH AND NOT EXISTS ${ARG_DESTINATION}/${PATH})
|
|
|
+ file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${ARG_DESTINATION}/${PATH})
|
|
|
+ endif ()
|
|
|
+ create_symlink (${INSTALL_SOURCE}${NAME} ${ARG_DESTINATION}/${NAME} FALLBACK_TO_COPY)
|
|
|
+ endforeach ()
|
|
|
+ else ()
|
|
|
+ create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION} FALLBACK_TO_COPY)
|
|
|
+ endif ()
|
|
|
+ else ()
|
|
|
+ get_filename_component (NAME ${INSTALL_SOURCE} NAME)
|
|
|
+ create_symlink (${INSTALL_SOURCE} ${ARG_DESTINATION}/${NAME} FALLBACK_TO_COPY)
|
|
|
+ endif ()
|
|
|
+ endforeach ()
|
|
|
+endmacro ()
|