Skip to content

Include error of generated header "ydlidar_config.h" in "DriverInterface.h" #58

@hannesduske

Description

@hannesduske

There is an include error of the generated header ydlidar_config.h in the file core/common/DriverInterface.h. The #include "ydlidar_config.h" statement that causes the error got introduced with commit 6bdbe78.
The build fails with the following error:

fatal error: ydlidar_config.h: No such file or directory
   10 | #include "ydlidar_config.h"
      |          ^~~~~~~~~~~~~~~~~~

The generated header ydlidar_config.h is located in the build directory which is not set as include directory of the library. See CMakeLists.txt lines 116 to 124:

115 #############################################################################################
116 #shared library
117 if(BUILD_SHARED_LIBS)
118 ydlidar_add_library(${PROJECT_NAME} SHARED ${SDK_SOURCES} ${SDK_HEADERS} ${GENERATED_HEADERS})
119 else()
120 ydlidar_add_library(${PROJECT_NAME} STATIC ${SDK_SOURCES} ${SDK_HEADERS} ${GENERATED_HEADERS})
121 endif()
122 
123 target_link_libraries(${PROJECT_NAME} ${SDK_LIBS})
124 target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) # build directory not set as include directory of the lib

Suggested fix:

124 target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}) # build directory now set as include directory of the lib

Tested on Ubuntu 24.04.1 LTS with amd64 and Ubuntu 20.04.6 LTS with arm64.

--  _________________________ PLATFORM _____________________________
--  Host                        : Linux6.8.0-45-genericx86_64
--  Is the system big endian?   :  No 
--  Word size (32/64 bit)       : 64
--  CMake version               : 3.28.3
--  CMake generator             : Unix Makefiles
--  CMake build tool            : /usr/bin/gmake
--  Compiler                    : GNU
--  Configuration               : Release
-- C++ flags (Release):      -std=c++11 -O3 -DNDEBUG
--  _________________________ PLATFORM _____________________________
--  Host                        : Linux6.8.0-1015-raspiaarch64
--  Is the system big endian?   :  No 
--  Word size (32/64 bit)       : 64
--  CMake version               : 3.16.3
--  CMake generator             : Unix Makefiles
--  CMake build tool            : /usr/bin/make
--  Compiler                    : GNU
--  Configuration               : Release
-- C++ flags (Release):      -std=c++11 -O3 -DNDEBUG

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions