cmake_minimum_required ( VERSION 2.8 )

if ( NOT DEFINED CMAKE_BUILD_TYPE )
  set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type" )
endif ()

project ( wrapper_linked_with_F77_function C Fortran )

include ( FortranCInterface )
FortranCInterface_HEADER ( FortranCInterface.h )
include_directories ( ${CMAKE_CURRENT_BINARY_DIR} )

find_package ( OpenTURNS NO_MODULE REQUIRED )
include ( ${OPENTURNS_USE_FILE} )

set ( SOURCEFILES code.f wrapper.c )

add_library ( wcode SHARED ${SOURCEFILES} )
set_target_properties ( wcode PROPERTIES PREFIX "" )
if ( MINGW )
  set_target_properties ( wcode PROPERTIES
                                LINK_FLAGS "-Wl,--enable-auto-import" )
  set_target_properties ( wcode PROPERTIES
                                SUFFIX .so ) 
endif ()
target_link_libraries ( wcode ${OPENTURNS_WRAPPER_LIBRARIES} )

install ( TARGETS wcode
          RUNTIME DESTINATION wrappers
          LIBRARY DESTINATION wrappers
          ARCHIVE DESTINATION wrappers
        )
        
install ( FILES wcode.xml DESTINATION wrappers )
