Re: [CMake] pkg-config and Cross_compiling
On Monday 07 July 2008, Hendrik Sattler wrote: Zitat von Alexander Neundorf [EMAIL PROTECTED]: On Wednesday 02 July 2008, Hendrik Sattler wrote: Am Mittwoch, 2. Juli 2008 18:59:37 schrieb Wookey: ... Additionally, I found that the include paths are another source of problems, not fully covered by the cmake cross compiling, yet. You really have to -I any path that is not known and specific to the cross compiler, using INCLUDE_DIRECTORIES(). This is not done automatically for the changed ROOT_PATH, yet. Can you please explain more detailled ? I don't understand what you mean. If you find such problems, please report them in the cmake bugtracker. If you include a non-standard header file in your program: #include foo/bar.h and foo sits /path/to/non-native (e.g. /opt/cross-root/usr/include with /opt/cross-root being CMAKE_FIND_ROOT_PATH), then it will not be found. How could it, the compiler doesn't know about /opt/cross-root as it is installed somewhere else. So you must tell the compiler with -I/opt/cross-root/usr/include that it should look there. Currently, I do something like: foreach ( dir ${CMAKE_FIND_ROOT_PATH} ) foreach ( inc usr/local/include usr/include include ) I think /usr/local/include isn't always part of the built-in search path, but usr/include and include look good. if ( EXISTS ${dir}/${inc} ) include_directories( SYSTEM ${dir}/${inc} ) endif ( EXISTS ${dir}/${inc} ) endforeach ( inc ) endforeach ( dir ) That make it just work. Same goes for pkg-config. If I do a find_* in cmake first to find that include, that will solve that, sure. Yes, that would be the general advice for that kind of problems. What do the other cmake devs think ? Is it the authors fault if he didn't search for the correct header using FIND_PATH() or should we add these include dirs automatically ? Beside that, what would you think about using -nostdinc ? Alex ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] pkg-config and Cross_compiling
Am Mittwoch, 2. Juli 2008 18:59:37 schrieb Wookey: I tried to fix the FindPkgConfig.cmake file to automaticaly do this, but found that it uses execute_process to call pkg-config and there seems to be no way to set an environment variable with this call. Am I missing something? Fixing this module to look in CMAKE_FIND_ROOT_PATH when cross-compiling seems like the best fix to me, but there may be a better way? Yes, that should be fixed. It should work to use SET() to set an environment variable and the child process from EXECUTE_PROCESS should get the copy of that environment. BUT: you must use PKG_CONFIG_LIBDIR instead of PKG_CONFIG_PATH! Additionally, I found that the include paths are another source of problems, not fully covered by the cmake cross compiling, yet. You really have to -I any path that is not known and specific to the cross compiler, using INCLUDE_DIRECTORIES(). This is not done automatically for the changed ROOT_PATH, yet. So eventually, the cross-compiled programs ends up including the wrong files :-( You have to be careful with that... The CMAKE_TOOLCHAIN_FILE can be used to set both, but this could also be handled automatically. HS ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] pkg-config and Cross_compiling
On 2008-07-02 19:39 +0200, Hendrik Sattler wrote: Am Mittwoch, 2. Juli 2008 18:59:37 schrieb Wookey: I tried to fix the FindPkgConfig.cmake file to automaticaly do this, but found that it uses execute_process to call pkg-config and there seems to be no way to set an environment variable with this call. Am I missing something? Fixing this module to look in CMAKE_FIND_ROOT_PATH when cross-compiling seems like the best fix to me, but there may be a better way? Yes, that should be fixed. It should work to use SET() to set an environment variable and the child process from EXECUTE_PROCESS should get the copy of that environment. BUT: you must use PKG_CONFIG_LIBDIR instead of PKG_CONFIG_PATH! Ah, so I do - well done. That will avoid native libs being found. I got the impression that SET() only set CMAKE variables, not environment ones, but maybe they ammount to the same thing? fx: reads docs again Ah, yes there is the ENV{} syntax. Brill. that means I can now add IF (CMAKE_CROSSCOMPILING) SET(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig/) to the toolchain file and that works fine. Putting that in FindPkgConfig.cmake should do the trick. Additionally, I found that the include paths are another source of problems, not fully covered by the cmake cross compiling, yet. You really have to -I any path that is not known and specific to the cross compiler, using INCLUDE_DIRECTORIES(). This is not done automatically for the changed ROOT_PATH, yet. Yes. I found that too. I added: IF (CMAKE_CROSSCOMPILING) INCLUDE_DIRECTORIES(BEFORE ${CMAKE_FIND_ROOT_PATH}/include) to my toolchain file, but it would have been nice is cmake did it for me. Wookey -- Principal hats: Balloonz - Toby Churchill - Aleph One - Debian http://wookware.org/ ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake