[CMake] Problem with cmake cross-compiling - make complains of missing header.

Eric Noulard eric.noulard at gmail.com
Wed Nov 9 14:00:40 EST 2011


2011/11/9 Thomas Walwyn <Thomas.Walwyn at uec.co.za>:
> Hi All,
>
>
>
> I’m brand-new to cmake, and have run into a problem cross compiling for an
> Intel embedded platform:
>
>
>
> Make complains about missing file 'curl/curl.h' when compiling against an
> Intel SDK for linux. 'curl/curl.h' resides in the cross-compile toolchain
> under [toolchain-folder]/include/curl/curl.h. The toolchain file
> 'toolchain.cmake' resides at the root of the SDK (toolchain.cmake attached
> to end).
>
>
>
> The build is configured with the usual 'cmake
> -DCMAKE_TOOLCHAIN_FILE=[path-to-toolchain] ..' from a 'build' folder in the
> src directory of my application tree. cmake finds the compiler toolchain
> (gcc, gxx, ar, etc.) and completes the configuration all good (cmake output
> attached to end). The problem comes in when make is called. The strange
> thing is, the variable 'CURL_HEADER' contains the path of curl/curl.h if the
> following is added to the CMakeLists.txt:
>
>
>
> FIND_FILE(
>
>         CURL_HEADER
>
>         curl/curl.h
>
>         ONLY_CMAKE_FIND_ROOT_PATH
>
>                   )

finding the file is not enough.
You then need to add corresponding path to the include directory list.
Something like:

find_path(CURL_INCLUDE_DIR
               NAMES curl.h
               ONLY_CMAKE_FIND_ROOT_PATH)

include_directories(${CURL_INCLUDE_DIR})
should do it.

or may be

include_directories(${CURL_INCLUDE_DIR}/..)  <-- parent dir

because you use #include "curl/curl.h" in your prog and not #include "curl.h"

> This means that cmake can 'see' the file that make is complaining about. My
> question is why, if cmake can see the file, does make complain that it
> cannot find the file?

Because CMakeLists.txt did not teach the **compiler** how to use/find it.

> Something must be missing with the configuration of
> the cross-compilation.
>
> For reference, the program compiles perfectly on the host system, without
> the -DCMAKE_TOOLCHAIN_FILE flag. The host system is Fedora 13 with curl and
> its headers installed.

probably because curl/curl.h is in a standard location like
/usr/include/curl/curl.h which is on the default include path.

>
> I've also attached the important bits of the make output to the end for
> reference.
>
>
>
> Any help is greatly appreciated.
>
>
>
> Many thanks and kind regards,
>
>
>
> Thomas Walwyn
>
>
>
> #------------------------toolchain.cmake----------------------------------#
>
>
>
> SET(CMAKE_SYSTEM_NAME Linux)
>
> SET(CMAKE_SYSTEM_VERSION 1)
>
> SET(CMAKE_C_COMPILER [path-to-compiler]/[platform]-linux-gcc)
>
> SET(CMAKE_FIND_ROOT_PATH [path-to-toolchain-folder])
>
> SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
>
> SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
>
> SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
>
>
>
> #------------------------cmake output----------------------------------#
>
>
>
> -- The C compiler identification is GNU
>
> -- The CXX compiler identification is GNU
>
> -- Check for working C compiler: [path-to-compiler]/[platform]-linux-gcc
>
> -- Check for working C compiler: [path-to-compiler]/[platform]-linux-gcc --
> works
>
> -- Detecting C compiler ABI info
>
> -- Detecting C compiler ABI info - done
>
> -- Check for working CXX compiler: [path-to-compiler]/[platform]-linux-c++
>
> -- Check for working CXX compiler: [path-to-compiler]/[platform]-linux-c++
> -- works
>
> -- Detecting CXX compiler ABI info
>
> -- Detecting CXX compiler ABI info - done
>
> -- Configuring done
>
> -- Generating done
>
> -- Build files have been written to: [path-to-application-folder]/build
>
>
>
> #-----------------------part of make which gives error------------------#
>
>
>
> cd [path-to-application-source] && [path-to-compiler]/[platform]-linux-gcc
> -DIPFrontend_EXPORTS -fPIC -I[path-to-application-source]/includes   -o
> [path-to-application-source]/[source-file].c.o   -c
> [path-to-application-source]/[source-file]/[path-to-application-source]/[source-file].c
>
> [path-to-application-source]/[source-file].c:50:23: error: curl/curl.h: No
> such file or directory
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list