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.

111 lines
4.1 KiB

  1. cmake_minimum_required(VERSION 3.1)
  2. project(sylvan LANGUAGES C CXX VERSION 1.2.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 -fPIC ${CMAKE_C_FLAGS}")
  20. set(CMAKE_CXX_FLAGS "-O2 -Wextra -Wall -fno-strict-aliasing -Wno-deprecated -fPIC ${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. if(USE_CARL)
  46. add_definitions(-DSYLVAN_HAVE_CARL)
  47. include_directories("${carl_INCLUDE_DIR}")
  48. message(STATUS "Sylvan - Using CArL.")
  49. else()
  50. message(STATUS "Sylvan - Not using CArL.")
  51. endif()
  52. include_directories(${CMAKE_SOURCE_DIR}/src)
  53. include(GNUInstallDirs)
  54. include(CTest)
  55. include_directories("${PROJECT_SOURCE_DIR}/../../../src")
  56. include_directories("${PROJECT_BINARY_DIR}/../../../include")
  57. include_directories(src)
  58. add_subdirectory(src)
  59. option(SYLVAN_BUILD_TESTS "Build example tools" ON)
  60. if(SYLVAN_BUILD_TESTS)
  61. add_subdirectory(test)
  62. endif()
  63. option(SYLVAN_BUILD_EXAMPLES "Build example tools" ON)
  64. if(SYLVAN_BUILD_EXAMPLES)
  65. add_subdirectory(examples)
  66. endif()
  67. option(SYLVAN_BUILD_DOCS "Build documentation" ON)
  68. if(SYLVAN_BUILD_DOCS)
  69. configure_file("docs/conf.py.in" "docs/conf.py" @ONLY)
  70. find_package(Sphinx REQUIRED)
  71. Sphinx_add_targets(sylvan ${CMAKE_CURRENT_BINARY_DIR}/docs ${CMAKE_CURRENT_SOURCE_DIR}/docs ${CMAKE_CURRENT_BINARY_DIR})
  72. add_custom_target(update_gh_pages
  73. COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/UpdateGHPages.cmake")
  74. add_dependencies(update_gh_pages sylvan_html)
  75. endif()
  76. set(CPACK_GENERATOR "DEB")
  77. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Multi-core implementation of decision diagrams")
  78. set(CPACK_PACKAGE_VENDOR "Tom van Dijk")
  79. set(CPACK_PACKAGE_CONTACT "Tom van Dijk <tom@tvandijk.nl>")
  80. set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
  81. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
  82. set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
  83. set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_MAJOR_VERSION})
  84. set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_MINOR_VERSION})
  85. set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_PATCH_VERSION})
  86. include(CPack)
  87. # pkg-config
  88. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sylvan.pc.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/sylvan.pc" @ONLY)
  89. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sylvan.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")