This will add one new custom target per DB file.
Each target will run xmllint on one specific XML file.
If xmllint fails - xml is not valid - the target fails,
and the whole build fails - so if there is an issue,
it will be noticeable.
---
 CMakeLists.txt | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b85656c..0bfaaa2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,7 @@ OPTION(BUILD_FOR_SSE "Build with support for SSE" ${X86_ON})
 OPTION(BUILD_FOR_SSE2 "Build with support for SSE2" ${X86_ON})
 OPTION(BUILD_DOC "Build documentation with doxygen" OFF)
 OPTION(INSTALL_HELPER_SCRIPTS "Install various helper scripts" ON)
+option(USE_XMLLINT "Run xmllint to test if data/db/*.xml are valid" ON)
 
 IF(NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE Debug CACHE STRING
@@ -142,6 +143,17 @@ IF(WIN32)
   ENDIF(MSVC)
 ENDIF(WIN32)
 
+# do we have xmllint?
+if(USE_XMLLINT)
+  find_program(Xmllint_BIN xmllint)
+  if(${Xmllint_BIN} STREQUAL "Xmllint_BIN-NOTFOUND")
+    message(STATUS "Missing xmllint")
+    set(USE_XMLLINT OFF)
+  else(${Xmllint_BIN} STREQUAL "Xmllint_BIN-NOTFOUND")
+    message(STATUS "Found xmllint")
+  endif(${Xmllint_BIN} STREQUAL "Xmllint_BIN-NOTFOUND")
+endif(USE_XMLLINT)
+
 # create config.h file
 CONFIGURE_FILE(include/lensfun/config.h.in.cmake ${CMAKE_BINARY_DIR}/config.h)
 # create lensfun.h file
@@ -167,9 +179,26 @@ ENDIF()
 
 # install db files
 FILE(GLOB DATABASE_FILES data/db/*.xml)
+
+if(USE_XMLLINT)
+  foreach(database ${DATABASE_FILES})
+    get_filename_component(DBNAME ${database} NAME_WE)
+    add_custom_target(
+      validate_${DBNAME} ALL
+      COMMAND ${Xmllint_BIN} --valid --noout ${database}
+      DEPENDS ${database}
+      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
+      COMMENT "Checking validity of ${database}"
+    )
+  endforeach(database)
+endif(USE_XMLLINT)
+
 INSTALL(FILES ${DATABASE_FILES} DESTINATION 
${CMAKE_INSTALL_DATAROOTDIR}/lensfun/version_${LENSFUN_DB_VERSION})
 INSTALL(FILES data/db/timestamp.txt DESTINATION 
${CMAKE_INSTALL_DATAROOTDIR}/lensfun/version_${LENSFUN_DB_VERSION})
 
+FILE(GLOB DATABASE_DTD data/db/*.dtd)
+INSTALL(FILES ${DATABASE_DTD} DESTINATION 
${CMAKE_INSTALL_DATAROOTDIR}/lensfun/version_${LENSFUN_DB_VERSION})
+
 # build documentation
 IF(BUILD_DOC)
   ADD_SUBDIRECTORY(docs)
-- 
2.7.0


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Lensfun-users mailing list
Lensfun-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lensfun-users

Reply via email to