2024-04-23 06:20:20 +08:00
|
|
|
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
|
2018-10-13 05:08:20 +08:00
|
|
|
|
2019-01-21 11:03:23 +08:00
|
|
|
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]+\"$")
|
2018-10-13 05:08:20 +08:00
|
|
|
string(REGEX REPLACE "#define OATPP_VERSION \"([0-9]+.[0-9]+.[0-9]+)\"$" "\\1" oatpp_VERSION "${OATPP_VERSION_MACRO}")
|
|
|
|
|
2019-01-25 11:22:01 +08:00
|
|
|
###################################################################################################
|
|
|
|
## These variables are passed to oatpp-module-install.cmake script
|
|
|
|
## use these variables to configure module installation
|
|
|
|
|
|
|
|
set(OATPP_THIS_MODULE_NAME oatpp) ## name of the module (also name of folders in installation dirs)
|
|
|
|
set(OATPP_THIS_MODULE_VERSION ${oatpp_VERSION}) ## version of the module (also sufix of folders in installation dirs)
|
|
|
|
|
|
|
|
###################################################################################################
|
|
|
|
|
|
|
|
project(oatpp VERSION ${OATPP_THIS_MODULE_VERSION} LANGUAGES CXX)
|
2018-10-13 05:08:20 +08:00
|
|
|
|
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
|
|
|
option(OATPP_INSTALL "Create installation target for oat++" ON)
|
|
|
|
option(OATPP_BUILD_TESTS "Create test target for oat++" ON)
|
2022-01-07 16:28:23 +08:00
|
|
|
option(OATPP_LINK_TEST_LIBRARY "Link oat++ test library" ON)
|
2020-06-02 22:32:27 +08:00
|
|
|
option(OATPP_LINK_ATOMIC "Link atomic library for other platform than MSVC|MINGW|APPLE|FreeBSD" ON)
|
2021-06-11 06:20:16 +08:00
|
|
|
option(OATPP_MSVC_LINK_STATIC_RUNTIME "MSVC: Link with static runtime (/MT and /MTd)." OFF)
|
2018-10-13 05:08:20 +08:00
|
|
|
|
2019-03-05 07:09:24 +08:00
|
|
|
###################################################################################################
|
|
|
|
## COMPILATION CONFIG #############################################################################
|
|
|
|
###################################################################################################
|
|
|
|
|
2022-01-07 16:28:23 +08:00
|
|
|
if(OATPP_LINK_TEST_LIBRARY)
|
2022-01-06 18:36:10 +08:00
|
|
|
set(OATPP_THIS_MODULE_LIBRARIES oatpp oatpp-test) ## list of libraries to find when find_package is called
|
|
|
|
set(OATPP_THIS_MODULE_TARGETS oatpp oatpp-test) ## list of targets to install
|
|
|
|
set(OATPP_THIS_MODULE_DIRECTORIES oatpp oatpp-test) ## list of directories to install
|
|
|
|
else()
|
|
|
|
set(OATPP_THIS_MODULE_LIBRARIES oatpp) ## list of libraries to find when find_package is called
|
|
|
|
set(OATPP_THIS_MODULE_TARGETS oatpp) ## list of targets to install
|
|
|
|
set(OATPP_THIS_MODULE_DIRECTORIES oatpp) ## list of directories to install
|
|
|
|
endif()
|
|
|
|
|
2019-03-05 07:09:24 +08:00
|
|
|
option(OATPP_DISABLE_ENV_OBJECT_COUNTERS "Disable object counting for Release builds for better performance" OFF)
|
|
|
|
option(OATPP_DISABLE_POOL_ALLOCATIONS "This will make oatpp::base::memory::MemoryPool, method obtain and free call new and delete directly" OFF)
|
|
|
|
|
|
|
|
set(OATPP_THREAD_HARDWARE_CONCURRENCY "AUTO" CACHE STRING "Predefined value for function oatpp::concurrency::Thread::getHardwareConcurrency()")
|
|
|
|
|
2019-06-08 04:25:19 +08:00
|
|
|
option(OATPP_COMPAT_BUILD_NO_THREAD_LOCAL "Disable 'thread_local' feature" OFF)
|
2020-06-05 05:49:07 +08:00
|
|
|
option(OATPP_COMPAT_BUILD_NO_SET_AFFINITY "No 'pthread_setaffinity_np' method" OFF)
|
2019-06-08 04:25:19 +08:00
|
|
|
|
2020-01-26 18:46:05 +08:00
|
|
|
option(OATPP_DISABLE_LOGV "DISABLE logs priority V" OFF)
|
|
|
|
option(OATPP_DISABLE_LOGD "DISABLE logs priority D" OFF)
|
|
|
|
option(OATPP_DISABLE_LOGI "DISABLE logs priority I" OFF)
|
|
|
|
option(OATPP_DISABLE_LOGW "DISABLE logs priority W" OFF)
|
|
|
|
option(OATPP_DISABLE_LOGE "DISABLE logs priority E" OFF)
|
|
|
|
|
2019-03-05 07:09:24 +08:00
|
|
|
## Print config ##################################################################################
|
|
|
|
|
|
|
|
message("\n############################################################################")
|
|
|
|
message("## oatpp module compilation config:\n")
|
|
|
|
|
|
|
|
message("OATPP_DISABLE_ENV_OBJECT_COUNTERS=${OATPP_DISABLE_ENV_OBJECT_COUNTERS}")
|
|
|
|
message("OATPP_THREAD_HARDWARE_CONCURRENCY=${OATPP_THREAD_HARDWARE_CONCURRENCY}")
|
2019-06-08 04:25:19 +08:00
|
|
|
message("OATPP_COMPAT_BUILD_NO_THREAD_LOCAL=${OATPP_COMPAT_BUILD_NO_THREAD_LOCAL}")
|
|
|
|
|
2019-03-05 07:09:24 +08:00
|
|
|
## Set definitions ###############################################################################
|
|
|
|
|
|
|
|
if(OATPP_DISABLE_ENV_OBJECT_COUNTERS)
|
|
|
|
add_definitions(-DOATPP_DISABLE_ENV_OBJECT_COUNTERS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OATPP_DISABLE_POOL_ALLOCATIONS)
|
|
|
|
add_definitions (-DOATPP_DISABLE_POOL_ALLOCATIONS)
|
2021-11-16 08:26:27 +08:00
|
|
|
message("WARNING: OATPP_DISABLE_POOL_ALLOCATIONS option is deprecated and has no effect.")
|
2019-03-05 07:09:24 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(AUTO_VALUE AUTO)
|
|
|
|
if(NOT OATPP_THREAD_HARDWARE_CONCURRENCY STREQUAL AUTO_VALUE)
|
|
|
|
add_definitions (-DOATPP_THREAD_HARDWARE_CONCURRENCY=${OATPP_THREAD_HARDWARE_CONCURRENCY})
|
|
|
|
endif()
|
|
|
|
|
2021-11-16 08:26:27 +08:00
|
|
|
if(OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT)
|
|
|
|
add_definitions (-DOATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT=${OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT})
|
|
|
|
message("WARNING: OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT option is deprecated and has no effect.")
|
|
|
|
endif()
|
2019-03-05 07:09:24 +08:00
|
|
|
|
2019-06-08 04:25:19 +08:00
|
|
|
if(OATPP_COMPAT_BUILD_NO_THREAD_LOCAL)
|
|
|
|
add_definitions(-DOATPP_COMPAT_BUILD_NO_THREAD_LOCAL)
|
|
|
|
endif()
|
|
|
|
|
2020-06-05 05:49:07 +08:00
|
|
|
if(OATPP_COMPAT_BUILD_NO_SET_AFFINITY)
|
|
|
|
add_definitions(-DOATPP_COMPAT_BUILD_NO_SET_AFFINITY)
|
|
|
|
endif()
|
|
|
|
|
2020-01-26 18:46:05 +08:00
|
|
|
if(OATPP_DISABLE_LOGV)
|
|
|
|
add_definitions(-DOATPP_DISABLE_LOGV)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OATPP_DISABLE_LOGD)
|
|
|
|
add_definitions(-DOATPP_DISABLE_LOGD)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OATPP_DISABLE_LOGI)
|
|
|
|
add_definitions(-DOATPP_DISABLE_LOGI)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OATPP_DISABLE_LOGW)
|
|
|
|
add_definitions(-DOATPP_DISABLE_LOGW)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OATPP_DISABLE_LOGE)
|
|
|
|
add_definitions(-DOATPP_DISABLE_LOGE)
|
|
|
|
endif()
|
|
|
|
|
2020-06-03 18:33:42 +08:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 5.0)
|
|
|
|
add_definitions(-DOATPP_DISABLE_STD_PUT_TIME)
|
|
|
|
endif()
|
|
|
|
|
2019-03-05 07:09:24 +08:00
|
|
|
message("\n############################################################################\n")
|
|
|
|
|
|
|
|
###################################################################################################
|
|
|
|
|
2019-01-25 11:22:01 +08:00
|
|
|
message("oatpp version: '${OATPP_THIS_MODULE_VERSION}'")
|
2019-01-23 13:27:14 +08:00
|
|
|
|
2023-08-05 17:36:41 +08:00
|
|
|
include(cmake/compiler-flags.cmake)
|
2020-01-07 08:10:48 +08:00
|
|
|
|
2021-06-11 15:55:01 +08:00
|
|
|
include(cmake/msvc-runtime.cmake)
|
|
|
|
configure_msvc_runtime()
|
|
|
|
|
2023-05-11 03:49:22 +08:00
|
|
|
include(cmake/project.cmake)
|
|
|
|
|
2019-01-21 11:03:23 +08:00
|
|
|
add_subdirectory(src)
|
2018-10-13 05:08:20 +08:00
|
|
|
|
|
|
|
if(OATPP_BUILD_TESTS)
|
|
|
|
enable_testing()
|
2019-01-21 11:03:23 +08:00
|
|
|
add_subdirectory(test)
|
2019-01-25 22:38:19 +08:00
|
|
|
endif()
|
2021-11-26 16:36:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
include(cpack.cmake)
|
|
|
|
|
|
|
|
# This must always be last!
|
|
|
|
include( CPack )
|