From a6954bdaae3dc968952ec722a2ba45814d14ae39 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Thu, 4 Oct 2018 23:54:21 +0200 Subject: [PATCH 1/3] CMakeLists.txt: Add missing N_SLCAN define --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7fbcc0..c29ef54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSO_RXQ_OVFL=40") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPF_CAN=29") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAF_CAN=PF_CAN") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DN_SLCAN=17") include_directories (.) include_directories (./include) From 572a66fb947857de1e4d9711e79f1c39c548c698 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Thu, 27 Sep 2018 13:14:27 +0200 Subject: [PATCH 2/3] CMakeLists.txt: clean up a bit Signed-off-by: Marc Kleine-Budde --- CMakeLists.txt | 52 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c29ef54..652cd35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.3) project(can-utils LANGUAGES C) +include (GNUInstallDirs) + if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() @@ -20,20 +22,42 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DN_SLCAN=17") include_directories (.) include_directories (./include) -set(PROGRAMS_ISOTP isotpdump isotprecv isotpsend isotpsniffer - isotptun isotpserver isotpperf) -set(PROGRAMS_CANGW cangw) -set(PROGRAMS_SLCAN slcan_attach slcand) -set(PROGRAMS_J1939 jacd jspy jsr testj1939) -set(PROGRAMS_CANLIB cansend cangen candump canplayer canlogserver - canbusload log2long log2asc asc2log) +set(PROGRAMS_CANLIB + asc2log + canbusload + candump + cangen + canlogserver + canplayer + cansend + log2asc + log2long +) -set(PROGRAMS can-calc-bit-timing cansniffer bcmserver - ${PROGRAMS_CANLIB} - ${PROGRAMS_ISOTP} - ${PROGRAMS_CANGW} - ${PROGRAMS_SLCAN} - slcanpty canfdtest +set(PROGRAMS_J1939 + jacd + jspy + jsr + testj1939 +) + +set(PROGRAMS + ${PROGRAMS_CANLIB} + bcmserver + can-calc-bit-timing + canfdtest + cangw + cansniffer + isotpdump + isotpperf + isotprecv + isotpsend + isotpserver + isotpsniffer + isotptun + slcan_attach + slcand + slcanpty ) if(NOT ANDROID) @@ -51,7 +75,7 @@ foreach(name ${PROGRAMS}) endif() add_executable(${name} ${name}.c ${SRC_DEPS}) - install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_BINDIR}) endforeach() From 04c171c285b3dba2c7e388d7e56a40d8a0dd9374 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Thu, 27 Sep 2018 13:35:36 +0200 Subject: [PATCH 3/3] CMakeLists.txt: build proper static libraries Signed-off-by: Marc Kleine-Budde --- CMakeLists.txt | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 652cd35..c6b3889 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,17 +64,28 @@ if(NOT ANDROID) list(APPEND PROGRAMS ${PROGRAMS_J1939}) endif() +add_library(can STATIC + lib.c + canframelen.c +) + +add_library(j1939 STATIC + libj1939.c +) + foreach(name ${PROGRAMS}) - set(SRC_DEPS) - if("${name}" STREQUAL "canbusload") - set(SRC_DEPS canframelen.c) - elseif("${name}" IN_LIST PROGRAMS_J1939) - set(SRC_DEPS libj1939.c) + add_executable(${name} ${name}.c) + + if("${name}" IN_LIST PROGRAMS_J1939) + target_link_libraries(${name} + PRIVATE j1939 + ) elseif("${name}" IN_LIST PROGRAMS_CANLIB) - set(SRC_DEPS lib.c) + target_link_libraries(${name} + PRIVATE can + ) endif() - add_executable(${name} ${name}.c ${SRC_DEPS}) install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_BINDIR}) endforeach()