source: trunk/CMakeLists.txt @ 1089

Revision 1085, 6.5 KB checked in by Freddie Akeroyd, 2 weeks ago (diff)

Tidy up rpm install
Refs #221

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
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
31if(WIN32)
32    cmake_minimum_required (VERSION 2.8.8)
33else()
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()
38endif()
39
40project(NeXusDefinitions)
41
42# include NXDL release number information
43include(cmake_include/nxdl_release.cmake)
44
45function(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})
50endfunction()
51
52function(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)
58endfunction()
59
60#
61# convert a native windows path to its equivalent cygwin path
62#
63function(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/
67endfunction()
68
69set(XSD_FILES NeXus.xsd nxdl.xsd nxdlTypes.xsd BASE.xsd)
70add_custom_target("DoXSD" ALL)
71foreach(F ${XSD_FILES})
72    configure_release("DoXSD" ${CMAKE_SOURCE_DIR}/${F} ${CMAKE_BINARY_DIR}/dist/${F})
73endforeach()
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
80if(UNIX)
81    set(CMAKE_INSTALL_PREFIX "/usr/share/nexus/")
82endif()
83set(NEXUS_DEFINITIONS "definitions")
84set(NEXUS_MANUAL "manual")
85
86find_package(PythonInterp)
87
88if (WIN32)
89    find_program(XSLTPROC xsltproc PATHS "${CMAKE_SOURCE_DIR}/utils/win32")
90else(WIN32)
91    find_program(XSLTPROC xsltproc )
92endif()
93find_program(SVNVERSION svnversion)
94
95# needed for windows NSIS installer
96file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} CMAKE_SOURCE_DIR_NATIVE)
97file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} CMAKE_BINARY_DIR_NATIVE)
98string(REPLACE "\\" "\\\\" CMAKE_SOURCE_DIR_NATIVE_D ${CMAKE_SOURCE_DIR_NATIVE})
99string(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
106if(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()
120else()
121        find_package(LATEX)
122        find_program(DBLATEX dblatex)
123endif()
124# Recurse into the subdirectories.
125#add_subdirectory (tutorial)
126add_subdirectory (base_classes)
127add_subdirectory (contributed_definitions)
128add_subdirectory (applications)
129add_subdirectory (schema)
130add_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
136foreach(F ${XSD_FILES})
137    INSTALL(FILES ${CMAKE_BINARY_DIR}/dist/${F} DESTINATION ${NEXUS_DEFINITIONS} COMPONENT definitions)
138endforeach()
139
140INSTALL(FILES LGPL.txt DESTINATION ${NEXUS_DEFINITIONS} COMPONENT definitions)
141INSTALL(FILES LGPL.txt DESTINATION ${NEXUS_MANUAL} COMPONENT manual)
142
143#
144# set CPack packaging options
145#
146configure_file("${PROJECT_SOURCE_DIR}/nexus_definitions.spec.in"
147                                "${PROJECT_BINARY_DIR}/nexus_definitions.spec"
148                                @ONLY)
149configure_file("${PROJECT_SOURCE_DIR}/CPackOptions.cmake.in"
150                                "${PROJECT_BINARY_DIR}/CPackOptions.cmake"
151                                @ONLY)
152set (CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackOptions.cmake")
153set (CPACK_GENERATOR TGZ) # not use ZIP on UNIX as problem with symlinks
154set (CPACK_SOURCE_GENERATOR TGZ) # not use ZIP on UNIX as problem with symlinks
155if(WIN32)
156    set (CPACK_GENERATOR ${CPACK_GENERATOR};ZIP;NSIS)
157    set (CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR};ZIP)
158elseif(APPLE)
159    set (CPACK_GENERATOR ${CPACK_GENERATOR};PackageMaker)
160elseif(CYGWIN)
161    set (CPACK_GENERATOR ${CPACK_GENERATOR};CygwinBinary)
162#    set (CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR};CygwinSource)
163elseif(UNIX)
164    set (CPACK_GENERATOR ${CPACK_GENERATOR};DEB;RPM)
165endif()
166# Include of CPack must always be last
167include(CPack)
Note: See TracBrowser for help on using the repository browser.