-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
55 lines (40 loc) · 1.46 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.19.0 FATAL_ERROR)
project(TOTP VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules(SODIUM QUIET libsodium)
endif ()
#set(CMAKE_CXX_CLANG_TIDY clang-tidy;
# -checks=*
# )
add_compile_options(-fdiagnostics-color=always)
set(CMAKE_BUILD_TYPE Release) # Debug
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not supported. Please create a new directory (e.g. 'Builds') and run CMake from there")
endif ()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include_directories(${PROJECT_SOURCE_DIR})
add_custom_target(__prebuild__ ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink "${PROJECT_BINARY_DIR}/compile_commands.json" "${PROJECT_SOURCE_DIR}/compile_commands.json"
)
add_library(otp)
target_sources(otp PRIVATE
otp.cpp otp.h
otpauthuri.cpp otpauthuri.h
)
if (SODIUM_FOUND)
target_include_directories(otp PUBLIC ${SODIUM_INCLUDE_DIRS})
target_link_directories(otp PUBLIC ${SODIUM_LIBRARY_DIRS})
endif ()
target_link_libraries(otp PUBLIC -lsodium)
set_target_properties(otp PROPERTIES PUBLIC_HEADER otp.h)
install(TARGETS otp PUBLIC_HEADER)
add_executable(totp)
target_sources(totp PRIVATE main.cpp)
target_link_libraries(totp PRIVATE otp)
# vim:fenc=utf-8 et sw=2: