summaryrefslogtreecommitdiff
path: root/indra/cmake/NFDE.cmake
blob: 196ba575b26ba0cba63e20075b98232348598be0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- cmake -*-
if(LINUX)
    set(USE_NFDE ON CACHE BOOL "Use Native File Dialog wrapper library")
    set(USE_NFDE_PORTAL ON CACHE BOOL "Use NFDE XDG Portals")
endif()

include_guard()

add_library(ll::nfde INTERFACE IMPORTED)
if(USE_NFDE)
    include(Prebuilt)
    use_prebuilt_binary(nfde)

    target_compile_definitions( ll::nfde INTERFACE LL_NFD=1)

    if (WINDOWS)
        target_link_libraries( ll::nfde INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/nfd.lib)
    elseif (DARWIN)
        target_link_libraries( ll::nfde INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libnfd.a)
    elseif (LINUX)
        if(USE_NFDE_PORTAL)
            target_link_libraries( ll::nfde INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libnfd_portal.a)
        else()
            target_link_libraries( ll::nfde INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libnfd_gtk.a)
        endif()
    endif ()

    if (LINUX)
        find_package(PkgConfig REQUIRED)
        if(NOT USE_NFDE_PORTAL)
            pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
            target_link_libraries(ll::nfde INTERFACE ${GTK3_LINK_LIBRARIES})
        else()
            pkg_check_modules(DBUS REQUIRED dbus-1)
            target_link_libraries(ll::nfde INTERFACE ${DBUS_LINK_LIBRARIES})
        endif()
    endif()

    target_include_directories( ll::nfde SYSTEM INTERFACE
            ${LIBS_PREBUILT_DIR}/include/nfde
            )
endif()