cmake_minimum_required(VERSION 3.28)

# define CXX interface library

    # define target & alias (for other projects consuming the "source-tree")
    add_library(iue-po_po INTERFACE)

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

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

    # define test

if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL)
    add_executable(iue-po_po.test po.test.cpp)
    target_link_libraries(iue-po_po.test iue-po_po)
    add_test(NAME iue-po_po.test COMMAND iue-po_po.test --option1 100 -option2 o2)
endif()

# define C interface library

    # define target & alias (for other projects consuming the "source-tree")
    add_library(iue-po_cpo INTERFACE)

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

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

    # define test

if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL)
    add_executable(iue-po_cpo.test cpo.test.c)
    target_link_libraries(iue-po_cpo.test iue-po_cpo)
    add_test(NAME iue-po_cpo.test COMMAND iue-po_cpo.test --option1 100 -option2 o2)
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-po-export DESTINATION "iue-po" )

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