CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. cmake_minimum_required(VERSION 3.15)
  2. project(scattnlay VERSION 2.3)
  3. cmake_host_system_information(RESULT HOSTNAME QUERY HOSTNAME)
  4. message("Build type is: ${CMAKE_BUILD_TYPE}")
  5. message("Host OS System: ${CMAKE_HOST_SYSTEM}")
  6. message("Hostname: ${HOSTNAME}")
  7. message("CMake version: ${CMAKE_VERSION}")
  8. # Select flags.
  9. set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g ")
  10. set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
  11. set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
  12. set(CMAKE_CXX_STANDARD 17)
  13. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  14. set(CMAKE_CXX_EXTENSIONS OFF)
  15. add_compile_options(-W -Wall -pedantic -Werror)
  16. add_compile_options(-funroll-loops -fstrict-aliasing)
  17. # compiler details
  18. message(" C++ Compiler: ${CMAKE_CXX_COMPILER_ID} "
  19. "${CMAKE_CXX_COMPILER_VERSION} "
  20. "${CMAKE_CXX_COMPILER_WRAPPER}")
  21. # installation details
  22. message(" Installation prefix: ${CMAKE_INSTALL_PREFIX}")
  23. # Find Boost
  24. set(BOOSTROOT $ENV{BOOST_DIR})
  25. if (USE_STATIC_LIBRARIES)
  26. set(Boost_USE_STATIC_LIBS ON)
  27. endif ()
  28. set(Boost_USE_MULTITHREADED OFF)
  29. set(Boost_USE_STATIC_RUNTIME OFF)
  30. find_package(Boost)
  31. # Set options
  32. option(ENABLE_MP "Use multiple precision" OFF)
  33. if (Boost_FOUND)
  34. if (${ENABLE_MP})
  35. add_compile_options(-DMULTI_PRECISION=100)
  36. endif ()
  37. if (Boost_INCLUDE_DIRS)
  38. if (${Boost_VERSION} VERSION_LESS 1.60.0)
  39. message(FATAL_ERROR
  40. "Found Boost library is too old; required is version 1.60.0 or newer!")
  41. endif ()
  42. message("Found Boost include dir: ${Boost_INCLUDE_DIR}")
  43. message("Found Boost library dir: ${Boost_LIBRARY_DIR}")
  44. message("Found Boost libraries: ${Boost_LIBRARIES}")
  45. include_directories(${Boost_INCLUDE_DIRS})
  46. endif ()
  47. endif()
  48. ##Find Python, NumPy and PyBind11
  49. #find_package(Python COMPONENTS Interpreter Development)
  50. #
  51. #include_directories(${Python_INCLUDE_DIRS})
  52. #
  53. #message("Python_EXECUTABLE: ${Python_EXECUTABLE}")
  54. #message("Python_FOUND: ${Python_FOUND}")
  55. #message("Python_VERSION: ${Python_VERSION}")
  56. #message("Python_Development_FOUND: ${Python_Development_FOUND}")
  57. #message("Python_LIBRARIES: ${Python_LIBRARIES}")
  58. #message("Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}")
  59. #
  60. ## Ensure that numpy is installed and read its include dir
  61. #exec_program(${Python_EXECUTABLE}
  62. # ARGS "-c \"import numpy; print(numpy.get_include())\""
  63. # OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
  64. # RETURN_VALUE NUMPY_NOT_FOUND
  65. # )
  66. #if (NUMPY_NOT_FOUND)
  67. # message(FATAL_ERROR "NumPy headers not found")
  68. #endif ()
  69. #
  70. ## Ensure that pybind11 is installed and read its include dir
  71. #exec_program(${Python_EXECUTABLE}
  72. # ARGS "-c \"import pybind11; print(pybind11.get_include())\""
  73. # OUTPUT_VARIABLE PYBIND11_INCLUDE_DIR
  74. # RETURN_VALUE PYBIND11_NOT_FOUND
  75. # )
  76. #if (PYBIND11_NOT_FOUND)
  77. # message(FATAL_ERROR "PyBind11 headers not found")
  78. #endif ()
  79. #
  80. ## Determine correct extension suffix
  81. #exec_program(${Python_EXECUTABLE}
  82. # ARGS "-c \"import distutils.sysconfig; print(distutils.sysconfig.get_config_var('EXT_SUFFIX'))\""
  83. # OUTPUT_VARIABLE EXT_SUFFIX
  84. # RETURN_VALUE SUFFIX_NOT_FOUND
  85. # )
  86. #if (SUFFIX_NOT_FOUND)
  87. # message(FATAL_ERROR "Extension suffix not found")
  88. #endif ()
  89. #include_directories(src)
  90. add_subdirectory(src)
  91. add_subdirectory(examples)
  92. #
  93. # Copy all python scripts to the build directory.
  94. #
  95. set(Python_SCRIPTS scattnlay/__init__.py scattnlay/main.py)
  96. foreach (_script ${Python_SCRIPTS})
  97. configure_file(
  98. ${PROJECT_SOURCE_DIR}/${_script}
  99. ${PROJECT_BINARY_DIR}/${_script}
  100. COPYONLY
  101. )
  102. endforeach ()
  103. enable_testing()
  104. add_subdirectory(tests)
  105. # add_test(NAME BuildExtWithPythonSetupPy
  106. # COMMAND ${Python_EXECUTABLE} setup.py build_ext
  107. # WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  108. add_test(NAME tox
  109. COMMAND tox)