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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. # FIND_PROGRAM(HAVEHG hg
  18. # PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
  19. # )
  20. # if(NOT HAVEHG)
  21. # message(STATUS "Mercurial (hg) was not found.")
  22. # endif(NOT HAVEHG)
  23. option(BUILD_SHARED_LIBS OFF)
  24. if(BUILD_SHARED_LIBS)
  25. set(LABEL_SUFFIX "shared")
  26. else()
  27. set(LABEL_SUFFIX "static")
  28. endif()
  29. if (NOT CMAKE_BUILD_TYPE)
  30. set(CMAKE_BUILD_TYPE "Release")
  31. endif()
  32. ###################
  33. # External Projects
  34. ###################
  35. include(ExternalProject)
  36. # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
  37. # Mercurial (hg) repo pull, Would it be better to just download latest stable?
  38. #ExternalProject_Add(EIGEN
  39. # HG_REPOSITORY "https://bitbucket.org/eigen/eigen/"
  40. # UPDATE_COMMAND ""
  41. # PATCH_COMMAND ""
  42. # PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  43. # CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  44. #)
  45. # Stable Eigen, requires manual updating when new releases, but lighter weight.
  46. ExternalProject_Add(EIGEN
  47. URL "http://bitbucket.org/eigen/eigen/get/3.2.7.tar.gz"
  48. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  49. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  50. )
  51. # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence)
  52. ExternalProject_Add(YAML-CPP
  53. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  54. GIT_TAG "master"
  55. UPDATE_COMMAND ""
  56. PATCH_COMMAND ""
  57. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  58. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  59. )
  60. add_compile_options(-DHAVE_YAMLCPP)
  61. # tinyxml2, this library is used for XML IO
  62. option( LEMMA_TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  63. if ( LEMMA_TINYXML_SUPPORT )
  64. ExternalProject_Add(TINYXML2
  65. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  66. GIT_TAG "master"
  67. UPDATE_COMMAND ""
  68. PATCH_COMMAND ""
  69. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  70. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON
  71. #-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  72. )
  73. add_compile_options(-DTINYXMLSUPPORT)
  74. endif()
  75. option( LEMMA_MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  76. if ( LEMMA_MATIO_SUPPORT )
  77. add_compile_options(-DHAVE_MATIO)
  78. # matio, this library is used for MATLAB file IO
  79. ExternalProject_ADD(MATIO
  80. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  81. GIT_TAG "master"
  82. UPDATE_COMMAND ""
  83. PATCH_COMMAND ""
  84. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  85. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  86. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  87. BUILD_IN_SOURCE 1
  88. BUILD_COMMAND ${MAKE}
  89. )
  90. endif()
  91. # We don't build VTK, it is too heavy.
  92. option (LEMMA_VTK_SUPPORT "VTK library for visualisation and grids" OFF)
  93. if ( LEMMA_VTK_SUPPORT )
  94. #find_package(VTK 6 REQUIRED NO_MODULE)
  95. find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  96. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  97. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL NO_MODULE)
  98. set(volumeRenderer volumerenderer.cxx)
  99. include(${VTK_USE_FILE})
  100. add_compile_options(-DLEMMAUSEVTK)
  101. # Compile Matplot_vtk if VTK is present
  102. add_subdirectory(Matplot_vtk)
  103. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  104. endif()
  105. #####################
  106. # Lemma Configuration
  107. #####################
  108. ####################
  109. # Add the c++11 flag
  110. # TODO add compiler specific instructions
  111. include(CheckCXXCompilerFlag)
  112. CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  113. CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  114. if(COMPILER_SUPPORTS_CXX11)
  115. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  116. elseif(COMPILER_SUPPORTS_CXX0X)
  117. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  118. else()
  119. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  120. endif()
  121. set(LEMMA_VERSION_MAJOR "0")
  122. set(LEMMA_VERSION_MINOR "0")
  123. set(LEMMA_VERSION_PATCH "1")
  124. set(LEMMA_VERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  125. configure_file (
  126. "${PROJECT_SOURCE_DIR}/include/LemmaConfig.h.in"
  127. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  128. )
  129. include_directories("${PROJECT_BINARY_DIR}/include")
  130. include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
  131. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  132. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  133. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  134. add_subdirectory (LemmaCore)
  135. ########################################################################
  136. # Build Modules
  137. add_subdirectory (Modules)
  138. ########################################################################
  139. #
  140. include_directories(${CMAKE_INSTALL_PREFIX}/include)
  141. add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
  142. target_link_libraries(Hello lemmacore)
  143. add_dependencies(Hello YAML-CPP)