Main Lemma Repository
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CMakeLists.txt 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. ExternalProject_Add(YAML-CPP
  60. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  61. GIT_TAG "master" #"release-0.5.3" #"master"
  62. UPDATE_COMMAND ""
  63. PATCH_COMMAND ""
  64. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  65. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  66. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} /
  67. -DYAML_CPP_BUILD_TESTS=OFF
  68. #-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING /
  69. #-DCXX_STANDARD=11 /
  70. #-DCXX_STANDARD_REQUIRED=ON
  71. )
  72. add_compile_options(-DHAVE_YAMLCPP)
  73. # CxxTest
  74. find_package(CxxTest)
  75. if (CXXTEST_FOUND)
  76. # Do nothing
  77. else()
  78. message( STATUS "CxxTest will be built and installed along with Lemma, override if desired in GUI." )
  79. ExternalProject_Add(CxxTest
  80. GIT_REPOSITORY "https://github.com/CxxTest/cxxtest.git"
  81. GIT_TAG "master"
  82. UPDATE_COMMAND ""
  83. PATCH_COMMAND ""
  84. CONFIGURE_COMMAND ""
  85. BUILD_COMMAND ""
  86. INSTALL_COMMAND ""
  87. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest
  88. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  89. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  90. )
  91. # The values "CACHE PATH "" FORCE" makes the GUI show the values of the local CxxTest, but this can cause issues
  92. # with users wanting to specify their own path, its not recommended
  93. set (CXXTEST_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/") # CACHE PATH "" FORCE )
  94. set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen") # CACHE PATH "" FORCE )
  95. find_package(CxxTest REQUIRED)
  96. endif()
  97. # tinyxml2, this library is used for XML IO
  98. option( LEMMA_TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  99. if ( LEMMA_TINYXML_SUPPORT )
  100. ExternalProject_Add(TINYXML2
  101. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  102. GIT_TAG "master"
  103. UPDATE_COMMAND ""
  104. PATCH_COMMAND ""
  105. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  106. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
  107. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  108. )
  109. add_compile_options(-DTINYXMLSUPPORT)
  110. endif()
  111. option( LEMMA_MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  112. if ( LEMMA_MATIO_SUPPORT )
  113. add_compile_options(-DHAVE_MATIO)
  114. # matio, this library is used for MATLAB file IO
  115. ExternalProject_ADD(MATIO
  116. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  117. GIT_TAG "master"
  118. UPDATE_COMMAND ""
  119. PATCH_COMMAND ""
  120. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  121. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  122. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  123. BUILD_IN_SOURCE 1
  124. BUILD_COMMAND ${MAKE}
  125. )
  126. endif()
  127. # We don't build VTK, it is too heavy.
  128. option (LEMMA_VTK6_SUPPORT "VTK library for visualisation and grids" OFF)
  129. if ( LEMMA_VTK6_SUPPORT )
  130. #find_package(VTK 6 REQUIRED NO_MODULE)
  131. find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  132. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  133. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL NO_MODULE)
  134. set(volumeRenderer volumerenderer.cxx)
  135. include(${VTK_USE_FILE})
  136. add_compile_options(-DLEMMAUSEVTK)
  137. # Compile Matplot_vtk if VTK is present
  138. #add_subdirectory(Matplot_vtk)
  139. #include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  140. endif()
  141. option (LEMMA_VTK7_SUPPORT "VTK library for visualisation and grids" OFF)
  142. if ( LEMMA_VTK7_SUPPORT )
  143. #find_package(VTK 7 REQUIRED NO_MODULE)
  144. find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  145. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  146. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
  147. set(volumeRenderer volumerenderer.cxx)
  148. include(${VTK_USE_FILE})
  149. add_compile_options(-DLEMMAUSEVTK)
  150. # Compile Matplot_vtk if VTK is present
  151. #add_subdirectory(Matplot_vtk)
  152. #include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  153. endif()
  154. #######################
  155. # Lemma Configuration #
  156. #######################
  157. #############################
  158. # Look for Ki Ha Lee (EM1D) #
  159. #############################
  160. FIND_LIBRARY( KIHA_EM1D kihaem1d )
  161. if ( KIHA_EM1D )
  162. add_compile_options(-DKIHALEE_EM1D)
  163. endif()
  164. ####################
  165. # Look for Boost
  166. ####################
  167. option (LEMMA_USE_BOOST "Boost is required by gaussian quadrature classes" OFF)
  168. if (LEMMA_USE_BOOST)
  169. find_package(Boost
  170. 1.58.0 # Minimum or EXACT version e.g. 1.36.0
  171. # COMPONENTS math # Boost libraries by their canonical name
  172. )
  173. if(Boost_FOUND)
  174. include_directories(${Boost_INCLUDE_DIRS})
  175. endif()
  176. find_path( HAVE_BOOST_SPECIAL_FUNCTIONS "boost/math/special_functions.hpp" )
  177. if(HAVE_BOOST_SPECIAL_FUNCTIONS)
  178. add_compile_options(-DHAVE_BOOST_SPECIAL_FUNCTIONS)
  179. endif()
  180. endif()
  181. ####################
  182. # Magic rpath flag
  183. ####################
  184. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  185. ####################
  186. # Add the c++11 flag
  187. # This has been moved to TARGET PROPERTY as each library is built
  188. # TODO add compiler specific instructions
  189. #include(CheckCXXCompilerFlag)
  190. #CHECK_CXX_COMPILER_FLAG(-std=c++14 COMPILER_SUPPORTS_CXX14)
  191. #CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  192. #CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  193. # TODO update this for MSVC and cross compatibility
  194. #if(COMPILER_SUPPORTS_CXX14)
  195. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  196. #elseif(COMPILER_SUPPORTS_CXX11)
  197. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  198. #elseif(COMPILER_SUPPORTS_CXX0X)
  199. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  200. #else()
  201. # message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or C++14 support. Please use a different C++ compiler.")
  202. #endif()
  203. option( LEMMA_BUILD_EXAMPLES "Compile example Lemma applications" OFF )
  204. option( LEMMA_USE_OPENMP "Use OpenMP in Lemma" OFF)
  205. if (LEMMA_USE_OPENMP)
  206. find_package(OpenMP)
  207. if (OPENMP_FOUND)
  208. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  209. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  210. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
  211. else()
  212. message (FATAL ERROR "OpenMP cannot be found, but was specified!")
  213. endif()
  214. endif()
  215. set(LEMMA_VERSION_MAJOR "0")
  216. set(LEMMA_VERSION_MINOR "2")
  217. set(LEMMA_VERSION_PATCH "0")
  218. set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")
  219. set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  220. configure_file (
  221. "${PROJECT_SOURCE_DIR}/config/LemmaConfig.h.in"
  222. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  223. )
  224. install ( FILES ${PROJECT_BINARY_DIR}/include/LemmaConfig.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/ )
  225. include_directories("${PROJECT_BINARY_DIR}/include")
  226. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  227. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  228. #######################################################################
  229. # CXXTEST Framework
  230. if(CXXTEST_FOUND)
  231. option (LEMMA_ENABLE_TESTING "Turn on unit testing" ON)
  232. if (LEMMA_ENABLE_TESTING)
  233. #include_directories(${CXXTEST_INCLUDE_DIR}) # Add this in testing CMakeLists.txt instead, cleaner
  234. enable_testing()
  235. endif()
  236. endif()
  237. ########################################################################
  238. # Build Modules
  239. add_subdirectory (Modules)
  240. ########################################################################
  241. # add a target to generate API documentation with Doxyfile.in
  242. # ALL make documentation build by default if possible
  243. find_package(Doxygen)
  244. if(DOXYGEN_FOUND)
  245. option( LEMMA_BUILD_DOCUMENTATION "Build Doxygen man pages" OFF )
  246. if (LEMMA_BUILD_DOCUMENTATION)
  247. # Custom header and footer option, enable in Doxygen
  248. # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/header.html
  249. # DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Documentation/header.html
  250. # )
  251. # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/footer.html
  252. # DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Documentation/footer.html
  253. # )
  254. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Documentation/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile @ONLY)
  255. add_custom_target(doc
  256. ALL
  257. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Documentation/Doxyfile
  258. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  259. COMMENT "Generating API documentation with Doxygen" VERBATIM
  260. )
  261. endif (LEMMA_BUILD_DOCUMENTATION)
  262. endif(DOXYGEN_FOUND)