CMakeLists.txt 3.77 KB
Newer Older
1 2
project(Patate)

3
cmake_minimum_required(VERSION 2.8.10)
Nicolas Mellado's avatar
Nicolas Mellado committed
4

Nicolas Mellado's avatar
Nicolas Mellado committed
5
# guard against in-source builds (source: Eigen)
6 7 8 9 10

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
endif()

Nicolas Mellado's avatar
Nicolas Mellado committed
11
# guard against bad build-type strings (source: Eigen)
12 13 14 15 16 17 18 19 20 21 22 23

if (NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release")
endif()

string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower)
if(    NOT cmake_build_type_tolower STREQUAL "debug"
   AND NOT cmake_build_type_tolower STREQUAL "release"
   AND NOT cmake_build_type_tolower STREQUAL "relwithdebinfo")
  message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, RelWithDebInfo (case-insensitive).")
endif()

24 25

# get changeset id
26 27 28 29 30 31
find_package(Git)
if(GIT_FOUND)
    execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
        WORKING_DIRECTORY ${Patate_SOURCE_DIR}
        OUTPUT_VARIABLE GIT_CHANGESET)
endif()
32

33 34 35 36
################################################################################
# Add core code source, so it is visible in dev environements                  #
################################################################################

Nicolas Mellado's avatar
Nicolas Mellado committed
37 38 39 40
add_subdirectory(Patate/Grenaille EXCLUDE_FROM_ALL)
add_subdirectory(Patate/Vitelotte EXCLUDE_FROM_ALL)
add_subdirectory(Patate/common)

41

42 43 44 45 46 47 48 49 50 51
################################################################################
# Generate install target                                                      #
################################################################################
if (NOT INCLUDE_INSTALL_DIR)
    set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)
endif (NOT INCLUDE_INSTALL_DIR)
install(DIRECTORY Patate DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING REGEX ".*\\.(hpp|h)$")
message("Patate will be installed in ${INCLUDE_INSTALL_DIR}/Patate")


52
################################################################################
53 54 55 56 57
# add a target to generate API documentation with Doxygen                      #
################################################################################

find_package(Doxygen)
if(DOXYGEN_FOUND)
58
  set (PATATE_PROJECT_NUMBER ${GIT_CHANGESET})
59

60
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc-src/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
61

62
  add_custom_target(doc
63
     ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/doc-src
64 65 66 67 68 69 70 71 72 73 74 75
     COMMAND ${CMAKE_COMMAND} -E copy_directory
       ${CMAKE_CURRENT_SOURCE_DIR}/doc-src/images/
       ${CMAKE_CURRENT_BINARY_DIR}/doc/html/images
     COMMAND ${CMAKE_COMMAND} -E copy
       ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG
       ${CMAKE_CURRENT_BINARY_DIR}/doc-src/
     COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
     DEPENDS
       ${CMAKE_CURRENT_SOURCE_DIR}/doc-src/Doxyfile.in
       ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     COMMENT "Generating API documentation with Doxygen" VERBATIM
76 77
  )
endif(DOXYGEN_FOUND)
78 79 80 81

################################################################################
# tests and examples                                                           #
################################################################################
82

Nicolas Mellado's avatar
Nicolas Mellado committed
83
# enable extra warnings
84
if (CMAKE_COMPILER_IS_GNUCXX)
85 86
    # Do NOT use list( APPEND ... ) with flags, as adding flags to a non-empty
    # CMAKE_[...]_FLAGS introduces unwanted semicolons.
87
    set( CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra  -Wdouble-promotion ${CMAKE_CXX_FLAGS}")
88
endif (CMAKE_COMPILER_IS_GNUCXX)
Nicolas Mellado's avatar
Nicolas Mellado committed
89

90 91
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

92
add_subdirectory(examples EXCLUDE_FROM_ALL)
93 94

include(cmake/ConfigureTesting.cmake)
Nicolas Mellado's avatar
Nicolas Mellado committed
95
add_subdirectory(tests EXCLUDE_FROM_ALL)
96