CGAL has several dependencies, including GMP and MPFR libraries. When CMake runs, it needs to determine the versions of these dependencies. To find the versions, CMake compiles and runs several small test programs that simply link with these libraries and output their versions. This works fine during a regular, non-cross-compiled build.
But when I cross-compile, naturally these test programs will not run on the host machine. Here's an example:
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 /opt/Company/ArmTools_GCC435_GLIBC_Q3_2011/bin/arm-rc-linux-gnueabi-g++ -fPIC CMakeFiles/cmTryCompileExec.dir/print_GMP_version.cpp.o -o cmTryCompileExec -rdynamic /home/pmw/Software-Engineering/build/Lib/mpir-2.6.0/arm/lib/libgmp.a gmake: Leaving directory `/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp' /home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: /home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: cannot execute binary file -- USING GMP_VERSION = 'unknown'
I found a suggestion (if I understand it correctly) to specify the GMP version explicitly; that should keep CMake from trying and failing to determine it. So I created a file containing this line:
and invoked CMake with the argument
-C path/to/my/file. But that didn't change anything. Then I tried invoking CMake with the argument
-DCMAKE_TOOLCHAIN_FILE=/path/to/my/file instead. Again, no effect. I see that CMake is able to find and parse this file, however.
So, how can I convince CMake to not try to build and execute cross-compiled programs on the host machine?
I apologize in advance if this Unix & Linux StackExchange site is not the best place for this question. Last week I posted my question on the CGAL mailing list (which is now the top three Google results for "cross-compiling cgal"; I am famous!) but received no replies.