CMakeLists.txt 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
  2. file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/src/oatpp/core/base/Environment.hpp" OATPP_VERSION_MACRO REGEX "#define OATPP_VERSION \"[0-9]+.[0-9]+.[0-9]+\"$")
  3. string(REGEX REPLACE "#define OATPP_VERSION \"([0-9]+.[0-9]+.[0-9]+)\"$" "\\1" oatpp_VERSION "${OATPP_VERSION_MACRO}")
  4. ###################################################################################################
  5. ## These variables are passed to oatpp-module-install.cmake script
  6. ## use these variables to configure module installation
  7. set(OATPP_THIS_MODULE_NAME oatpp) ## name of the module (also name of folders in installation dirs)
  8. set(OATPP_THIS_MODULE_VERSION ${oatpp_VERSION}) ## version of the module (also sufix of folders in installation dirs)
  9. set(OATPP_THIS_MODULE_LIBRARIES oatpp oatpp-test) ## list of libraries to find when find_package is called
  10. set(OATPP_THIS_MODULE_TARGETS oatpp oatpp-test) ## list of targets to install
  11. set(OATPP_THIS_MODULE_DIRECTORIES oatpp oatpp-test) ## list of directories to install
  12. ###################################################################################################
  13. project(oatpp VERSION ${OATPP_THIS_MODULE_VERSION} LANGUAGES CXX)
  14. option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
  15. option(OATPP_INSTALL "Create installation target for oat++" ON)
  16. option(OATPP_BUILD_TESTS "Create test target for oat++" ON)
  17. ###################################################################################################
  18. ## COMPILATION CONFIG #############################################################################
  19. ###################################################################################################
  20. option(OATPP_DISABLE_ENV_OBJECT_COUNTERS "Disable object counting for Release builds for better performance" OFF)
  21. option(OATPP_DISABLE_POOL_ALLOCATIONS "This will make oatpp::base::memory::MemoryPool, method obtain and free call new and delete directly" OFF)
  22. set(OATPP_THREAD_HARDWARE_CONCURRENCY "AUTO" CACHE STRING "Predefined value for function oatpp::concurrency::Thread::getHardwareConcurrency()")
  23. set(OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT "10" CACHE STRING "Number of shards of ThreadDistributedMemoryPool")
  24. option(OATPP_COMPAT_BUILD_NO_THREAD_LOCAL "Disable 'thread_local' feature" OFF)
  25. ## Print config ##################################################################################
  26. message("\n############################################################################")
  27. message("## oatpp module compilation config:\n")
  28. message("OATPP_DISABLE_ENV_OBJECT_COUNTERS=${OATPP_DISABLE_ENV_OBJECT_COUNTERS}")
  29. message("OATPP_DISABLE_POOL_ALLOCATIONS=${OATPP_DISABLE_POOL_ALLOCATIONS}")
  30. message("OATPP_THREAD_HARDWARE_CONCURRENCY=${OATPP_THREAD_HARDWARE_CONCURRENCY}")
  31. message("OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT=${OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT}")
  32. message("OATPP_COMPAT_BUILD_NO_THREAD_LOCAL=${OATPP_COMPAT_BUILD_NO_THREAD_LOCAL}")
  33. ## Set definitions ###############################################################################
  34. if(OATPP_DISABLE_ENV_OBJECT_COUNTERS)
  35. add_definitions(-DOATPP_DISABLE_ENV_OBJECT_COUNTERS)
  36. endif()
  37. if(OATPP_DISABLE_POOL_ALLOCATIONS)
  38. add_definitions (-DOATPP_DISABLE_POOL_ALLOCATIONS)
  39. endif()
  40. set(AUTO_VALUE AUTO)
  41. if(NOT OATPP_THREAD_HARDWARE_CONCURRENCY STREQUAL AUTO_VALUE)
  42. add_definitions (-DOATPP_THREAD_HARDWARE_CONCURRENCY=${OATPP_THREAD_HARDWARE_CONCURRENCY})
  43. endif()
  44. add_definitions (
  45. -DOATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT=${OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT}
  46. )
  47. if(OATPP_COMPAT_BUILD_NO_THREAD_LOCAL)
  48. add_definitions(-DOATPP_COMPAT_BUILD_NO_THREAD_LOCAL)
  49. endif()
  50. message("\n############################################################################\n")
  51. ###################################################################################################
  52. message("oatpp version: '${OATPP_THIS_MODULE_VERSION}'")
  53. add_subdirectory(src)
  54. if(OATPP_BUILD_TESTS)
  55. enable_testing()
  56. add_subdirectory(test)
  57. endif()