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

# ${SRC} cmake file defines ${SOURCES} variable which holds all sources used during compilation
include_cmake(${SRC})

enable_all_warnings()
enable_warnings_as_errors()

# Adds a library target called <name> to be built from the source files listed in the command invocation.
# The <name> corresponds to the logical target name and must be globally unique within a project.
# The actual file name of the library built is constructed based on conventions of the native platform (such as lib<name>.a or <name>.lib).
add_library(Common SHARED ${SOURCES})
UNCRUSTIFY(Common ${SOURCES})

target_include_directories(Common
	SYSTEM PRIVATE
		"${Boost_INCLUDE_DIRS}"
)

target_include_directories(Common
    PRIVATE
        "${OPENIPC_ROOT}/Source/Public_Include"
    )

set_target_properties(Common PROPERTIES
                      OUTPUT_NAME Common_${ARCHITECTURE_NAME}
                      DEFINE_SYMBOL COMMON_EXPORTS
                      FOLDER "/Components")

# Link a target to given libraries.
target_link_libraries(Common PRIVATE  Error
                                      StructuredData
                                      Logging
                                      CommonUtils
                                      Telemetry
                                      ${Boost_FILESYSTEM_LIBRARY}
                                      ${Boost_THREAD_LIBRARY}
                                      ${Boost_SYSTEM_LIBRARY}
                                      Threads::Threads
                                      ${CMAKE_DL_LIBS})

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

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

INSTALL_PDB(Common)
