# library sources
foreach( _src ${libemos_srcs} )
  list( APPEND emos_dp_srcs ../${_src} )
endforeach()


# compiler definitions:
# - configure Fortran-based targets for double precision (compilation & linking)
# - allow/disallow GRIBEX with configuration
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${emos_double_precision_flags}")
if( HAVE_GRIBEX_ABORT )
  set_source_files_properties( ../gribex/gribex.F PROPERTIES COMPILE_DEFINITIONS "GRIBEX_ABORT" )
endif()


# library target
set( CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
include_directories( ${LIBEMOS_BASE_DIR}/interpolation ${LIBEMOS_BASE_DIR}/bufrdc_wmo )

ecbuild_add_library(
  TYPE        STATIC
  TARGET      emos
  OUTPUT_NAME "emosR64"
  DEFINITIONS ${LIBEMOS_DEFINITIONS}
  SOURCES     ../libemos_version.c ${emos_dp_srcs}
  GENERATED   ../libemos_version.c )


#if( BUILD_SHARED_LIBS )
#  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
#               libemosR64.so ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/libemos.R64.D64.I32.so)" )
#else()
  install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
               libemosR64.a ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}/libemos.R64.D64.I32.a)" )
#endif()

