- )
-
-INSTALL(TARGETS _MEDLoader DESTINATION ${MED_salomepythondir})
-INSTALL(FILES MEDLoader.i MEDLoaderCommon.i MEDLoaderTypemaps.i DESTINATION ${MED_salomeinclude_HEADERS})
-SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDLoader.py ${CMAKE_CURRENT_SOURCE_DIR}/libMEDLoader_Swig.py)
-INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${MED_salomescript_PYTHON})
-
-ADD_TEST(MEDLoaderTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest.py)
-ADD_TEST(MEDLoaderTest2 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest2.py)
-ADD_TEST(MEDLoaderTest3 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest3.py)
-ADD_TEST(MEDLoaderExamplesTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderExamplesTest.py)
-ADD_TEST(SauvLoaderTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/SauvLoaderTest.py)
+ ${PROJECT_BINARY_DIR}/doc
+)
+
+SET (SWIG_MODULE_MEDLoader_EXTRA_DEPS ${MEDLoader_SWIG_DPYS_FILES}
+ ${medloader_HEADERS_HXX}
+ ${medcoupling_HEADERS_HXX} ${medcoupling_HEADERS_TXX}
+ ${interpkernel_HEADERS_HXX} ${interpkernel_HEADERS_TXX})
+
+# SWIG must run after the doc if we want to have the docstrings extracted from Doxygen
+# into the Python module:
+IF(MEDCOUPLING_BUILD_DOC)
+ LIST(APPEND SWIG_MODULE_MEDLoader_EXTRA_FLAGS -DWITH_DOCSTRINGS)
+ LIST(APPEND SWIG_MODULE_MEDLoader_EXTRA_DEPS
+ ${PROJECT_BINARY_DIR}/doc/MEDLoader_doc.i
+ swig_ready)
+ENDIF()
+
+IF(WIN32)
+ SET_PROPERTY(SOURCE MEDLoader.i PROPERTY COMPILE_DEFINITIONS WIN32)
+ENDIF()
+
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_MODULE(MEDLoader python MEDLoader.i)
+ELSE()
+ SWIG_ADD_LIBRARY(MEDLoader LANGUAGE python SOURCES MEDLoader.i)
+ENDIF()
+
+SWIG_LINK_LIBRARIES(MEDLoader ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medloader medcouplingcpp )
+SWIG_CHECK_GENERATION(MEDLoader)
+IF(WIN32)
+ SET_TARGET_PROPERTIES(_MEDLoader PROPERTIES DEBUG_OUTPUT_NAME _MEDLoader_d)
+ # To increase the size of the .obj file on Windows because MEDLoaderPYTHON_wrap.cxx, generated by SWIG, is too big
+ TARGET_COMPILE_OPTIONS(_MEDLoader PRIVATE /bigobj)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _MEDLoader DESTINATION ${MEDCOUPLING_INSTALL_PYTHON})
+INSTALL(FILES MEDLoader.i MEDLoaderTypemaps.i MEDLoaderCommon.i MEDLoaderFinalize.i DESTINATION ${MEDCOUPLING_INSTALL_HEADERS})
+
+SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/MEDLoader.py ${MEDCOUPLING_INSTALL_PYTHON} EXTRA_DPYS "${SWIG_MODULE_MEDLoader_REAL_NAME}")
+
+INSTALL(FILES MEDLoaderSplitter.py DESTINATION ${MEDCOUPLING_INSTALL_PYTHON})
+
+
+INSTALL(FILES ${ALL_TESTS} MEDLoaderDataForTest.py MEDLoaderTest1.py MEDLoaderTest2.py MEDLoaderTest3.py DESTINATION ${MEDCOUPLING_INSTALL_SCRIPT_SCRIPTS})
+
+INSTALL(FILES CaseIO.py CaseReader.py CaseWriter.py VTKReader.py DESTINATION ${MEDCOUPLING_INSTALL_PYTHON})
+
+INSTALL(FILES case2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} )
+INSTALL(FILES med2case PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} )
+INSTALL(FILES ConvertMEDFileTo33.py ConvertMEDFileTo30.py PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MEDCOUPLING_INSTALL_BINS} )
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+
+FOREACH(test ${BASE_TESTS})
+ GET_FILENAME_COMPONENT(testname ${test} NAME_WE)
+ ADD_TEST(NAME ${testname}
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test})
+ SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}")
+ENDFOREACH()
+
+IF(NUMPY_FOUND)
+ # Add Remapper to the Python path:
+ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK "${CMAKE_CURRENT_BINARY_DIR}/../../MEDCoupling_Swig")
+ SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+ FOREACH(test ${NUMPY_TESTS})
+ GET_FILENAME_COMPONENT(testname ${test} NAME_WE)
+ ADD_TEST(NAME ${testname}
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test})
+ SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}")
+ ENDFOREACH()
+ENDIF(NUMPY_FOUND)
+
+# Application tests
+
+SET(TEST_INSTALL_DIRECTORY ${MEDCOUPLING_INSTALL_TESTS}/MEDLoader_Swig)
+
+SET(MEDLOADER_TEST_FILES
+ ${ALL_TESTS}
+ MEDLoaderDataForTest.py
+ MEDLoaderTest1.py
+ MEDLoaderTest2.py
+ MEDLoaderTest3.py
+ CaseIO.py
+ CaseReader.py
+ CaseWriter.py
+ VTKReader.py
+ MEDLoaderSplitter.py
+)
+
+INSTALL(FILES ${MEDLOADER_TEST_FILES} DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${TEST_INSTALL_DIRECTORY}
+ RENAME CTestTestfile.cmake)
+INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})