This repository has been archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
96 lines (73 loc) · 2.14 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
cmake_minimum_required(VERSION 3.16)
project(pcsc-cpp)
# The libpcsc-cpp library itself.
add_library(${PROJECT_NAME}
STATIC
include/${PROJECT_NAME}/${PROJECT_NAME}.hpp
include/${PROJECT_NAME}/${PROJECT_NAME}-utils.hpp
include/${PROJECT_NAME}/comp_winscard.hpp
include/flag-set-cpp/flag_set.hpp
include/magic_enum/magic_enum.hpp
src/Context.hpp
src/Reader.cpp
src/SCardCall.hpp
src/SmartCard.cpp
src/listReaders.cpp
src/utils.cpp
)
target_include_directories(${PROJECT_NAME}
PUBLIC
include
)
target_compile_features(${PROJECT_NAME}
PUBLIC
cxx_std_17
)
target_compile_options(${PROJECT_NAME} PUBLIC
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -pedantic -Werror>
)
target_compile_definitions(${PROJECT_NAME} PUBLIC
$<$<CXX_COMPILER_ID:MSVC>:WIN32_LEAN_AND_MEAN;UNICODE;_CRT_SECURE_NO_WARNINGS>
)
target_link_libraries(${PROJECT_NAME} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:Ws2_32>
)
# PC/SC API dependencies.
add_library(pcsc INTERFACE)
if(MSVC)
target_link_libraries(pcsc INTERFACE winscard)
elseif(APPLE)
target_link_libraries(pcsc INTERFACE "-framework PCSC")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(PCSC libpcsclite REQUIRED IMPORTED_TARGET)
target_include_directories(${PROJECT_NAME} PRIVATE ${PCSC_INCLUDE_DIRS})
target_link_libraries(pcsc INTERFACE PkgConfig::PCSC)
endif()
# Common testing options.
enable_testing()
find_package(GTest REQUIRED)
# Mock tests that use libpcsc-mock to mock PC/SC API calls.
set(MOCK_TEST_EXE lib${PROJECT_NAME}-test-mock)
add_subdirectory(tests/lib/libpcsc-mock)
add_executable(${MOCK_TEST_EXE}
tests/mock/test-select-card-reader-and-card.cpp
tests/mock/test-connect-to-card-transmit-apdus.cpp
)
target_link_libraries(${MOCK_TEST_EXE}
${PROJECT_NAME}
pcsc-mock
GTest::Main
)
add_test(${MOCK_TEST_EXE} ${MOCK_TEST_EXE})
# Integration tests that use the real operating system PC/SC service.
set(INTEGRATION_TEST_EXE lib${PROJECT_NAME}-test-integration)
add_executable(${INTEGRATION_TEST_EXE}
tests/integration/test-${PROJECT_NAME}.cpp
)
target_link_libraries(${INTEGRATION_TEST_EXE}
${PROJECT_NAME}
pcsc
GTest::Main
)