Skip to content

Commit 12664ef

Browse files
Merge pull request #105 from marckleinebudde/cmake-cleanup
Cmake cleanup
2 parents 1c81f7f + 04c171c commit 12664ef

File tree

1 file changed

+58
-22
lines changed

1 file changed

+58
-22
lines changed

CMakeLists.txt

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.3)
22

33
project(can-utils LANGUAGES C)
44

5+
include (GNUInstallDirs)
6+
57
if(NOT CMAKE_BUILD_TYPE)
68
set(CMAKE_BUILD_TYPE Release)
79
endif()
@@ -15,42 +17,76 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
1517
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSO_RXQ_OVFL=40")
1618
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPF_CAN=29")
1719
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAF_CAN=PF_CAN")
20+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DN_SLCAN=17")
1821

1922
include_directories (.)
2023
include_directories (./include)
2124

22-
set(PROGRAMS_ISOTP isotpdump isotprecv isotpsend isotpsniffer
23-
isotptun isotpserver isotpperf)
24-
set(PROGRAMS_CANGW cangw)
25-
set(PROGRAMS_SLCAN slcan_attach slcand)
26-
set(PROGRAMS_J1939 jacd jspy jsr testj1939)
27-
set(PROGRAMS_CANLIB cansend cangen candump canplayer canlogserver
28-
canbusload log2long log2asc asc2log)
29-
30-
set(PROGRAMS can-calc-bit-timing cansniffer bcmserver
31-
${PROGRAMS_CANLIB}
32-
${PROGRAMS_ISOTP}
33-
${PROGRAMS_CANGW}
34-
${PROGRAMS_SLCAN}
35-
slcanpty canfdtest
25+
set(PROGRAMS_CANLIB
26+
asc2log
27+
canbusload
28+
candump
29+
cangen
30+
canlogserver
31+
canplayer
32+
cansend
33+
log2asc
34+
log2long
35+
)
36+
37+
set(PROGRAMS_J1939
38+
jacd
39+
jspy
40+
jsr
41+
testj1939
42+
)
43+
44+
set(PROGRAMS
45+
${PROGRAMS_CANLIB}
46+
bcmserver
47+
can-calc-bit-timing
48+
canfdtest
49+
cangw
50+
cansniffer
51+
isotpdump
52+
isotpperf
53+
isotprecv
54+
isotpsend
55+
isotpserver
56+
isotpsniffer
57+
isotptun
58+
slcan_attach
59+
slcand
60+
slcanpty
3661
)
3762

3863
if(NOT ANDROID)
3964
list(APPEND PROGRAMS ${PROGRAMS_J1939})
4065
endif()
4166

67+
add_library(can STATIC
68+
lib.c
69+
canframelen.c
70+
)
71+
72+
add_library(j1939 STATIC
73+
libj1939.c
74+
)
75+
4276
foreach(name ${PROGRAMS})
43-
set(SRC_DEPS)
44-
if("${name}" STREQUAL "canbusload")
45-
set(SRC_DEPS canframelen.c)
46-
elseif("${name}" IN_LIST PROGRAMS_J1939)
47-
set(SRC_DEPS libj1939.c)
77+
add_executable(${name} ${name}.c)
78+
79+
if("${name}" IN_LIST PROGRAMS_J1939)
80+
target_link_libraries(${name}
81+
PRIVATE j1939
82+
)
4883
elseif("${name}" IN_LIST PROGRAMS_CANLIB)
49-
set(SRC_DEPS lib.c)
84+
target_link_libraries(${name}
85+
PRIVATE can
86+
)
5087
endif()
5188

52-
add_executable(${name} ${name}.c ${SRC_DEPS})
53-
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
89+
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_BINDIR})
5490
endforeach()
5591

5692

0 commit comments

Comments
 (0)