-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
33 lines (27 loc) · 1.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
cmake_minimum_required(VERSION 3.1.0)
# Parse the current version from the version header
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/src/j1939decode.h" version_defines
REGEX "#define J1939DECODE_VERSION_(MAJOR|MINOR|PATCH)")
foreach(ver ${version_defines})
if(ver MATCHES "#define J1939DECODE_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
set(VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
endif()
endforeach()
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
message(STATUS "j1939decode version: ${VERSION}")
project(j1939decode
VERSION "${VERSION}"
LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(STATIC_LIB static)
set(SHARED_LIB shared)
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
add_subdirectory(src)