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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
  2. ####################################################################################################
  3. # Lemma versioning, set Major, minor, and patch here #
  4. set(LEMMA_VERSION_MAJOR "0") #
  5. set(LEMMA_VERSION_MINOR "2") #
  6. set(LEMMA_VERSION_PATCH "1") #
  7. set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"") #
  8. set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}") #
  9. ####################################################################################################
  10. ########################################
  11. # ################################## #
  12. # # Pre-Build checks/ dependencies # #
  13. # ################################## #
  14. ########################################
  15. ## Options--what do you want to do
  16. option ( BUILD_SHARED_LIBS "Shared or static libraries" OFF )
  17. option ( LEMMA_ENABLE_TESTING "Turn on unit testing" OFF )
  18. option ( LEMMA_BUILD_EXAMPLES "Compile example Lemma applications" OFF )
  19. option ( LEMMA_USE_OPENMP "Use OpenMP in Lemma" OFF )
  20. option ( LEMMA_BUILD_DOCUMENTATION "Build Doxygen man pages" OFF )
  21. ## Hard Dependencies
  22. find_package (Eigen3 3.3 NO_MODULE QUIET) # Matrix/Vector & Math
  23. find_package (yaml-cpp 0.6 QUIET) # Serialisation of classes
  24. INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIR})
  25. if (LEMMA_BUILD_DOCUMENTATION)
  26. find_package(Doxygen REQUIRED)
  27. endif()
  28. ## Optional Dependencies
  29. if (LEMMA_ENABLE_TESTING)
  30. message (STATUS "LEMMA_ENABLE_TESTING is set" )
  31. #find_package (CxxTest QUIET) # Unit testing
  32. if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/cxxtest")
  33. set (CXXTEST_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/" CACHE PATH "" FORCE)
  34. else()
  35. set (CXXTEST_INCLUDE_DIR "CXXTEST_INCLUDE_DIR-NOTFOUND" CACHE PATH "" FORCE)
  36. endif()
  37. if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen")
  38. set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen" CACHE PATH "" FORCE)
  39. else()
  40. set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "CXXTEST_PYTHON_TESTGEN_EXECUTABLE-NOTFOUND" CACHE PATH "" FORCE)
  41. endif ()
  42. find_package (CxxTest) # Unit testing
  43. message (STATUS "CXXTEST_FOUND ${CxxTest_FOUND}" )
  44. endif()
  45. #######################################################################
  46. # CXXTEST Framework
  47. if(CXXTEST_FOUND)
  48. if (LEMMA_ENABLE_TESTING)
  49. #include_directories(${CXXTEST_INCLUDE_DIR}) # Add this in testing CMakeLists.txt instead, cleaner
  50. enable_testing()
  51. endif()
  52. endif()
  53. ## Optional Dependencies
  54. if ( NOT Eigen3_FOUND OR
  55. NOT yaml-cpp_FOUND OR
  56. (LEMMA_ENABLE_TESTING AND NOT CxxTest_FOUND) )
  57. message ( STATUS "Missing hard dependencies have been found, these will be downloaded any compiled." )
  58. message ( STATUS "This necessitates a two step build." )
  59. message ( STATUS "Build these packages first...THEN RERUN CMAKE!" )
  60. project (SUPERBUILD NONE)
  61. # execute the superbuild (this script will be invoked again without the
  62. # USE_SUPERBUILD option this time)
  63. include (CMake/SuperBuild.cmake)
  64. #add_dependencies(SUPERBUILD CxxTest)
  65. return() # stop processing this file further
  66. else()
  67. #project (Blah) # <-- YOUR PROJECT NAME HERE
  68. message( STATUS "CXX test Dir${CXXTEST_DIR}" )
  69. message( STATUS "Everything was found, happy Lemma-ing" )
  70. endif()
  71. # Mac OSX RPATH is weird
  72. # enable @rpath in the install name for any shared library being built
  73. # note: it is planned that a future version of CMake will enable this by default
  74. if(POLICY CMP0015)
  75. cmake_policy(SET CMP0015 NEW)
  76. endif()
  77. set(CMAKE_MACOSX_RPATH 1)
  78. project (Lemma CXX)
  79. ##############################
  80. # required external programs # for downloading packages
  81. ##############################
  82. FIND_PROGRAM(HAVEGIT git
  83. PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
  84. )
  85. if(NOT HAVEGIT)
  86. message(FATAL_ERROR "Lemma requires that git is installed and in the path of your machine")
  87. endif(NOT HAVEGIT)
  88. if(BUILD_SHARED_LIBS)
  89. set(LABEL_SUFFIX "shared")
  90. else()
  91. set(LABEL_SUFFIX "static")
  92. endif()
  93. if(NOT CMAKE_BUILD_TYPE)
  94. set(CMAKE_BUILD_TYPE "Release" CACHE STRING
  95. "Choose the type of build, options are: Debug Release
  96. RelWithDebInfo MinSizeRel."
  97. FORCE)
  98. endif(NOT CMAKE_BUILD_TYPE)
  99. ###################
  100. # External Projects
  101. ###################
  102. # We don't build VTK, it is too heavy.
  103. option (LEMMA_VTK6_SUPPORT "VTK library for visualisation and grids" OFF)
  104. if ( LEMMA_VTK6_SUPPORT )
  105. #find_package(VTK 6 REQUIRED NO_MODULE)
  106. find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  107. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  108. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL NO_MODULE)
  109. set(volumeRenderer volumerenderer.cxx)
  110. include(${VTK_USE_FILE})
  111. add_compile_options(-DLEMMAUSEVTK)
  112. # Compile Matplot_vtk if VTK is present
  113. #add_subdirectory(Matplot_vtk)
  114. #include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  115. endif()
  116. option (LEMMA_VTK7_SUPPORT "VTK library for visualisation and grids" OFF)
  117. if ( LEMMA_VTK7_SUPPORT )
  118. #find_package(VTK 7 REQUIRED NO_MODULE)
  119. find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  120. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  121. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
  122. set(volumeRenderer volumerenderer.cxx)
  123. if (VTK_FOUND)
  124. message(STATUS "VTK 7 was found! ")
  125. include(${VTK_USE_FILE})
  126. #add_compile_options(-DLEMMAUSEVTK)
  127. #target_compile_definitions( lemmacore PRIVATE LEMMAUSEVTK=1 )
  128. add_definitions(-DLEMMAUSEVTK)
  129. else()
  130. ExternalProject_Add(VTK
  131. GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
  132. GIT_TAG "v7.1.1"
  133. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk7
  134. CMAKE_ARGS
  135. -DBUILD_SHARED_LIBS:BOOL=ON
  136. -DBUILD_EXAMPLES:BOOL=OFF
  137. -DBUILD_TESTING:BOOL=OFF
  138. -DVTK_Group_Web:BOOL=OFF
  139. -DModule_vtkImagingMath:BOOL=ON
  140. LOG_DOWNLOAD 0
  141. LOG_UPDATE 0
  142. )
  143. endif()
  144. endif()
  145. option (LEMMA_VTK8_SUPPORT "VTK library for visualisation and grids" OFF)
  146. if ( LEMMA_VTK8_SUPPORT )
  147. find_package(VTK 8.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  148. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  149. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
  150. if (VTK_FOUND)
  151. message(STATUS "VTK 8 was found! ")
  152. set(volumeRenderer volumerenderer.cxx)
  153. include(${VTK_USE_FILE})
  154. else()
  155. message( STATUS "External build of VTK 8 has been added, this may take some time to build." )
  156. ExternalProject_Add(VTK8
  157. GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
  158. GIT_TAG "v8.1.0"
  159. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk8
  160. CMAKE_ARGS
  161. -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  162. -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  163. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} /
  164. -DBUILD_SHARED_LIBS:BOOL=ON /
  165. -DBUILD_EXAMPLES:BOOL=OFF /
  166. -DBUILD_TESTING:BOOL=OFF /
  167. -DVTK_Group_Web:BOOL=OFF /
  168. -DModule_vtkImagingMath:BOOL=ON /
  169. LOG_DOWNLOAD 0 /
  170. LOG_UPDATE 0
  171. )
  172. endif()
  173. add_definitions(-DLEMMAUSEVTK)
  174. endif()
  175. #######################
  176. # Lemma Configuration #
  177. #######################
  178. #############################
  179. # Look for Ki Ha Lee (EM1D) #
  180. #############################
  181. FIND_LIBRARY( KIHA_EM1D kihaem1d )
  182. if ( KIHA_EM1D )
  183. add_definitions(-DKIHALEE_EM1D)
  184. endif()
  185. ####################
  186. # Look for Boost
  187. ####################
  188. option (LEMMA_USE_BOOST "Boost is required by gaussian quadrature classes" OFF)
  189. if (LEMMA_USE_BOOST)
  190. find_package(Boost
  191. 1.58.0 # Minimum or EXACT version e.g. 1.36.0
  192. # COMPONENTS math # Boost libraries by their canonical name
  193. )
  194. if(Boost_FOUND)
  195. include_directories(${Boost_INCLUDE_DIRS})
  196. endif()
  197. find_path( HAVE_BOOST_SPECIAL_FUNCTIONS "boost/math/special_functions.hpp" )
  198. if(HAVE_BOOST_SPECIAL_FUNCTIONS)
  199. add_compile_options(-DHAVE_BOOST_SPECIAL_FUNCTIONS)
  200. endif()
  201. endif()
  202. ####################
  203. # Magic rpath flag
  204. ####################
  205. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  206. if (LEMMA_USE_OPENMP)
  207. find_package(OpenMP)
  208. if (OPENMP_FOUND)
  209. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  210. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  211. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
  212. else()
  213. message (FATAL ERROR "OpenMP cannot be found, but was specified!")
  214. endif()
  215. endif()
  216. configure_file (
  217. "${PROJECT_SOURCE_DIR}/config/LemmaConfig.h.in"
  218. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  219. )
  220. install ( FILES ${PROJECT_BINARY_DIR}/include/LemmaConfig.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/ )
  221. include_directories("${PROJECT_BINARY_DIR}/include")
  222. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  223. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  224. ########################################################################
  225. # Build Modules
  226. add_subdirectory (Modules)
  227. ########################################################################
  228. # add a target to generate API documentation with Doxyfile.in
  229. # ALL make documentation build by default if possible
  230. find_package(Doxygen)
  231. if(DOXYGEN_FOUND)
  232. if (LEMMA_BUILD_DOCUMENTATION)
  233. # Custom header and footer option, enable in Doxygen
  234. # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/header.html
  235. # DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Documentation/header.html
  236. # )
  237. # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/footer.html
  238. # DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Documentation/footer.html
  239. # )
  240. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Documentation/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile @ONLY)
  241. add_custom_target(doc
  242. ALL
  243. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile
  244. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  245. COMMENT "Generating API documentation with Doxygen" VERBATIM
  246. )
  247. endif (LEMMA_BUILD_DOCUMENTATION)
  248. endif(DOXYGEN_FOUND)
  249. # vim: set tabstop=4 shiftwidth=4 expandtab: