1 # Copyright (C) 2012-2013 EDF
3 # This file is part of SALOME HYDRO module.
5 # SALOME HYDRO module is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # SALOME HYDRO module is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with SALOME HYDRO module. If not, see <http://www.gnu.org/licenses/>.
18 ADD_SUBDIRECTORY(eficas)
20 # --- Python files ---
27 SET(INSTALL_DIR ${SALOME_INSTALL_PYTHON}/salome/hydro/telemac2d)
31 SALOME_INSTALL_SCRIPTS("${PYFILES}" ${INSTALL_DIR})
33 # This macro is used to transform the list of libraries against which the
34 # module is linked into a list of linker flags (-L and -l). If we just use the
35 # list of libraries in the linker command, the full path of the libraries is
36 # registered in the module dependencies, so it doesn't work when the installation
38 MACRO(LIB_LIST_TO_LINKER_FLAGS LINKER_FLAGS_VAR LIB_LIST)
39 SET(${LINKER_FLAGS_VAR})
40 FOREACH(LIB ${LIB_LIST})
41 GET_FILENAME_COMPONENT(DIRNAME ${LIB} PATH)
42 # Get the library filename without the shortest extension. We can't use
43 # command GET_FILENAME_COMPONENT with option NAME_WE because it returns
44 # the filename without the longest extension. For example, we need to get
45 # "libpython2.7" from "libpython2.7.so" and not "libpython2".
46 GET_FILENAME_COMPONENT(LIBFILENAME ${LIB} NAME)
47 STRING(FIND ${LIBFILENAME} "." DOTPOS REVERSE)
48 STRING(SUBSTRING ${LIBFILENAME} 0 ${DOTPOS} FILENAME_WO_EXT)
49 STRING(SUBSTRING ${FILENAME_WO_EXT} 3 -1 LIBNAME)
50 LIST(APPEND ${LINKER_FLAGS_VAR} "-L${DIRNAME}" "-l${LIBNAME}")
51 ENDFOREACH(LIB ${LIB_LIST})
52 ENDMACRO(LIB_LIST_TO_LINKER_FLAGS)
54 SET (MEDFILE_LIBRARIES ${MEDFILE_ROOT_DIR}/lib/libmedC.so)
55 LIB_LIST_TO_LINKER_FLAGS(LINKER_FLAGS "${TELEMAC_LIBRARIES};${HDF5_hdf5_LIBRARY};${MEDFILE_LIBRARIES};${PYTHON_LIBRARY}")
57 # Python wrapping for Telemac2D created with f2py
58 SET(T2D_WRAP_API_LIB _apit2d.so)
59 SET(T2D_WRAP_API_PYF_FILE apit2d.pyf)
60 SET(T2D_WRAP_API_SRC_FILES ${TELEMAC_API_SRC_DIR}/api_handle_var_t2d.f90
61 ${TELEMAC_API_SRC_DIR}/api_interface_t2d.f90
62 ${TELEMAC_API_SRC_DIR}/api_handle_error_t2d.f90)
64 # This sed string is used to add necessary definitions to the pyf file
65 SET(SEDSTRING "s:python module _apit2d ! in:python module _apit2d ! in\\nusercode '''const int nb_var_t2d=100\\;\\n''':")
67 ADD_CUSTOM_COMMAND(OUTPUT ${T2D_WRAP_API_LIB}
68 COMMAND f2py -c ${T2D_WRAP_API_PYF_FILE} -I${TELEMAC_INCLUDE_DIR} ${LINKER_FLAGS}
69 MAIN_DEPENDENCY ${T2D_WRAP_API_PYF_FILE}
72 ADD_CUSTOM_COMMAND(OUTPUT ${T2D_WRAP_API_PYF_FILE}
73 COMMAND f2py -h ${T2D_WRAP_API_PYF_FILE} -m _apit2d ${T2D_WRAP_API_SRC_FILES}
74 skip: get_boolean_t2d_d get_double_t2d_d get_integer_t2d_d get_string_t2d_d get_var_size_t2d_d
75 set_boolean_t2d_d set_double_t2d_d set_integer_t2d_d set_string_t2d_d :
76 COMMAND sed -i -e \"${SEDSTRING}\" ${T2D_WRAP_API_PYF_FILE}
77 MAIN_DEPENDENCY ${T2D_WRAP_API_SRC_FILES}
80 ADD_CUSTOM_TARGET(BUILD_T2D_WRAP_API_LIB ALL DEPENDS ${T2D_WRAP_API_LIB})
81 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${T2D_WRAP_API_LIB} DESTINATION ${INSTALL_DIR})