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

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

enable_all_warnings()
enable_warnings_as_errors()

add_library(StructuredData_Objects OBJECT ${SOURCES})

set_target_properties(StructuredData_Objects PROPERTIES
                      DEFINE_SYMBOL STRUCTUREDDATA_EXPORTS
                      FOLDER "/Foundation")

target_compile_definitions(StructuredData_Objects PRIVATE STRUCTUREDDATA_EXPORTS)

target_include_directories(StructuredData_Objects
    PRIVATE
        "${OPENIPC_ROOT}/Source/Public_Include"
        "${OPENIPC_ROOT}/Source/Foundation/CommonUtils/Public"
		"${OPENIPC_ROOT}/ThirdParty/Xerces-C++/3.2.2/include/"
		"${OPENIPC_ROOT}/ThirdParty/Xerces-C++/3.2.2/${SYSTEM_NAME}/include/"

    PUBLIC
        "Public")

target_include_directories(StructuredData_Objects
    SYSTEM PUBLIC
        "${Boost_INCLUDE_DIRS}"
		 "${OPENIPC_ROOT}/Source/Foundation/CommonUtils/Public")

target_link_libraries(StructuredData_Objects PUBLIC ${XERCES_LIBRARIES})

# enable or disable encryption
if (CONFIG_INCLUDE_STRUCTUREDDATA_ENCRYPTION_SUPPORT)
    target_compile_definitions(StructuredData_Objects PUBLIC CONFIG_INCLUDE_STRUCTUREDDATA_ENCRYPTION_SUPPORT=true)
    target_include_directories(StructuredData_Objects
        PUBLIC
            "${OPENIPC_ROOT}/Source/Foundation/Encryption/Public"
            "${CMAKE_CURRENT_BINARY_DIR}/../Encryption/Generated")
    target_link_libraries(StructuredData_Objects PUBLIC Encryption)
else()
    target_compile_definitions(StructuredData_Objects PUBLIC CONFIG_INCLUDE_STRUCTUREDDATA_ENCRYPTION_SUPPORT=false)
endif()

set(DUMMY_SOURCE_FILE "${CMAKE_CURRENT_BINARY_DIR}/Generated/dummy.cpp")
if (NOT EXISTS "${DUMMY_SOURCE_FILE}")
    file(WRITE "${DUMMY_SOURCE_FILE}" "/*This is needed because some generators (e.g. Xcode) do not like targets that are only made up of objects*/")
endif()

add_library(StructuredData_Static STATIC ${DUMMY_SOURCE_FILE})

target_link_libraries(StructuredData_Static PRIVATE StructuredData_Objects
                                                    CommonUtils
                                                    ${Boost_FILESYSTEM_LIBRARY}
                                                    ${Boost_THREAD_LIBRARY}
                                                    ${Boost_SYSTEM_LIBRARY}
                                                    ${CMAKE_DL_LIBS}
                                                    Threads::Threads)

set_target_properties(StructuredData_Static PROPERTIES
                      OUTPUT_NAME StructuredData_Static_${ARCHITECTURE_NAME}
                      FOLDER "/Foundation")

target_include_directories(StructuredData_Static
    PUBLIC
        "Public")

if (UNIX AND NOT APPLE)
    target_link_libraries(StructuredData_Static INTERFACE "-Wl,-Bsymbolic")
endif()
