cmake_minimum_required(VERSION 3.28)

# define CXX interface library

    # define target & alias (i.e. consuming projects can experience namespaces)
    add_library(iue-io_csv INTERFACE)
    target_link_libraries(iue-io_csv INTERFACE iue-other_honly)
    #target_link_libraries(iue-io_csv INTERFACE OpenMP::OpenMP_CXX)

    # define sources of target
    target_sources(iue-io_csv
                    INTERFACE FILE_SET public_headers TYPE HEADERS BASE_DIRS ${PROJECT_SOURCE_DIR} FILES csv.hpp)

    # define installation step
    install(TARGETS iue-io_csv EXPORT iue-io-export
                                       FILE_SET public_headers DESTINATION "./")

    # define test
if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL)
    add_executable(iue-io_csv.test csv.test.cpp)
    target_link_libraries(iue-io_csv.test iue-io_csv)
    add_test(NAME iue-io_csv.test COMMAND iue-io_csv.test)
endif()

# define C interface library

    # define target & alias (i.e. consuming projects can experience namespaces)
    add_library(iue-io_ccsv INTERFACE)

    # define sources of target
    target_sources(iue-io_ccsv
                    INTERFACE FILE_SET public_headers TYPE HEADERS BASE_DIRS ${PROJECT_SOURCE_DIR} FILES ccsv.h)

    # define installation step
    install(TARGETS iue-io_ccsv EXPORT iue-io-export
                                        FILE_SET public_headers DESTINATION "./")

    # define test

if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL) 
    add_executable(iue-io_ccsv.test ccsv.test.c)
    target_link_libraries(iue-io_ccsv.test iue-io_ccsv)
    add_test(NAME iue-io_ccsv.test COMMAND iue-io_ccsv.test)
endif()

# export targets for consuming cmake projects

    # generate and install a .cmake file to allow dependend projects consuming the "install-tree" to import all targets
    install(EXPORT iue-io-export DESTINATION "iue-io" )

    # allow dependend projects consuming the "build-tree" to use all targets
    export(EXPORT iue-io-export )
