From 04c171c285b3dba2c7e388d7e56a40d8a0dd9374 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Thu, 27 Sep 2018 13:35:36 +0200 Subject: [PATCH] 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()