You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.2 KiB

2 months ago
  1. cmake_minimum_required(VERSION 3.1)
  2. project(sylvan LANGUAGES C CXX VERSION 1.4.0)
  3. set(PROJECT_DESCRIPTION "Sylvan, a parallel decision diagram library")
  4. set(PROJECT_URL "https://github.com/trolando/sylvan")
  5. message(STATUS "CMake build configuration for Sylvan ${PROJECT_VERSION}")
  6. set(CMAKE_C_STANDARD 11)
  7. set(CMAKE_C_STANDARD_REQUIRED ON)
  8. set(CMAKE_CXX_STANDARD 14)
  9. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  10. if(NOT CMAKE_BUILD_TYPE)
  11. set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
  12. ENDIF(NOT CMAKE_BUILD_TYPE)
  13. # Some info
  14. message(STATUS "OS: ${CMAKE_SYSTEM_NAME}")
  15. message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}")
  16. set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
  17. option(SYLVAN_PORTABLE "If set, the created library will be portable." OFF)
  18. option(USE_CARL "Sets whether carl should be included." ON)
  19. set(CMAKE_C_FLAGS "-O2 -Wextra -Wall -fno-strict-aliasing ${CMAKE_C_FLAGS}")
  20. set(CMAKE_CXX_FLAGS "-O2 -Wextra -Wall -fno-strict-aliasing -Wno-deprecated ${CMAKE_CXX_FLAGS}")
  21. if (NOT SYLVAN_PORTABLE)
  22. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
  23. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
  24. endif()
  25. option(WITH_COVERAGE "Add generation of test coverage" OFF)
  26. if(WITH_COVERAGE)
  27. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -coverage")
  28. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -coverage")
  29. find_program(GCOV_PATH gcov)
  30. find_program(LCOV_PATH lcov)
  31. find_program(GENHTML_PATH genhtml)
  32. add_custom_target(coverage
  33. # Cleanup lcov
  34. ${LCOV_PATH} --directory . --zerocounters
  35. # Run tests
  36. COMMAND make test
  37. # Capture counters
  38. COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} --directory . --capture --output-file coverage.info
  39. COMMAND ${LCOV_PATH} --remove coverage.info 'test/*' '/usr/*' 'examples/*' 'src/lace*' 'src/sha2.c' --output-file coverage.info.cleaned
  40. COMMAND ${GENHTML_PATH} -o coverage coverage.info.cleaned
  41. COMMAND ${CMAKE_COMMAND} -E remove coverage.info coverage.info.cleaned
  42. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  43. )
  44. endif()
  45. message(STATUS "Sylvan - Including Boost directories located at ${Boost_INCLUDE_DIRS}.")
  46. include_directories("${Boost_INCLUDE_DIRS}")
  47. if(USE_CARL)
  48. add_definitions(-DSYLVAN_HAVE_CARL)
  49. message(STATUS "Sylvan - Using CArL.")
  50. find_package(carl REQUIRED PATHS ${carl_DIR} NO_DEFAULT_PATH)
  51. else()
  52. message(STATUS "Sylvan - Not using CArL.")
  53. endif()
  54. include_directories(${CMAKE_SOURCE_DIR}/src)
  55. include(GNUInstallDirs)
  56. include(CTest)
  57. include_directories("${PROJECT_SOURCE_DIR}/../../../src")
  58. include_directories("${PROJECT_BINARY_DIR}/../../../include")
  59. include_directories(src)
  60. add_subdirectory(src)
  61. option(SYLVAN_BUILD_TESTS "Build example tests" ON)
  62. if(SYLVAN_BUILD_TESTS)
  63. add_subdirectory(test)
  64. endif()
  65. option(SYLVAN_BUILD_EXAMPLES "Build example tools" OFF)
  66. if(SYLVAN_BUILD_EXAMPLES)
  67. add_subdirectory(examples)
  68. endif()
  69. option(SYLVAN_BUILD_DOCS "Build documentation" OFF)
  70. if(SYLVAN_BUILD_DOCS)
  71. configure_file("docs/conf.py.in" "docs/conf.py" @ONLY)
  72. find_package(Sphinx REQUIRED)
  73. Sphinx_add_targets(sylvan ${CMAKE_CURRENT_BINARY_DIR}/docs ${CMAKE_CURRENT_SOURCE_DIR}/docs ${CMAKE_CURRENT_BINARY_DIR})
  74. add_custom_target(update_gh_pages
  75. COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/UpdateGHPages.cmake")
  76. add_dependencies(update_gh_pages sylvan_html)
  77. endif()
  78. set(CPACK_GENERATOR "DEB")
  79. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Multi-core implementation of decision diagrams")
  80. set(CPACK_PACKAGE_VENDOR "Tom van Dijk")
  81. set(CPACK_PACKAGE_CONTACT "Tom van Dijk <tom@tvandijk.nl>")
  82. set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
  83. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
  84. set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
  85. set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_MAJOR_VERSION})
  86. set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_MINOR_VERSION})
  87. set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_PATCH_VERSION})
  88. include(CPack)
  89. # pkg-config
  90. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sylvan.pc.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/sylvan.pc" @ONLY)
  91. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sylvan.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")