Merge pull request #105 from marckleinebudde/cmake-cleanup

Cmake cleanup
pull/106/head
Marc Kleine-Budde 2018-10-05 00:08:24 +02:00 committed by GitHub
commit 12664efa9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 57 additions and 21 deletions

View File

@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.3)
project(can-utils LANGUAGES C) project(can-utils LANGUAGES C)
include (GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif() endif()
@ -15,42 +17,76 @@ 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} -DSO_RXQ_OVFL=40")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPF_CAN=29") 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} -DAF_CAN=PF_CAN")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DN_SLCAN=17")
include_directories (.) include_directories (.)
include_directories (./include) include_directories (./include)
set(PROGRAMS_ISOTP isotpdump isotprecv isotpsend isotpsniffer set(PROGRAMS_CANLIB
isotptun isotpserver isotpperf) asc2log
set(PROGRAMS_CANGW cangw) canbusload
set(PROGRAMS_SLCAN slcan_attach slcand) candump
set(PROGRAMS_J1939 jacd jspy jsr testj1939) cangen
set(PROGRAMS_CANLIB cansend cangen candump canplayer canlogserver canlogserver
canbusload log2long log2asc asc2log) canplayer
cansend
log2asc
log2long
)
set(PROGRAMS can-calc-bit-timing cansniffer bcmserver set(PROGRAMS_J1939
${PROGRAMS_CANLIB} jacd
${PROGRAMS_ISOTP} jspy
${PROGRAMS_CANGW} jsr
${PROGRAMS_SLCAN} testj1939
slcanpty canfdtest )
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) if(NOT ANDROID)
list(APPEND PROGRAMS ${PROGRAMS_J1939}) list(APPEND PROGRAMS ${PROGRAMS_J1939})
endif() endif()
add_library(can STATIC
lib.c
canframelen.c
)
add_library(j1939 STATIC
libj1939.c
)
foreach(name ${PROGRAMS}) foreach(name ${PROGRAMS})
set(SRC_DEPS) add_executable(${name} ${name}.c)
if("${name}" STREQUAL "canbusload")
set(SRC_DEPS canframelen.c) if("${name}" IN_LIST PROGRAMS_J1939)
elseif("${name}" IN_LIST PROGRAMS_J1939) target_link_libraries(${name}
set(SRC_DEPS libj1939.c) PRIVATE j1939
)
elseif("${name}" IN_LIST PROGRAMS_CANLIB) elseif("${name}" IN_LIST PROGRAMS_CANLIB)
set(SRC_DEPS lib.c) target_link_libraries(${name}
PRIVATE can
)
endif() endif()
add_executable(${name} ${name}.c ${SRC_DEPS}) install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endforeach() endforeach()