Salome HOME
Fix compilation on Windows with VS 2017 after implementation 64 bit ids in MEDCOUPLING.
[modules/med.git] / src / MEDCalculator / Swig / CMakeLists.txt
1 # Copyright (C) 2012-2019  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Author : Anthony Geay (CEA/DEN)
20
21 ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
22
23 FIND_PACKAGE(SWIG REQUIRED)
24 INCLUDE(${SWIG_USE_FILE})
25
26 INCLUDE_DIRECTORIES(
27   ${PYTHON_INCLUDE_DIRS}
28   ${NUMPY_INCLUDE_DIR}
29   ${MEDFILE_INCLUDE_DIRS}
30   ${HDF5_INCLUDE_DIRS}
31   ${MEDCOUPLING_INCLUDE_DIRS}
32   ${CMAKE_CURRENT_SOURCE_DIR}
33   ${CMAKE_CURRENT_SOURCE_DIR}/..
34   )
35
36 SET(medcalculatorspython_SOURCES
37   SPythonInterpreter.cxx
38   SPythonParser.cxx
39   )
40
41 ADD_LIBRARY(medcalculatorspython SHARED ${medcalculatorspython_SOURCES})
42 TARGET_LINK_LIBRARIES(medcalculatorspython ${MEDCoupling_interpkernel} ${PYTHON_LIBRARIES})
43 INSTALL(TARGETS medcalculatorspython DESTINATION ${SALOME_INSTALL_LIBS})
44
45 SET_SOURCE_FILES_PROPERTIES(MEDCalculator.i PROPERTIES CPLUSPLUS ON)
46 SET_SOURCE_FILES_PROPERTIES(MEDCalculator.i PROPERTIES SWIG_FLAGS "-py3")
47 IF(WIN32)
48   SET_PROPERTY(SOURCE MEDCalculator.i PROPERTY COMPILE_DEFINITIONS WIN32)
49 ENDIF()
50 SET(SWIG_MODULE_MEDCalculator_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
51 IF(MEDCOUPLING_USE_64BIT_IDS)
52   STRING(APPEND SWIG_MODULE_MEDCalculator_EXTRA_FLAGS ";-DMEDCOUPLING_USE_64BIT_IDS")
53 ENDIF(MEDCOUPLING_USE_64BIT_IDS)
54 IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
55   SWIG_ADD_MODULE(MEDCalculator python MEDCalculator.i)
56 ELSE()
57   SWIG_ADD_LIBRARY(MEDCalculator LANGUAGE python SOURCES MEDCalculator.i)
58 ENDIF()
59
60 SWIG_LINK_LIBRARIES(MEDCalculator ${PYTHON_LIBRARIES} medcalculator)
61
62 IF(WIN32)
63   SET_TARGET_PROPERTIES(_MEDCalculator PROPERTIES DEBUG_OUTPUT_NAME _MEDCalculator_d)
64   # To increase the size of the .obj file on Windows because MEDLoaderPYTHON_wrap.cxx, generated by SWIG, is too big
65   TARGET_COMPILE_OPTIONS(_MEDCalculator PRIVATE /bigobj) 
66 ENDIF(WIN32)
67
68 FILE(GLOB medcalculatorspython_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
69 INSTALL(FILES ${medcalculatorspython_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
70 INSTALL(TARGETS _MEDCalculator DESTINATION ${SALOME_INSTALL_PYTHON})
71 INSTALL(FILES MEDCalculator.i MEDCalculatorTypemaps.i DESTINATION ${SALOME_INSTALL_HEADERS})
72 SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/MEDCalculator.py ${SALOME_INSTALL_PYTHON} EXTRA_DPYS "${SWIG_MODULE_MEDCalculator_REAL_NAME}")