-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
85 lines (72 loc) · 2.48 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
cmake_minimum_required(VERSION 3.22)
project(emsha
VERSION 1.1.1
LANGUAGES CXX
DESCRIPTION "A compact HMAC-SHA-256 C++11 library.")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_VERBOSE_MAKEFILES ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(SET_EMSHA_NO_HEXSTRING OFF CACHE BOOL
"Don't include support for hex strings.")
if (SET_EMSHA_NO_HEXSTRING)
add_definitions(EMSHA_NO_HEXSTRING)
endif ()
set(SET_EMSHA_NO_HEXLUT OFF CACHE BOOL
"Don't use a LUT for hex strings (saves ~256B of memory).")
if (SET_EMSHA_NO_HEXLUT)
add_definitions("-DEMSHA_NO_HEXLUT")
endif ()
set(SET_EMSHA_NO_SELFTEST OFF CACHE BOOL
"Disable the internal self-tests.")
if (SET_EMSHA_NO_SELFTEST)
add_definitions("-DEMSHA_NO_SELFTEST")
endif ()
include(CTest)
enable_testing()
# compile options:
# -Wall Default to all errors.
# -Wextra And a few extra.
# -Werror And require them to be fixed to build.
# -Wno-unused-function This is a library. Not every function is used here.
# -Wno-unused-parameter Some functions have parameters defined for compatibility,
# and aren't used in the implementation.
add_compile_options(
"-static"
"-Wall"
"-Wextra"
"-Werror"
"-Wno-unused-function"
"-Wno-unused-parameter"
"-g"
"$<$<CONFIG:RELEASE>:-O2>"
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options("-stdlib=libc++")
else ()
# nothing special for gcc at the moment
endif ()
### Set up the build ###
set(HEADERS
include/emsha/emsha.h
include/emsha/sha256.h
include/emsha/hmac.h
include/emsha/internal.h)
set(SOURCES src/emsha.cc src/sha256.cc src/hmac.cc)
include_directories(include)
### Build products ###
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
### TESTS ###
set(TEST_SOURCES test/test_utils.cc)
macro(generate_test name)
add_executable(${name} test/${name}.cc ${TEST_SOURCES} ${ARGN})
target_link_libraries(${name} ${PROJECT_NAME})
target_include_directories(${name} PRIVATE test)
add_test(${name} ${name})
endmacro()
generate_test(test_${PROJECT_NAME})
generate_test(test_hmac)
generate_test(test_mem)
generate_test(test_sha256)
include(cmake/docs.cmake)
include(cmake/install.cmake)
include(cmake/packaging.cmake)