CMakeLists.txt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #
  2. # Copyright (c) 2008-2013 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-Docs)
  24. # There could be bug in CMake find_package() command, it currently does not honor NO_CMAKE_FIND_ROOT_PATH option for a non-rooted search as per CMake's documentation
  25. # As a workaround, we unset CMAKE_FIND_ROOT_PATH (even when we are cross-compiling) but in this scope ONLY in order to always do a non-rooted search for Doxygen package
  26. unset (CMAKE_FIND_ROOT_PATH)
  27. # Find Doxygen and DOT packages
  28. find_package (Doxygen QUIET)
  29. if (DOXYGEN_FOUND)
  30. # Generate platform specific Doxyfile automatically
  31. if (NOT USE_OPENGL EQUAL DOXYFILE_USE_OPENGL OR ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in IS_NEWER_THAN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
  32. set (DOXYFILE_USE_OPENGL ${USE_OPENGL} CACHE INTERNAL "USE_OPENGL flag when Doxyfile was last generated")
  33. if (USE_OPENGL)
  34. set (EXCLUDE_GRAPHICS_API Direct3D9)
  35. else ()
  36. set (EXCLUDE_GRAPHICS_API OpenGL)
  37. endif ()
  38. configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
  39. endif ()
  40. # Dump AngelScript and LuaScript API to Doxygen file if the tool is available
  41. # CMake's custom command output is intentionally set to mismatch with the tool's output file location to achieve two desired side-effect results:
  42. # 1) 'make clean' does not remove the generated ScriptAPI.dox and LuaScriptAPI.dox in the 'Docs' subdirectory
  43. # 2) ScriptAPI.dox and LuaScriptAPI.dox always get refreshed first before the 'doc' target is being built (similar to VS-only PRE_BUILD custom command)
  44. if (TARGET ScriptCompiler AND NOT CMAKE_CROSSCOMPILING)
  45. add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox
  46. COMMAND ${PROJECT_ROOT_DIR}/Bin/ScriptCompiler -dumpapi ScriptAPI.dox AngelScriptAPI.h
  47. DEPENDS Urho3D ScriptCompiler
  48. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  49. COMMENT "Dumping AngelScript API to ScriptAPI.dox")
  50. else ()
  51. add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox COMMAND echo dummy >${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox)
  52. endif ()
  53. if (ENABLE_LUAJIT)
  54. set (jit jit)
  55. endif ()
  56. if (TARGET lua${jit}_interpreter AND NOT CMAKE_CROSSCOMPILING)
  57. if (WIN32)
  58. file (GLOB pkglist ${PROJECT_ROOT_DIR}/Source/Engine/LuaScript/pkgs/*.pkg)
  59. else ()
  60. set (pkglist *.pkg)
  61. endif ()
  62. add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox
  63. COMMAND ${PROJECT_ROOT_DIR}/Bin/lua${jit} pkgToDox.lua ${CMAKE_CURRENT_SOURCE_DIR}/LuaScriptAPI.dox ${pkglist}
  64. DEPENDS Urho3D lua${jit}_interpreter
  65. WORKING_DIRECTORY ${PROJECT_ROOT_DIR}/Source/Engine/LuaScript/pkgs
  66. COMMENT "Dumping LuaScript API to LuaScriptAPI.dox")
  67. else ()
  68. add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox COMMAND echo dummy >${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox)
  69. endif ()
  70. # If ENABLE_DOCS build option is set then add the custom 'doc' target into the default 'all' target, i.e. a normal build would not only build the software but also the documentation
  71. if (ENABLE_DOCS_QUIET)
  72. set (ENABLE_DOCS 1)
  73. if (CMAKE_HOST_WIN32)
  74. set (REDIRECT_STDOUT 1>nul) # In quiet mode, redirect standard output stream of Doxygen to a null device
  75. else ()
  76. set (REDIRECT_STDOUT 1>/dev/null)
  77. endif ()
  78. endif ()
  79. if (ENABLE_DOCS)
  80. set (ALL ALL)
  81. endif ()
  82. # Add custom 'doc' target for generating Urho3D documentation
  83. add_custom_target (doc ${ALL}
  84. COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile ${REDIRECT_STDOUT}
  85. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox ${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox # Note: these two dependencies need to be made explicit or otherwise CMake would not automatically 'refresh' them with provided custom command
  86. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  87. COMMENT "Generating documentation with Doxygen")
  88. endif ()
  89. # Make sure html output directory exists and not empty
  90. file (WRITE ${CMAKE_CURRENT_SOURCE_DIR}/html/Readme.txt "If ENABLE_DOCS build option is not set then use 'make doc' command or an equivalent command in IDE to re-generate Urho3D documentation before calling 'make install' or its equivalent.")
  91. # Currently it is not possible to make built-in 'install' target to depend on 'doc' in CMake, therefore 'make doc' command need to be invoked manually before 'make install' in order to install the SDK with complete documentation
  92. # Unless, ENABLE_DOCS build option is set in which case the custom 'doc' target is part of the default 'all' target which in turn the 'install' target depends on, so a single 'make install' alone is suffice to install everything
  93. install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/html/ DESTINATION ${DEST_SHARE_DIR}/Docs USE_SOURCE_PERMISSIONS)