Browse Source

Fix documentation build on platforms that do not have tool targets.

- Prevent 'make clean' or its equivalent to remove the generated ScriptAPI.dox and LuaScriptAPI.dox in the 'Docs' subdirectory.
- Always refresh the generated API Doxygen files before building 'doc' target when the tools are available.
- Move document-build binary directory into the respective project main binary directory.
Yao Wei Tjong 姚伟忠 12 years ago
parent
commit
ac6d9f40b0

+ 27 - 7
Docs/CMakeLists.txt

@@ -42,28 +42,48 @@ if (DOXYGEN_FOUND)
     endif ()
     endif ()
 
 
     # Dump AngelScript and LuaScript API to Doxygen file if the tool is available
     # Dump AngelScript and LuaScript API to Doxygen file if the tool is available
+    # CMake's custom command output is intentionally set to mismatch with the tool's output file location to achieve two desired side-effect results:
+    # 1) 'make clean' does not remove the generated ScriptAPI.dox and LuaScriptAPI.dox in the 'Docs' subdirectory
+    # 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)
     if (TARGET ScriptCompiler)
     if (TARGET ScriptCompiler)
-        add_custom_command (OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/ScriptAPI.dox
-            COMMAND ${PROJECT_ROOT_DIR}/Bin/ScriptCompiler -dumpapi ScriptAPI.dox AngelScriptAPI.h DEPENDS Urho3D ScriptCompiler
+        add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox
+            COMMAND ${PROJECT_ROOT_DIR}/Bin/ScriptCompiler -dumpapi ScriptAPI.dox AngelScriptAPI.h
+            DEPENDS Urho3D ScriptCompiler
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
             COMMENT "Dumping AngelScript API to ScriptAPI.dox")
             COMMENT "Dumping AngelScript API to ScriptAPI.dox")
+    else ()
+        add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox COMMAND echo dummy >${CMAKE_CURRENT_BINARY_DIR}/ScriptAPI.dox)
+    endif ()
+    if (ENABLE_LUAJIT)
+        set (jit jit)
     endif ()
     endif ()
-    string (TOLOWER "${JIT}" jit)   # Note: ${JIT} could be empty if LuaJIT is not enabled
     if (TARGET lua${jit}_interpreter)
     if (TARGET lua${jit}_interpreter)
-        add_custom_command (OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/LuaScriptAPI.dox
-            COMMAND ${PROJECT_ROOT_DIR}/Bin/lua${jit} pkgToDox.lua ${CMAKE_CURRENT_SOURCE_DIR}/LuaScriptAPI.dox *.pkg DEPENDS Urho3D lua${jit}_interpreter ${PROJECT_ROOT_DIR}/Source/Engine/LuaScript/pkgs/pkgToDox.lua
+        add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox
+            COMMAND ${PROJECT_ROOT_DIR}/Bin/lua${jit} pkgToDox.lua ${CMAKE_CURRENT_SOURCE_DIR}/LuaScriptAPI.dox *.pkg
+            DEPENDS Urho3D lua${jit}_interpreter
             WORKING_DIRECTORY ${PROJECT_ROOT_DIR}/Source/Engine/LuaScript/pkgs
             WORKING_DIRECTORY ${PROJECT_ROOT_DIR}/Source/Engine/LuaScript/pkgs
             COMMENT "Dumping LuaScript API to LuaScriptAPI.dox")
             COMMENT "Dumping LuaScript API to LuaScriptAPI.dox")
+    else ()
+        add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox COMMAND echo dummy >${CMAKE_CURRENT_BINARY_DIR}/LuaScriptAPI.dox)
     endif ()
     endif ()
-    
+
     # 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
     # 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
+    if (ENABLE_DOCS_QUIET)
+        set (ENABLE_DOCS 1)
+        if (CMAKE_HOST_WIN32)
+            set (REDIRECT_STDOUT 1>nul)     # In quiet mode, redirect standard output stream of Doxygen to a null device
+        else ()
+            set (REDIRECT_STDOUT 1>/dev/null)
+        endif ()
+    endif ()
     if (ENABLE_DOCS)
     if (ENABLE_DOCS)
         set (ALL ALL)
         set (ALL ALL)
     endif ()
     endif ()
 
 
     # Add custom 'doc' target for generating Urho3D documentation
     # Add custom 'doc' target for generating Urho3D documentation
     add_custom_target (doc ${ALL}
     add_custom_target (doc ${ALL}
-        COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ScriptAPI.dox ${CMAKE_CURRENT_SOURCE_DIR}/LuaScriptAPI.dox   # Note: these two dependencies need to be made explicit or otherwise CMake would not automatically 'refresh' them with provided custom command
+        COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile ${REDIRECT_STDOUT}
+        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
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
         COMMENT "Generating documentation with Doxygen")
         COMMENT "Generating documentation with Doxygen")
 endif ()
 endif ()

+ 1 - 1
Source/CMakeLists.txt

@@ -113,4 +113,4 @@ if (NOT IOS AND NOT ANDROID AND ENABLE_EXTRAS)
 endif ()
 endif ()
 
 
 # Urho3D documentation
 # Urho3D documentation
-add_subdirectory (../Docs ../doc-Build)
+add_subdirectory (../Docs ${PROJECT_BINARY_DIR}/Docs)

+ 1 - 1
Source/ThirdParty/Lua/CMakeLists.txt

@@ -49,7 +49,7 @@ if (NOT IOS AND (NOT DEFINED ENABLE_TOOLS OR ENABLE_TOOLS))
 
 
     # Setup target
     # Setup target
     setup_executable ()
     setup_executable ()
-    adjust_target_name ()
+    adjust_target_name ()   # Adjust to intended target output name
 
 
     # Define target name for Lua compiler
     # Define target name for Lua compiler
     set (TARGET_NAME luac)
     set (TARGET_NAME luac)

+ 1 - 1
Source/ThirdParty/LuaJIT/CMakeLists.txt

@@ -284,5 +284,5 @@ if (NOT IOS AND (NOT DEFINED ENABLE_TOOLS OR ENABLE_TOOLS))
 
 
     # Setup target
     # Setup target
     setup_executable ()
     setup_executable ()
-    adjust_target_name ()
+    adjust_target_name ()   # Adjust to intended target output name
 endif ()
 endif ()