cmake_minimum_required(VERSION 2.6) # define compiler in order not to take clang # and clang++ as default compilers # do rm -rf CMakeFiles/* CMakeCache.txt # if it is not working set(CMAKE_C_COMPILER "/usr/bin/gcc") set(CMAKE_CXX_COMPILER "/usr/bin/g++") # --------------------- # the project # --------------------- project(MyProject) # define build to be a release set( CMAKE_BUILD_TYPE Release ) # put binary in 'bin' directory set( EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE} ) # add flags to be able to compile with C++11 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11" ) include_directories( src src/maths ) # define files of user 'maths' library file( GLOB_RECURSE source_files_maths src/${VERSION}/maths/* ) add_library( maths SHARED ${source_files_maths} ) # define files of the binary file( GLOB_RECURSE source_files src/*.cpp ) # tell to generate the binary ./main.exe from source files add_executable( main.exe ${source_files} ) # find boost libraries find_package( Boost COMPONENTS system filesystem REQUIRED ) # tell to link with maths and boost libraries target_link_libraries( main.exe maths ${Boost_FILESYSTEM_LIBRARY_RELEASE} ${Boost_SYSTEM_LIBRARY_RELEASE} )