Main Lemma Repository
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CMakeLists.txt 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. option(BUILD_SHARED_LIBS OFF)
  21. if(BUILD_SHARED_LIBS)
  22. set(LABEL_SUFFIX "shared")
  23. else()
  24. set(LABEL_SUFFIX "static")
  25. endif()
  26. if (NOT CMAKE_BUILD_TYPE)
  27. set(CMAKE_BUILD_TYPE "Release")
  28. endif()
  29. ###################
  30. # External Projects
  31. ###################
  32. include(ExternalProject)
  33. # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
  34. # Mercurial (hg) repo pull, Would it be better to just download latest stable?
  35. #find_package(Eigen3 REQUIRED)
  36. #if (EIGEN3_FOUND)
  37. # # do nothing
  38. # include_directories(EIGEN3_INCLUDE_DIR)
  39. #else()
  40. if (HAVEHG)
  41. ExternalProject_Add(EIGEN
  42. HG_REPOSITORY "https://bitbucket.org/eigen/eigen/"
  43. UPDATE_COMMAND ""
  44. HG_TAG "default"
  45. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  46. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  47. )
  48. ELSE()
  49. # Stable Eigen
  50. ExternalProject_Add(EIGEN
  51. URL "http://bitbucket.org/eigen/eigen/get/default.tar.gz" # tip from repo
  52. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  53. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  54. )
  55. ENDIF()
  56. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  57. #endif()
  58. # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence)
  59. ExternalProject_Add(YAML-CPP
  60. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  61. GIT_TAG "master"
  62. UPDATE_COMMAND ""
  63. PATCH_COMMAND ""
  64. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  65. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  66. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  67. )
  68. add_compile_options(-DHAVE_YAMLCPP)
  69. # CxxTest
  70. find_package(CxxTest)
  71. if (CXXTEST_FOUND)
  72. # Do nothing
  73. else()
  74. ExternalProject_Add(CxxTest
  75. GIT_REPOSITORY "https://github.com/CxxTest/cxxtest.git"
  76. GIT_TAG "master"
  77. UPDATE_COMMAND ""
  78. PATCH_COMMAND ""
  79. CONFIGURE_COMMAND ""
  80. BUILD_COMMAND ""
  81. INSTALL_COMMAND ""
  82. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest
  83. )
  84. set (CXXTEST_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/")
  85. set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen" )
  86. find_package(CxxTest REQUIRED)
  87. endif()
  88. # tinyxml2, this library is used for XML IO
  89. option( LEMMA_TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  90. if ( LEMMA_TINYXML_SUPPORT )
  91. ExternalProject_Add(TINYXML2
  92. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  93. GIT_TAG "master"
  94. UPDATE_COMMAND ""
  95. PATCH_COMMAND ""
  96. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  97. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON
  98. #-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  99. )
  100. add_compile_options(-DTINYXMLSUPPORT)
  101. endif()
  102. option( LEMMA_MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  103. if ( LEMMA_MATIO_SUPPORT )
  104. add_compile_options(-DHAVE_MATIO)
  105. # matio, this library is used for MATLAB file IO
  106. ExternalProject_ADD(MATIO
  107. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  108. GIT_TAG "master"
  109. UPDATE_COMMAND ""
  110. PATCH_COMMAND ""
  111. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  112. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  113. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  114. BUILD_IN_SOURCE 1
  115. BUILD_COMMAND ${MAKE}
  116. )
  117. endif()
  118. # We don't build VTK, it is too heavy.
  119. option (LEMMA_VTK6_SUPPORT "VTK library for visualisation and grids" OFF)
  120. if ( LEMMA_VTK6_SUPPORT )
  121. #find_package(VTK 6 REQUIRED NO_MODULE)
  122. find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  123. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  124. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL NO_MODULE)
  125. set(volumeRenderer volumerenderer.cxx)
  126. include(${VTK_USE_FILE})
  127. add_compile_options(-DLEMMAUSEVTK)
  128. # Compile Matplot_vtk if VTK is present
  129. add_subdirectory(Matplot_vtk)
  130. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  131. endif()
  132. option (LEMMA_VTK7_SUPPORT "VTK library for visualisation and grids" OFF)
  133. if ( LEMMA_VTK7_SUPPORT )
  134. #find_package(VTK 7 REQUIRED NO_MODULE)
  135. find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  136. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  137. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
  138. set(volumeRenderer volumerenderer.cxx)
  139. include(${VTK_USE_FILE})
  140. add_compile_options(-DLEMMAUSEVTK)
  141. # Compile Matplot_vtk if VTK is present
  142. add_subdirectory(Matplot_vtk)
  143. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  144. endif()
  145. #####################
  146. # Lemma Configuration
  147. #####################
  148. ####################
  149. # Add the c++11 flag
  150. # TODO add compiler specific instructions
  151. include(CheckCXXCompilerFlag)
  152. CHECK_CXX_COMPILER_FLAG(-std=c++14 COMPILER_SUPPORTS_CXX14)
  153. CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  154. CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  155. if(COMPILER_SUPPORTS_CXX14)
  156. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  157. elseif(COMPILER_SUPPORTS_CXX11)
  158. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  159. elseif(COMPILER_SUPPORTS_CXX0X)
  160. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  161. else()
  162. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or C++14 support. Please use a different C++ compiler.")
  163. endif()
  164. option( LEMMA_USE_OPENMP "Use OpenMP in Lemma" OFF)
  165. CHECK_CXX_COMPILER_FLAG(-fopenmp COMPILER_SUPPORTS_OPENMP)
  166. if(COMPILER_SUPPORTS_OPENMP AND LEMMA_USE_OPENMP )
  167. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -DLEMMAUSEOMP")
  168. endif()
  169. set(LEMMA_VERSION_MAJOR "0")
  170. set(LEMMA_VERSION_MINOR "1")
  171. set(LEMMA_VERSION_PATCH "1")
  172. set(LEMMA_VERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  173. configure_file (
  174. "${PROJECT_SOURCE_DIR}/include/LemmaConfig.h.in"
  175. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  176. )
  177. include_directories("${PROJECT_BINARY_DIR}/include")
  178. include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
  179. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  180. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  181. if(CXXTEST_FOUND)
  182. option (LEMMA_ENABLE_TESTING "Turn on unit testing" ON)
  183. if (LEMMA_ENABLE_TESTING)
  184. include_directories(${CXXTEST_INCLUDE_DIR})
  185. enable_testing()
  186. #CXXTEST_ADD_TEST(tester_executable runner.cpp
  187. # ${CMAKE_CURRENT_SOURCE_DIR}/src/myTestsuite.h)
  188. #CXXTEST_ADD_TEST(unittest_foo foo_test.cc
  189. # ${CMAKE_CURRENT_SOURCE_DIR}/src/myTestSuite.h)
  190. #target_link_libraries(unittest_foo foo) # as needed
  191. # else()
  192. # message(FATAL_ERROR "CxxTest not found.")
  193. endif()
  194. endif()
  195. add_subdirectory (LemmaCore)
  196. ########################################################################
  197. # Build Modules
  198. add_subdirectory (Modules)
  199. ########################################################################
  200. #
  201. include_directories(${CMAKE_INSTALL_PREFIX}/include)
  202. # add a target to generate API documentation with Doxygen
  203. # ALL make documentation build by default if possible
  204. find_package(Doxygen)
  205. if(DOXYGEN_FOUND)
  206. option( LEMMA_BUILD_DOCUMENTATION "Build Doxygen man pages" OFF )
  207. if (LEMMA_BUILD_DOCUMENTATION)
  208. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Documentation/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile @ONLY)
  209. add_custom_target(doc
  210. ALL
  211. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile
  212. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  213. COMMENT "Generating API documentation with Doxygen" VERBATIM
  214. )
  215. endif (LEMMA_BUILD_DOCUMENTATION)
  216. endif(DOXYGEN_FOUND)