-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
55 lines (47 loc) · 1.43 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
cmake_minimum_required(VERSION 3.10)
project(libpaseto
VERSION 1.0
LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Werror)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SODIUM REQUIRED libsodium)
include_directories(${SODIUM_INCLUDE_DIRS})
include_directories(include)
set(PASETO_SOURCES
src/paseto_v2_local.c
src/paseto_v2_public.c
src/paseto.c
src/helpers.c
src/helpers.h
include/paseto.h)
configure_file("paseto.pc.in" "paseto.pc" @ONLY)
# shared library build
add_library(paseto SHARED ${PASETO_SOURCES})
target_link_libraries(paseto ${SODIUM_LIBRARIES})
install(TARGETS paseto
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES include/paseto.h
DESTINATION include)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/paseto.pc"
DESTINATION lib/pkgconfig)
# test executable
add_executable(pasetotest
test/main.c
test/helpers.h
test/helpers.c
test/test.h
test/test.c
test/v2vectors.h
test/v2vectors.c
test/v2publicvectors.c)
target_compile_definitions(pasetotest PRIVATE _POSIX_C_SOURCE=200809L)
target_link_libraries(pasetotest ${SODIUM_LIBRARIES} paseto)
# examples
set(EXAMPLES example_v2_local example_v2_public gen-keys paseto-v2-local-encrypt paseto-v2-local-decrypt)
foreach(EXAMPLE ${EXAMPLES})
add_executable(${EXAMPLE} examples/${EXAMPLE}.c)
target_link_libraries(${EXAMPLE} ${SODIUM_LIBRARIES} paseto)
endforeach()