# FreeRDP: A Remote Desktop Protocol Implementation
# FreeRDP SDL Client
#
# Copyright 2022 Armin Novak <anovak@thincast.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "sdl2-freerdp")

find_package(SDL2 REQUIRED COMPONENTS)
include_directories(SYSTEM ${SDL2_INCLUDE_DIR})
include_directories(SYSTEM ${SDL2_INCLUDE_DIRS})

find_package(Threads REQUIRED)

add_subdirectory(dialogs)
set(SRCS
    sdl_types.hpp
    sdl_utils.cpp
    sdl_utils.hpp
    sdl_kbd.cpp
    sdl_kbd.hpp
    sdl_touch.cpp
    sdl_touch.hpp
    sdl_pointer.cpp
    sdl_pointer.hpp
    sdl_disp.cpp
    sdl_disp.hpp
    sdl_monitor.cpp
    sdl_monitor.hpp
    sdl_freerdp.hpp
    sdl_freerdp.cpp
    sdl_channels.hpp
    sdl_channels.cpp
    sdl_window.hpp
    sdl_window.cpp
)

list(APPEND LIBS
        winpr
        freerdp
        freerdp-client
        Threads::Threads
        sdl2_client_res
        sdl2-dialogs
		sdl-common-aad-view
		sdl-common-prefs
    )

if (NOT WITH_SDL_LINK_SHARED)
    list(APPEND LIBS ${SDL2_STATIC_LIBRARIES})
else()
    list(APPEND LIBS ${SDL2_LIBRARIES})
endif()

AddTargetWithResourceFile(${MODULE_NAME} TRUE "${PROJECT_VERSION}" SRCS)

target_link_libraries(${MODULE_NAME} PRIVATE ${LIBS})

set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/SDL")

if (NOT WITH_CLIENT_SDL_VERSIONED)
    get_target_property(OUT_NAME ${MODULE_NAME} OUTPUT_NAME)
    string(REPLACE "${MODULE_NAME}" "${PROJECT_NAME}" OUT_NAME "${OUT_NAME}")
    set_target_properties(${MODULE_NAME}
        PROPERTIES
        OUTPUT_NAME ${OUT_NAME})
endif()

install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)

add_subdirectory(man)
