Skip to content

Commit 55ea7ed

Browse files
committed
Add object library for print_helpers
This simplifies the management of dependencies related to print_helpers.
1 parent e41f1e9 commit 55ea7ed

File tree

6 files changed

+23
-31
lines changed

6 files changed

+23
-31
lines changed

tests/CMakeLists.txt

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##############################################################################
2-
# Copyright (c) 2021, 2022 Leon Lynch
2+
# Copyright (c) 2021-2023 Leon Lynch
33
#
44
# This file is licensed under the terms of the LGPL v2.1 license.
55
# See LICENSE file.
@@ -8,31 +8,16 @@
88
cmake_minimum_required(VERSION 3.16)
99

1010
if (BUILD_TESTING)
11-
add_executable(emv_ttl_tpdu_test emv_ttl_tpdu_test.c ../tools/print_helpers.c)
12-
target_link_libraries(emv_ttl_tpdu_test
13-
PRIVATE
14-
emv_strings # For print_helpers
15-
emv
16-
iso7816 # For print_helpers
17-
)
11+
add_executable(emv_ttl_tpdu_test emv_ttl_tpdu_test.c)
12+
target_link_libraries(emv_ttl_tpdu_test PRIVATE print_helpers emv)
1813
add_test(emv_ttl_tpdu_test emv_ttl_tpdu_test)
1914

20-
add_executable(emv_ttl_pcsc_test emv_ttl_pcsc_test.c ../tools/print_helpers.c)
21-
target_link_libraries(emv_ttl_pcsc_test
22-
PRIVATE
23-
emv_strings # For print_helpers
24-
emv
25-
iso7816 # For print_helpers
26-
)
15+
add_executable(emv_ttl_pcsc_test emv_ttl_pcsc_test.c)
16+
target_link_libraries(emv_ttl_pcsc_test PRIVATE print_helpers emv)
2717
add_test(emv_ttl_pcsc_test emv_ttl_pcsc_test)
2818

29-
add_executable(emv_str_parse_test emv_str_parse_test.c ../tools/print_helpers.c)
30-
target_link_libraries(emv_str_parse_test
31-
PRIVATE
32-
emv_strings # For print_helpers
33-
emv
34-
iso7816 # For print_helpers
35-
)
19+
add_executable(emv_str_parse_test emv_str_parse_test.c)
20+
target_link_libraries(emv_str_parse_test PRIVATE print_helpers emv_strings)
3621
add_test(emv_str_parse_test emv_str_parse_test)
3722

3823
add_executable(emv_aid_info_test emv_aid_info_test.c)

tests/emv_str_parse_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <string.h>
2626

2727
// For debug output
28-
#include "../tools/print_helpers.h"
28+
#include "print_helpers.h"
2929

3030
int main(void)
3131
{

tests/emv_ttl_pcsc_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <string.h>
2727

2828
// For debug output
29-
#include "../tools/print_helpers.h"
29+
#include "print_helpers.h"
3030

3131
struct apdu_t {
3232
size_t c_apdu_len;

tests/emv_ttl_tpdu_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <string.h>
2828

2929
// For debug output
30-
#include "../tools/print_helpers.h"
30+
#include "print_helpers.h"
3131

3232
struct tpdu_t {
3333
size_t c_tpdu_len;

tools/CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##############################################################################
2-
# Copyright (c) 2022 Leon Lynch
2+
# Copyright (c) 2022-2023 Leon Lynch
33
#
44
# This file is licensed under the terms of the LGPL v2.1 license.
55
# See LICENSE file.
@@ -47,14 +47,21 @@ endif()
4747

4848
include(GNUInstallDirs) # Provides CMAKE_INSTALL_* variables and good defaults for install()
4949

50+
# Print helpers object library
51+
add_library(print_helpers OBJECT EXCLUDE_FROM_ALL print_helpers.c)
52+
target_include_directories(print_helpers INTERFACE
53+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
54+
)
55+
target_link_libraries(print_helpers PRIVATE iso7816 emv emv_strings)
56+
5057
# EMV decode command line tool
5158
if(BUILD_EMV_DECODE)
52-
add_executable(emv-decode emv-decode.c print_helpers.c)
59+
add_executable(emv-decode emv-decode.c)
5360
set_source_files_properties(emv-decode.c
5461
PROPERTIES
5562
COMPILE_DEFINITIONS EMV_UTILS_VERSION_STRING="${EMV_UTILS_VERSION_STRING}"
5663
)
57-
target_link_libraries(emv-decode PRIVATE emv_strings emv iso7816 iso8859)
64+
target_link_libraries(emv-decode PRIVATE print_helpers iso7816 emv emv_strings iso8859)
5865
if(TARGET libargp::argp)
5966
target_link_libraries(emv-decode PRIVATE libargp::argp)
6067
endif()
@@ -77,12 +84,12 @@ if(BUILD_EMV_TOOL)
7784
)
7885
endif()
7986

80-
add_executable(emv-tool emv-tool.c print_helpers.c ../src/pcsc.c)
87+
add_executable(emv-tool emv-tool.c ../src/pcsc.c)
8188
set_source_files_properties(emv-tool.c
8289
PROPERTIES
8390
COMPILE_DEFINITIONS EMV_UTILS_VERSION_STRING="${EMV_UTILS_VERSION_STRING}"
8491
)
85-
target_link_libraries(emv-tool PRIVATE emv_strings emv iso7816)
92+
target_link_libraries(emv-tool PRIVATE print_helpers iso7816 emv emv_strings)
8693
if(TARGET libargp::argp)
8794
target_link_libraries(emv-tool PRIVATE libargp::argp)
8895
endif()

tools/print_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include "emv_tlv.h"
3131
#include "emv_dol.h"
3232
#include "emv_app.h"
33-
#include "emv_strings.h"
3433
#include "emv_debug.h"
34+
#include "emv_strings.h"
3535

3636
#include <stdlib.h>
3737
#include <stdio.h>

0 commit comments

Comments
 (0)