Install the m68k atari cross compiling toolchain


There are several ways to get the cross compiler for your system. Here isthe info's that you will need (http://vincent.riviere.free.fr/soft/m68k-atari-mint). There is Cygwin installator and ready Debian/Ubuntu x86 and amd64 packages. You can also build everything from sources, but it will be rather time consuming.

Write a CMake toolchain file


For CMake to be able to crosscompile software, it requires you to write a toolchain file, which tells CMake some information about the toolchain. With the examples used above it will look like (ready to use file is added as an attachment at the bottom of this page):
Toolchain-m68k-atari-mint.cmake
# the name of the target operating system SET(CMAKE_SYSTEM_NAME AtariTOS) # which compilers to use for C and C++ SET(CMAKE_C_COMPILER m68k-atari-mint-gcc) SET(CMAKE_CXX_COMPILER m68k-atari-mint-g++) # here is the target environment located SET(CMAKE_FIND_ROOT_PATH /usr/m68k-atari-mint $HOME/gcc-atari) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search # programs in the host environment set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


Save this file as Toolchain-m68k-atari-mint.cmake to some location where you will put all your toolchain files, e.g. $HOME. As you can see CMAKE_FIND_ROOT_PATH is set to /usr/m68k-atari-mint, which contains the headers and libraries installed with the toolchain. This second directory is intended to hold other libraries you will compile using m68k-atari-gcc, they should be installed under this install prefix. This way the FIND_XXX() commands in CMake will find both the headers and libraries coming with the toolchain as well as additional libraries you have built for this platform.

Build the software for Atari TOS


Let's say you have the classical hello world software with a CMake based buildsystem and want to build this for TOS using m68k-atari-mint-gcc.



main.c
#include <stdio.h> int main() { printf("Hello worldn"); return 0; }



CMakeLists.txt
ADD_EXECUTABLE(hello main.c)



Then run CMake on it to generate the buildfiles, the important point is that you tell it to use the toolchain file you just wrote:

~/src/helloworld/ $ mkdir build ~/src/helloworld/ $ cd build ~/src/helloworld/build/ $ cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-m68k-atari-mint.cmake -DCMAKE_INSTALL_PREFIX=~/m68k-atari-mint-installdir .. -- Configuring done -- Generating done -- Build files have been written to: ~/src/helloworld/build ~/src/helloworld/build/ $ make Scanning dependencies of target hello [100%] Building C object CMakeFiles/hello.dir/main.o Linking C executable hello [100%] Built target hello



So that's all. It actually doesn't matter whether it's just a "hello world" or some complex piece of software, the only difference is the usage of the toolchain file. If the software has all required configure checks, it should just build also with this toolchain.