-
Notifications
You must be signed in to change notification settings - Fork 34
/
CMakeLists.txt
145 lines (130 loc) · 3.94 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Copyright (C) 2023-2024, Abel Cheung
# rifiuti2 is released under Revised BSD License.
# Please see LICENSE file for more info.
cmake_minimum_required(VERSION 3.17 FATAL_ERROR) # cmake -E rm
project(rifiuti2
VERSION 0.8.1
HOMEPAGE_URL "https://github.com/abelcheung/rifiuti2/"
DESCRIPTION "Windows recycle bin analysis tool"
LANGUAGES C)
set(PROJECT_BUG_REPORT_URL "${PROJECT_HOMEPAGE_URL}issues")
set(PROJECT_TOOL_USAGE_URL "${PROJECT_HOMEPAGE_URL}wiki/Usage-and-Examples")
set(PROJECT_GH_PAGE "https://abelcheung.github.io/rifiuti2/")
include(GNUInstallDirs)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
if(DEFINED CMAKE_C_FLAGS_DEBUG)
string(APPEND CMAKE_C_FLAGS_DEBUG " -O0 -Wextra")
else()
set(CMAKE_C_FLAGS_DEBUG "-O0 -Wextra")
endif()
if(NOT DEFINED CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "")
endif()
string(APPEND CMAKE_C_FLAGS
" -DG_LOG_DOMAIN=\\\"${PROJECT_NAME}\\\" -Wall -Werror")
set(CMAKE_STATIC_LINKER_FLAGS "-static")
configure_file(src/config.h.in config.h)
configure_file(docs/rifiuti.1.in rifiuti.1)
configure_file(docs/readme.txt.in readme.txt)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED "glib-2.0 >= 2.40.0")
# Do static build in Windows, which require finding
# extra libraries
if (WIN32)
pkg_check_modules(ICONV REQUIRED "iconv")
list(APPEND GLIB_STATIC_CFLAGS_OTHER -DGLIB_STATIC_COMPILATION)
endif()
foreach(bin rifiuti rifiuti-vista)
add_executable(
${bin}
src/${bin}.c
src/${bin}.h
)
target_include_directories(
${bin} BEFORE
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
)
target_sources(
${bin}
PRIVATE
src/utils.c
src/utils.h
src/utils-conv.c
src/utils-conv.h
src/utils-error.h
src/utils-io.c
src/utils-io.h
src/utils-platform.h
)
if(WIN32)
target_sources(${bin}
PRIVATE src/utils-win.c)
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
target_sources(${bin}
PRIVATE src/utils-linux.c)
endif()
if(WIN32)
target_include_directories(${bin} PRIVATE
${GLIB_STATIC_INCLUDE_DIRS} ${ICONV_STATIC_INCLUDE_DIRS})
target_compile_options (${bin} PRIVATE
${GLIB_STATIC_CFLAGS_OTHER} ${ICONV_STATIC_CFLAGS_OTHER})
target_link_libraries (${bin} PRIVATE authz
${GLIB_STATIC_LIBRARIES} ${ICONV_STATIC_LIBRARIES})
target_link_directories (${bin} PRIVATE
${GLIB_STATIC_LIBRARY_DIRS} ${ICONV_STATIC_LIBRARY_DIRS})
target_link_options (${bin} BEFORE PRIVATE ${CMAKE_STATIC_LINKER_FLAGS})
else()
target_include_directories(${bin} PRIVATE ${GLIB_INCLUDE_DIRS})
target_compile_options (${bin} PRIVATE ${GLIB_CFLAGS_OTHER})
target_link_libraries (${bin} PRIVATE ${GLIB_LIBRARIES})
target_link_directories (${bin} PRIVATE ${GLIB_LIBRARY_DIRS})
endif()
endforeach()
# Install: Windows use simplistic folder,
# non-Windows follow FHS.
if(WIN32)
set(CMAKE_INSTALL_BINDIR .)
set(CMAKE_INSTALL_DOCDIR doc)
else()
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/rifiuti.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
)
endif()
install(
TARGETS
rifiuti
rifiuti-vista
RUNTIME
)
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/LICENSE
${CMAKE_CURRENT_SOURCE_DIR}/docs/THANKS.txt
${CMAKE_CURRENT_BINARY_DIR}/readme.txt
TYPE DOC
)
include(CTest)
add_subdirectory(test)
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION})
if(WIN32)
set(CPACK_GENERATOR "ZIP")
set(CPACK_SOURCE_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TXZ")
endif()
set(CPACK_SOURCE_IGNORE_FILES
.editorconfig
.git/
.gitattribute
.gitignore
.github/
CTestConfig.cmake
${CMAKE_BINARY_DIR}/
${PROJECT_BINARY_DIR}/
)
include(CPack)