# SPDX-FileCopyrightText: 2013 - 2014 Dan Vrátil
# SPDX-FileCopyrightText: 2016 - 2017 Elvis Angelaccio
# SPDX-FileCopyrightText: 2019 - 2020 David Barchiesi
# SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau
# SPDX-FileCopyrightText: 2022 Laurent Montel
# SPDX-FileCopyrightText: 2023 Nicolas Fella
# SPDX-FileCopyrightText: 2024 Bernardo Gomes Negri <b.gomes.negri@gmail.com>
#
# SPDX-License-Identifier: GPL-2.0-or-later

include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_BINARY_DIR})

set(kio_onedrive_SRCS
    kio_onedrive.cpp)

ecm_qt_declare_logging_category(kio_onedrive_SRCS
    HEADER onedrivedebug.h
    IDENTIFIER ONEDRIVE
    CATEGORY_NAME kf6.kio.onedrive)

kcoreaddons_add_plugin(kio_onedrive
    SOURCES ${kio_onedrive_SRCS}
    INSTALL_NAMESPACE kf6/kio)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    message(WARNING "This project does not work currently with GCC due to a bug (see Fedora bug 2263269).
To compile with LLVM, clear the CMake cache (delete CMakeCache.txt and CMakeFiles in the build dir) and run with environment variables CC=clang and CXX=clang++")
    target_compile_options(kio_onedrive PUBLIC "-fmodules-ts")
endif()

target_sources(kio_onedrive PRIVATE
    FILE_SET module_files TYPE CXX_MODULES FILES
    URLUtils.cpp
    URLHandler.cpp
    OnedriveWorker.cpp
    DriveItem.cpp)

target_link_libraries(kio_onedrive
    Qt6::Core
    Qt6::Network
    KF6::KIOCore
    KF6::I18n
    KAccounts6)

#Currently does not work with _FORTIFY_SOURCE, likely because of compiler/libc bugs.
target_compile_options(kio_onedrive PRIVATE "-D_FORTIFY_SOURCE=0")
target_compile_options(kio_onedrive PRIVATE "-Wno-macro-redefined")
set_target_properties(kio_onedrive PROPERTIES OUTPUT_NAME "onedrive" CXX_STANDARD 20 CXX_SCAN_FOR_MODULES true)
