# Copyright (C) 2012-2013 EDF # # This file is part of SALOME HYDRO module. # # SALOME HYDRO module is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # SALOME HYDRO module is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with SALOME HYDRO module. If not, see . ADD_SUBDIRECTORY(eficas) # --- Python files --- SET(PYFILES __init__.py polygon.py ) SET(INSTALL_DIR ${SALOME_INSTALL_PYTHON}/salome/hydro/telemac2d) # --- rules --- SALOME_INSTALL_SCRIPTS("${PYFILES}" ${INSTALL_DIR}) # This macro is used to transform the list of libraries against which the # module is linked into a list of linker flags (-L and -l). If we just use the # list of libraries in the linker command, the full path of the libraries is # registered in the module dependencies, so it doesn't work when the installation # is moved. MACRO(LIB_LIST_TO_LINKER_FLAGS LINKER_FLAGS_VAR LIB_LIST) SET(${LINKER_FLAGS_VAR}) FOREACH(LIB ${LIB_LIST}) GET_FILENAME_COMPONENT(DIRNAME ${LIB} PATH) # Get the library filename without the shortest extension. We can't use # command GET_FILENAME_COMPONENT with option NAME_WE because it returns # the filename without the longest extension. For example, we need to get # "libpython2.7" from "libpython2.7.so" and not "libpython2". GET_FILENAME_COMPONENT(LIBFILENAME ${LIB} NAME) STRING(FIND ${LIBFILENAME} "." DOTPOS REVERSE) STRING(SUBSTRING ${LIBFILENAME} 0 ${DOTPOS} FILENAME_WO_EXT) STRING(SUBSTRING ${FILENAME_WO_EXT} 3 -1 LIBNAME) LIST(APPEND ${LINKER_FLAGS_VAR} "-L${DIRNAME}" "-l${LIBNAME}") ENDFOREACH(LIB ${LIB_LIST}) ENDMACRO(LIB_LIST_TO_LINKER_FLAGS) SET (MEDFILE_LIBRARIES ${MEDFILE_ROOT_DIR}/lib/libmedC.so) LIB_LIST_TO_LINKER_FLAGS(LINKER_FLAGS "${TELEMAC_LIBRARIES};${HDF5_hdf5_LIBRARY};${MEDFILE_LIBRARIES};${PYTHON_LIBRARY}") # Python wrapping for Telemac2D created with f2py SET(T2D_WRAP_API_LIB _apit2d.so) SET(T2D_WRAP_API_PYF_FILE apit2d.pyf) SET(T2D_WRAP_API_SRC_FILES ${TELEMAC_API_SRC_DIR}/api_handle_var_t2d.f90 ${TELEMAC_API_SRC_DIR}/api_interface_t2d.f90 ${TELEMAC_API_SRC_DIR}/api_handle_error_t2d.f90) # This sed string is used to add necessary definitions to the pyf file SET(SEDSTRING "s:python module _apit2d ! in:python module _apit2d ! in\\nusercode '''const int nb_var_t2d=100\\;\\n''':") ADD_CUSTOM_COMMAND(OUTPUT ${T2D_WRAP_API_LIB} COMMAND f2py -c ${T2D_WRAP_API_PYF_FILE} -I${TELEMAC_INCLUDE_DIR} ${LINKER_FLAGS} MAIN_DEPENDENCY ${T2D_WRAP_API_PYF_FILE} ) ADD_CUSTOM_COMMAND(OUTPUT ${T2D_WRAP_API_PYF_FILE} COMMAND f2py -h ${T2D_WRAP_API_PYF_FILE} -m _apit2d ${T2D_WRAP_API_SRC_FILES} skip: get_boolean_t2d_d get_double_t2d_d get_integer_t2d_d get_string_t2d_d get_var_size_t2d_d set_boolean_t2d_d set_double_t2d_d set_integer_t2d_d set_string_t2d_d : COMMAND sed -i -e \"${SEDSTRING}\" ${T2D_WRAP_API_PYF_FILE} MAIN_DEPENDENCY ${T2D_WRAP_API_SRC_FILES} ) ADD_CUSTOM_TARGET(BUILD_T2D_WRAP_API_LIB ALL DEPENDS ${T2D_WRAP_API_LIB}) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${T2D_WRAP_API_LIB} DESTINATION ${INSTALL_DIR})