It’s an example of b***dy quick attempt to configure CMake-based build of a fairly large library written in C++ programming language. It is GEOS.
Seven. A lucky number. Arnulf‘s nickname. Total number of lines (commands) of CMake script to configure build of GEOS C++ core as a static library using sources form SVN trunk:
Create trunk/CMakeLists.txt file:
project(geos)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
add_subdirectory(src)
Create trunk/src/CMakeLists.txt file:
include_directories(${CMAKE_SOURCE_DIR}/include)
file(GLOB_RECURSE geos_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_library(geos STATIC ${geos_SRC})
In fact, only six lines are really required. The third line in file trunk/CMakeLists.txt is optional.
mloskot@dog:~/dev/geos/_svn/trunk$ svn status ? CMakeLists.txt ? src/CMakeLists.txt mloskot@dog:~/dev/geos/_svn/trunk$ mkdir ../build mloskot@dog:~/dev/geos/_svn/trunk$ cd ../build/ mloskot@dog:~/dev/geos/_svn/build$ cmake ../trunk -- The C compiler identification is GNU -- The CXX compiler identification is GNU -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /home/mloskot/dev/geos/_svn/build mloskot@dog:~/dev/geos/_svn/build$ mloskot@dog:~/dev/geos/_svn/build$ make -j5 Scanning dependencies of target geos [ 0%] Building CXX object src/CMakeFiles/geos_lib.dir/operation/valid/RepeatedPointTester.cpp.o ...
and 53 seconds later my Intel Core 2 Duo 2.4GHz box announces:
[100%] Building CXX object src/CMakeFiles/geos.dir/linearref/LengthIndexOfPoint.cpp.o Linking CXX static library libgeos.a [100%] Built target geos
This build configuration is universal and cross platform, thus should work on all platforms supported by CMake.
Simply, you can not afford not use the best cross-platform build system that ever existed :-)