CMake first pass
parent
47f2e7a180
commit
1a4846cf5c
|
|
@ -0,0 +1,56 @@
|
|||
cmake_minimum_required(VERSION 3.3)
|
||||
|
||||
project(can-utils LANGUAGES C)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
||||
add_definitions(-D_GNU_SOURCE)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-parentheses")
|
||||
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")
|
||||
|
||||
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 can-calc-bit-timing cansniffer bcmserver
|
||||
${PROGRAMS_CANLIB}
|
||||
${PROGRAMS_ISOTP}
|
||||
${PROGRAMS_CANGW}
|
||||
${PROGRAMS_SLCAN}
|
||||
slcanpty canfdtest
|
||||
)
|
||||
|
||||
if(NOT ANDROID)
|
||||
list(APPEND PROGRAMS ${PROGRAMS_J1939})
|
||||
endif()
|
||||
|
||||
foreach(name ${PROGRAMS})
|
||||
if("${name}" STREQUAL "canbusload")
|
||||
set(SRC_DEPS canframelen)
|
||||
elseif("${name}" IN_LIST PROGRAMS_J1939)
|
||||
set(SRC_DEPS libj1939.c)
|
||||
elseif("${name}" IN_LIST PROGRAMS_CANLIB)
|
||||
set(SRC_DEPS lib.c)
|
||||
endif()
|
||||
|
||||
add_executable(${name} ${name}.c ${SRC_DEPS})
|
||||
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
endforeach()
|
||||
|
||||
|
||||
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/cmake/make_uninstall.cmake")
|
||||
10
README.md
10
README.md
|
|
@ -47,6 +47,16 @@ subsystem (aka SocketCAN):
|
|||
* slcand : daemon for serial line CAN interface configuration
|
||||
* slcanpty : creates a pty for applications using the slcan ASCII protocol
|
||||
|
||||
#### CMake Project Generator
|
||||
* Place your build folder anywhere, passing CMake the path. Relative or absolute.
|
||||
* Some examples using a build folder under the source tree root:
|
||||
* Android : cmake -DCMAKE_TOOLCHAIN_FILE=/home/joel/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-21 -DANDROID_ABI=armeabi-v7a .. && make
|
||||
* Raspberry Pi : cmake -DCMAKE_TOOLCHAIN_FILE=/home/joel/rpi/tools/build/cmake/rpi.toolchain.cmake .. && make
|
||||
* Linux : cmake -GNinja .. && ninja
|
||||
* Linux : CC=clang cmake .. && make
|
||||
* To override the base installation directory use: CMAKE_INSTALL_PREFIX
|
||||
* ie. CC=clang cmake -DCMAKE_INSTALL_PREFIX=./out .. && make install
|
||||
|
||||
### Additional Information:
|
||||
|
||||
* [SocketCAN Documentation (Linux Kernel)](https://www.kernel.org/doc/Documentation/networking/can.txt)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
|
||||
endif()
|
||||
|
||||
file(READ "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "[\r\n]" ";" files "${files}")
|
||||
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling ${file}")
|
||||
if(EXISTS "${file}")
|
||||
file(REMOVE ${file})
|
||||
if (EXISTS "${file}")
|
||||
message(FATAL_ERROR "Problem when removing ${file}, please check your permissions")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "File ${file} does not exist.")
|
||||
endif()
|
||||
endforeach()
|
||||
Loading…
Reference in New Issue