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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. ###################
  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. #ExternalProject_Add(EIGEN
  36. # HG_REPOSITORY "https://bitbucket.org/eigen/eigen/"
  37. # UPDATE_COMMAND ""
  38. # PATCH_COMMAND ""
  39. # PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  40. # CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  41. #)
  42. # Stable Eigen, requires manual updating when new releases, but lighter weight.
  43. ExternalProject_Add(EIGEN
  44. URL "http://bitbucket.org/eigen/eigen/get/3.2.7.tar.gz"
  45. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  46. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  47. )
  48. # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence)
  49. ExternalProject_Add(YAML-CPP
  50. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  51. GIT_TAG "master"
  52. UPDATE_COMMAND ""
  53. PATCH_COMMAND ""
  54. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  55. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  56. )
  57. add_compile_options(-DHAVE_YAMLCPP)
  58. # tinyxml2, this library is used for XML IO
  59. option(TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  60. if ( TINYXML_SUPPORT )
  61. ExternalProject_Add(TINYXML2
  62. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  63. GIT_TAG "master"
  64. UPDATE_COMMAND ""
  65. PATCH_COMMAND ""
  66. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  67. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON
  68. #-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  69. )
  70. add_compile_options(-DTINYXMLSUPPORT)
  71. endif()
  72. option(MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  73. if ( MATIO_SUPPORT )
  74. add_compile_options(-DHAVE_MATIO)
  75. # matio, this library is used for MATLAB file IO
  76. ExternalProject_ADD(MATIO
  77. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  78. GIT_TAG "master"
  79. UPDATE_COMMAND ""
  80. PATCH_COMMAND ""
  81. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  82. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  83. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  84. BUILD_IN_SOURCE 1
  85. BUILD_COMMAND ${MAKE}
  86. )
  87. endif()
  88. # We don't build VTK, it is too heavy.
  89. option (VTK_SUPPORT "VTK library for visualisation and grids" OFF)
  90. if (VTK_SUPPORT)
  91. find_package(VTK 6 REQUIRED NO_MODULE)
  92. include(${VTK_USE_FILE})
  93. add_compile_options(-DLEMMAUSEVTK)
  94. # Compile Matplot_vtk if VTK is present
  95. add_subdirectory(Matplot_vtk)
  96. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  97. endif()
  98. #####################
  99. # Lemma Configuration
  100. #####################
  101. ####################
  102. # Add the c++11 flag
  103. # TODO add compiler specific instructions
  104. include(CheckCXXCompilerFlag)
  105. CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  106. CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  107. if(COMPILER_SUPPORTS_CXX11)
  108. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  109. elseif(COMPILER_SUPPORTS_CXX0X)
  110. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  111. else()
  112. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  113. endif()
  114. set(LEMMA_VERSION_MAJOR "0")
  115. set(LEMMA_VERSION_MINOR "0")
  116. set(LEMMA_VERSION_PATCH "1")
  117. set(LEMMA_VERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  118. configure_file (
  119. "${PROJECT_SOURCE_DIR}/include/LemmaConfig.h.in"
  120. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  121. )
  122. include_directories("${PROJECT_BINARY_DIR}/include")
  123. include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
  124. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  125. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  126. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  127. add_subdirectory (LemmaCore)
  128. ########################################################################
  129. # Build Modules
  130. add_subdirectory (Modules)
  131. ########################################################################
  132. #
  133. include_directories(${CMAKE_INSTALL_PREFIX}/include)
  134. add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
  135. target_link_libraries(Hello lemmacore)
  136. add_dependencies(Hello YAML-CPP)