[CMake] CMake 2.6.0 cross-compile: 1st time failed, 2nd time passed
ning
mailxiening at gmail.com
Mon Aug 4 21:38:22 EDT 2008
Hi, all
Just for other cmake newbies, like me, who run into cross-compiler that
is not able to build a simple program by default without special flags.
When I go on reading the wiki
http://www.cmake.org/Wiki/CMake_Cross_Compiling
I found that I should use CMakeForceCompiler module to bypass build
of cmTryCompileExec. It works for me now.
One note: It looks like CMAKE_C_FLAGS should not be set in
cross-tools.cmake which is assigned to -DCMAKE_TOOLCHAIN_FILE
in command line. CMAKE_C_FLAGS for cross compiler should
be surrounded by "if (CMAKE_CROSSCOMPILING)...endif" in
CMakeLists.txt. Although I did not find a statement about this in
2.6.0 documents.
Best regards.
ning
> Message: 5
> Date: Fri, 1 Aug 2008 13:36:09 +0900
> From: ning <mailxiening at gmail.com>
> Subject: [CMake] CMake 2.6.0 cross-compile: 1st time failed, 2nd time
> passed
> To: cmake at cmake.org
> Message-ID:
> <27f31620807312136p416519a3r6d9727d05e2adee3 at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Hi List,
>
> I am here trying to cross-compile a tiny demo project
> with cmake 2.6.0.
>
> When I ran cmake for the first time, link failed because
> CMAKE_C_FLAGS was not used to compile cmTryCompileExec.
> Then I modified nothing, but only ran cmake again.
> CMAKE_C_FLAGS was used properly and link passed.
>
> The project settings and logs are attached below.
> Could you point out which part I have done wrong and
> how to fix it.
> Thanks in advance.
>
> Best regards.
> ning
>
> =====project setting=====
> -----dir structure-----
> .
> |-- CMakeLists.txt
> |-- build/
> |-- cross-tools.cmake
> `-- tiny.c
>
> -----tiny.c-----
> #include <stdio.h>
> int main()
> {
> printf("tiny\n");
> return 0;
> }
>
> -----CMakeLists.txt-----
> PROJECT(tiny C)
> ADD_EXECUTABLE(tiny tiny.c)
>
> -----cross-tools.cmake-----
> # cross compile path variables
> SET(TOOLS_PATH "/tftpboot/x86-linux2")
> SET(SYSROOT_PATH "/tftpboot/sysroot")
> # cross compiler tools
> SET(CMAKE_SYSTEM_NAME Linux)
> SET(CMAKE_C_FLAGS "--sysroot=${SYSROOT_PATH} -mfloat-abi=softfp")
> SET(CMAKE_C_COMPILER "arm-wrs-linux-gnueabi-gcc")
> # search path
> SET(CMAKE_FIND_ROOT_PATH ${SYSROOT_PATH} ${TOOLS_PATH})
> # search for programs/header/libs in target directories
> SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
> SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
> SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
> =====project setting end=====
>
> =====1st time=====
> -----command line-----
> $cd build
> $rm -r *
> $cmake -DCMAKE_TOOLCHAIN_FILE=../cross-tools.cmake ..
>
> -----CMakeFiles/CMakeError.log-----
> 10: Linking C executable cmTryCompileExec
> 11: /usr/local/bin/cmake -E cmake_link_script
> CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
> 12: /tftpboot/x86-linux2/bin/arm-wrs-linux-gnueabi-gcc
> -fPIC CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o
> -o cmTryCompileExec -rdynamic.
> 13: /tftpboot/x86-linux2/bin/ld:
> crt1.o: No such file: No such file or directory
> =====1st time end=====
>
> =====2nd time=====
> -----command line-----
> $cmake -DCMAKE_TOOLCHAIN_FILE=../cross-tools.cmake ..
>
> -----CMakeFiles/CMakeOutput.log-----
> 53: Linking C executable cmTryCompileExec
> 54: /usr/local/bin/cmake -E cmake_link_script
> CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
> 55: /tftpboot/x86-linux2/bin/arm-wrs-linux-gnueabi-gcc
> --sysroot=/tftpboot/sysroot -mfloat-abi=softfp -fPIC
> CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o
> -o cmTryCompileExec -rdynamic.
> =====2nd time end=====
>
>
More information about the CMake
mailing list