11cmake_minimum_required (VERSION 3.16)
22
3- project (dbc
4- VERSION 0.2.0
5- DESCRIPTION "C++ DBC Parser"
6- )
3+ # Keep this on one line for release checking
4+ project (dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser" )
75
86# -- PROJECT OPTIONS -- #
97option (DBC_ENABLE_TESTS "Enable Unittests" ON )
108option (DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF )
119option (DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF )
10+ option (DBC_GENERATE_SINGLE_HEADER "This will run the generator for the single header file version. Default is OFF since we make a static build. Requires cargo installed." OFF )
1211# ---------------------- #
1312
1413set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
@@ -27,20 +26,18 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
2726
2827find_package (FastFloat QUIET )
2928if (NOT ${FastFloat_FOUND} )
30- include (FetchContent)
31- FetchContent_Declare(
32- FastFloat
33- GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
34- GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1
35- )
36- # FetchContent_MakeAvailable(FastFloat)
37- FetchContent_Populate(FastFloat)
38- add_subdirectory (${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL )
29+ include (FetchContent)
30+ FetchContent_Declare(
31+ FastFloat
32+ GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
33+ GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1
34+ )
35+ FetchContent_MakeAvailable(FastFloat)
3936endif ()
4037
4138# add where to find the source files
4239list (APPEND SOURCE_FILES
43- ${PROJECT_SOURCE_DIR} /src/utils.cpp
40+ ${PROJECT_SOURCE_DIR} /src/utils.cpp
4441 ${PROJECT_SOURCE_DIR} /src/message.cpp
4542 ${PROJECT_SOURCE_DIR} /src/signal.cpp
4643 ${PROJECT_SOURCE_DIR} /src/dbc.cpp
@@ -55,50 +52,51 @@ list(APPEND HEADER_FILES
5552)
5653
5754if (DBC_ENABLE_TESTS)
58- include (CTest)
59- add_subdirectory (test )
55+ include (CTest)
56+ add_subdirectory (test )
6057endif ()
6158
6259if (DBC_GENERATE_DOCS)
63- add_subdirectory (doc )
60+ add_subdirectory (doc )
6461endif ()
6562
6663list (APPEND GCC_CLANG_COMPILE_FLAGS
67- -Wall -Wextra -Wpedantic
68- -Wconversion -Wint-in-bool -context
69- -Wmissing-declarations -Wmissing-field-initializers
70- -Werror
64+ -Wall -Wextra -Wpedantic
65+ -Wconversion -Wint-in-bool -context
66+ -Wmissing-declarations -Wmissing-field-initializers
67+ -Werror
7168)
7269
7370
7471if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
75- add_compile_options (/W4 /WX)
72+ add_compile_options (/W4 /WX)
7673elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
77- # Clang shadow warnings aren't as sensitive as gcc
78- add_compile_options (${GCC_CLANG_COMPILE_FLAGS} -Wshadow)
74+ # Clang shadow warnings aren't as sensitive as gcc
75+ add_compile_options (${GCC_CLANG_COMPILE_FLAGS} -Wshadow)
7976else ()
80- add_compile_options (${GCC_CLANG_COMPILE_FLAGS} )
77+ add_compile_options (${GCC_CLANG_COMPILE_FLAGS} )
8178endif ()
8279
8380add_library (${PROJECT_NAME} STATIC ${SOURCE_FILES} )
8481target_link_libraries (${PROJECT_NAME} FastFloat::fast_float)
8582target_include_directories (${PROJECT_NAME} PUBLIC
86- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
87- $<INSTALL_INTERFACE:include >
83+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
84+ $<INSTALL_INTERFACE:include >
8885)
8986target_compile_features (${PROJECT_NAME} PRIVATE cxx_std_11)
9087
9188target_sources (${PROJECT_NAME} INTERFACE FILE_SET HEADERS
92- TYPE HEADERS
93- BASE_DIRS ${PROJECT_SOURCE_DIR} /include /libdbc
94- FILES ${HEADER_FILES}
89+ TYPE HEADERS
90+ BASE_DIRS ${PROJECT_SOURCE_DIR} /include /libdbc
91+ FILES ${HEADER_FILES}
9592)
9693
97- add_custom_target (release
98- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
99- COMMAND ${CMAKE_SOURCE_DIR} /scripts/create_single_header.sh
100- DEPENDS ${PROJECT_NAME}
101- )
94+ if (DBC_GENERATE_SINGLE_HEADER)
95+ add_custom_target (single_header ALL
96+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
97+ COMMAND ${CMAKE_SOURCE_DIR} /scripts/create_single_header.sh
98+ )
99+ endif ()
102100
103101## Installation
104102# install lib
@@ -111,5 +109,5 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTA
111109# Generate pkg-config file
112110configure_file (${PROJECT_NAME} .pc.in ${PROJECT_NAME} .pc @ONLY)
113111install (
114- FILES ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} .pc
115- DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
112+ FILES ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} .pc
113+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
0 commit comments