Reply To: CMake project not recognizing header files in sysroot/usr/local/include

Sysprogs forums Forums VisualGDB CMake project not recognizing header files in sysroot/usr/local/include Reply To: CMake project not recognizing header files in sysroot/usr/local/include

#26127
nOlander
Participant

This is how the CMake file is set up:

cmake_minimum_required(VERSION 3.0)
project(PLCComms VERSION 0.2.3)

set(SRC
    src/service.cpp
    src/PLC_control.cpp
)

add_library(Snap7-Wrapper src/S7Object_Wrapper.cpp)

set_target_properties(Snap7-Wrapper
    PROPERTIES
        LANGUAGES CXX
        CXX_STANDARD 14
        CXX_STANDARD_REQUIRED ON
        CXX_EXTENSIONS OFF
        DESCRIPTION "Wrapper around snap7 library"
        VERSION 0.0.2
)

target_include_directories(Snap7-Wrapper
PUBLIC
    ${PROJECT_SOURCE_DIR}/include
PRIVATE
    ${CMAKE_SOURCE_DIR}/include
    C:/SysGCC/raspberry/arm-linux-gnueabihf/sysroot/usr/local/include
)

target_compile_options(Snap7-Wrapper
PRIVATE
    -Werror
)
target_link_libraries(Snap7-Wrapper
    snap7
)

add_executable(${PROJECT_NAME} ${SRC})

set_target_properties(${PROJECT_NAME}
    PROPERTIES
        LANGUAGES CXX
        CXX_STANDARD 14
        CXX_STANDARD_REQUIRED ON
        CXX_EXTENSIONS OFF
        DESCRIPTION "Handles communication between PLC and clients via ZeroMQ"
)

configure_file(
    ${PROJECT_SOURCE_DIR}/include/project_config.h.in
    ${PROJECT_SOURCE_DIR}/include/project_config.h
)

target_include_directories(${PROJECT_NAME}
PUBLIC
    ${PROJECT_SOURCE_DIR}/include
PRIVATE
    ${CMAKE_SOURCE_DIR}/include
)

target_compile_options(${PROJECT_NAME}
PRIVATE
    -Werror
)
target_link_libraries(${PROJECT_NAME}
    zmq
    msgpack11
    Config
    Snap7-Wrapper
    systemd
)

The directory with the header file that’s not being found is  C:/SysGCC/raspberry/arm-linux-gnueabihf/sysroot/usr/local/include and it gets added to the CMakeLists.txt via this line: target_include_directories(Snap7-Wrapper PRIVATE ../../=/usr/local/include). I did notice that it was being inserted above the already existing target_include_directories for that target, so I tried manually editing it in to the existing one but it didn’t make a difference.

You mentioned making sure to utilize ${CMAKE_SYSROOT}/path/to/include format, but I noticed that the line inserted automatically didn’t do that and instead used ../../=/usr/local/include.

Do those help at all?

I also checked the VS Properties for the project and under Type it says “CMake Project”. Is this a regular CMake Project like you said and if so, how can I change it to and Advanced CMake Project?