source: trunk/bindings/python/CMakeLists.txt @ 1822

Revision 1707, 2.8 KB checked in by Stephen Rankin, 7 months ago (diff)

Packaging updates - set type of item i.e Runtime etc. ref#281

Line 
1## Process this file with cmake
2#====================================================================
3#  NeXus - Neutron & X-ray Common Data Format
4#
5#  CMakeLists for building the NeXus library and applications.
6#
7#  Copyright (C) 2011 Stephen Rankin
8#
9#  This library is free software; you can redistribute it and/or
10#  modify it under the terms of the GNU Lesser General Public
11#  License as published by the Free Software Foundation; either
12#  version 2 of the License, or (at your option) any later version.
13#
14#  This library is distributed in the hope that it will be useful,
15#  but WITHOUT ANY WARRANTY; without even the implied warranty of
16#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17#  Lesser General Public License for more details.
18#
19#  You should have received a copy of the GNU Lesser General Public
20#  License along with this library; if not, write to the Free
21#  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22#  MA  02111-1307  USA
23#
24#  For further information, see <http://www.nexusformat.org>
25#
26#
27#====================================================================
28
29if(DEFINED PYTHONINTERP_FOUND)
30
31    SET (PYDOC_OUTPUT napi.html)
32    SET (NXSPYTHON_DOC nxs.napi.html)
33    SET (NXSPYTHON_SOURCE ${CMAKE_SOURCE_DIR}/bindings/python/nxs/napi.py)
34
35    GET_TARGET_PROPERTY(LIB_NAME NeXus_Shared_Library LOCATION)
36    SET (ENV{NEXUSLIB} ${LIB_NAME})
37
38    FILE(READ ${NXSPYTHON_SOURCE} TEMP_SOURCE_IN)
39
40    STRING(REGEX REPLACE "nxprefix = .*" "nxprefix = ${CMAKE_INSTALL_PREFIX}" TEMP_SOURCE_OUT ${TEMP_SOURCE_IN})
41
42    FILE(WRITE nxs/napi.py.out ${TEMP_SOURCE_OUT})
43
44    #We need to run py_compile somehow now on napi.py.out
45    #according to the Makefile.am. py_compile is not portable
46    #and DESTDIR is not available as a variable in CMAKE
47    #(more googleing needed).
48
49    ADD_CUSTOM_COMMAND(
50        OUTPUT    ${PYDOC_OUTPUT}
51        COMMAND   ${CMAKE_COMMAND}
52        ARGS      -D NEXUSLIB="${LIB_NAME}" -D NXSPYTHON_SOURCE="${NXSPYTHON_SOURCE}" -D PYTHON_DOC="${PYTHON_DOC}" -P "${CMAKE_SOURCE_DIR}/bindings/python/pythondoc.cmake"
53        COMMENT   "Build NXS Python Docs"
54    )
55
56 #   ADD_CUSTOM_COMMAND(
57 #       OUTPUT    ${PYDOC_OUTPUT}
58 #       COMMAND   ${CMAKE_COMMAND} -E env "NEXUSLIB=${LIB_NAME}" ${PYTHON_DOC}
59 #       ARGS      -w ${NXSPYTHON_SOURCE}
60 #       COMMENT   "Build NXS Python Docs"
61 #   )
62
63    ADD_CUSTOM_COMMAND(
64        OUTPUT    ${NXSPYTHON_DOC}
65        COMMAND   ${CMAKE_COMMAND}
66        ARGS      -E copy ${PYDOC_OUTPUT} ${NXSPYTHON_DOC}
67        DEPENDS   ${PYDOC_OUTPUT}
68        COMMENT   "Rename NXS Python Docs"
69    )
70
71    ADD_CUSTOM_TARGET(NXSPythonBuild ALL echo
72        DEPENDS   ${NXSPYTHON_DOC}
73    )
74
75    install (FILES ${CMAKE_BINARY_DIR}/bindings/python/${NXSPYTHON_DOC} DESTINATION ${NXDOCDIR}/python COMPONENT Documentation)
76   
77endif(DEFINED PYTHONINTERP_FOUND)
78
79
Note: See TracBrowser for help on using the repository browser.