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.6KB

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