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

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