CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #
  2. # Copyright (c) 2008-2017 the Urho3D project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22. # Set project name
  23. project (Urho3D-Tools)
  24. # Find Urho3D library
  25. find_package (Urho3D REQUIRED)
  26. include_directories (${URHO3D_INCLUDE_DIRS})
  27. # Urho3DPlayer target is rather special, although it is here, it is not a tool because it is built into target platform binary as opposed to host platform
  28. # In order to test the player on Web platform built using Emscripten, the request parameters need to be parsed into Module['argument'] (see https://github.com/kripken/emscripten/blob/master/src/emrun_prejs.js for inspiration)
  29. # The CTest could "run" the Urho3DPlayer.html with script name as parameter, thanks to emrun performing this parsing automatically
  30. # In a production environment, however, the request parameters parsing has to be done by the application itself one way or another
  31. if (URHO3D_ANGELSCRIPT OR URHO3D_LUA${JIT})
  32. # Add Urho3DPlayer as target only when one of the supported scripting subystems is enabled
  33. add_subdirectory (Urho3DPlayer)
  34. endif ()
  35. # Build PackageTool using host compiler toolchain
  36. if (CMAKE_CROSSCOMPILING AND URHO3D_PACKAGING)
  37. check_native_compiler_exist ()
  38. # When cross-compiling, build the host tool as external project
  39. include (ExternalProject)
  40. if (IOS OR TVOS)
  41. # When cross-compiling for iOS/tvOS the host environment has been altered by xcodebuild for the said platform, the following fix is required to reset the host environment before spawning another process to configure/generate project file for external project
  42. # Also workaround a known CMake/Xcode generator bug which prevents it from installing native tool binaries correctly
  43. set (ALTERNATE_COMMAND CMAKE_COMMAND /usr/bin/env -i PATH=$ENV{PATH} CC=${SAVED_CC} CXX=${SAVED_CXX} CI=$ENV{CI} ${CMAKE_COMMAND} BUILD_COMMAND bash -c "sed -i '' 's/\$$\(EFFECTIVE_PLATFORM_NAME\)//g' CMakeScripts/install_postBuildPhase.make*")
  44. else ()
  45. set (ALTERNATE_COMMAND CMAKE_COMMAND ${CMAKE_COMMAND} -E env CC=${SAVED_CC} CXX=${SAVED_CXX} CI=$ENV{CI} ${CMAKE_COMMAND})
  46. endif ()
  47. ExternalProject_Add (PackageTool
  48. SOURCE_DIR ${CMAKE_SOURCE_DIR}/Source/Tools/PackageTool
  49. CMAKE_ARGS -DDEST_RUNTIME_DIR=${CMAKE_BINARY_DIR}/bin/tool -DBAKED_CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DBAKED_CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
  50. ${ALTERNATE_COMMAND})
  51. add_make_clean_files (${CMAKE_BINARY_DIR}/bin/tool/PackageTool)
  52. if (CMAKE_HOST_WIN32 AND NOT HAS_MKLINK)
  53. add_dependencies (PackageTool Urho3D) # Ensure Urho3D headers are fresh when building PackageTool externally on Windows host system without MKLINK
  54. endif ()
  55. install (PROGRAMS ${CMAKE_BINARY_DIR}/bin/tool/PackageTool DESTINATION ${DEST_RUNTIME_DIR}/tool)
  56. endif ()
  57. if (URHO3D_TOOLS)
  58. # Urho3D tools
  59. add_subdirectory (AssetImporter)
  60. add_subdirectory (OgreImporter)
  61. add_subdirectory (PackageTool)
  62. add_subdirectory (RampGenerator)
  63. add_subdirectory (SpritePacker)
  64. if (URHO3D_ANGELSCRIPT)
  65. add_subdirectory (ScriptCompiler)
  66. endif ()
  67. elseif (NOT CMAKE_CROSSCOMPILING AND URHO3D_PACKAGING)
  68. # PackageTool target is required but we are not cross-compiling, so build it as per normal
  69. add_subdirectory (PackageTool)
  70. endif ()