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.

183 lines
5.8 KiB

3 months ago
  1. # # # # # # # # # # # # # # # # # # # # # #
  2. # A. Project properties.
  3. # B. Options.
  4. # C. Find system tools and libraries.
  5. # D. Write information files.
  6. # E. Invoke subdirectories.
  7. # F. Export Compile Information
  8. # G. CPack
  9. # # # # # # # # # # # # # # # # # # # # # #
  10. cmake_minimum_required (VERSION 3.2 FATAL_ERROR)
  11. # # # # # # # # # # # # # # # # # # # # # #
  12. # A. Project properties
  13. # # # # # # # # # # # # # # # # # # # # # #
  14. project(carl CXX)
  15. # path to find own modules
  16. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
  17. # Include own macros.
  18. include( carlmacros )
  19. set_version(18 08)
  20. set( PROJECT_FULLNAME "carl")
  21. set( PROJECT_DESCRIPTION "Computer ARithmetic Library")
  22. set( carl_NAME "CArL" )
  23. set( carl_DESCRIPTION ${PROJECT_DESCRIPTION} )
  24. message(STATUS "Version: ${PROJECT_FULLNAME} ${PROJECT_VERSION_FULL}")
  25. # # # # # # # # # # # # # # # # # # # # # #
  26. # B. Options
  27. # # # # # # # # # # # # # # # # # # # # # #
  28. # options
  29. option( DEVELOPER "Compile with extra warnings" OFF )
  30. option( ALLWARNINGS "Compile with even more warnings" OFF )
  31. option( LOGGING "Enable logging within the carl library" OFF )
  32. export_option(LOGGING)
  33. option( LOGGING_DISABLE_INEFFICIENT "Disable log messages about inefficient methods" OFF )
  34. option( TIMING "Enable timing within the carl library" OFF )
  35. export_option(TIMING)
  36. option( FORCE_SHIPPED_RESOURCES "Do not look in system for resources which are included" OFF )
  37. export_option(FORCE_SHIPPED_RESOURCES)
  38. option( FORCE_SHIPPED_GMP "Do not look in system for lib gmp" OFF )
  39. export_option(FORCE_SHIPPED_GMP)
  40. option( USE_GINAC "Compile with testing with the runtime and result comparisons of carl to ginac" OFF )
  41. export_option(USE_GINAC)
  42. option( COMPARE_WITH_Z3 "Compile benchmarks that compare to z3" OFF )
  43. option( USE_Z3_NUMBERS "Make z3 rationals available in carl" OFF )
  44. option( USE_CLN_NUMBERS "Make cln rationals and integers available in carl" OFF )
  45. export_option(USE_CLN_NUMBERS)
  46. option( USE_COCOA "Use CoCoALib" OFF )
  47. export_option(USE_COCOA)
  48. option( USE_BLISS "Use bliss" OFF )
  49. export_option(USE_BLISS)
  50. OPTION( USE_MPFR_FLOAT "Use the mpfr implementation of floating point numbers." OFF )
  51. export_option(USE_MPFR_FLOAT)
  52. option( USE_COTIRE "Use cotire to generate and use precompiled headers" OFF )
  53. option( BUILD_STATIC "Build the static library as well" OFF )
  54. export_option(BUILD_STATIC)
  55. option( BUILD_DOXYGEN "Build doxygen if not found" OFF )
  56. export_option(BUILD_DOXYGEN)
  57. option( THREAD_SAFE "Use mutexing to assure thread safety" OFF )
  58. export_option(THREAD_SAFE)
  59. option( PRUNE_MONOMIAL_POOL "Prune monomial pool" ON )
  60. option( EXCLUDE_TESTS_FROM_ALL "If set, tests will not be compiled by default" OFF )
  61. export_option(EXCLUDE_TESTS_FROM_ALL)
  62. set(CLANG_SANITIZER "none" CACHE STRING "Compile with the respective sanitizer")
  63. set_property(CACHE CLANG_SANITIZER PROPERTY STRINGS none address memory thread)
  64. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  65. if (NOT CMAKE_BUILD_TYPE)
  66. set(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "Build type." FORCE)
  67. endif()
  68. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "DEBUG" "RELEASE")
  69. set(CARL_LIBRARIES_DIR "${PROJECT_BINARY_DIR}/lib")
  70. # Offer the user the choice of overriding the installation directories
  71. set(INCLUDE_INSTALL_DIR include/ CACHE PATH "Installation directory for header files" )
  72. set(LIB_INSTALL_DIR lib/ CACHE PATH "Installation directory for libraries")
  73. #set(SYSCONFIG_INSTALL_DIR etc/carl/ CACHE PATH "Installation for system configuration files)
  74. set(BIN_INSTALL_DIR lib/ CACHE PATH "Installation directory for executables")
  75. if(WIN32 AND NOT CYGWIN)
  76. set(DEF_INSTALL_CMAKE_DIR CMake)
  77. else()
  78. set(DEF_INSTALL_CMAKE_DIR lib/cmake/carl)
  79. endif()
  80. set(CMAKE_INSTALL_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
  81. foreach(p LIB BIN INCLUDE CMAKE)
  82. set(var ${p}_INSTALL_DIR)
  83. if(NOT IS_ABSOLUTE "${${var}}")
  84. set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
  85. endif()
  86. endforeach()
  87. # path to put in the executables after building.
  88. set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Directory for built executables")
  89. include(compiler-options)
  90. set(DYNAMIC_EXT ".so")
  91. set(STATIC_EXT ".a")
  92. if(APPLE)
  93. set(DYNAMIC_EXT ".dylib")
  94. set(STATIC_EXT ".a")
  95. elseif (WIN32)
  96. set(DYNAMIC_EXT ".dll")
  97. set(STATIC_EXT ".lib")
  98. endif()
  99. if(BUILD_STATIC)
  100. message(STATUS "Building static: yes")
  101. if (LOGGING)
  102. message(WARNING "A static build with logging enabled will probably trigger a segfault!")
  103. endif()
  104. else()
  105. message(STATUS "Building static: no")
  106. endif()
  107. include(cotire)
  108. # RPATH settings
  109. # don't skip the full RPATH for the build tree
  110. SET(CMAKE_SKIP_BUILD_RPATH FALSE)
  111. # when building, don't use the install RPATH already (but only when installing)
  112. SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  113. # the RPATH to be used when installing
  114. SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  115. # don't add the automatically determined parts of the RPATH
  116. # which point to directories outside the build tree to the install RPATH
  117. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  118. # # # # # # # # # # # # # # # # # # # # # #
  119. # C. Find system tools and libraries.
  120. #
  121. # 1. Required libraries for core.
  122. # 2. Optional libraries for core.
  123. # 3. Development and debug libraries.
  124. # # # # # # # # # # # # # # # # # # # # # #
  125. # # # # # # # # # # # # # # # # # # # # # #
  126. # C.1. Required libraries for core.
  127. # # # # # # # # # # # # # # # # # # # # # #
  128. include(resources/resources.cmake)
  129. # we only search for this libraries in the system, if we do not force using the shipped resources.
  130. enable_testing()
  131. #dl must be linked LAST as this is required for the stacktrace in util/platform.h
  132. if (NOT WIN32)
  133. list(APPEND carl_LIBRARIES_DYNAMIC pthread dl)
  134. endif()
  135. include(clang-tidy)
  136. include(coverage)
  137. if (TARGET Doxygen::doxygen)
  138. add_subdirectory(doxygen-conf)
  139. endif()
  140. add_subdirectory(src)
  141. include(export)
  142. if (BINDINGS_PYTHON)
  143. add_subdirectory(bindings/pycarl)
  144. endif()
  145. include(resources/addons/addons.cmake)
  146. include(packaging)
  147. include(prepare-ci)