# Build the ibv_message_transport library

project (ibv_message_transport C)
cmake_minimum_required (VERSION 2.8)

add_library (ibv_message_transport "ibv_controller_worker_messages.c"
                                   "ibv_message_bw_common.c"
                                   "ibv_message_bw_communication_context.c"
                                   "ibv_message_bw_receive.c"
                                   "ibv_message_bw_transmit.c")

# Build the ibv_message_transport library

project (ibv_message_transport C)
cmake_minimum_required (VERSION 2.8)

add_library (ibv_message_transport "ibv_controller_worker_messages.c"
                                   "ibv_message_bw_common.c"
                                   "ibv_message_bw_communication_context.c"
                                   "ibv_message_bw_receive.c"
                                   "ibv_message_bw_transmit.c")

# The directory in which the Ada spec files are generated by the generate_ada_specs script
set (GENERATE_SPEC_DIR "${CMAKE_SOURCE_DIR}/../../ibv_message_passing_ada_project/source/ibv_message_transport")

# Run the generate_ada_specs.sh script to generate the Ada interface specs if either:
# - The top level .ads files don't exist (covers the case of a clean build)
# - The implicit depedencies of the top level C include files used as the source for the Ada interface specs
#   (covers the case of re-generating after a change to the C interface)
set (INTERFACE_LIB_INTERFACE "${GENERATE_SPEC_DIR}/ibv_message_bw_interface_h.ads")
set (MESSAGES_INTERFACE "${GENERATE_SPEC_DIR}/ibv_controller_worker_messages_h.ads")
add_custom_command (OUTPUT "${INTERFACE_LIB_INTERFACE}" "${MESSAGES_INTERFACE}"
                    COMMAND "${PROJECT_SOURCE_DIR}/generate_ada_specs.sh"
                    IMPLICIT_DEPENDS C "${PROJECT_SOURCE_DIR}/ibv_message_bw_interface_ada.h"
                    IMPLICIT_DEPENDS C "${PROJECT_SOURCE_DIR}/ibv_controller_worker_messages_ada.h"
                    COMMENT "Generating Ada specs")
add_custom_target (ibv_message_transport_ada_spec ALL
                   DEPENDS "${INTERFACE_LIB_INTERFACE}" "${MESSAGES_INTERFACE}")
Add CMake custom target to automatically generate the Ada interface specs on on a clean build, or when the C interface files change
Add CMake custom target to automatically generate the Ada interface specs on on a clean build, or when the C interface files change
