Skip to content

Commit 29edf4c

Browse files
committed
Adding the dependencies correctly. Need to install the header before the test target
1 parent 68a8f83 commit 29edf4c

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

CMakeLists.txt

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cmake_minimum_required(VERSION 3.16)
22

33
project(dbc
4-
VERSION 0.2.0
5-
DESCRIPTION "C++ DBC Parser"
4+
VERSION 0.2.0
5+
DESCRIPTION "C++ DBC Parser"
66
)
77

88
# -- PROJECT OPTIONS -- #
@@ -28,20 +28,20 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
2828

2929
find_package(FastFloat QUIET)
3030
if (NOT ${FastFloat_FOUND})
31-
include(FetchContent)
32-
FetchContent_Declare(
33-
FastFloat
34-
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
35-
GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1
36-
)
37-
# FetchContent_MakeAvailable(FastFloat)
38-
FetchContent_Populate(FastFloat)
39-
add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL)
31+
include(FetchContent)
32+
FetchContent_Declare(
33+
FastFloat
34+
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
35+
GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1
36+
)
37+
# FetchContent_MakeAvailable(FastFloat)
38+
FetchContent_Populate(FastFloat)
39+
add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL)
4040
endif()
4141

4242
# add where to find the source files
4343
list(APPEND SOURCE_FILES
44-
${PROJECT_SOURCE_DIR}/src/utils.cpp
44+
${PROJECT_SOURCE_DIR}/src/utils.cpp
4545
${PROJECT_SOURCE_DIR}/src/message.cpp
4646
${PROJECT_SOURCE_DIR}/src/signal.cpp
4747
${PROJECT_SOURCE_DIR}/src/dbc.cpp
@@ -56,50 +56,50 @@ list(APPEND HEADER_FILES
5656
)
5757

5858
if(DBC_ENABLE_TESTS)
59-
include(CTest)
60-
add_subdirectory(test)
59+
include(CTest)
60+
add_subdirectory(test)
6161
endif()
6262

6363
if(DBC_GENERATE_DOCS)
64-
add_subdirectory(doc)
64+
add_subdirectory(doc)
6565
endif()
6666

6767
list(APPEND GCC_CLANG_COMPILE_FLAGS
68-
-Wall -Wextra -Wpedantic
69-
-Wconversion -Wint-in-bool-context
70-
-Wmissing-declarations -Wmissing-field-initializers
71-
-Werror
68+
-Wall -Wextra -Wpedantic
69+
-Wconversion -Wint-in-bool-context
70+
-Wmissing-declarations -Wmissing-field-initializers
71+
-Werror
7272
)
7373

7474

7575
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
76-
add_compile_options(/W4 /WX)
76+
add_compile_options(/W4 /WX)
7777
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
78-
# Clang shadow warnings aren't as sensitive as gcc
79-
add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow)
78+
# Clang shadow warnings aren't as sensitive as gcc
79+
add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow)
8080
else()
81-
add_compile_options(${GCC_CLANG_COMPILE_FLAGS})
81+
add_compile_options(${GCC_CLANG_COMPILE_FLAGS})
8282
endif()
8383

8484
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
8585
target_link_libraries(${PROJECT_NAME} FastFloat::fast_float)
8686
target_include_directories(${PROJECT_NAME} PUBLIC
87-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
88-
$<INSTALL_INTERFACE:include>
87+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
88+
$<INSTALL_INTERFACE:include>
8989
)
9090
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
9191

9292
target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS
93-
TYPE HEADERS
94-
BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc
95-
FILES ${HEADER_FILES}
93+
TYPE HEADERS
94+
BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc
95+
FILES ${HEADER_FILES}
9696
)
9797

9898
if(DBC_GENERATE_SINGLE_HEADER)
99-
add_custom_target(single_header ALL
100-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
101-
COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh
102-
)
99+
add_custom_target(single_header ALL
100+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
101+
COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh
102+
)
103103
endif()
104104

105105
## Installation
@@ -113,5 +113,5 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTA
113113
# Generate pkg-config file
114114
configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
115115
install(
116-
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
117-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
116+
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
117+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ if(DBC_GENERATE_SINGLE_HEADER)
6868
target_include_directories(dbcSingleHeaderTest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/single_header/)
6969

7070
catch_discover_tests(dbcSingleHeaderTest)
71+
72+
add_dependencies(dbcSingleHeaderTest single_header)
7173
endif()

0 commit comments

Comments
 (0)