From version 2.6.0 cmake includes support for cross-compiling. The CMake manual provides a useful source of background information here.
Cross-compiling plplot is complicated because a full build involves lots of external libraries for different drivers and multiple different compilers /interpreters for the language bindings. However, it is possible to build a cut-down version of PLplot using cmake. PLplot compiles and runs several executables to create source files / data for the project at build time. Obviously it is not generally possible to run the cross-compiled versions and so access is also required to a native build tree in which to find the native versions of the build-time executables. Support for this was only added to PLplot on 3rd March 2009 (svn revision 9665).
The following instructions were written and tested on using the mingw32 cross-compiler for Windows running under Linux. Debian and Ubuntu supply packages for this environment so it is simple to install and test.
This can just be a normal PLplot build. The only thing to be careful of it to ensure that it uses dynamic drivers if you intend to use them for the cross compiler otherwise get-drv-info will not be built.
See the CMake manual for details of this for individual platforms. The mingw32 example worked fine for me.
Using this method I have successfully cross-compiled the C++ bindings and the ps and svg drivers. Note that neither of these has external dependencies. For reference the cmake command line looked like
cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-mingw32.cmake -DDEFAULT_NO_DEVICES=ON -DPLD_ps=ON -DPLD_svg=ON -DPKG_CONFIG_EXECUTABLE=Not-Found -DDEFAULT_NO_BINDINGS=ON -DENABLE_cxx=ON -DNaNAwareCCompiler=ON -DCMAKE_NATIVE_BINARY_DIR=/home/andrew/software/plplot/build
../plplot
The content of this page is available under the GNU Free Documentation License 1.2.
I had problems trying to follow these steps:
My CMAKE_TOOLCHAIN_FILE looks like this:
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
The command I use is:
/usr/local/bin/cmake-3.6.3/cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DDEFAULT_NO_DEVICES=ON -DPLD_svg=ON -DPKG_CONFIG_EXECUTABLE=Not-Found ../pplot
The cmake filed with errors:
fatal error: termios.h: No such file or directory
fatal error: crt_externs.h: No such file or directory
fatal error: sys/wait.h: No such file or directory
error: ld returned 1 exit status
Can you help?
Thanks