CMakeLists.txt 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #
  2. # Copyright (c) 2008-2014 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. # Macro for enabling IDE-specific integration with Urho3D documentation (See comments in Doxyfile for more detail instructions)
  25. macro (enable_help IDE)
  26. if (${IDE} OR CMAKE_EXTRA_GENERATOR MATCHES ${IDE})
  27. set (${IDE}_HELP YES)
  28. else ()
  29. set (${IDE}_HELP NO)
  30. endif ()
  31. endmacro ()
  32. # 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
  33. # 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
  34. unset (CMAKE_FIND_ROOT_PATH)
  35. # Find Doxygen and DOT packages
  36. find_package (Doxygen QUIET)
  37. if (DOXYGEN_FOUND)
  38. # Generate platform specific Doxyfile automatically
  39. if (NOT URHO3D_OPENGL EQUAL DOXYFILE_URHO3D_OPENGL OR ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in IS_NEWER_THAN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
  40. set (DOXYFILE_URHO3D_OPENGL ${URHO3D_OPENGL} CACHE INTERNAL "URHO3D_OPENGL flag when Doxyfile was last generated")
  41. if (URHO3D_OPENGL)
  42. set (EXCLUDE_GRAPHICS_API Direct3D9)
  43. else ()
  44. set (EXCLUDE_GRAPHICS_API OpenGL)
  45. endif ()
  46. foreach (IDE XCODE MSVC Eclipse CodeBlocks)
  47. enable_help (${IDE})
  48. endforeach ()
  49. configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
  50. endif ()
  51. # Dump AngelScript and LuaScript API to Doxygen file if the tool is available
  52. # CMake's custom command output is intentionally set to mismatch with the tool's output file location to achieve two desired side-effect results:
  53. # 1) 'make clean' does not remove the generated ScriptAPI.dox and LuaScriptAPI.dox in the 'Docs' subdirectory
  54. # 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)
  55. if (TARGET ScriptCompiler AND NOT CMAKE_CROSSCOMPILING)
  56. add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox
  57. COMMAND ${PROJECT_ROOT_DIR}/Bin/ScriptCompiler -dumpapi ScriptAPI.dox AngelScriptAPI.h
  58. DEPENDS Urho3D ScriptCompiler
  59. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  60. COMMENT "Dumping AngelScript API to ScriptAPI.dox")
  61. else ()
  62. add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox COMMAND echo dummy >${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox)
  63. endif ()
  64. if (TARGET tolua++ AND NOT CMAKE_CROSSCOMPILING)
  65. file (GLOB PKGS RELATIVE ${PROJECT_ROOT_DIR}/Source/Engine/LuaScript/pkgs ${PROJECT_ROOT_DIR}/Source/Engine/LuaScript/pkgs/*.pkg)
  66. list (SORT PKGS)
  67. set (PKGLIST "// This is a generated file. DO NOT EDIT!\n\n")
  68. foreach (PKG ${PKGS})
  69. set (PKGLIST "${PKGLIST}$pfile \"${PKG}\"\n")
  70. endforeach ()
  71. file (WRITE ${PROJECT_ROOT_DIR}/Bin/LuaPkgToDox.txt ${PKGLIST})
  72. add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox
  73. COMMAND ${PROJECT_ROOT_DIR}/Bin/tolua++ -L ToDoxHook.lua -P -o ${CMAKE_CURRENT_SOURCE_DIR}/LuaScriptAPI.dox ${PROJECT_ROOT_DIR}/Bin/LuaPkgToDox.txt
  74. DEPENDS Urho3D tolua++
  75. WORKING_DIRECTORY ${PROJECT_ROOT_DIR}/Source/Engine/LuaScript/pkgs
  76. COMMENT "Dumping LuaScript API to LuaScriptAPI.dox")
  77. else ()
  78. add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox COMMAND echo dummy >${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox)
  79. endif ()
  80. # If URHO3D_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
  81. if (URHO3D_DOCS_QUIET)
  82. set (URHO3D_DOCS 1)
  83. if (CMAKE_HOST_WIN32)
  84. set (REDIRECT_STDOUT 1>nul) # In quiet mode, redirect standard output stream of Doxygen to a null device
  85. else ()
  86. set (REDIRECT_STDOUT 1>/dev/null)
  87. endif ()
  88. endif ()
  89. if (URHO3D_DOCS)
  90. set (ALL ALL)
  91. endif ()
  92. # Add custom 'doc' target for generating Urho3D documentation
  93. add_custom_target (doc ${ALL}
  94. COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile ${REDIRECT_STDOUT}
  95. 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
  96. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  97. COMMENT "Generating documentation with Doxygen")
  98. endif ()
  99. # Make sure html output directory exists and not empty
  100. file (WRITE ${CMAKE_CURRENT_SOURCE_DIR}/html/Readme.txt "If URHO3D_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.")
  101. # 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
  102. # Unless, URHO3D_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
  103. install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/html/ DESTINATION ${DEST_SHARE_DIR}/Docs ${DEST_PERMISSIONS})