Skip to content

Commit

Permalink
Spawn calls to cygwin to build PDF via dblatex on Windows - also add …
Browse files Browse the repository at this point in the history
…shortcuts to PDF to windows menu

refs #221

git-svn-id: https://svn.nexusformat.org/definitions/trunk@1078 e2afd93b-eb5f-4fc1-b239-527b97798288
  • Loading branch information
FreddieAkeroyd authored and Freddie Akeroyd committed May 4, 2012
1 parent fe4733e commit cce257d
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 15 deletions.
46 changes: 38 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,21 @@ endfunction()

function(configure_nxdl TARGET NXDL_DIR DIST_DIR NXDL_FILES)
foreach(F ${NXDL_FILES})
set(NXDL ${NXDL_DIR}/${F})
configure_release(${TARGET} ${NXDL} ${DIST_DIR}/${F})
set(NXDL ${NXDL_DIR}/${F})
configure_release(${TARGET} ${NXDL} ${DIST_DIR}/${F})
endforeach()
configure_release(${TARGET} ${NXDL_DIR}/nxdlformat.xsl ${DIST_DIR}/nxdlformat.xsl)
endfunction()

#
# convert a native windows path to its equivalent cygwin path
#
function(to_cygwin_path PATH RESULT)
file(TO_CMAKE_PATH ${PATH} CP) # changes \ to / on windows
string(REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" CP2 ${CP}) # c:/ -> /c/
set(${RESULT} "/cygdrive${CP2}" PARENT_SCOPE) # /c/ -> /cygdrive/c/
endfunction()

set(XSD_FILES NeXus.xsd nxdl.xsd nxdlTypes.xsd BASE.xsd)
add_custom_target("DoXSD" ALL)
foreach(F ${XSD_FILES})
Expand All @@ -75,8 +84,6 @@ set(NEXUS_DEFINITIONS "definitions")
set(NEXUS_MANUAL "manual")

find_package(PythonInterp)
find_package(LATEX)
find_program(DBLATEX dblatex)

if (WIN32)
find_program(XSLTPROC xsltproc PATHS "${CMAKE_SOURCE_DIR}/utils/win32")
Expand All @@ -85,10 +92,35 @@ else(WIN32)
endif()
find_program(SVNVERSION svnversion)

#configure_file("${PROJECT_SOURCE_DIR}/utils/win32/dblatex_cygwin.bat.in"
# "${PROJECT_BINARY_DIRECTORY}/utils/win32/dblatex_cygwin.bat"
# needed for windows NSIS installer
file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} CMAKE_SOURCE_DIR_NATIVE)
file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} CMAKE_BINARY_DIR_NATIVE)
string(REPLACE "\\" "\\\\" CMAKE_SOURCE_DIR_NATIVE_D ${CMAKE_SOURCE_DIR_NATIVE})
string(REPLACE "\\" "\\\\" CMAKE_BINARY_DIR_NATIVE_D ${CMAKE_BINARY_DIR_NATIVE})

#configure_file("${PROJECT_SOURCE_DIR}/utils/win32/dblatex_win.bat.in"
# "${PROJECT_BINARY_DIR}/dblatex_win.bat"
# @ONLY)


if(WIN32)
# we use cygwin on windows for dblatex etc
find_program(CYGPATH_EXECUTABLE cygpath PATHS "c:/cygwin" PATH_SUFFIXES "bin" DOC "CYGWIN cygpath program")
get_filename_component(CYGPATHDIR "${CYGPATH_EXECUTABLE}" PATH)
get_filename_component(CYGDIR "${CYGPATHDIR}/.." ABSOLUTE)
file(TO_NATIVE_PATH ${CYGDIR} CYGDIR_NATIVE)
configure_file("${PROJECT_SOURCE_DIR}/utils/win32/dblatex_cygwin.bat.in"
"${PROJECT_BINARY_DIR}/dblatex_cygwin.bat"
@ONLY)
if(IS_DIRECTORY "${CYGDIR}" AND EXISTS "${CYGDIR}/bin/dblatex")
set(DBLATEX "${PROJECT_BINARY_DIR}/dblatex_cygwin.bat")
else()
message(WARNING "CYGWIN dblatex NOT FOUND - no PDF documentation")
endif()
else()
find_package(LATEX)
find_program(DBLATEX dblatex)
endif()
# Recurse into the subdirectories.
#add_subdirectory (tutorial)
add_subdirectory (base_classes)
Expand All @@ -106,8 +138,6 @@ foreach(F ${XSD_FILES})
endforeach()
INSTALL(FILES LGPL DESTINATION ${NEXUS_DEFINITIONS} COMPONENT definitions)

