Salome HOME
merge master v1.6
authorPaul RASCLE <paul.rascle@edf.fr>
Fri, 9 Dec 2016 16:31:11 +0000 (17:31 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Fri, 9 Dec 2016 16:31:11 +0000 (17:31 +0100)
1  2 
src/salome_hydro/telemac2d/CMakeLists.txt

index ffcf67054c2e8afcc43f5650c2214868453658ae,26bb4155d5871a6cb344a5a6fce032c759b42867..e6fc7f98433bb8c0ec6242b71bd1f6e8de1f5b5e
  #  along with SALOME HYDRO module.  If not, see <http://www.gnu.org/licenses/>.
  
  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})
++