-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
88 lines (65 loc) · 2.44 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
cmake_minimum_required (VERSION 2.6)
project (dush C)
set (PROG_VERSION_MAJOR 0)
set (PROG_VERSION_MINOR 10)
# include binary file in order to find config.h
include_directories("${PROJECT_BINARY_DIR}")
add_executable(dush dush.c)
set (COMMON_FLAGS "-std=c99 -Wall -pedantic")
# enable 64 bits off_t on 32 bits platforms
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE)
if (CMAKE_BUILD_TYPE STREQUAL "debug")
set (DEBUG_FLAGS "-O0 -g")
else()
set (CMAKE_BUILD_TYPE "release")
endif()
message ("-- Building target: ${CMAKE_BUILD_TYPE}")
set (CMAKE_C_FLAGS_RELEASE "${COMMON_FLAGS}")
set (CMAKE_C_FLAGS_DEBUG "${COMMON_FLAGS} ${DEBUG_FLAGS}")
install (TARGETS dush DESTINATION bin)
install (FILES dush.1 DESTINATION share/man/man1)
include (CheckIncludeFiles)
CHECK_INCLUDE_FILES (uthash.h HAVE_UTHASH_H)
if (NOT HAVE_UTHASH_H)
message(FATAL_ERROR "Install uthash")
endif()
include (CheckFunctionExists)
CHECK_FUNCTION_EXISTS("getopt_long" HAVE_GETOPT_LONG)
include (CheckTypeSize)
set (CMAKE_EXTRA_INCLUDE_FILES sys/ioctl.h)
CHECK_TYPE_SIZE("struct winsize" HAVE_STRUCT_WINSIZE)
include (CheckSymbolExists)
# first shot, maybe someday other libcs catch up...
CHECK_SYMBOL_EXISTS(FTW_ACTIONRETVAL ftw.h HAVE_ACTIONRETVAL_LIBC)
if (NOT HAVE_ACTIONRETVAL_LIBC) # not in your clib, check for glibc
message(STATUS "FTW_ACTIONRETVAL not defined, trying -D_GNU_SOURCE")
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
CHECK_SYMBOL_EXISTS(FTW_ACTIONRETVAL ftw.h HAVE_ACTIONRETVAL_GLIBC)
if (HAVE_ACTIONRETVAL_GLIBC)
add_definitions(-D_GNU_SOURCE)
else()
message(FATAL_ERROR "FTW_ACTIONRETVAL not defined, get glibc")
endif()
endif()
configure_file (
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
# build a CPack driven installer package
# generall:
include (InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set (CPACK_PACKAGE_CONTACT
"Roland Kammerer <[email protected]>")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY
"find and display largest files/directories")
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
set (CPACK_PACKAGE_VERSION_MAJOR "${PROG_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${PROG_VERSION_MINOR}")
# DEB specific
set (CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "uthash-dev (>=1.8)")
# RPM specific
set (CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
set (CPACK_RPM_PACKAGE_LICENSE "GPLv3+")
include (CPack)