Main Lemma Repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. cmake_minimum_required (VERSION 2.8.7)
  2. project (Lemma CXX)
  3. # required external programs (for runtime of nix, not buildtime)
  4. FIND_PROGRAM(HAVEGIT git
  5. PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
  6. )
  7. if(NOT HAVEGIT)
  8. message(FATAL_ERROR "Lemma requires that git is installed and in the path of your machine")
  9. endif(NOT HAVEGIT)
  10. # FIND_PROGRAM(HAVEHG hg
  11. # PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
  12. # )
  13. # if(NOT HAVEHG)
  14. # message(STATUS "Mercurial (hg) was not found.")
  15. # endif(NOT HAVEHG)
  16. ###################
  17. # External Projects
  18. ###################
  19. include(ExternalProject)
  20. # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
  21. # Mercurial (hg) repo pull, Would it be better to just download latest stable?
  22. #ExternalProject_Add(EIGEN
  23. # HG_REPOSITORY "https://bitbucket.org/eigen/eigen/"
  24. # UPDATE_COMMAND ""
  25. # PATCH_COMMAND ""
  26. # PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  27. # CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  28. #)
  29. # Stable Eigen, requires manual updating when new releases, but lighter weight.
  30. ExternalProject_Add(EIGEN
  31. URL "http://bitbucket.org/eigen/eigen/get/3.2.7.tar.gz"
  32. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  33. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  34. )
  35. # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence)
  36. ExternalProject_Add(YAML-CPP
  37. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  38. GIT_TAG "master"
  39. UPDATE_COMMAND ""
  40. PATCH_COMMAND ""
  41. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  42. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON
  43. )
  44. add_compile_options(-DHAVE_YAMLCPP)
  45. # tinyxml2, this library is used for XML IO
  46. option(TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  47. if ( TINYXML_SUPPORT )
  48. ExternalProject_Add(TINYXML2
  49. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  50. GIT_TAG "master"
  51. UPDATE_COMMAND ""
  52. PATCH_COMMAND ""
  53. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  54. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  55. )
  56. add_compile_options(-DTINYXMLSUPPORT)
  57. endif()
  58. option(MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  59. if ( MATIO_SUPPORT )
  60. add_compile_options(-DHAVE_MATIO)
  61. # matio, this library is used for MATLAB file IO
  62. ExternalProject_ADD(MATIO
  63. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  64. GIT_TAG "master"
  65. UPDATE_COMMAND ""
  66. PATCH_COMMAND ""
  67. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  68. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  69. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  70. BUILD_IN_SOURCE 1
  71. BUILD_COMMAND ${MAKE}
  72. )
  73. endif()
  74. # We don't build VTK, it is too heavy.
  75. option (VTK_SUPPORT "VTK library for visualisation and grids" OFF)
  76. if (VTK_SUPPORT)
  77. find_package(VTK 6 REQUIRED NO_MODULE)
  78. include(${VTK_USE_FILE})
  79. add_compile_options(-DLEMMAUSEVTK)
  80. # Compile Matplot_vtk if VTK is present
  81. add_subdirectory(Matplot_vtk)
  82. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  83. endif()
  84. #####################
  85. # Lemma Configuration
  86. #####################
  87. ####################
  88. # Add the c++11 flag
  89. # TODO add compiler specific instructions
  90. include(CheckCXXCompilerFlag)
  91. CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  92. CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  93. if(COMPILER_SUPPORTS_CXX11)
  94. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  95. elseif(COMPILER_SUPPORTS_CXX0X)
  96. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  97. else()
  98. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  99. endif()
  100. set(LEMMA_VERSION_MAJOR "0")
  101. set(LEMMA_VERSION_MINOR "0")
  102. set(LEMMA_VERSION_PATCH "1")
  103. set(LEMMA_VERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  104. configure_file (
  105. "${PROJECT_SOURCE_DIR}/include/LemmaConfig.h.in"
  106. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  107. )
  108. include_directories("${PROJECT_BINARY_DIR}/include")
  109. include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
  110. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  111. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  112. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  113. add_subdirectory (LemmaCore)
  114. ########################################################################
  115. # Build Modules
  116. add_subdirectory (Modules)
  117. ########################################################################
  118. #
  119. include_directories(${CMAKE_INSTALL_PREFIX}/include)
  120. add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
  121. target_link_libraries(Hello lemmacore)
  122. add_dependencies(Hello YAML-CPP)