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.

68 lines
2.2 KiB

  1. cmake_minimum_required(VERSION 2.6)
  2. project(sylvan C CXX)
  3. enable_testing()
  4. option(SYLVAN_PORTABLE "If set, the created library will be portable." OFF)
  5. set(CMAKE_C_FLAGS "-O3 -Wextra -Wall -fno-strict-aliasing -std=gnu11 -fPIC")
  6. set(CMAKE_CXX_FLAGS "-O3 -Wextra -Wall -fno-strict-aliasing -Wno-deprecated-register -std=c++14 -fPIC")
  7. if (NOT SYLVAN_PORTABLE)
  8. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
  9. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
  10. endif()
  11. option(USE_CARL "Sets whether carl should be included." ON)
  12. option(WITH_COVERAGE "Add generation of test coverage" OFF)
  13. if(WITH_COVERAGE)
  14. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -coverage")
  15. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -coverage")
  16. find_program(GCOV_PATH gcov)
  17. find_program(LCOV_PATH lcov)
  18. find_program(GENHTML_PATH genhtml)
  19. add_custom_target(coverage
  20. # Cleanup lcov
  21. ${LCOV_PATH} --directory . --zerocounters
  22. # Run tests
  23. COMMAND make test
  24. # Capture counters
  25. COMMAND ${LCOV_PATH} --gcov-tool ${GCOV_PATH} --directory . --capture --output-file coverage.info
  26. COMMAND ${LCOV_PATH} --remove coverage.info 'test/*' '/usr/*' 'examples/*' 'src/sylvan_mtbdd*' 'src/lace*' 'src/sylvan_ldd*' 'src/avl.h' 'src/sha2.c' --output-file coverage.info.cleaned
  27. COMMAND ${GENHTML_PATH} -o coverage coverage.info.cleaned
  28. COMMAND ${CMAKE_COMMAND} -E remove coverage.info coverage.info.cleaned
  29. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  30. )
  31. endif()
  32. if(USE_CARL)
  33. add_definitions(-DSYLVAN_HAVE_CARL)
  34. include_directories("${carl_INCLUDE_DIR}")
  35. message(STATUS "Sylvan - using CARL.")
  36. else()
  37. message(STATUS "Sylvan - not using CARL.")
  38. endif()
  39. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
  40. find_package(GMP REQUIRED)
  41. include_directories(${GMP_INCLUDE_DIR})
  42. include_directories("${PROJECT_SOURCE_DIR}/../../../src")
  43. include_directories("${PROJECT_BINARY_DIR}/../../../include")
  44. include_directories(src)
  45. add_subdirectory(src)
  46. option(SYLVAN_BUILD_TEST "Build test programs" ON)
  47. if(SYLVAN_BUILD_TEST)
  48. add_subdirectory(test)
  49. endif()
  50. option(SYLVAN_BUILD_EXAMPLES "Build example tools" OFF)
  51. if(SYLVAN_BUILD_EXAMPLES)
  52. add_subdirectory(examples)
  53. endif()