file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} CMAKE_SOURCE_DIR_NATIVE)
string(REPLACE "\\" "\\\\" CMAKE_SOURCE_DIR_NATIVE_D ${CMAKE_SOURCE_DIR_NATIVE})
#
# set CPack packaging options
#
Expand Down
6 changes: 5 additions & 1 deletion CPackOptions.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ if (${CPACK_GENERATOR} STREQUAL "NSIS")
set(CPACK_PACKAGE_ICON "@CMAKE_SOURCE_DIR_NATIVE_D@\\package\\nexus.ico")
set(CPACK_NSIS_MUI_ICON "@CMAKE_SOURCE_DIR_NATIVE_D@\\package\\nexus.ico")
set(CPACK_NSIS_MUI_UNIICON "@CMAKE_SOURCE_DIR_NATIVE_D@\\package\\nexus.ico")
set(CPACK_NSIS_MENU_LINKS "manual/NeXusManual.html" "NeXus Manual" "definitions" "NeXus Definitions" "http://www.nexusformat.org/" "NeXus Web Site")
set(CPACK_NSIS_MENU_LINKS "manual/NeXusManual.html" "NeXus Manual (HTML)"
"manual/NeXusManual.pdf" "NeXus User Manual (PDF)"
"manual/NeXusRefDoc.pdf" "NeXus Reference Manual (PDF)"
"definitions" "NeXus Definitions (NXDL)"
"http://www.nexusformat.org/" "NeXus Web Site")
endif()

cpack_add_component(definitions
Expand Down
7 changes: 6 additions & 1 deletion README.cmake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ For example, in the top of the build directory run:
But this is just an example.
The sphinx version of the manual is not ready to use cmake.

If you are building a distribution kit on Windows using NSIS, see http://nsis.sourceforge.net/ZipDLL_plug-in if you get a ZipDLL error
If you are building a distribution kit on Windows using NSIS, see http://nsis.sourceforge.net/ZipDLL_plug-in if you get a ZipDLL error

Windows
-------

To build PDF documentation on windows cygwin is required - it is called from the windows build to run DBLATEX.
17 changes: 12 additions & 5 deletions manual/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ set(BUILT_NEXUSMANUAL NeXusManual.pdf NeXusManual.html NeXusRefDoc.pdf)

#set(CLEANING_LIST ${BUILT_NEXUSMANUAL} ${BUILT_NEXUSREFDOC} html/ classes/ types.xml units.xml nxdl_desc.xml)

# for details, see: http://dblatex.sourceforge.net/doc/sec-custom.html
set (DBLATEX_OPTS -P table.in.float=0 -P doc.lot.show="figure" -I"${CMAKE_SOURCE_DIR}/manual" -b pdftex -tpdf -x "--path" -x "${CMAKE_BINARY_DIR}/manual:${CMAKE_BINARY_DIR}/manual/classes" )
if(WIN32)
to_cygwin_path("${CMAKE_SOURCE_DIR}" CMAKE_SOURCE_DIR_DBLATEX)
to_cygwin_path("${CMAKE_BINARY_DIR}" CMAKE_BINARY_DIR_DBLATEX)
else()
set(CMAKE_SOURCE_DIR_DBLATEX "${CMAKE_SOURCE_DIR}")
set(CMAKE_BINARY_DIR_DBLATEX "${CMAKE_BINARY_DIR}")
endif()

# for details, see: http://dblatex.sourceforge.net/doc/sec-custom.html
set(DBLATEX_OPTS -P table.in.float=0 -P doc.lot.show="figure" -I"${CMAKE_SOURCE_DIR_DBLATEX}/manual" -b pdftex -tpdf -x "--path" -x "${CMAKE_BINARY_DIR_DBLATEX}/manual:${CMAKE_BINARY_DIR_DBLATEX}/manual/classes" )
set(OUTPUT_BASE_TEXT_FILES)
set(OUTPUT_BASE_XML_FILES)
set(OUTPUT_BASE_XML_TARGETS)
Expand Down Expand Up @@ -289,15 +296,15 @@ if (DBLATEX)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/manual/NeXusManual.pdf
COMMAND ${DBLATEX}
ARGS -V -Pset.book.num=1 ${DBLATEX_OPTS} ${CMAKE_SOURCE_DIR}/manual/NeXusManual.xml -o ${CMAKE_BINARY_DIR}/manual/NeXusManual.pdf
ARGS -V -Pset.book.num=1 ${DBLATEX_OPTS} -o ${CMAKE_BINARY_DIR_DBLATEX}/manual/NeXusManual.pdf ${CMAKE_SOURCE_DIR_DBLATEX}/manual/NeXusManual.xml
DEPENDS ${CMAKE_SOURCE_DIR}/manual/NeXusManual.xml
COMMENT "Generating NeXusManual.pdf"
)

