Building glean with cmake

Now you can build glean on GNU/Linux or Windows using cmake. The advantages over GNU make are:

Build glean on GNU/Linux

Simply type

    cmake -Hsrc -Bbuild
    make -C build

Everything should be autodetected for you.

Build glean on Windows

Simply type

    cmake -G "Visual Studio 9 2008" -Hsrc -Bbuild
    cmake --build build --config Debug %*

Everything should be autodetected for you.

Build glean for Windows on GNU/Linux

Create a Toolchain.cmake file containing:

# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)

# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)

# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)

# 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)

Create a Cache.cmake file containing:

set(GLUT_INCLUDE_DIR "/path/to/glut/include" CACHE PATH "" FORCE)
set(GLUT_glut_LIBRARY "/path/to/glut/lib/libglut32.a" CACHE FILEPATH "" FORCE)

Then do:

cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=/path/to/Toolchain.cmake -C /path/to/Cache.cmake -Hsrc -Bbuild
make -C build

Read this for more information about CMake and MinGW cross compilation.