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===== _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake