Skip to content

Commit 949926a

Browse files
committed
Add cmake file
From mlabbe#99.
1 parent 67345b8 commit 949926a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_minimum_required(VERSION 3.8.0)
2+
project(nativefiledialog)
3+
4+
if(UNIX AND NOT APPLE AND NOT ANDROID)
5+
set(LINUX 1)
6+
endif()
7+
8+
set(SOURCES src/nfd_common.c)
9+
10+
# Add specific implementations
11+
if (WIN32)
12+
list(APPEND SOURCES src/nfd_win.cpp)
13+
list(APPEND PREPROCESSOR_DEFINITIONS
14+
UNICODE
15+
_UNICODE
16+
)
17+
elseif (APPLE)
18+
list(APPEND SOURCES src/nfd_cocoa.m)
19+
elseif (LINUX)
20+
list(APPEND SOURCES src/nfd_gtk.c)
21+
else()
22+
message(FATAL_ERROR "Cannot detect your system")
23+
endif()
24+
25+
add_library(nativefiledialog ${SOURCES})
26+
target_include_directories(nativefiledialog PUBLIC src/include)
27+
target_compile_definitions(nativefiledialog PUBLIC ${PREPROCESSOR_DEFINITIONS})
28+
29+
if(LINUX)
30+
find_package(PkgConfig)
31+
if (PKG_CONFIG_FOUND)
32+
pkg_check_modules(GTK "gtk+-3.0")
33+
if (GTK_FOUND)
34+
target_link_libraries(nativefiledialog ${GTK_LIBRARIES})
35+
add_definitions(${GTK_CFLAGS} ${GTK_CFLAGS_OTHER})
36+
endif()
37+
endif()
38+
endif()
39+
40+
install(TARGETS nativefiledialog DESTINATION lib)

0 commit comments

Comments
 (0)