Main Lemma Repository
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

CMakeLists.txt 5.2KB

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