Lemma is an Electromagnetics API
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CMakeLists.txt 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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( LEMMA_TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  60. if ( LEMMA_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( LEMMA_MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  73. if ( LEMMA_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 (LEMMA_VTK_SUPPORT "VTK library for visualisation and grids" OFF)
  90. if ( LEMMA_VTK_SUPPORT )
  91. #find_package(VTK 6 REQUIRED NO_MODULE)
  92. find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources
  93. vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle
  94. vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL NO_MODULE)
  95. set(volumeRenderer volumerenderer.cxx)
  96. include(${VTK_USE_FILE})
  97. add_compile_options(-DLEMMAUSEVTK)
  98. # Compile Matplot_vtk if VTK is present
  99. add_subdirectory(Matplot_vtk)
  100. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  101. endif()
  102. #####################
  103. # Lemma Configuration
  104. #####################
  105. ####################
  106. # Add the c++11 flag
  107. # TODO add compiler specific instructions
  108. include(CheckCXXCompilerFlag)
  109. CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  110. CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  111. if(COMPILER_SUPPORTS_CXX11)
  112. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  113. elseif(COMPILER_SUPPORTS_CXX0X)
  114. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  115. else()
  116. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  117. endif()
  118. set(LEMMA_VERSION_MAJOR "0")
  119. set(LEMMA_VERSION_MINOR "0")
  120. set(LEMMA_VERSION_PATCH "1")
  121. set(LEMMA_VERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  122. configure_file (
  123. "${PROJECT_SOURCE_DIR}/include/LemmaConfig.h.in"
  124. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  125. )
  126. include_directories("${PROJECT_BINARY_DIR}/include")
  127. include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
  128. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  129. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  130. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  131. add_subdirectory (LemmaCore)
  132. ########################################################################
  133. # Build Modules
  134. add_subdirectory (Modules)
  135. ########################################################################
  136. #
  137. include_directories(${CMAKE_INSTALL_PREFIX}/include)
  138. add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
  139. target_link_libraries(Hello lemmacore)
  140. add_dependencies(Hello YAML-CPP)