set(MODULE_NAME network)

set(platform_INCLUDES)
set(platform_LIBS)

if(UNIX)
list(APPEND platform_INCLUDES 
	sockets/BerkeleySocket.h
	sockets/BerkeleySocket.cpp
	server/UnixSocketServer.h
	server/UnixSocketServer.cpp
	client/unix/UnixSocketClient.h
	client/unix/UnixSocketClient.cpp
	)
else()
list(APPEND platform_INCLUDES 
	server/win32/Win32WebServer.h
    server/win32/Win32WebServer.cpp
	server/win32/Win32TempFile.h
	server/win32/Win32TempFile.cpp
	server/win32/Win32WebRequest.h
	server/win32/Win32WebRequest.cpp
	server/win32/Win32WebResponse.h
	server/win32/Win32WebResponse.cpp
	server/win32/Win32Buffer.h
	server/win32/Win32Buffer.cpp
	server/WinsockServer.h
	server/WinsockServer.cpp
	client/win32/WinsockClient.h
	client/win32/WinsockClient.cpp
	sockets/WinsockInterface.h
	sockets/WinsockInterface.cpp
	sockets/WinsockSocket.h
	sockets/WinsockSocket.cpp
	)
    list(APPEND platform_LIBS Httpapi.lib Ws2_32.lib)
endif()

list(APPEND HEADERS 
    NetworkManager.h
	client/HttpClient.h
	client/PlatformSocketClient.h
	server/HttpServer.h
	server/PlatformSocketServer.h
    sockets/Socket.h
	sockets/IPlatformSocket.h
    )

list(APPEND SOURCES 
	client/HttpClient.cpp
	server/HttpServer.cpp
    NetworkManager.cpp
    sockets/Socket.cpp
    )

add_library(${MODULE_NAME} SHARED ${SOURCES} ${platform_INCLUDES} ${HEADERS})

target_include_directories(${MODULE_NAME} PUBLIC
                          ${CMAKE_CURRENT_SOURCE_DIR}
                          ${CMAKE_CURRENT_SOURCE_DIR}/sockets
						  ${CMAKE_CURRENT_SOURCE_DIR}/server
						  ${CMAKE_CURRENT_SOURCE_DIR}/server/win32
						  ${CMAKE_CURRENT_SOURCE_DIR}/client
						  ${CMAKE_CURRENT_SOURCE_DIR}/client/win32
						  ${CMAKE_CURRENT_SOURCE_DIR}/client/unix
                          )
set_target_properties( ${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )                          
target_link_libraries( ${MODULE_NAME} PUBLIC core ${platform_LIBS})

set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src/base)
