cmake: special target to build/install docs only
authorAlexander Alekhin <alexander.alekhin@intel.com>
Fri, 9 Dec 2016 17:03:05 +0000 (20:03 +0300)
committerAlexander Alekhin <alexander.alekhin@intel.com>
Tue, 13 Dec 2016 17:13:06 +0000 (20:13 +0300)
CMakeLists.txt
doc/CMakeLists.txt

index c6c8adb..3f2ceb9 100644 (file)
@@ -278,12 +278,14 @@ if (ANDROID)
   endif()
 endif()
 
-if(ANDROID OR WIN32)
-  set(OPENCV_DOC_INSTALL_PATH doc)
-elseif(INSTALL_TO_MANGLED_PATHS)
-  set(OPENCV_DOC_INSTALL_PATH share/OpenCV-${OPENCV_VERSION}/doc)
-else()
-  set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
+if(NOT DEFINED OPENCV_DOC_INSTALL_PATH)
+  if(ANDROID OR WIN32)
+    set(OPENCV_DOC_INSTALL_PATH doc)
+  elseif(INSTALL_TO_MANGLED_PATHS)
+    set(OPENCV_DOC_INSTALL_PATH share/OpenCV-${OPENCV_VERSION}/doc)
+  else()
+    set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
+  endif()
 endif()
 
 if(WIN32)
index 29d5a0a..ebb3855 100644 (file)
@@ -49,7 +49,7 @@ if(BUILD_DOCS AND HAVE_SPHINX)
   function(ocv_doc_add_file_to_fake_root source destination)
     add_custom_command(
       OUTPUT "${DOC_FAKE_ROOT}/${destination}"
-      COMMAND "${CMAKE_COMMAND}" -E copy "${source}" "${DOC_FAKE_ROOT}/${destination}"
+      COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${source}" "${DOC_FAKE_ROOT}/${destination}"
       DEPENDS "${source}"
       COMMENT "Copying ${destination} to fake root..."
       VERBATIM
@@ -184,4 +184,16 @@ if(HAVE_DOC_GENERATOR)
   foreach(f ${OPTIONAL_DOC_LIST})
     install(FILES "${f}" DESTINATION "${OPENCV_DOC_INSTALL_PATH}" OPTIONAL COMPONENT docs)
   endforeach()
+
+  # Alias to build/install docs only
+  set(__deps "")
+  foreach(target docs html_docs doxygen)
+    if(TARGET ${target})
+      list(APPEND __deps ${target})
+    endif()
+  endforeach()
+  add_custom_target(install_docs
+      DEPENDS ${__deps}
+      COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=docs -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+  )
 endif(HAVE_DOC_GENERATOR)