From fac962ec9f5ff47a61a726367b4489ca6a0d1520 Mon Sep 17 00:00:00 2001 From: Alvaro Barua Date: Sun, 23 Aug 2020 13:59:13 +0100 Subject: [PATCH 1/3] Added CMakiLists --- CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..dfba3b6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.8.0) +project(nativefiledialog) + + +set(SOURCES src/nfd_common.c) + +# Add specific implementations +if (WIN32) + list(APPEND SOURCES src/nfd_win.cpp) +elseif (APPLE) + list(APPEND SOURCES src/nfd_cocoa.m) +elseif (UNIX) + list(APPEND SOURCES src/nfd_gtk.c) +else() + message(FATAL_ERROR "Cannot detect your system") +endif() + +add_library(nativefiledialog ${SOURCES}) +target_include_directories(nativefiledialog PUBLIC src/include) +install(TARGETS nativefiledialog DESTINATION lib) \ No newline at end of file From f21652d8aa30a72f9ccc95eb219f7a93dfe1644a Mon Sep 17 00:00:00 2001 From: Alvaro Date: Tue, 25 Aug 2020 14:17:08 +0100 Subject: [PATCH 2/3] Added proper configuration for Linux builds --- CMakeLists.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfba3b6..68caddc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.8.0) project(nativefiledialog) +if(UNIX AND NOT APPLE AND NOT ANDROID) + set(LINUX 1) +endif() set(SOURCES src/nfd_common.c) @@ -9,7 +12,7 @@ if (WIN32) list(APPEND SOURCES src/nfd_win.cpp) elseif (APPLE) list(APPEND SOURCES src/nfd_cocoa.m) -elseif (UNIX) +elseif (LINUX) list(APPEND SOURCES src/nfd_gtk.c) else() message(FATAL_ERROR "Cannot detect your system") @@ -17,4 +20,16 @@ endif() add_library(nativefiledialog ${SOURCES}) target_include_directories(nativefiledialog PUBLIC src/include) + +if(LINUX) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(GTK "gtk+-3.0") + if (GTK_FOUND) + target_link_libraries(nativefiledialog ${GTK_LIBRARIES}) + add_definitions(${GTK_CFLAGS} ${GTK_CFLAGS_OTHER}) + endif() + endif() +endif() + install(TARGETS nativefiledialog DESTINATION lib) \ No newline at end of file From 434b5d67a83377792901cb965596e30cca0f3b4d Mon Sep 17 00:00:00 2001 From: Alvaro Barua Date: Tue, 9 Mar 2021 12:28:28 +0000 Subject: [PATCH 3/3] Fixes UNICODE error on windows CMakeLists --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68caddc..507172e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,10 @@ set(SOURCES src/nfd_common.c) # Add specific implementations if (WIN32) list(APPEND SOURCES src/nfd_win.cpp) + list(APPEND PREPROCESSOR_DEFINITIONS + UNICODE + _UNICODE + ) elseif (APPLE) list(APPEND SOURCES src/nfd_cocoa.m) elseif (LINUX) @@ -20,6 +24,7 @@ endif() add_library(nativefiledialog ${SOURCES}) target_include_directories(nativefiledialog PUBLIC src/include) +target_compile_definitions(nativefiledialog PUBLIC ${PREPROCESSOR_DEFINITIONS}) if(LINUX) find_package(PkgConfig)