|
|
@@ -703,7 +703,22 @@ macro (setup_executable)
|
|
|
endif ()
|
|
|
if (DEST_RUNTIME_DIR)
|
|
|
# Need to check if the destination variable is defined first because this macro could be called by external project that does not wish to install anything
|
|
|
- install (TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${DEST_RUNTIME_DIR} BUNDLE DESTINATION ${DEST_BUNDLE_DIR})
|
|
|
+ if (EMSCRIPTEN)
|
|
|
+ # todo: Just use generator-expression when CMake minimum version is 3.0
|
|
|
+ if (CMAKE_VERSION VERSION_LESS 3.0)
|
|
|
+ get_target_property (LOCATION ${TARGET_NAME} LOCATION)
|
|
|
+ get_filename_component (LOCATION ${LOCATION} DIRECTORY)
|
|
|
+ else ()
|
|
|
+ set (LOCATION $<TARGET_FILE_DIR:${TARGET_NAME}>)
|
|
|
+ endif ()
|
|
|
+ unset (FILES)
|
|
|
+ foreach (EXT data html html.mem js)
|
|
|
+ list (APPEND FILES ${LOCATION}/${TARGET_NAME}.${EXT})
|
|
|
+ endforeach ()
|
|
|
+ install (FILES ${FILES} DESTINATION ${DEST_BUNDLE_DIR})
|
|
|
+ else ()
|
|
|
+ install (TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${DEST_RUNTIME_DIR} BUNDLE DESTINATION ${DEST_BUNDLE_DIR})
|
|
|
+ endif ()
|
|
|
endif ()
|
|
|
endmacro ()
|
|
|
|
|
|
@@ -764,7 +779,18 @@ macro (setup_main_executable)
|
|
|
set (PRELOAD_FLAGS "${PRELOAD_FLAGS} --preload-file ${RESOURCE_${DIR}_PATHNAME}@/${NAME}")
|
|
|
endif ()
|
|
|
endforeach ()
|
|
|
- set (PACKAGING_DEP DEPENDS PackageTool)
|
|
|
+ # Urho3D project builds the PackageTool as required; external project uses PackageTool found in the Urho3D build tree or Urho3D SDK
|
|
|
+ find_program (PACKAGE_TOOL PackageTool HINTS ${CMAKE_BINARY_DIR}/bin/tool ${URHO3D_HOME}/bin/tool DOC "Path to PackageTool" NO_DEFAULT_PATH)
|
|
|
+ if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
|
|
|
+ set (PACKAGING_DEP DEPENDS PackageTool)
|
|
|
+ elseif (NOT PACKAGE_TOOL)
|
|
|
+ message (WARNING "PackageTool was not found 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 PackageTool executable manually into bin/tool subdirectory in your own project build tree.")
|
|
|
+ endif ()
|
|
|
+ if (NOT PACKAGE_TOOL)
|
|
|
+ set (PACKAGE_TOOL ${CMAKE_BINARY_DIR}/bin/tool/PackageTool)
|
|
|
+ endif ()
|
|
|
set (PACKAGING_COMMENT " and packaging")
|
|
|
# The *.pak will be generated during build time, suppress error during CMake configuration/generation time
|
|
|
set_property (SOURCE ${RESOURCE_PAKS} PROPERTY GENERATED TRUE)
|
|
|
@@ -882,16 +908,14 @@ macro (setup_main_executable)
|
|
|
if (CMAKE_HOST_WIN32)
|
|
|
# On Windows host, always assumes there are changes so resource dirs would be repackaged in each build, however, still make sure the *.pak timestamp is not altered unnecessarily
|
|
|
if (URHO3D_PACKAGING)
|
|
|
- set (PACKAGING_COMMAND && echo Packaging ${DIR}... && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tool/PackageTool ${DIR} ${RESOURCE_${DIR}_PATHNAME}.new -c -q && ${CMAKE_COMMAND} -E copy_if_different ${RESOURCE_${DIR}_PATHNAME}.new ${RESOURCE_${DIR}_PATHNAME} && ${CMAKE_COMMAND} -E remove ${RESOURCE_${DIR}_PATHNAME}.new)
|
|
|
+ set (PACKAGING_COMMAND && echo Packaging ${DIR}... && ${PACKAGE_TOOL} ${DIR} ${RESOURCE_${DIR}_PATHNAME}.new -c -q && ${CMAKE_COMMAND} -E copy_if_different ${RESOURCE_${DIR}_PATHNAME}.new ${RESOURCE_${DIR}_PATHNAME} && ${CMAKE_COMMAND} -E remove ${RESOURCE_${DIR}_PATHNAME}.new)
|
|
|
endif ()
|
|
|
list (APPEND COMMANDS COMMAND ${CMAKE_COMMAND} -E touch ${DIR} ${PACKAGING_COMMAND})
|
|
|
else ()
|
|
|
# On Unix-like hosts, detect the changes in the resource directory recursively so they are only repackaged and/or rebundled (Xcode only) as necessary
|
|
|
if (URHO3D_PACKAGING)
|
|
|
- set (PACKAGING_COMMAND && echo Packaging ${DIR}... && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tool/PackageTool ${DIR} ${RESOURCE_${DIR}_PATHNAME} -c -q)
|
|
|
- # Below output command generates the output when it is not yet exists: if [ ! -e ${${RESOURCE_${DIR}_PATHNAME} ]; then ${PACKAGING_COMMAND}; fi
|
|
|
- # Alas, it cannot be done as concisely because of a known CMake bug (http://www.cmake.org/Bug/view.php?id=9317) in its handling of bash '[' operator
|
|
|
- set (OUTPUT_COMMAND ls -1 ${RESOURCE_${DIR}_PATHNAME} >/dev/null 2>&1 || \( true ${PACKAGING_COMMAND} \))
|
|
|
+ set (PACKAGING_COMMAND && echo Packaging ${DIR}... && ${PACKAGE_TOOL} ${DIR} ${RESOURCE_${DIR}_PATHNAME} -c -q)
|
|
|
+ set (OUTPUT_COMMAND test -e ${RESOURCE_${DIR}_PATHNAME} || \( true ${PACKAGING_COMMAND} \))
|
|
|
else ()
|
|
|
set (OUTPUT_COMMAND true) # Nothing to output
|
|
|
endif ()
|
|
|
@@ -1120,11 +1144,9 @@ macro (install_header_files)
|
|
|
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)
|
|
|
# Our macro supports PATTERN <list> but CMake's install command does not, so convert the list to: PATTERN <value1> PATTERN <value2> ...
|
|
|
@@ -1139,7 +1161,7 @@ macro (install_header_files)
|
|
|
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 ^ExternalProject-)
|
|
|
- install (${INSTALL_TYPE} ${INSTALL_SOURCES} DESTINATION ${ARG_DESTINATION} ${INSTALL_PERMISSIONS} ${INSTALL_MATCHING})
|
|
|
+ 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
|