#
# This is CMakeLists for project: Logging
#
project(Logging)

include_cmake(${SRC})

add_library(Logging SHARED ${SOURCES} )

target_include_directories(Logging
    SYSTEM PRIVATE
    "${Boost_INCLUDE_DIRS}"
    "${ZLIB_INCLUDE_DIR}"
    "${LIBZIP_INCLUDE_DIRS}"
)

target_include_directories(Logging
    PRIVATE
        "${IPC_ROOT}/Public_Include"
        "${IPC_ROOT}/Private/InternalUtils"
        "${OPENIPC_ROOT}/Source/Public_Include"
)

# Create the static file that informs users about the fact that log files have moved
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LOGS_HAVE_MOVED.txt"
"The OpenIPC logs have moved. They can now be found under the \".OpenIPC\" folder in your user directory.

Examples:
    - Windows: C:\\Users\\<user>\\.OpenIPC
    - GNU/Linux: /home/<user>/.OpenIPC
    - macOS: /Users/<user>/.OpenIPC
    - Generic UNIX: ~/.OpenIPC
")

set_target_properties(Logging PROPERTIES
                      OUTPUT_NAME Logging_${ARCHITECTURE_NAME}
                      DEFINE_SYMBOL LOGGING_EXPORTS
                      FOLDER "/Foundation")

target_link_libraries(Logging PRIVATE InternalUtils
                                      CommonUtils
                                      ${Boost_LOCALE_LIBRARY}
                                      ${Boost_FILESYSTEM_LIBRARY}
                                      ${Boost_LOG_LIBRARY}
                                      ${Boost_THREAD_LIBRARY}
                                      ${Boost_SYSTEM_LIBRARY}
                                      ${LIBZIP_LIBRARIES}
                                      ${ZLIB_LIBRARIES}
                                      ${CMAKE_DL_LIBS}
                                      Threads::Threads)

if(UNIX AND NOT APPLE)
    target_link_libraries(Logging PRIVATE rt)
endif()

install(TARGETS Logging
        LIBRARY DESTINATION ${DPL_BIN_ROOT} COMPONENT openipc
        RUNTIME DESTINATION ${DPL_BIN_ROOT} COMPONENT openipc)

INSTALL_PDB(Logging)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LOGS_HAVE_MOVED.txt"
        DESTINATION ${DPL_BIN_ROOT}/Log
        COMPONENT openipc)

if(CONFIG_SHIP_PLUGINSDK)
    install(TARGETS Logging
            ARCHIVE DESTINATION "${DPL_PROBEPLUGINSDK_LIBS}" COMPONENT probepluginsdk
            LIBRARY DESTINATION "${DPL_PROBEPLUGINSDK_LIBS}" COMPONENT probepluginsdk
            RUNTIME DESTINATION "${DPL_PROBEPLUGINSDK_LIBS}" COMPONENT probepluginsdk)

    INSTALL_PDB(Logging)
endif()
