CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. # Select flags.
  8. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  9. set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g ")
  10. set(CMAKE_CXX_FLAGS_RELEASE "-O3")
  11. set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
  12. set(CMAKE_CXX_STANDARD 14)
  13. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  14. set(CMAKE_CXX_EXTENSIONS OFF)
  15. add_compile_options(-Wall)
  16. add_compile_options(-funroll-loops -fstrict-aliasing)
  17. # Set options
  18. option(ENABLE_MP "Use multiple precision" ON)
  19. if (${ENABLE_MP})
  20. add_compile_options(-DMULTI_PRECISION=100)
  21. endif ()
  22. # compiler details
  23. message(" C++ Compiler: ${CMAKE_CXX_COMPILER_ID} "
  24. "${CMAKE_CXX_COMPILER_VERSION} "
  25. "${CMAKE_CXX_COMPILER_WRAPPER}")
  26. # installation details
  27. message(" Installation prefix: ${CMAKE_INSTALL_PREFIX}")
  28. # Find Boost
  29. set(BOOSTROOT $ENV{BOOST_DIR})
  30. if (USE_STATIC_LIBRARIES)
  31. set(Boost_USE_STATIC_LIBS ON)
  32. endif ()
  33. set(Boost_USE_MULTITHREADED OFF)
  34. set(Boost_USE_STATIC_RUNTIME OFF)
  35. find_package(Boost
  36. REQUIRED COMPONENTS chrono filesystem iostreams regex serialization system timer)
  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. #Find Python and NumPy
  48. find_package(Python COMPONENTS Interpreter Development)
  49. include_directories(${Python_INCLUDE_DIRS})
  50. message("Python_EXECUTABLE:${Python_EXECUTABLE}")
  51. message("Python_FOUND:${Python_FOUND}")
  52. message("Python_VERSION:${Python_VERSION}")
  53. message("Python_Development_FOUND:${Python_Development_FOUND}")
  54. message("Python_LIBRARIES:${Python_LIBRARIES}")
  55. # This comes to hand if we also need to use the NumPy C API
  56. exec_program(${Python_EXECUTABLE}
  57. ARGS "-c \"import numpy; print(numpy.get_include())\""
  58. OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
  59. RETURN_VALUE NUMPY_NOT_FOUND
  60. )
  61. if (NUMPY_NOT_FOUND)
  62. message(FATAL_ERROR "NumPy headers not found")
  63. endif ()
  64. #include_directories(src)
  65. add_subdirectory(src)