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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
  2. set(LEMMA_VERSION_MAJOR "0")
  3. set(LEMMA_VERSION_MINOR "2")
  4. set(LEMMA_VERSION_PATCH "1")
  5. set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")
  6. set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  7. # Mac OSX RPATH is weird
  8. # enable @rpath in the install name for any shared library being built
  9. # note: it is planned that a future version of CMake will enable this by default
  10. if(POLICY CMP0015)
  11. cmake_policy(SET CMP0015 NEW)
  12. endif()
  13. set(CMAKE_MACOSX_RPATH 1)
  14. project (Lemma CXX)
  15. ##############################
  16. # required external programs # for downloading packages
  17. ##############################
  18. FIND_PROGRAM(HAVEGIT git
  19. PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
  20. )
  21. if(NOT HAVEGIT)
  22. message(FATAL_ERROR "Lemma requires that git is installed and in the path of your machine")
  23. endif(NOT HAVEGIT)
  24. option(BUILD_SHARED_LIBS OFF)
  25. if(BUILD_SHARED_LIBS)
  26. set(LABEL_SUFFIX "shared")
  27. else()
  28. set(LABEL_SUFFIX "static")
  29. endif()
  30. if(NOT CMAKE_BUILD_TYPE)
  31. set(CMAKE_BUILD_TYPE "Release" CACHE STRING
  32. "Choose the type of build, options are: Debug Release
  33. RelWithDebInfo MinSizeRel."
  34. FORCE)
  35. endif(NOT CMAKE_BUILD_TYPE)
  36. ###################
  37. # External Projects
  38. ###################
  39. include(ExternalProject)
  40. ##########################################################################################
  41. # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
  42. # Eigen now has an official mirror on GitHub, so Mercurial is no longer a requirement!
  43. ExternalProject_Add(EIGEN
  44. GIT_REPOSITORY "https://github.com/eigenteam/eigen-git-mirror.git"
  45. UPDATE_COMMAND ""
  46. GIT_TAG "3.3.3" #"default"
  47. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  48. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  49. )
  50. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  51. #############################################################################################
  52. # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence)
  53. #find_package(yaml-cpp)
  54. if (yaml-cpp_FOUND)
  55. message( STATUS "YAML-CPP FOUND ${yaml-cpp_FOUND}" )
  56. message( STATUS "YAML-CPP LIBRARIES ${YAML_CPP_LIBRARIES}" )
  57. message( STATUS "YAML-CPP LIBRARY ${yaml-cpp_LIBRARY}" )
  58. else()
  59. message( STATUS "YAML-CPP WAS NOT FOUND" )
  60. ExternalProject_Add(YAML_CPP
  61. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  62. GIT_TAG "yaml-cpp-0.6.1" # "master"
  63. UPDATE_COMMAND ""
  64. PATCH_COMMAND ""
  65. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  66. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  67. -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  68. -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
  69. -DYAML_CPP_BUILD_TESTS=OFF
  70. )
  71. find_package(yaml-cpp)
  72. endif()
  73. # CxxTest
  74. find_package(CxxTest)
  75. if (CXXTEST_FOUND)
  76. # Do nothing
  77. message( STATUS "CXXTEST FOUND" )
  78. else()
  79. message( STATUS "CxxTest will be built and installed along with Lemma, override if desired in GUI." )
  80. ExternalProject_Add(CxxTest
  81. GIT_REPOSITORY "https://github.com/CxxTest/cxxtest.git"
  82. GIT_TAG "master"
  83. UPDATE_COMMAND ""
  84. PATCH_COMMAND ""
  85. CONFIGURE_COMMAND ""
  86. BUILD_COMMAND ""
  87. INSTALL_COMMAND ""
  88. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest
  89. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} /
  90. -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  91. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  92. )
  93. # The values "CACHE PATH "" FORCE" makes the GUI show the values of the local CxxTest, but this can cause issues
  94. # with users wanting to specify their own path, its not recommended
  95. set (CXXTEST_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/") # CACHE PATH "" FORCE )
  96. set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen") # CACHE PATH "" FORCE )
  97. find_package(CxxTest REQUIRED)
  98. endif()
  99. # tinyxml2, this library is used for XML IO
  100. option( LEMMA_TINYXML_SUPPORT "TinyXML library support for .xml files" OFF)
  101. if ( LEMMA_TINYXML_SUPPORT )
  102. ExternalProject_Add(TINYXML2
  103. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  104. GIT_TAG "master"
  105. UPDATE_COMMAND ""
  106. PATCH_COMMAND ""
  107. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  108. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  109. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  110. )
  111. add_compile_options(-DTINYXMLSUPPORT)
  112. endif()
  113. option( LEMMA_MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  114. if ( LEMMA_MATIO_SUPPORT )
  115. add_compile_options(-DHAVE_MATIO)
  116. # matio, this library is used for MATLAB file IO
  117. ExternalProject_ADD(MATIO
  118. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  119. GIT_TAG "master"
  120. UPDATE_COMMAND ""
  121. PATCH_COMMAND ""
  122. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  123. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  124. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  125. BUILD_IN_SOURCE 1
  126. BUILD_COMMAND ${MAKE}
  127. )
  128. endif()
  129. # We don't build VTK, it is too heavy.
  130. option (LEMMA_VTK6_SUPPORT "VTK library for visualisation and grids" OFF)
  131. if ( LEMMA_VTK6_SUPPORT )
  132. #find_package(VTK 6 REQUIRED NO_MODULE)
  133. find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  134. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  135. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL NO_MODULE)
  136. set(volumeRenderer volumerenderer.cxx)
  137. include(${VTK_USE_FILE})
  138. add_compile_options(-DLEMMAUSEVTK)
  139. # Compile Matplot_vtk if VTK is present
  140. #add_subdirectory(Matplot_vtk)
  141. #include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  142. endif()
  143. option (LEMMA_VTK7_SUPPORT "VTK library for visualisation and grids" OFF)
  144. if ( LEMMA_VTK7_SUPPORT )
  145. #find_package(VTK 7 REQUIRED NO_MODULE)
  146. find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  147. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  148. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
  149. set(volumeRenderer volumerenderer.cxx)
  150. if (VTK_FOUND)
  151. message(STATUS "VTK 7 was found! ")
  152. include(${VTK_USE_FILE})
  153. #add_compile_options(-DLEMMAUSEVTK)
  154. #target_compile_definitions( lemmacore PRIVATE LEMMAUSEVTK=1 )
  155. add_definitions(-DLEMMAUSEVTK)
  156. else()
  157. ExternalProject_Add(VTK
  158. GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
  159. GIT_TAG "v7.1.1"
  160. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk7
  161. CMAKE_ARGS
  162. -DBUILD_SHARED_LIBS:BOOL=ON
  163. -DBUILD_EXAMPLES:BOOL=OFF
  164. -DBUILD_TESTING:BOOL=OFF
  165. -DVTK_Group_Web:BOOL=OFF
  166. -DModule_vtkImagingMath:BOOL=ON
  167. LOG_DOWNLOAD 0
  168. LOG_UPDATE 0
  169. )
  170. endif()
  171. endif()
  172. option (LEMMA_VTK8_SUPPORT "VTK library for visualisation and grids" OFF)
  173. if ( LEMMA_VTK8_SUPPORT )
  174. find_package(VTK 8.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  175. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  176. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
  177. if (VTK_FOUND)
  178. message(STATUS "VTK 8 was found! ")
  179. set(volumeRenderer volumerenderer.cxx)
  180. include(${VTK_USE_FILE})
  181. else()
  182. message( STATUS "External build of VTK 8 has been added, this may take some time to build." )
  183. ExternalProject_Add(VTK8
  184. GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
  185. GIT_TAG "v8.1.0"
  186. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk8
  187. CMAKE_ARGS
  188. -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  189. -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  190. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} /
  191. -DBUILD_SHARED_LIBS:BOOL=ON /
  192. -DBUILD_EXAMPLES:BOOL=OFF /
  193. -DBUILD_TESTING:BOOL=OFF /
  194. -DVTK_Group_Web:BOOL=OFF /
  195. -DModule_vtkImagingMath:BOOL=ON /
  196. LOG_DOWNLOAD 0 /
  197. LOG_UPDATE 0
  198. )
  199. endif()
  200. add_definitions(-DLEMMAUSEVTK)
  201. endif()
  202. #######################
  203. # Lemma Configuration #
  204. #######################
  205. #############################
  206. # Look for Ki Ha Lee (EM1D) #
  207. #############################
  208. FIND_LIBRARY( KIHA_EM1D kihaem1d )
  209. if ( KIHA_EM1D )
  210. add_definitions(-DKIHALEE_EM1D)
  211. endif()
  212. ####################
  213. # Look for Boost
  214. ####################
  215. option (LEMMA_USE_BOOST "Boost is required by gaussian quadrature classes" OFF)
  216. if (LEMMA_USE_BOOST)
  217. find_package(Boost
  218. 1.58.0 # Minimum or EXACT version e.g. 1.36.0
  219. # COMPONENTS math # Boost libraries by their canonical name
  220. )
  221. if(Boost_FOUND)
  222. include_directories(${Boost_INCLUDE_DIRS})
  223. endif()
  224. find_path( HAVE_BOOST_SPECIAL_FUNCTIONS "boost/math/special_functions.hpp" )
  225. if(HAVE_BOOST_SPECIAL_FUNCTIONS)
  226. add_compile_options(-DHAVE_BOOST_SPECIAL_FUNCTIONS)
  227. endif()
  228. endif()
  229. ####################
  230. # Magic rpath flag
  231. ####################
  232. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  233. option( LEMMA_BUILD_EXAMPLES "Compile example Lemma applications" OFF )
  234. option( LEMMA_USE_OPENMP "Use OpenMP in Lemma" OFF)
  235. if (LEMMA_USE_OPENMP)
  236. find_package(OpenMP)
  237. if (OPENMP_FOUND)
  238. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  239. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  240. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
  241. else()
  242. message (FATAL ERROR "OpenMP cannot be found, but was specified!")
  243. endif()
  244. endif()
  245. configure_file (
  246. "${PROJECT_SOURCE_DIR}/config/LemmaConfig.h.in"
  247. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  248. )
  249. install ( FILES ${PROJECT_BINARY_DIR}/include/LemmaConfig.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/ )
  250. include_directories("${PROJECT_BINARY_DIR}/include")
  251. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  252. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  253. #######################################################################
  254. # CXXTEST Framework
  255. if(CXXTEST_FOUND)
  256. option (LEMMA_ENABLE_TESTING "Turn on unit testing" ON)
  257. if (LEMMA_ENABLE_TESTING)
  258. #include_directories(${CXXTEST_INCLUDE_DIR}) # Add this in testing CMakeLists.txt instead, cleaner
  259. enable_testing()
  260. endif()
  261. endif()
  262. ########################################################################
  263. # Build Modules
  264. add_subdirectory (Modules)
  265. ########################################################################
  266. # add a target to generate API documentation with Doxyfile.in
  267. # ALL make documentation build by default if possible
  268. find_package(Doxygen)
  269. if(DOXYGEN_FOUND)
  270. option( LEMMA_BUILD_DOCUMENTATION "Build Doxygen man pages" OFF )
  271. if (LEMMA_BUILD_DOCUMENTATION)
  272. # Custom header and footer option, enable in Doxygen
  273. # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/header.html
  274. # DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Documentation/header.html
  275. # )
  276. # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/footer.html
  277. # DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Documentation/footer.html
  278. # )
  279. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Documentation/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile @ONLY)
  280. add_custom_target(doc
  281. ALL
  282. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile
  283. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  284. COMMENT "Generating API documentation with Doxygen" VERBATIM
  285. )
  286. endif (LEMMA_BUILD_DOCUMENTATION)
  287. endif(DOXYGEN_FOUND)