Lemma is an Electromagnetics API
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 9.7KB

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