| 1 | ## Process this file with cmake |
|---|
| 2 | # $Id$ |
|---|
| 3 | #==================================================================== |
|---|
| 4 | # NeXus - A common data format for neutron, x-ray and muon science. |
|---|
| 5 | # |
|---|
| 6 | # CMakeLists for building the NeXus library and applications. |
|---|
| 7 | # |
|---|
| 8 | # Copyright (C) 2008-2012 NeXus International Advisory Committee (NIAC) |
|---|
| 9 | # |
|---|
| 10 | # This library is free software; you can redistribute it and/or |
|---|
| 11 | # modify it under the terms of the GNU Lesser General Public |
|---|
| 12 | # License as published by the Free Software Foundation; either |
|---|
| 13 | # version 2 of the License, or (at your option) any later version. |
|---|
| 14 | # |
|---|
| 15 | # This library is distributed in the hope that it will be useful, |
|---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 18 | # Lesser General Public License for more details. |
|---|
| 19 | # |
|---|
| 20 | # You should have received a copy of the GNU Lesser General Public |
|---|
| 21 | # License along with this library; if not, write to the Free |
|---|
| 22 | # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|---|
| 23 | # MA 02111-1307 USA |
|---|
| 24 | # |
|---|
| 25 | # For further information, see <http://www.nexusformat.org> |
|---|
| 26 | # |
|---|
| 27 | # |
|---|
| 28 | #==================================================================== |
|---|
| 29 | |
|---|
| 30 | # we need 2.8.8 for correct component install with CPACK for archives |
|---|
| 31 | if(WIN32) |
|---|
| 32 | cmake_minimum_required (VERSION 2.8.8) |
|---|
| 33 | else() |
|---|
| 34 | cmake_minimum_required (VERSION 2.8.8) |
|---|
| 35 | if (${CMAKE_VERSION} VERSION_LESS 2.8.4) |
|---|
| 36 | set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove this line when CMake >= 2.8.4 is required |
|---|
| 37 | endif() |
|---|
| 38 | endif() |
|---|
| 39 | |
|---|
| 40 | project(NeXusDefinitions) |
|---|
| 41 | |
|---|
| 42 | # include NXDL release number information |
|---|
| 43 | include(cmake_include/nxdl_release.cmake) |
|---|
| 44 | |
|---|
| 45 | function(configure_release TARGET INFILE OUTFILE) |
|---|
| 46 | get_filename_component(F ${INFILE} NAME) |
|---|
| 47 | add_custom_command(OUTPUT "${OUTFILE}" COMMAND ${CMAKE_COMMAND} -DINPUT_FILE="${INFILE}" -DOUTPUT_FILE="${OUTFILE}" -DMATCH_STRING="\@NXDL_RELEASE\@" -DREPLACE_STRING="${NXDL_RELEASE}" -P "${CMAKE_SOURCE_DIR}/cmake_include/replace.cmake" DEPENDS "${INFILE}" "${CMAKE_BINARY_DIR}/CMakeCache.txt" COMMENT "Rebuilding ${F}") |
|---|
| 48 | add_custom_target(${TARGET}-${F} DEPENDS "${OUTFILE}") |
|---|
| 49 | add_dependencies(${TARGET} ${TARGET}-${F}) |
|---|
| 50 | endfunction() |
|---|
| 51 | |
|---|
| 52 | function(configure_nxdl TARGET NXDL_DIR DIST_DIR NXDL_FILES) |
|---|
| 53 | foreach(F ${NXDL_FILES}) |
|---|
| 54 | set(NXDL ${NXDL_DIR}/${F}) |
|---|
| 55 | configure_release(${TARGET} ${NXDL} ${DIST_DIR}/${F}) |
|---|
| 56 | endforeach() |
|---|
| 57 | configure_release(${TARGET} ${NXDL_DIR}/nxdlformat.xsl ${DIST_DIR}/nxdlformat.xsl) |
|---|
| 58 | endfunction() |
|---|
| 59 | |
|---|
| 60 | # |
|---|
| 61 | # convert a native windows path to its equivalent cygwin path |
|---|
| 62 | # |
|---|
| 63 | function(to_cygwin_path PATH RESULT) |
|---|
| 64 | file(TO_CMAKE_PATH ${PATH} CP) # changes \ to / on windows |
|---|
| 65 | string(REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" CP2 ${CP}) # c:/ -> /c/ |
|---|
| 66 | set(${RESULT} "/cygdrive${CP2}" PARENT_SCOPE) # /c/ -> /cygdrive/c/ |
|---|
| 67 | endfunction() |
|---|
| 68 | |
|---|
| 69 | set(XSD_FILES NeXus.xsd nxdl.xsd nxdlTypes.xsd BASE.xsd) |
|---|
| 70 | add_custom_target("DoXSD" ALL) |
|---|
| 71 | foreach(F ${XSD_FILES}) |
|---|
| 72 | configure_release("DoXSD" ${CMAKE_SOURCE_DIR}/${F} ${CMAKE_BINARY_DIR}/dist/${F}) |
|---|
| 73 | endforeach() |
|---|
| 74 | |
|---|
| 75 | # 2012-02-18,PRJ: sphinx directory is not ready for cmake yet |
|---|
| 76 | #option (BUILD_SPHINX "Build documentation using sphinx" OFF) |
|---|
| 77 | |
|---|
| 78 | # CMAKE_INSTALL_PREFIX is only used if CMAKE_SET_DESTDIR is true, |
|---|
| 79 | # so it will not be used in zip and tgz packages |
|---|
| 80 | if(UNIX) |
|---|
| 81 | set(CMAKE_INSTALL_PREFIX "/usr/share/nexus/") |
|---|
| 82 | endif() |
|---|
| 83 | set(NEXUS_DEFINITIONS "definitions") |
|---|
| 84 | set(NEXUS_MANUAL "manual") |
|---|
| 85 | |
|---|
| 86 | find_package(PythonInterp) |
|---|
| 87 | |
|---|
| 88 | if (WIN32) |
|---|
| 89 | find_program(XSLTPROC xsltproc PATHS "${CMAKE_SOURCE_DIR}/utils/win32") |
|---|
| 90 | else(WIN32) |
|---|
| 91 | find_program(XSLTPROC xsltproc ) |
|---|
| 92 | endif() |
|---|
| 93 | find_program(SVNVERSION svnversion) |
|---|
| 94 | |
|---|
| 95 | # needed for windows NSIS installer |
|---|
| 96 | file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} CMAKE_SOURCE_DIR_NATIVE) |
|---|
| 97 | file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} CMAKE_BINARY_DIR_NATIVE) |
|---|
| 98 | string(REPLACE "\\" "\\\\" CMAKE_SOURCE_DIR_NATIVE_D ${CMAKE_SOURCE_DIR_NATIVE}) |
|---|
| 99 | string(REPLACE "\\" "\\\\" CMAKE_BINARY_DIR_NATIVE_D ${CMAKE_BINARY_DIR_NATIVE}) |
|---|
| 100 | |
|---|
| 101 | #configure_file("${PROJECT_SOURCE_DIR}/utils/win32/dblatex_win.bat.in" |
|---|
| 102 | # "${PROJECT_BINARY_DIR}/dblatex_win.bat" |
|---|
| 103 | # @ONLY) |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | if(WIN32) |
|---|
| 107 | # we use cygwin on windows for dblatex etc |
|---|
| 108 | find_program(CYGPATH_EXECUTABLE cygpath PATHS "c:/cygwin" PATH_SUFFIXES "bin" DOC "CYGWIN cygpath program") |
|---|
| 109 | get_filename_component(CYGPATHDIR "${CYGPATH_EXECUTABLE}" PATH) |
|---|
| 110 | get_filename_component(CYGDIR "${CYGPATHDIR}/.." ABSOLUTE) |
|---|
| 111 | file(TO_NATIVE_PATH ${CYGDIR} CYGDIR_NATIVE) |
|---|
| 112 | configure_file("${PROJECT_SOURCE_DIR}/utils/win32/dblatex_cygwin.bat.in" |
|---|
| 113 | "${PROJECT_BINARY_DIR}/dblatex_cygwin.bat" |
|---|
| 114 | @ONLY) |
|---|
| 115 | if(IS_DIRECTORY "${CYGDIR}" AND EXISTS "${CYGDIR}/bin/dblatex") |
|---|
| 116 | set(DBLATEX "${PROJECT_BINARY_DIR}/dblatex_cygwin.bat") |
|---|
| 117 | else() |
|---|
| 118 | message(WARNING "CYGWIN dblatex NOT FOUND - no PDF documentation") |
|---|
| 119 | endif() |
|---|
| 120 | else() |
|---|
| 121 | find_package(LATEX) |
|---|
| 122 | find_program(DBLATEX dblatex) |
|---|
| 123 | endif() |
|---|
| 124 | # Recurse into the subdirectories. |
|---|
| 125 | #add_subdirectory (tutorial) |
|---|
| 126 | add_subdirectory (base_classes) |
|---|
| 127 | add_subdirectory (contributed_definitions) |
|---|
| 128 | add_subdirectory (applications) |
|---|
| 129 | add_subdirectory (schema) |
|---|
| 130 | add_subdirectory (manual) |
|---|
| 131 | # 2012-02-18,PRJ: sphinx directory is not ready for cmake yet |
|---|
| 132 | #if(BUILD_SPHINX) |
|---|
| 133 | # add_subdirectory (sphinx) |
|---|
| 134 | #endif(BUILD_SPHINX) |
|---|
| 135 | |
|---|
| 136 | foreach(F ${XSD_FILES}) |
|---|
| 137 | INSTALL(FILES ${CMAKE_BINARY_DIR}/dist/${F} DESTINATION ${NEXUS_DEFINITIONS} COMPONENT definitions) |
|---|
| 138 | endforeach() |
|---|
| 139 | |
|---|
| 140 | INSTALL(FILES LGPL.txt DESTINATION ${NEXUS_DEFINITIONS} COMPONENT definitions) |
|---|
| 141 | INSTALL(FILES LGPL.txt DESTINATION ${NEXUS_MANUAL} COMPONENT manual) |
|---|
| 142 | |
|---|
| 143 | # |
|---|
| 144 | # set CPack packaging options |
|---|
| 145 | # |
|---|
| 146 | configure_file("${PROJECT_SOURCE_DIR}/nexus_definitions.spec.in" |
|---|
| 147 | "${PROJECT_BINARY_DIR}/nexus_definitions.spec" |
|---|
| 148 | @ONLY) |
|---|
| 149 | configure_file("${PROJECT_SOURCE_DIR}/CPackOptions.cmake.in" |
|---|
| 150 | "${PROJECT_BINARY_DIR}/CPackOptions.cmake" |
|---|
| 151 | @ONLY) |
|---|
| 152 | set (CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackOptions.cmake") |
|---|
| 153 | set (CPACK_GENERATOR TGZ) # not use ZIP on UNIX as problem with symlinks |
|---|
| 154 | set (CPACK_SOURCE_GENERATOR TGZ) # not use ZIP on UNIX as problem with symlinks |
|---|
| 155 | if(WIN32) |
|---|
| 156 | set (CPACK_GENERATOR ${CPACK_GENERATOR};ZIP;NSIS) |
|---|
| 157 | set (CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR};ZIP) |
|---|
| 158 | elseif(APPLE) |
|---|
| 159 | set (CPACK_GENERATOR ${CPACK_GENERATOR};PackageMaker) |
|---|
| 160 | elseif(CYGWIN) |
|---|
| 161 | set (CPACK_GENERATOR ${CPACK_GENERATOR};CygwinBinary) |
|---|
| 162 | # set (CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR};CygwinSource) |
|---|
| 163 | elseif(UNIX) |
|---|
| 164 | set (CPACK_GENERATOR ${CPACK_GENERATOR};DEB;RPM) |
|---|
| 165 | endif() |
|---|
| 166 | # Include of CPack must always be last |
|---|
| 167 | include(CPack) |
|---|