Skip to content

Commit

Permalink
Add object library for print_helpers
Browse files Browse the repository at this point in the history
This simplifies the management of dependencies related to print_helpers.
  • Loading branch information
leonlynch committed Mar 14, 2023
1 parent e41f1e9 commit 55ea7ed
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 31 deletions.
29 changes: 7 additions & 22 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##############################################################################
# Copyright (c) 2021, 2022 Leon Lynch
# Copyright (c) 2021-2023 Leon Lynch
#
# This file is licensed under the terms of the LGPL v2.1 license.
# See LICENSE file.
Expand All @@ -8,31 +8,16 @@
cmake_minimum_required(VERSION 3.16)

if (BUILD_TESTING)
add_executable(emv_ttl_tpdu_test emv_ttl_tpdu_test.c ../tools/print_helpers.c)
target_link_libraries(emv_ttl_tpdu_test
PRIVATE
emv_strings # For print_helpers
emv
iso7816 # For print_helpers
)
add_executable(emv_ttl_tpdu_test emv_ttl_tpdu_test.c)
target_link_libraries(emv_ttl_tpdu_test PRIVATE print_helpers emv)
add_test(emv_ttl_tpdu_test emv_ttl_tpdu_test)

add_executable(emv_ttl_pcsc_test emv_ttl_pcsc_test.c ../tools/print_helpers.c)
target_link_libraries(emv_ttl_pcsc_test
PRIVATE
emv_strings # For print_helpers
emv
iso7816 # For print_helpers
)
add_executable(emv_ttl_pcsc_test emv_ttl_pcsc_test.c)
target_link_libraries(emv_ttl_pcsc_test PRIVATE print_helpers emv)
add_test(emv_ttl_pcsc_test emv_ttl_pcsc_test)

add_executable(emv_str_parse_test emv_str_parse_test.c ../tools/print_helpers.c)
target_link_libraries(emv_str_parse_test
PRIVATE
emv_strings # For print_helpers
emv
iso7816 # For print_helpers
)
add_executable(emv_str_parse_test emv_str_parse_test.c)
target_link_libraries(emv_str_parse_test PRIVATE print_helpers emv_strings)
add_test(emv_str_parse_test emv_str_parse_test)

add_executable(emv_aid_info_test emv_aid_info_test.c)
Expand Down
2 changes: 1 addition & 1 deletion tests/emv_str_parse_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <string.h>

// For debug output
#include "../tools/print_helpers.h"
#include "print_helpers.h"

int main(void)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/emv_ttl_pcsc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <string.h>

// For debug output
#include "../tools/print_helpers.h"
#include "print_helpers.h"

struct apdu_t {
size_t c_apdu_len;
Expand Down
2 changes: 1 addition & 1 deletion tests/emv_ttl_tpdu_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <string.h>

// For debug output
#include "../tools/print_helpers.h"
#include "print_helpers.h"

struct tpdu_t {
size_t c_tpdu_len;
Expand Down
17 changes: 12 additions & 5 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##############################################################################
# Copyright (c) 2022 Leon Lynch
# Copyright (c) 2022-2023 Leon Lynch
#
# This file is licensed under the terms of the LGPL v2.1 license.
# See LICENSE file.
Expand Down Expand Up @@ -47,14 +47,21 @@ endif()

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

# Print helpers object library
add_library(print_helpers OBJECT EXCLUDE_FROM_ALL print_helpers.c)
target_include_directories(print_helpers INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
target_link_libraries(print_helpers PRIVATE iso7816 emv emv_strings)

# EMV decode command line tool
if(BUILD_EMV_DECODE)
add_executable(emv-decode emv-decode.c print_helpers.c)
add_executable(emv-decode emv-decode.c)
set_source_files_properties(emv-decode.c
PROPERTIES
COMPILE_DEFINITIONS EMV_UTILS_VERSION_STRING="${EMV_UTILS_VERSION_STRING}"
)
target_link_libraries(emv-decode PRIVATE emv_strings emv iso7816 iso8859)
target_link_libraries(emv-decode PRIVATE print_helpers iso7816 emv emv_strings iso8859)
if(TARGET libargp::argp)
target_link_libraries(emv-decode PRIVATE libargp::argp)
endif()
Expand All @@ -77,12 +84,12 @@ if(BUILD_EMV_TOOL)
)
endif()

add_executable(emv-tool emv-tool.c print_helpers.c ../src/pcsc.c)
add_executable(emv-tool emv-tool.c ../src/pcsc.c)
set_source_files_properties(emv-tool.c
PROPERTIES
COMPILE_DEFINITIONS EMV_UTILS_VERSION_STRING="${EMV_UTILS_VERSION_STRING}"
)
target_link_libraries(emv-tool PRIVATE emv_strings emv iso7816)
target_link_libraries(emv-tool PRIVATE print_helpers iso7816 emv emv_strings)
if(TARGET libargp::argp)
target_link_libraries(emv-tool PRIVATE libargp::argp)
endif()
Expand Down
2 changes: 1 addition & 1 deletion tools/print_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include "emv_tlv.h"
#include "emv_dol.h"
#include "emv_app.h"
#include "emv_strings.h"
#include "emv_debug.h"
#include "emv_strings.h"

#include <stdlib.h>
#include <stdio.h>
Expand Down

0 comments on commit 55ea7ed

Please sign in to comment.