file(GLOB sources "*.c" "*.cpp")
#
# Copyright Intel Corporation.
# 
# This software and the related documents are Intel copyrighted materials, and
# your use of them is governed by the express license under which they were
# provided to you (License). Unless the License provides otherwise, you may
# not use, modify, copy, publish, distribute, disclose or transmit this
# software or the related documents without Intel's prior written permission.
# 
# This software and the related documents are provided as is, with no express
# or implied warranties, other than those that are expressly stated in the
# License.
#

link_directories(${EXAMPLES_LIB_DIRS})

foreach(src ${sources})
    get_filename_component(executable ${src} NAME_WE)
    add_executable(${executable} ${src})
    target_include_directories(${executable} PRIVATE ${EXAMPLES_INC_DIRS})
    target_link_libraries(${executable} PUBLIC rt)
    target_link_libraries(${executable} PUBLIC m)
    target_link_libraries(${executable} PRIVATE ccl)
    target_link_libraries(${executable} PUBLIC -L${I_MPI_ROOT}/lib/release/)
    target_link_libraries(${executable} PUBLIC mpi)
    target_link_libraries(${executable} PUBLIC ${COMPUTE_BACKEND_TARGET_NAME})
    install(TARGETS ${executable} RUNTIME DESTINATION ${CCL_INSTALL_EXAMPLES}/external_launcher OPTIONAL)
endforeach()

configure_file(run.sh ${CMAKE_CURRENT_BINARY_DIR}/run.sh @ONLY)
configure_file(run_binary.sh ${CMAKE_CURRENT_BINARY_DIR}/run_binary.sh @ONLY)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run.sh DESTINATION ${CCL_INSTALL_EXAMPLES}/external_launcher/  OPTIONAL)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run_binary.sh DESTINATION ${CCL_INSTALL_EXAMPLES}/external_launcher/ OPTIONAL)
    
