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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. cmake_minimum_required (VERSION 2.8.12)
  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. # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
  34. # Mercurial (hg) repo pull, Would it be better to just download latest stable?
  35. #find_package(Eigen3 REQUIRED)
  36. #if (EIGEN3_FOUND)
  37. # # do nothing
  38. # include_directories(EIGEN3_INCLUDE_DIR)
  39. #else()
  40. FIND_PROGRAM( HAVEHG hg
  41. PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
  42. )
  43. if (HAVEHG)
  44. ExternalProject_Add(EIGEN
  45. HG_REPOSITORY "https://bitbucket.org/eigen/eigen/"
  46. UPDATE_COMMAND ""
  47. HG_TAG "3.3.2" #"default"
  48. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  49. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  50. )
  51. ELSE()
  52. # Use Stable Eigen instead
  53. ExternalProject_Add(EIGEN
  54. #URL "http://bitbucket.org/eigen/eigen/get/default.tar.gz" # tip from repo
  55. URL "http://bitbucket.org/eigen/eigen/get/3.3.2.tar.gz"
  56. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  57. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  58. )
  59. ENDIF()
  60. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  61. # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence)
  62. ExternalProject_Add(YAML-CPP
  63. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  64. GIT_TAG "master" #"release-0.5.3" #"master"
  65. UPDATE_COMMAND ""
  66. PATCH_COMMAND ""
  67. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  68. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  69. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  70. )
  71. add_compile_options(-DHAVE_YAMLCPP)
  72. # CxxTest
  73. find_package(CxxTest)
  74. if (CXXTEST_FOUND)
  75. # Do nothing
  76. else()
  77. ExternalProject_Add(CxxTest
  78. GIT_REPOSITORY "https://github.com/CxxTest/cxxtest.git"
  79. GIT_TAG "master"
  80. UPDATE_COMMAND ""
  81. PATCH_COMMAND ""
  82. CONFIGURE_COMMAND ""
  83. BUILD_COMMAND ""
  84. INSTALL_COMMAND ""
  85. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest
  86. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  87. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  88. )
  89. set (CXXTEST_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/")
  90. set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen" )
  91. find_package(CxxTest REQUIRED)
  92. endif()
  93. # tinyxml2, this library is used for XML IO
  94. option( LEMMA_TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  95. if ( LEMMA_TINYXML_SUPPORT )
  96. ExternalProject_Add(TINYXML2
  97. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  98. GIT_TAG "master"
  99. UPDATE_COMMAND ""
  100. PATCH_COMMAND ""
  101. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  102. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  103. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  104. )
  105. add_compile_options(-DTINYXMLSUPPORT)
  106. endif()
  107. option( LEMMA_MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  108. if ( LEMMA_MATIO_SUPPORT )
  109. add_compile_options(-DHAVE_MATIO)
  110. # matio, this library is used for MATLAB file IO
  111. ExternalProject_ADD(MATIO
  112. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  113. GIT_TAG "master"
  114. UPDATE_COMMAND ""
  115. PATCH_COMMAND ""
  116. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  117. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  118. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  119. BUILD_IN_SOURCE 1
  120. BUILD_COMMAND ${MAKE}
  121. )
  122. endif()
  123. # We don't build VTK, it is too heavy.
  124. option (LEMMA_VTK6_SUPPORT "VTK library for visualisation and grids" OFF)
  125. if ( LEMMA_VTK6_SUPPORT )
  126. #find_package(VTK 6 REQUIRED NO_MODULE)
  127. find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  128. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  129. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL NO_MODULE)
  130. set(volumeRenderer volumerenderer.cxx)
  131. include(${VTK_USE_FILE})
  132. add_compile_options(-DLEMMAUSEVTK)
  133. # Compile Matplot_vtk if VTK is present
  134. #add_subdirectory(Matplot_vtk)
  135. #include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  136. endif()
  137. option (LEMMA_VTK7_SUPPORT "VTK library for visualisation and grids" OFF)
  138. if ( LEMMA_VTK7_SUPPORT )
  139. #find_package(VTK 7 REQUIRED NO_MODULE)
  140. find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  141. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  142. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
  143. set(volumeRenderer volumerenderer.cxx)
  144. include(${VTK_USE_FILE})
  145. add_compile_options(-DLEMMAUSEVTK)
  146. # Compile Matplot_vtk if VTK is present
  147. #add_subdirectory(Matplot_vtk)
  148. #include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  149. endif()
  150. #####################
  151. # Lemma Configuration
  152. #####################
  153. #####################
  154. # Look for Ki Ha Lee
  155. #####################
  156. FIND_LIBRARY( KIHA_EM1D kihaem1d ) # PATHS ${/home/tirons/local/lib} )
  157. if ( KIHA_EM1D )
  158. add_compile_options(-DKIHALEE_EM1D)
  159. endif()
  160. ####################
  161. # Look for Boost
  162. ####################
  163. option (LEMMA_USE_BOOST "Boost is required by gaussian quadrature classes" OFF)
  164. if (LEMMA_USE_BOOST)
  165. find_package(Boost
  166. 1.58.0 # Minimum or EXACT version e.g. 1.36.0
  167. # COMPONENTS math # Boost libraries by their canonical name
  168. )
  169. if(Boost_FOUND)
  170. include_directories(${Boost_INCLUDE_DIRS})
  171. endif()
  172. find_path( HAVE_BOOST_SPECIAL_FUNCTIONS "boost/math/special_functions.hpp" )
  173. if(HAVE_BOOST_SPECIAL_FUNCTIONS)
  174. add_compile_options(-DHAVE_BOOST_SPECIAL_FUNCTIONS)
  175. endif()
  176. endif()
  177. ####################
  178. # Magic rpath flag
  179. ####################
  180. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  181. ####################
  182. # Add the c++11 flag
  183. # TODO add compiler specific instructions
  184. include(CheckCXXCompilerFlag)
  185. CHECK_CXX_COMPILER_FLAG(-std=c++14 COMPILER_SUPPORTS_CXX14)
  186. CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  187. CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  188. if(COMPILER_SUPPORTS_CXX14)
  189. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  190. elseif(COMPILER_SUPPORTS_CXX11)
  191. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  192. elseif(COMPILER_SUPPORTS_CXX0X)
  193. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  194. else()
  195. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or C++14 support. Please use a different C++ compiler.")
  196. endif()
  197. option( LEMMA_BUILD_EXAMPLES "Compile example Lemma applications" OFF )
  198. option( LEMMA_USE_OPENMP "Use OpenMP in Lemma" OFF)
  199. CHECK_CXX_COMPILER_FLAG(-fopenmp COMPILER_SUPPORTS_OPENMP)
  200. if(COMPILER_SUPPORTS_OPENMP AND LEMMA_USE_OPENMP )
  201. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -DLEMMAUSEOMP")
  202. endif()
  203. set(LEMMA_VERSION_MAJOR "0")
  204. set(LEMMA_VERSION_MINOR "1")
  205. set(LEMMA_VERSION_PATCH "1")
  206. set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")
  207. set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  208. configure_file (
  209. "${PROJECT_SOURCE_DIR}/config/LemmaConfig.h.in"
  210. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  211. )
  212. install ( FILES ${PROJECT_BINARY_DIR}/include/LemmaConfig.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/ )
  213. include_directories("${PROJECT_BINARY_DIR}/include")
  214. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  215. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  216. #######################################################################
  217. # CXXTEST Framework
  218. if(CXXTEST_FOUND)
  219. option (LEMMA_ENABLE_TESTING "Turn on unit testing" ON)
  220. if (LEMMA_ENABLE_TESTING)
  221. #include_directories(${CXXTEST_INCLUDE_DIR}) # Add this in testing CMakeLists.txt instead, cleaner
  222. enable_testing()
  223. endif()
  224. endif()
  225. ########################################################################
  226. # Build Modules
  227. add_subdirectory (Modules)
  228. ########################################################################
  229. # add a target to generate API documentation with Doxygen
  230. # ALL make documentation build by default if possible
  231. find_package(Doxygen)
  232. if(DOXYGEN_FOUND)
  233. option( LEMMA_BUILD_DOCUMENTATION "Build Doxygen man pages" OFF )
  234. if (LEMMA_BUILD_DOCUMENTATION)
  235. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Documentation/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile @ONLY)
  236. add_custom_target(doc
  237. ALL
  238. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile
  239. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  240. COMMENT "Generating API documentation with Doxygen" VERBATIM
  241. )
  242. endif (LEMMA_BUILD_DOCUMENTATION)
  243. endif(DOXYGEN_FOUND)