Revision: 75994
          http://sourceforge.net/p/brlcad/code/75994
Author:   starseeker
Date:     2020-06-01 14:51:37 +0000 (Mon, 01 Jun 2020)
Log Message:
-----------
Experiment with generator expressions and add_custom_command/add_custom_target. 
 Generator expressions will work only in COMMAND, so unfortunately we can't 
implement the most robust approach - i.e. specify the actual file outputs as 
the OUTPUT and DEPENDS arguments.  Instead, we use a stamp file specific to the 
command that generates a per-configuration stamp file using the 
CMAKE_CFG_INTDIR variable to detect if the build target has run for the current 
configuration.  This has the drawback that the build target will fail to detect 
the removal of the per-config output and re-run, but it will re-run if the 
stamp file is removed or (more importantly) if the source file is edited.

Modified Paths:
--------------
    brlcad/trunk/doc/docbook/CMakeLists.txt
    brlcad/trunk/misc/CMake/DocBook.cmake
    brlcad/trunk/misc/CMake/Path_Setup.cmake

Added Paths:
-----------
    brlcad/trunk/doc/docbook/db_dir_info.c

Modified: brlcad/trunk/doc/docbook/CMakeLists.txt
===================================================================
--- brlcad/trunk/doc/docbook/CMakeLists.txt     2020-06-01 14:05:53 UTC (rev 
75993)
+++ brlcad/trunk/doc/docbook/CMakeLists.txt     2020-06-01 14:51:37 UTC (rev 
75994)
@@ -1,3 +1,7 @@
+# Define a build target that builds a no-op executable, so we can ensure
+# a target for generator expression use regardless of other changes elsewhere
+# in the build system
+add_executable(db_dir_info db_dir_info.c)
 
 # We need various configuration files set up for DocBook processing tools
 add_subdirectory(resources)
@@ -14,20 +18,19 @@
   configure_file(${CMAKE_SOURCE_DIR}/doc/docbook/fop.xconf.in 
${CMAKE_BINARY_DIR}/doc/docbook/fop.xconf)
 endif(BRLCAD_EXTRADOCS_PDF)
 
+# For the html files, we need brlcad.css
+add_custom_command(
+  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/brlcad_css-${CMAKE_CFG_INTDIR}-done
+  COMMAND "${CMAKE_COMMAND}" -E copy_if_different 
${CMAKE_CURRENT_SOURCE_DIR}/css/brlcad.css 
$<TARGET_FILE_DIR:db_dir_info>/${RBIN_DIR}/${DOC_DIR}/html/css/brlcad.css
+  COMMAND "${CMAKE_COMMAND}" -E touch  
${CMAKE_CURRENT_BINARY_DIR}/brlcad_css-${CMAKE_CFG_INTDIR}-done
+  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/css/brlcad.css
+  )
+add_custom_target(brlcad_css DEPENDS 
${CMAKE_CURRENT_BINARY_DIR}/brlcad_css-${CMAKE_CFG_INTDIR}-done)
+install(FILES css/brlcad.css DESTINATION ${DOC_DIR}/html/css)
+
 # Include CMake macros for DocBook.
 include(${BRLCAD_SOURCE_DIR}/misc/CMake/DocBook.cmake)
 
-# For the html files, we need brlcad.css
-if(NOT CMAKE_CONFIGURATION_TYPES)
-  configure_file(css/brlcad.css 
${CMAKE_BINARY_DIR}/${DOC_DIR}/html/css/brlcad.css)
-else(NOT CMAKE_CONFIGURATION_TYPES)
-  foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
-    string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER)
-    configure_file(css/brlcad.css 
${CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}}/${DOC_DIR}/html/css/brlcad.css)
-  endforeach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
-endif(NOT CMAKE_CONFIGURATION_TYPES)
-install(FILES css/brlcad.css DESTINATION ${DOC_DIR}/html/css)
-
 add_subdirectory(articles)
 add_subdirectory(books)
 add_subdirectory(lessons)
@@ -35,10 +38,15 @@
 add_subdirectory(specifications)
 add_subdirectory(system)
 
