-
Notifications
You must be signed in to change notification settings - Fork 89
/
CMakeLists.txt
107 lines (90 loc) · 2.99 KB
/
CMakeLists.txt
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Clip Library
# Copyright (c) 2015-2024 David Capello
cmake_minimum_required(VERSION 3.5)
project(clip LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# Use libc++ explicitly so we can compile for
# CMAKE_OSX_DEPLOYMENT_TARGET=10.7 or 10.8
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
option(CLIP_ENABLE_IMAGE "Compile with support to copy/paste images" on)
if(WIN32)
option(CLIP_ENABLE_LIST_FORMATS "Compile with support to list clipboard formats" off)
endif()
option(CLIP_EXAMPLES "Compile clip examples" on)
option(CLIP_TESTS "Compile clip tests" on)
if(UNIX AND NOT APPLE)
option(CLIP_X11_WITH_PNG "Compile with libpng to support copy/paste image in png format" on)
endif()
add_library(clip clip.cpp)
if(CLIP_ENABLE_IMAGE)
target_sources(clip PRIVATE image.cpp)
target_compile_definitions(clip PUBLIC -DCLIP_ENABLE_IMAGE=1)
endif()
if(CLIP_ENABLE_LIST_FORMATS)
target_compile_definitions(clip PUBLIC -DCLIP_ENABLE_LIST_FORMATS=1)
endif()
if(WIN32)
option(CLIP_SUPPORT_WINXP "Enable Windows XP support" OFF)
target_sources(clip PRIVATE clip_win.cpp)
if(CLIP_ENABLE_IMAGE)
target_sources(clip PRIVATE clip_win_bmp.cpp clip_win_wic.cpp)
target_link_libraries(clip shlwapi)
endif()
if(MSVC)
target_compile_definitions(clip PRIVATE -D_SCL_SECURE_NO_WARNINGS)
endif()
if (CLIP_SUPPORT_WINXP)
target_compile_definitions(clip PRIVATE -DCLIP_SUPPORT_WINXP)
endif()
# MinGW requires the windowscodecs just because CLSIDs are defined
# in the windowscodecs.a file instead of the wincodec.h file (?!)
if(MINGW)
find_library(CLIP_WINDOWSCODECS_LIBRARY windowscodecs)
if(CLIP_WINDOWSCODECS_LIBRARY)
target_link_libraries(clip ${CLIP_WINDOWSCODECS_LIBRARY})
endif()
endif()
elseif(APPLE)
target_compile_options(clip PRIVATE -fobjc-arc)
find_library(COCOA_LIBRARY Cocoa)
if(COCOA_LIBRARY)
target_sources(clip PRIVATE clip_osx.mm)
target_link_libraries(clip ${COCOA_LIBRARY})
else()
target_sources(clip PRIVATE clip_none.cpp)
endif()
elseif(UNIX)
include(CheckIncludeFiles)
check_include_files(xcb/xcb.h HAVE_XCB_XLIB_H)
if(HAVE_XCB_XLIB_H)
target_compile_definitions(clip PRIVATE -DHAVE_XCB_XLIB_H)
target_link_libraries(clip xcb pthread)
if(CLIP_ENABLE_IMAGE AND CLIP_X11_WITH_PNG)
check_include_files(png.h HAVE_PNG_H)
if(CLIP_X11_PNG_LIBRARY)
set(PNG_LIBRARY ${CLIP_X11_PNG_LIBRARY})
else()
find_library(PNG_LIBRARY png)
endif()
if(HAVE_PNG_H AND PNG_LIBRARY)
target_compile_definitions(clip PRIVATE -DHAVE_PNG_H)
endif()
target_link_libraries(clip ${PNG_LIBRARY})
endif()
target_sources(clip PRIVATE clip_x11.cpp)
else()
target_sources(clip PRIVATE clip_none.cpp)
endif()
else()
target_sources(clip PRIVATE clip_none.cpp)
endif()
if(CLIP_EXAMPLES)
add_subdirectory(examples)
endif()
if(CLIP_TESTS)
enable_testing()
add_subdirectory(tests)
endif()