Lemma is an Electromagnetics API
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

CMakeLists.txt 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. cmake_minimum_required (VERSION 2.8.12)
  2. if(POLICY CMP0015)
  3. cmake_policy(SET CMP0015 NEW)
  4. endif()
  5. project (Lemma CXX)
  6. # required external programs (for runtime of nix, not buildtime)
  7. FIND_PROGRAM(HAVEGIT git
  8. PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
  9. )
  10. if(NOT HAVEGIT)
  11. message(FATAL_ERROR "Lemma requires that git is installed and in the path of your machine")
  12. endif(NOT HAVEGIT)
  13. # FIND_PROGRAM(HAVEHG hg
  14. # PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
  15. # )
  16. # if(NOT HAVEHG)
  17. # message(STATUS "Mercurial (hg) was not found.")
  18. # endif(NOT HAVEHG)
  19. option(BUILD_SHARED_LIBS OFF)
  20. ###################
  21. # External Projects
  22. ###################
  23. include(ExternalProject)
  24. # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
  25. # Mercurial (hg) repo pull, Would it be better to just download latest stable?
  26. #ExternalProject_Add(EIGEN
  27. # HG_REPOSITORY "https://bitbucket.org/eigen/eigen/"
  28. # UPDATE_COMMAND ""
  29. # PATCH_COMMAND ""
  30. # PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  31. # CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  32. #)
  33. # Stable Eigen, requires manual updating when new releases, but lighter weight.
  34. ExternalProject_Add(EIGEN
  35. URL "http://bitbucket.org/eigen/eigen/get/3.2.7.tar.gz"
  36. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
  37. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
  38. )
  39. # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence)
  40. ExternalProject_Add(YAML-CPP
  41. GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
  42. GIT_TAG "master"
  43. UPDATE_COMMAND ""
  44. PATCH_COMMAND ""
  45. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
  46. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  47. )
  48. add_compile_options(-DHAVE_YAMLCPP)
  49. # tinyxml2, this library is used for XML IO
  50. option(TINYXML_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  51. if ( TINYXML_SUPPORT )
  52. ExternalProject_Add(TINYXML2
  53. GIT_REPOSITORY "https://github.com/leethomason/tinyxml2.git"
  54. GIT_TAG "master"
  55. UPDATE_COMMAND ""
  56. PATCH_COMMAND ""
  57. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/tinyxml2
  58. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON
  59. #-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
  60. )
  61. add_compile_options(-DTINYXMLSUPPORT)
  62. endif()
  63. option(MATIO_SUPPORT "MATIO library support for MATLAB .mat files" OFF)
  64. if ( MATIO_SUPPORT )
  65. add_compile_options(-DHAVE_MATIO)
  66. # matio, this library is used for MATLAB file IO
  67. ExternalProject_ADD(MATIO
  68. GIT_REPOSITORY "git://git.code.sf.net/p/matio/matio"
  69. GIT_TAG "master"
  70. UPDATE_COMMAND ""
  71. PATCH_COMMAND ""
  72. PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/matio
  73. #CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/external/matio/src/MATIO/autogen.sh && configure
  74. CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX}
  75. BUILD_IN_SOURCE 1
  76. BUILD_COMMAND ${MAKE}
  77. )
  78. endif()
  79. # We don't build VTK, it is too heavy.
  80. option (VTK_SUPPORT "VTK library for visualisation and grids" OFF)
  81. if (VTK_SUPPORT)
  82. find_package(VTK 6 REQUIRED NO_MODULE)
  83. include(${VTK_USE_FILE})
  84. add_compile_options(-DLEMMAUSEVTK)
  85. # Compile Matplot_vtk if VTK is present
  86. add_subdirectory(Matplot_vtk)
  87. include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
  88. endif()
  89. #####################
  90. # Lemma Configuration
  91. #####################
  92. ####################
  93. # Add the c++11 flag
  94. # TODO add compiler specific instructions
  95. include(CheckCXXCompilerFlag)
  96. CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11)
  97. CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X)
  98. if(COMPILER_SUPPORTS_CXX11)
  99. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  100. elseif(COMPILER_SUPPORTS_CXX0X)
  101. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  102. else()
  103. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  104. endif()
  105. set(LEMMA_VERSION_MAJOR "0")
  106. set(LEMMA_VERSION_MINOR "0")
  107. set(LEMMA_VERSION_PATCH "1")
  108. set(LEMMA_VERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
  109. configure_file (
  110. "${PROJECT_SOURCE_DIR}/include/LemmaConfig.h.in"
  111. "${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
  112. )
  113. include_directories("${PROJECT_BINARY_DIR}/include")
  114. include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
  115. include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
  116. include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
  117. link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
  118. add_subdirectory (LemmaCore)
  119. ########################################################################
  120. # Build Modules
  121. add_subdirectory (Modules)
  122. ########################################################################
  123. #
  124. include_directories(${CMAKE_INSTALL_PREFIX}/include)
  125. add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
  126. target_link_libraries(Hello lemmacore)
  127. add_dependencies(Hello YAML-CPP)