-CMAKEFILES(README fop.xconf.in log4j.properties)
-CMAKEFILES(README.DB_authors_notes)
-CMAKEFILES(css/brlcad.css)
-CMAKEFILES(CMakeLists.txt)
+set(ignore_files
+  CMakeLists.txt
+  README
+  README.DB_authors_notes
+  css/brlcad.css
+  fop.xconf.in
+  log4j.properties
+  )
+CMAKEFILES(${ignore_files})
 
 # Local Variables:
 # tab-width: 8

Added: brlcad/trunk/doc/docbook/db_dir_info.c
===================================================================
--- brlcad/trunk/doc/docbook/db_dir_info.c                              (rev 0)
+++ brlcad/trunk/doc/docbook/db_dir_info.c      2020-06-01 14:51:37 UTC (rev 
75994)
@@ -0,0 +1,32 @@
+/*                     D B _ D I R _ I N F O . C
+ * BRL-CAD
+ *
+ * Published in 2020 by the United States Government.
+ * This work is in the public domain.
+ *
+ */
+/** @file dir_info.c
+ *
+ * This is a stub file, whose purpose is to provide the Docbook logic with an
+ * add_executable build target that can be passed to scripts in order to decode
+ * at runtime what the location of BR-CAD's build directory is.
+ *
+ * Unlike most other BRL-CAD logic, Docbook building may be done without any
+ * software build targets needing to be processed if the necessary system
+ * tools are in place.  Since it is otherwise difficult to reliably get the
+ * location of the current build directory in multiconfig build tools, this
+ * file is used to provide a db_dir_info build target to reference in CMake.
+ */
+
+int main() {
+}
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/doc/docbook/db_dir_info.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: brlcad/trunk/misc/CMake/DocBook.cmake
===================================================================
--- brlcad/trunk/misc/CMake/DocBook.cmake       2020-06-01 14:05:53 UTC (rev 
75993)
+++ brlcad/trunk/misc/CMake/DocBook.cmake       2020-06-01 14:51:37 UTC (rev 
75994)
@@ -148,6 +148,9 @@
 # Convenience target to launch all DocBook builds
 add_custom_target(docbook ALL)
 set_target_properties(docbook PROPERTIES FOLDER "DocBook")
+if (TARGET brlcad_css)
+  add_dependencies(docbook brlcad_css)
+endif (TARGET brlcad_css)
 
 macro(ADD_DOCBOOK fmts in_xml_files outdir deps_list)
 
@@ -256,6 +259,9 @@
        # the docbook targets are built.
        #add_custom_target(docbook-${fname_root}-${path_md5} DEPENDS ${outputs})
        #set_target_properties(docbook-${fname_root}-${path_md5} PROPERTIES 
FOLDER "DocBook")
+       #if (TARGET brlcad_css)
+       #  add_dependencies(docbook-${fname_root}-${path_md5} brlcad_css)
+       #endif (TARGET brlcad_css)
       endif(NOT "${outputs}" STREQUAL "")
 
     endforeach(fname ${xml_files})

Modified: brlcad/trunk/misc/CMake/Path_Setup.cmake
===================================================================
--- brlcad/trunk/misc/CMake/Path_Setup.cmake    2020-06-01 14:05:53 UTC (rev 
75993)
+++ brlcad/trunk/misc/CMake/Path_Setup.cmake    2020-06-01 14:51:37 UTC (rev 
75994)
@@ -40,6 +40,21 @@
   set(BIN_DIR bin)
 endif(NOT BIN_DIR)
 
+# Define a relative path that will "reset" a path back to
+# the point before BIN_DIR was appended.  This is primarily
+# useful when working with generator expressions
+unset(RBIN_DIR CACHE)
+set(LBIN_DIR "${BIN_DIR}")
+while (NOT "${LBIN_DIR}" STREQUAL "")
+  get_filename_component(LBDIR "${LBIN_DIR}" DIRECTORY)
+  set(LBIN_DIR "${LBDIR}")
+  if ("${RBIN_DIR}" STREQUAL "")
+    set(RBIN_DIR "..")
+  else ("${RBIN_DIR}" STREQUAL "")
+    set(RBIN_DIR "../${RBIN_DIR}")
+  endif ("${RBIN_DIR}" STREQUAL "")
+endwhile (NOT "${LBIN_DIR}" STREQUAL "")
+
 # The location in which to install BRL-CAD libraries.
 if(NOT LIB_DIR)
   set(LIB_DIR lib)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to