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 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. if (HAVEHG)
  39. ExternalProject_Add(EIGEN
  40. HG_REPOSITORY "https://bitbucket.org/eigen/eigen/"
  41. UPDATE_COMMAND ""
  42. HG_TAG "default"
  43. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  44. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  45. )
  46. ELSE()
  47. # Stable Eigen, requires manual updating when new releases, but lighter weight.
  48. ExternalProject_Add(EIGEN
  49. #URL "http://bitbucket.org/eigen/eigen/get/3.2.7.tar.gz"
  50. URL "http://bitbucket.org/eigen/eigen/get/default.tar.gz" # tip from repo
  51. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  52. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  53. )
  54. ENDIF()
  55. # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence)
  56. ExternalProject_Add(YAML-CPP
  57. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  58. GIT_TAG "master"
  59. UPDATE_COMMAND ""
  60. PATCH_COMMAND ""
  61. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  62. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  63. )
  64. add_compile_options(-DHAVE_YAMLCPP)
  65. # tinyxml2, this library is used for XML IO
  66. option( LEMMA_TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  67. if ( LEMMA_TINYXML_SUPPORT )
  68. ExternalProject_Add(TINYXML2
  69. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  70. GIT_TAG "master"
  71. UPDATE_COMMAND ""
  72. PATCH_COMMAND ""
  73. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  74. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON
  75. #-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  76. )
  77. add_compile_options(-DTINYXMLSUPPORT)
  78. endif()
  79. option( LEMMA_MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  80. if ( LEMMA_MATIO_SUPPORT )
  81. add_compile_options(-DHAVE_MATIO)
  82. # matio, this library is used for MATLAB file IO
  83. ExternalProject_ADD(MATIO
  84. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  85. GIT_TAG "master"
  86. UPDATE_COMMAND ""
  87. PATCH_COMMAND ""
  88. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  89. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  90. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  91. BUILD_IN_SOURCE 1
  92. BUILD_COMMAND ${MAKE}
  93. )
  94. endif()
  95. # We don't build VTK, it is too heavy.
  96. option (LEMMA_VTK6_SUPPORT "VTK library for visualisation and grids" OFF)
  97. if ( LEMMA_VTK6_SUPPORT )
  98. #find_package(VTK 6 REQUIRED NO_MODULE)
  99. find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  100. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  101. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL NO_MODULE)
  102. set(volumeRenderer volumerenderer.cxx)
  103. include(${VTK_USE_FILE})
  104. add_compile_options(-DLEMMAUSEVTK)
  105. # Compile Matplot_vtk if VTK is present
  106. add_subdirectory(Matplot_vtk)
  107. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  108. endif()
  109. option (LEMMA_VTK7_SUPPORT "VTK library for visualisation and grids" OFF)
  110. if ( LEMMA_VTK7_SUPPORT )
  111. #find_package(VTK 7 REQUIRED NO_MODULE)
  112. find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  113. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  114. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
  115. set(volumeRenderer volumerenderer.cxx)
  116. include(${VTK_USE_FILE})
  117. add_compile_options(-DLEMMAUSEVTK)
  118. # Compile Matplot_vtk if VTK is present
  119. add_subdirectory(Matplot_vtk)
  120. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  121. endif()
  122. #####################
  123. # Lemma Configuration
  124. #####################
  125. ####################
  126. # Add the c++11 flag
  127. # TODO add compiler specific instructions
  128. include(CheckCXXCompilerFlag)
  129. CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  130. CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  131. if(COMPILER_SUPPORTS_CXX11)
  132. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  133. elseif(COMPILER_SUPPORTS_CXX0X)
  134. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  135. else()
  136. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  137. endif()
  138. option( LEMMA_USE_OPENMP "Use OpenMP in Lemma" OFF)
  139. CHECK_CXX_COMPILER_FLAG(-fopenmp COMPILER_SUPPORTS_OPENMP)
  140. if(COMPILER_SUPPORTS_OPENMP AND LEMMA_USE_OPENMP )
  141. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -DLEMMAUSEOMP")
  142. endif()
  143. set(LEMMA_VERSION_MAJOR "0")
  144. set(LEMMA_VERSION_MINOR "0")
  145. set(LEMMA_VERSION_PATCH "1")
  146. set(LEMMA_VERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  147. configure_file (
  148. "${PROJECT_SOURCE_DIR}/include/LemmaConfig.h.in"
  149. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  150. )
  151. include_directories("${PROJECT_BINARY_DIR}/include")
  152. include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
  153. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  154. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  155. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  156. add_subdirectory (LemmaCore)
  157. ########################################################################
  158. # Build Modules
  159. add_subdirectory (Modules)
  160. ########################################################################
  161. #
  162. include_directories(${CMAKE_INSTALL_PREFIX}/include)
  163. add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
  164. target_link_libraries(Hello lemmacore)
  165. add_dependencies(Hello YAML-CPP)
  166. # add a target to generate API documentation with Doxygen
  167. # ALL make documentation build by default if possible
  168. find_package(Doxygen)
  169. if(DOXYGEN_FOUND)
  170. option( LEMMA_BUILD_DOCUMENTATION "Build Doxygen man pages" OFF )
  171. if (LEMMA_BUILD_DOCUMENTATION)
  172. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Documentation/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile @ONLY)
  173. add_custom_target(doc
  174. ALL
  175. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile
  176. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  177. COMMENT "Generating API documentation with Doxygen" VERBATIM
  178. )
  179. endif (LEMMA_BUILD_DOCUMENTATION)
  180. endif(DOXYGEN_FOUND)