EthOptions.cmake 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. macro(configure_project)
  2. set(NAME ${PROJECT_NAME})
  3. # Default to RelWithDebInfo configuration if no configuration is explicitly specified.
  4. if (NOT CMAKE_BUILD_TYPE)
  5. set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
  6. "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
  7. endif()
  8. eth_default_option(STATIC_BUILD OFF)
  9. # features
  10. eth_default_option(VMTRACE OFF)
  11. eth_default_option(PROFILING OFF)
  12. eth_default_option(FATDB ON)
  13. eth_default_option(ROCKSDB OFF)
  14. eth_default_option(PARANOID OFF)
  15. eth_default_option(MINIUPNPC ON)
  16. # components
  17. eth_default_option(TESTS ON)
  18. eth_default_option(TOOLS ON)
  19. eth_default_option(ETHASHCL ON)
  20. eth_default_option(EVMJIT OFF)
  21. # Resolve any clashes between incompatible options.
  22. if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
  23. if (PARANOID)
  24. message("Paranoia requires debug - disabling for release build.")
  25. set(PARANOID OFF)
  26. endif ()
  27. if (VMTRACE)
  28. message("VM Tracing requires debug - disabling for release build.")
  29. set (VMTRACE OFF)
  30. endif ()
  31. endif ()
  32. if (STATIC_BUILD)
  33. set(STATIC_LINKING 1)
  34. set(BUILD_SHARED_LIBS 0)
  35. endif ()
  36. # Define a matching property name of each of the "features".
  37. foreach(FEATURE ${ARGN})
  38. set(SUPPORT_${FEATURE} TRUE)
  39. endforeach()
  40. # Temporary pre-processor symbol used for hiding broken unit-tests.
  41. # Hiding them behind this pre-processor symbol lets us turn them off
  42. # and on again easily enough, and also to grep for them.
  43. add_definitions(-DDISABLE_BROKEN_UNIT_TESTS_UNTIL_WE_FIX_THEM)
  44. # TODO: Eliminate this pre-processor symbol, which is a bad pattern.
  45. # Common code has no business knowing which application it is part of.
  46. add_definitions(-DETH_TRUE)
  47. # Are we including the JIT EVM module?
  48. # That pulls in a quite heavyweight LLVM dependency, which is
  49. # not suitable for all platforms.
  50. if (EVMJIT)
  51. add_definitions(-DETH_EVMJIT)
  52. endif ()
  53. # FATDB is an option to include the reverse hashes for the trie,
  54. # i.e. it allows you to iterate over the contents of the state.
  55. if (FATDB)
  56. add_definitions(-DETH_FATDB)
  57. endif ()
  58. # TODO: What does "paranoia" even mean?
  59. if (PARANOID)
  60. add_definitions(-DETH_PARANOIA)
  61. endif ()
  62. # TODO: What does "VM trace" even mean?
  63. if (VMTRACE)
  64. add_definitions(-DETH_VMTRACE)
  65. endif ()
  66. # CI Builds should provide (for user builds this is totally optional)
  67. # -DBUILD_NUMBER - A number to identify the current build with. Becomes TWEAK component of project version.
  68. # -DVERSION_SUFFIX - A string to append to the end of the version string where applicable.
  69. if (NOT DEFINED BUILD_NUMBER)
  70. # default is big so that local build is always considered greater
  71. # and can easily replace CI build for for all platforms if needed.
  72. # Windows max version component number is 65535
  73. set(BUILD_NUMBER 65535)
  74. endif()
  75. # Suffix like "-rc1" e.t.c. to append to versions wherever needed.
  76. if (NOT DEFINED VERSION_SUFFIX)
  77. set(VERSION_SUFFIX "")
  78. endif()
  79. include(EthBuildInfo)
  80. create_build_info(${NAME})
  81. print_config(${NAME})
  82. endmacro()
  83. macro(print_config NAME)
  84. message("")
  85. message("------------------------------------------------------------------------")
  86. message("-- Configuring ${NAME}")
  87. message("------------------------------------------------------------------------")
  88. message("-- CMake Version ${CMAKE_VERSION}")
  89. message("-- CMAKE_BUILD_TYPE Build type ${CMAKE_BUILD_TYPE}")
  90. message("-- TARGET_PLATFORM Target platform ${CMAKE_SYSTEM_NAME}")
  91. message("-- STATIC BUILD ${STATIC_BUILD}")
  92. message("--------------------------------------------------------------- features")
  93. if (SUPPORT_CPUID)
  94. message("-- Hardware identification support ${CPUID_FOUND}")
  95. endif()
  96. if (SUPPORT_CURL)
  97. message("-- HTTP Request support ${CURL_FOUND}")
  98. endif()
  99. if (SUPPORT_VMTRACE)
  100. message("-- VMTRACE VM execution tracing ${VMTRACE}")
  101. endif()
  102. message("-- PROFILING Profiling support ${PROFILING}")
  103. if (SUPPORT_FATDB)
  104. message("-- FATDB Full database exploring ${FATDB}")
  105. endif()
  106. if (SUPPORT_ROCKSDB)
  107. message("-- ROCKSDB Prefer rocksdb to leveldb ${ROCKSDB}")
  108. endif()
  109. if (SUPPORT_PARANOID)
  110. message("-- PARANOID - ${PARANOID}")
  111. endif()
  112. if (SUPPORT_MINIUPNPC)
  113. message("-- MINIUPNPC - ${MINIUPNPC}")
  114. endif()
  115. message("------------------------------------------------------------- components")
  116. if (SUPPORT_TESTS)
  117. message("-- TESTS Build tests ${TESTS}")
  118. endif()
  119. if (SUPPORT_TOOLS)
  120. message("-- TOOLS Build tools ${TOOLS}")
  121. endif()
  122. if (SUPPORT_ETHASHCL)
  123. message("-- ETHASHCL Build OpenCL components ${ETHASHCL}")
  124. endif()
  125. if (SUPPORT_EVMJIT)
  126. message("-- EVMJIT Build LLVM-based JIT EVM ${EVMJIT}")
  127. endif()
  128. message("------------------------------------------------------------------------")
  129. message("")
  130. endmacro()