-
Notifications
You must be signed in to change notification settings - Fork 123
/
CMakeLists.txt
112 lines (90 loc) · 4.45 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
###########################################################################
# Do the sip generation, for python bindings
###########################################################################
set( PY_MODULE_NAME mantidvsipython )
include_directories ( ${PYTHON_INCLUDE_PATH} )
set ( MANTIDQT_SIP_DIR ${CMAKE_SOURCE_DIR}/MantidQt/Python )
set ( SIP_SPEC ${CMAKE_CURRENT_SOURCE_DIR}/mantidvsi.sip )
set ( SIP_SRC_IN ${CMAKE_CURRENT_SOURCE_DIR}/sip_mantidvsi.cpp.in )
set ( SIP_SRC ${CMAKE_CURRENT_BINARY_DIR}/sip_mantidvsi.cpp )
set ( SIP_SRC_AUTO sipmantidvsipythonpart0.cpp )
# We need to manually add all the headers that are in the sip file
# so that the dependencies are known to CMake
set ( SIP_HDRS
../../../MantidQt/API/inc/MantidQtAPI/VatesViewerInterface.h
../ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h
)
set( SRC_UNITY_IGNORE_FILES )
###########################################################################
# Sip generated files
###########################################################################
# The code generated by sip causes compiler warnings therefore the
# generated file is wrapped by ${SIP_SRC} and these warnings are
# disabled. In order for VS2010 to to this correctly the second
# custom command below is required
# Flags used:
# -e : C++ exceptions turn into python exceptions.
# -j1 : split into 1 file
# -w : enable warnings
# -o : automatic docstrings (not supported in old version < 4.10)
add_custom_command ( OUTPUT ${SIP_SRC_AUTO}
COMMAND ${SIP_EXECUTABLE}
-I ${PYQT4_SIP_DIR} ${PYQT4_SIP_FLAGS}
-I ${MANTIDQT_SIP_DIR}
-c ${CMAKE_CURRENT_BINARY_DIR} -j1 -w
-e
${SIP_SPEC}
DEPENDS mantidvsi.sip ${SIP_HDRS}
COMMENT "Generating mantidvsi python bindings using sip"
)
add_custom_command ( OUTPUT ${SIP_SRC}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${SIP_SRC_IN} ${SIP_SRC}
DEPENDS ${SIP_SRC_AUTO}
COMMENT ""
)
# Needed for sip.h header that can end up in a different place to to the main Python include directory
include_directories ( ${SIP_INCLUDE_DIR} )
# Needed for sip generated files to find includes in src
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} )
# Other folders that need to be included...
include_directories ( ../QtWidgets/inc )
include_directories ( ../ViewWidgets/inc )
include_directories ( ${CMAKE_SOURCE_DIR}/MantidQt/API/inc )
# to find the ui_*.h auto-generated files
include_directories ( ${CMAKE_CURRENT_BINARY_DIR}/../QtWidgets )
include_directories ( ${CMAKE_CURRENT_BINARY_DIR}/../ViewWidgets )
###########################################################################
# Python files
###########################################################################
set( PY_FILES vsi.py )
copy_python_files_to_dir ( "${PY_FILES}"
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
PYTHON_INSTALL_FILES )
# This creates the target library for python bindings and handles the python modules
add_library ( ${PY_MODULE_NAME} MODULE ${SIP_SRC} ${PYTHON_INSTALL_FILES} )
if(WIN32)
# Windows: Python library name needs to end in .pyd for Windows
set_target_properties( ${PY_MODULE_NAME} PROPERTIES PREFIX "" SUFFIX ".pyd" )
# Debug python library expects imported module names to end in _d
if ( PYTHON_DEBUG_LIBRARY )
set_target_properties ( ${PY_MODULE_NAME} PROPERTIES DEBUG_OUTPUT_NAME ${PY_MODULE_NAME}_d )
endif ()
elseif ( APPLE )
# Mac: and in .so on the Mac, with no "lib" prefix either
set_target_properties ( ${PY_MODULE_NAME} PROPERTIES PREFIX "" SUFFIX .so )
else ()
# Linux: needs to NOT have the usual "lib" prefix.
set_target_properties( ${PY_MODULE_NAME} PROPERTIES PREFIX "" )
endif ()
# ... and links to other required libs ...
target_link_libraries ( ${PY_MODULE_NAME}
VatesAPI MantidQtAPI VatesSimpleGuiViewWidgets VatesSimpleGuiQtWidgets
${QT_LIBRARIES} ${QWT_LIBRARIES}
${PYTHON_LIBRARIES}
)
###########################################################################
# Installation settings
###########################################################################
install ( TARGETS ${PY_MODULE_NAME} DESTINATION ${BIN_DIR} )
install ( FILES ${PY_FILES} DESTINATION ${BIN_DIR} )