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

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