# some systems have no shared libraries support, so check it
if(NOT DEFINED TARGET_SUPPORTS_SHARED_LIBS OR TARGET_SUPPORTS_SHARED_LIBS)
    add_executable(SharedApp SharedApp/Main.cpp)
    target_link_libraries(SharedApp PRIVATE plog::plog)
    set_target_properties(SharedApp PROPERTIES FOLDER Samples/Shared)
    # define PLOG_GLOBAL to share plog instances across modules (PLOG_EXPORT to export on Windows)
    if(WIN32)
        target_compile_definitions(SharedApp PRIVATE PLOG_EXPORT)
        set_target_properties(SharedApp PROPERTIES ENABLE_EXPORTS 1)
    else()
        target_compile_definitions(SharedApp PRIVATE PLOG_GLOBAL)
        target_link_libraries(SharedApp PRIVATE SharedLib1 SharedLib2)
    endif()

    add_library(SharedLib1 SHARED SharedLib1/Main.cpp)
    target_link_libraries(SharedLib1 PRIVATE plog::plog)
    set_target_properties(SharedLib1 PROPERTIES FOLDER Samples/Shared)
    # define PLOG_GLOBAL to share plog instances across modules (PLOG_IMPORT to import on Windows)
    if(WIN32)
        target_compile_definitions(SharedLib1 PRIVATE PLOG_IMPORT)
        target_link_libraries(SharedLib1 PRIVATE SharedApp)
    else()
        target_compile_definitions(SharedLib1 PRIVATE PLOG_GLOBAL)
    endif()

    add_library(SharedLib2 SHARED SharedLib2/Main.cpp)
    target_link_libraries(SharedLib2 PRIVATE plog::plog)
    set_target_properties(SharedLib2 PROPERTIES FOLDER Samples/Shared)
    # define PLOG_GLOBAL to share plog instances across modules (PLOG_IMPORT to import on Windows)
    if(WIN32)
        target_compile_definitions(SharedLib2 PRIVATE PLOG_IMPORT)
        target_link_libraries(SharedLib2 PRIVATE SharedApp)
    else()
        target_compile_definitions(SharedLib2 PRIVATE PLOG_GLOBAL)
    endif()
endif()
