Skip to content

Commit

Permalink
Merge pull request #5 from Murmele/fixBuild2
Browse files Browse the repository at this point in the history
fix build for Ubuntu
  • Loading branch information
ihedvall authored Jan 22, 2023
2 parents 9bfbaf0 + 4f38abe commit 1977a28
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
# test if cmake finds the dbcLib automatically
- name: TestInstall
run: |
cd test/TestDBCLibCmake
cd test/TestdbclibCMake
mkdir -p build
cd build
cmake -G Ninja ..
Expand Down
66 changes: 40 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,30 @@ if (FLEX_FOUND)
endif ()

ADD_FLEX_BISON_DEPENDENCY(DBC_SCANNER DBC_PARSER)
set(DBCL_HEADERS
include/dbc/attribute.h
include/dbc/network.h
include/dbc/envvar.h
include/dbc/node.h
include/dbc/message.h
include/dbc/signal.h
include/dbc/signalgroup.h
include/dbc/dbcfile.h
)

add_library(dbc STATIC
${BISON_DBC_PARSER_OUTPUTS}
${FLEX_DBC_SCANNER_OUTPUTS}
src/attribute.cpp include/dbc/attribute.h
src/network.cpp include/dbc/network.h
src/envvar.cpp include/dbc/envvar.h
src/node.cpp include/dbc/node.h
src/message.cpp include/dbc/message.h
src/signal.cpp include/dbc/signal.h
src/signalgroup.cpp include/dbc/signalgroup.h
${DBCL_HEADERS}
src/attribute.cpp
src/network.cpp
src/envvar.cpp
src/node.cpp
src/message.cpp
src/signal.cpp
src/signalgroup.cpp
src/dbcscanner.cpp src/dbcscanner.h
src/dbcfile.cpp include/dbc/dbcfile.h
src/dbcfile.cpp
src/dbchelper.cpp src/dbchelper.h src/dbcmessage.cpp include/dbc/dbcmessage.h include/dbc/isampleobserver.h src/signalobserver.cpp include/dbc/signalobserver.h)

target_include_directories(dbc PUBLIC
Expand All @@ -74,19 +85,14 @@ target_include_directories(dbc PUBLIC
)
target_include_directories(dbc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
# target_include_directories(dbc PRIVATE ${Boost_INCLUDE_DIRS})
target_include_directories(dbc PRIVATE ${FLEX_INCLUDE_DIRS})
#target_include_directories(dbc PRIVATE ${FLEX_INCLUDE_DIRS})

cmake_print_properties(TARGETS dbc PROPERTIES INCLUDE_DIRECTORIES)

if (MSVC)
target_compile_definitions(dbc PRIVATE _WIN32_WINNT=0x0A00)
endif ()

# set(DBC_PUBLIC_HEADERS *** )

# set_target_properties(dbc PROPERTIES PUBLIC_HEADER "${DBCL_PUBLIC_HEADERS}")
# get_target_property(PH dbc PUBLIC_HEADER)
# message(STATUS "DBC Target Includes: " "${PH}")
if (DBC_TOOLS)
# add_subdirectory(listend)
endif ()
Expand Down Expand Up @@ -116,30 +122,38 @@ endif ()
##### Packaging and installation ###############################################
##################################################################################
# install headers
if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23)
install(TARGETS dbc
FILE_SET HEADERS
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
else()
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/dbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
# FILE_SET makes problems with GTest
#if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23)
# target_sources(dbc PUBLIC
# FILE_SET HEADERS
# TYPE HEADERS
# BASE_DIRS include/dbc
# FILES ${HEADERS})
#else()
if (WIN32)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/dbc DESTINATION dbc/include)
else()
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/dbc DESTINATION include)
endif()
#endif()

if (WIN32)
install(TARGETS dbc
EXPORT dbcTargets
LIBRARY DESTINATION dbc/lib
ARCHIVE DESTINATION dbc/lib
RUNTIME DESTINATION dbc/bin
PUBLIC_HEADER DESTINATION dbc/include)
# FILE_SET HEADERS DESTINATION dbc/include
)
else()
install(TARGETS dbc
EXPORT dbcTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include/dbclib)
# PUBLIC_HEADER
# FILE_SET HEADERS DESTINATION include/dbc
)
endif()

include(CMakePackageConfigHelpers)
Expand Down Expand Up @@ -172,7 +186,7 @@ install(EXPORT dbcTargets
FILE
dbcTargets.cmake
NAMESPACE
Upstream::
Dbc::
DESTINATION
${ConfigPackageLocation}
)
Expand Down
3 changes: 1 addition & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ add_executable(test_dbc
test_dbchelper.cpp)

target_include_directories(test_dbc PRIVATE
../include
../src
../src # dbchelper.h
${GTEST_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS})
target_include_directories(test_dbc PRIVATE ${FLEX_INCLUDE_DIRS})
Expand Down
2 changes: 1 addition & 1 deletion test/TestdbclibCMake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ find_package(dbc REQUIRED)

add_executable(TestdbcCMake ${CMAKE_CURRENT_SOURCE_DIR}/../../doc/dbclibexample.cpp)
target_compile_definitions(TestdbcCMake PRIVATE DBC_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../../doc/example.dbc")
target_link_libraries(TestdbcCMake Upstream::dbc)
target_link_libraries(TestdbcCMake Dbc::dbc)

0 comments on commit 1977a28

Please sign in to comment.