add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/manual/NeXusRefDoc.pdf
COMMAND ${DBLATEX}
ARGS -V -Pset.book.num=2 ${DBLATEX_OPTS} ${CMAKE_SOURCE_DIR}/manual/NeXusManual.xml -o ${CMAKE_BINARY_DIR}/manual/NeXusRefDoc.pdf
ARGS -V -Pset.book.num=2 ${DBLATEX_OPTS} -o ${CMAKE_BINARY_DIR_DBLATEX}/manual/NeXusRefDoc.pdf ${CMAKE_SOURCE_DIR_DBLATEX}/manual/NeXusManual.xml
DEPENDS ${CMAKE_SOURCE_DIR}/manual/NeXusManual.xml
COMMENT "Generating NeXusRefDoc.pdf"
)
Expand Down Expand Up @@ -330,7 +337,7 @@ endif()


if (DBLATEX)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NeXusManual.pdf ${CMAKE_CURRENT_BINARY_DIR}/NeXusRefDoc.pdf DESTINATION ${NEXUS_MANUAL} COMPONENT manual)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NeXusManual.pdf ${CMAKE_CURRENT_BINARY_DIR}/NeXusRefDoc.pdf DESTINATION ${NEXUS_MANUAL} COMPONENT manual)
endif(DBLATEX)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NeXusManual.html DESTINATION ${NEXUS_MANUAL} COMPONENT manual)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html img examples DESTINATION ${NEXUS_MANUAL} COMPONENT manual PATTERN ".svn" EXCLUDE)
Expand Down
4 changes: 4 additions & 0 deletions utils/win32/dblatex_cygwin.bat.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
set CYGDIR=@CYGDIR_NATIVE@
set CYGPATH=%CYGDIR%\bin\cygpath.exe
%CYGDIR%\bin\bash.exe --login -c "dblatex %*"
6 changes: 6 additions & 0 deletions utils/win32/dblatex_win.bat.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
set MYDBLATEX=@DBLATEX_EXEC_NATIVE@
set MYPYTHON=@PYTHON_EXECUTABLE_NATIVE@
set MYCMAKEDIR=@CMAKE_SOURCE_DIR_NATIVE@
set PATH=%MYCMAKEDIR%\utils\win32;%PATH%
%MYPYTHON% %MYDBLATEX% %*

0 comments on commit cce257d

Please sign in to comment.