-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
131 lines (111 loc) · 4.11 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
cmake_minimum_required(VERSION 3.10)
project(sofutobanku)
set(MAJOR_VERSION 1)
set(MINOR_VERSION 0)
set(PACKAGE sofutobanku)
set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
set(VERSION ${VERSION_STRING})
# We require C++11 because of unique_ptr, et al.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_library(SBRadLib STATIC "")
add_executable(sbradclient "")
add_executable(sbradclient_tests "")
#
# Make /usr the default install prefix
#
SET(SOFUTOBANKU_INSTALL_PREFIX "/usr" CACHE PATH "Prefix prepended to install directories")
SET(CMAKE_INSTALL_PREFIX "${SOFUTOBANKU_INSTALL_PREFIX}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
#
# Replace directory variables in scripts
#
SET(_default_sysconf_dir "etc")
IF(CMAKE_INSTALL_PREFIX STREQUAL "/usr")
SET(_default_sysconf_dir "/etc")
SET(CPACK_PACKAGE_RELOCATABLE FALSE)
ENDIF()
SET(CMAKE_INSTALL_SYSCONFDIR "${_default_sysconf_dir}")
SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
SET(_instdir "${PROJECT_BINARY_DIR}/instfiles")
FILE(REMOVE_RECURSE "${_instdir}")
SET(_etcdir "${_instdir}/etc")
FILE(MAKE_DIRECTORY "${_etcdir}")
CONFIGURE_FILE("${CMAKE_CURRENT_LIST_DIR}/etc/dibbler.sh.in" "${_etcdir}/dibbler.sh" @ONLY)
INSTALL(FILES "${_etcdir}/dibbler.sh"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}")
CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/src/config.h.in"
"${PROJECT_BINARY_DIR}/config.h")
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
#
# Include nettle for MD5 calculation
#
find_package(PkgConfig REQUIRED)
pkg_search_module(NETTLE REQUIRED nettle)
if(NETTLE_FOUND)
include_directories(${NETTLE_INCLUDE_DIRS})
message(STATUS "Using nettle ${NETTLE_VERSION}")
else()
# We should not reach here since nettle is REQUIRED
endif()
#
# Include radcli for RADIUS client
#
pkg_search_module(RADCLI REQUIRED radcli)
if(RADCLI_FOUND)
include_directories(${RADCLI_INCLUDE_DIRS})
message(STATUS "Using radcli ${RADCLI_VERSION}")
else()
# We should not get here since radcli is REQUIRED
endif()
target_link_libraries(SBRadLib ${NETTLE_LIBRARIES} ${RADCLI_LIBRARIES})
INSTALL(TARGETS sbradclient DESTINATION sbin)
INSTALL(FILES etc/dictionary.softbank DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}")
#
# GoogleTest is used for testing functions
#
find_package(GTest REQUIRED)
if(GTEST_FOUND)
include_directories(${GTEST_INCLUDE_DIRS})
message(STATUS "Using GoogleTest ${GTEST_VERSION}")
else()
# We should not get here since GoogleTest is REQUIRED
endif()
# Now set up the sources
include(src/CMakeLists.txt)
#
# Setup testing
#
enable_testing()
include(GoogleTest)
gtest_discover_tests(sbradclient_tests)
#
# Packaging instructions
#
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION ${VERSION_STRING})
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/LICENSE")
set(CPACK_PACKAGE_VENDOR "Kenny Root")
set(CPACK_PACKAGE_CONTACT "https://github.com/kruton/sofutobanku/")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_RPM_PACKAGE_DESCRIPTION "Sets up Internet connections for Softbank Hikari")
set(CPACK_RPM_PACKAGE_URL "https://github.com/kruton/sofutobanku/")
set(CPACK_RPM_PACKAGE_LICENSE "ASL 2.0")
set(CPACK_RPM_PACKAGE_GROUP "System Environment/Base")
set(CPACK_RPM_BUILDREQUIRES "cmake, radcli-devel, nettle-devel >= 2.3")
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_LIST_DIR}/ChangeLog.txt")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
LIST(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/sbin")
LIST(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/local")
set(CPACK_GENERATOR "RPM;DEB")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES
"^${PROJECT_SOURCE_DIR}/build/"
"^${PROJECT_SOURCE_DIR}/\\\\.git/"
"^${PROJECT_SOURCE_DIR}/\\\\."
)
include(CPack)