Hello there,

>> So does someone have a hint, how to successfully include the right
>> header files from the cross compiling build tree and linking against
>> the appropriate libraries then in our cmake files?
>
> The problem occurs when running cmake, right? How do you search for the
> headers?

Exactly.

> You should use find_path(...). If you use the default prepare stage, then
> cmake is called with the proper parameters to find stuff in
> sysroot-target.

This looks only slightly different in our rule:

    $(STATEDIR)/foo.prepare:
        @$(call targetinfo, $@)
        @$(call clean, $(FOO_DIR)/config.cache)
        rm -rf $(FOO_BUILD_DIR)
        mkdir -p $(FOO_BUILD_DIR)
        cd $(FOO_BUILD_DIR)/ && \
            $(FOO_PATH) $(FOO_CONF_ENV) \
            cmake .. $(FOO_CMAKE)
        @$(call touch, $@)

compared to what is stated in the "manual":

    $(STATEDIR)/@pack...@.prepare:
        @$(call targetinfo)
        @$(call clean, $(@pack...@_dir)/config.cache)
        cd $(@pack...@_dir) && \
            $(@pack...@_path) $(@pack...@_env) \
            cmake $(@pack...@_cmake)
        @$(call touch)

The PATH and ENV variables are set the same, the only difference is an
explicit out-of-source-build with cmake. I found some subtly errors in
other parts of our rule and some other errors in our
FindNETSNMP.cmake. Currently the latter looks like this:

    IF(NOT NETSNMP_INCLUDE_DIR)
    find_path(NETSNMP_INCLUDE_DIR
        NAMES
            net-snmp-includes.h
            net-snmp-config.h
        PATHS
        /usr/include
        /usr/local/include
        PATH_SUFFIXES
            net-snmp
    )
    ENDIF()

    IF(NOT NETSNMP_LIBRARIES)
    find_library(NETSNMP_LIBRARIES
        NAMES
        netsnmp
        PATHS
        /usr/lib
        /usr/local/lib
    )
    ENDIF()

    IF (NETSNMP_INCLUDE_DIR AND NETSNMP_LIBRARIES)
        SET(NETSNMP_FOUND "YES")
    ELSE ()
        SET(NETSNMP_FOUND "NO")
    ENDIF ()

    IF (NETSNMP_FOUND)
        IF (NOT NETSNMP_FIND_QUIETLY)
            MESSAGE(STATUS "Found netsnmp library: ${NETSNMP_LIBRARIES}")
        ENDIF ()
    ELSE ()
        IF (NOT NETSNMP_FIND_QUIETLY)
            MESSAGE(STATUS "Could not find netsnmp library.")
        ENDIF ()
    ENDIF ()

    MARK_AS_ADVANCED(NETSNMP_INCLUDE_DIR NETSNMP_LIBRARIES)

However this doesn't work correctly yet. In our rule file we still set
the following:

    FOO_CMAKE += -DLIBCGI_INCLUDE_DIR=$(SYSROOT)/usr/include/libcgi
    FOO_CMAKE += -DLIBCGI_LIBRARIES=$(SYSROOT)/usr/lib/libcgi.so
    FOO_CMAKE += -DNETSNMP_INCLUDE_DIR=$(SYSROOT)/usr/include
    FOO_CMAKE += -DNETSNMP_LIBRARIES=$(SYSROOT)/usr/lib/libnetsnmp.so

When setting this at least our build completes, but without the libs
are not found. (The system libs however are found when building
without ptxdist on x86 with the same cmake files.)

Currently I'm not aware how to further debug the cmake part and how
the includes and libs are searched, lacks some cmake experience still.

Regards
Alexander



-- 
ptxdist mailing list
ptxdist@pengutronix.de

Reply via email to