diff --git a/CMakeLists.txt b/CMakeLists.txt index 099bf3c59cd32599447a61776becd8adf3583e78..f67bdb6aadd57cc5203b80dd9be1286fbb68b19c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -382,6 +382,10 @@ find_package_message(MODULE_LUAPATH "Lua package.path: ${MODULE_LUAPATH}" find_package_message(MODULE_LIBPATH "Lua package.cpath: ${MODULE_LIBPATH}" "${MODULE_LIBPATH}") +set(TARANTOOL_DEBUG OFF) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(TARANTOOL_DEBUG ON) +endif(CMAKE_BUILD_TYPE STREQUAL "Debug") ## ## Third-Party libraries diff --git a/cmake/BuildAres.cmake b/cmake/BuildAres.cmake index b86d793d1454a5058d81d229b6fd15caceb09b24..603b1ea987f103ec0e17b7d60d976e9ffc199103 100644 --- a/cmake/BuildAres.cmake +++ b/cmake/BuildAres.cmake @@ -11,6 +11,7 @@ macro(ares_build) endif() set(ARES_CMAKE_FLAGS "-DCARES_STATIC=ON") + list(APPEND ARES_CMAKE_FLAGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") list(APPEND ARES_CMAKE_FLAGS "-DCARES_SHARED=OFF") list(APPEND ARES_CMAKE_FLAGS "-DCARES_BUILD_TOOLS=OFF") # We build both static and shared versions of curl, so ares diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake index 410488403110fa18a91b3476d5569f4474c97f47..6a29674246ad5e9bd55e48764674c28a508b4025 100644 --- a/cmake/BuildLibCURL.cmake +++ b/cmake/BuildLibCURL.cmake @@ -185,11 +185,14 @@ macro(curl_build) # catch the symbols may require extra work. list(APPEND LIBCURL_CMAKE_FLAGS "-DCURL_ZSTD=OFF") list(APPEND LIBCURL_CMAKE_FLAGS "-DLIBCURL_OUTPUT_NAME=libcurl") - list(APPEND LIBCURL_CMAKE_FLAGS "-DENABLE_CURLDEBUG=OFF") - list(APPEND LIBCURL_CMAKE_FLAGS "-DENABLE_DEBUG=OFF") + list(APPEND LIBCURL_CMAKE_FLAGS "-DENABLE_CURLDEBUG=${TARANTOOL_DEBUG}") + list(APPEND LIBCURL_CMAKE_FLAGS "-DENABLE_DEBUG=${TARANTOOL_DEBUG}") list(APPEND LIBCURL_CMAKE_FLAGS "-DUSE_MSH3=OFF") list(APPEND LIBCURL_CMAKE_FLAGS "-DENABLE_WEBSOCKETS=OFF") list(APPEND LIBCURL_CMAKE_FLAGS "-DCMAKE_UNITY_BUILD=OFF") + # Note that CMake build does not allow build curl and libcurl debug + # enabled, see https://github.com/curl/curl/blob/master/docs/INSTALL.cmake + list(APPEND LIBCURL_CMAKE_FLAGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") # We need PIC at least to enable build for Fedora on # ARM64 CPU. Without it configuration with Fedora diff --git a/cmake/BuildLibEIO.cmake b/cmake/BuildLibEIO.cmake index a542a3deafcd645276516a7a37083510c2c20a80..b493b23aa0c550aa4e64b85b2cebbc2aeed7947e 100644 --- a/cmake/BuildLibEIO.cmake +++ b/cmake/BuildLibEIO.cmake @@ -11,6 +11,10 @@ macro(libeio_build) set(eio_compile_flags "${eio_compile_flags} -DHAVE_SYS_PRCTL_H -DHAVE_PRCTL_SET_NAME") endif () + if (TARANTOOL_DEBUG) + set(eio_compile_flags + "${eio_compile_flags} ${CMAKE_C_FLAGS_DEBUG}") + endif (TARANTOOL_DEBUG) set(eio_src ${PROJECT_SOURCE_DIR}/third_party/tarantool_eio.c diff --git a/cmake/BuildLibEV.cmake b/cmake/BuildLibEV.cmake index a8fef0a8d01653e9273ca8de1d363c125b1e817f..39738713f414719a425cf97ce72cb3d5f040fef0 100644 --- a/cmake/BuildLibEV.cmake +++ b/cmake/BuildLibEV.cmake @@ -25,6 +25,10 @@ macro(libev_build) set(ev_compile_flags "${ev_compile_flags} -DEV_USE_KQUEUE") endif() + if (TARANTOOL_DEBUG) + set(ev_compile_flags "${ev_compile_flags} ${CMAKE_C_FLAGS_DEBUG}") + endif(TARANTOOL_DEBUG) + list(APPEND ev_link_libraries "m") if (TARGET_OS_DEBIAN_FREEBSD) # libev depends on librt under kFreeBSD diff --git a/cmake/BuildZSTD.cmake b/cmake/BuildZSTD.cmake index 995a5245de8d0acc404443b2f67d9fb4483827b6..0dceb759c49b9e6c2ddd0d578e0c2c7d4752ae2a 100644 --- a/cmake/BuildZSTD.cmake +++ b/cmake/BuildZSTD.cmake @@ -30,6 +30,11 @@ macro(zstd_build) if (CC_HAS_WNO_IMPLICIT_FALLTHROUGH) set(zstd_cflags "${zstd_cflags} -Wno-implicit-fallthrough") endif() + if (TARANTOOL_DEBUG) + # See lib/common/debug.h, + # https://github.com/facebook/zstd/blob/7567769a7e8e8236a2015769a5083d0f090a654b/lib/common/debug.h#L21-L29 + set(zstd_cflags "${zstd_cflags} -DDEBUG_LEVEL=2") + endif() set_source_files_properties(${zstd_src} PROPERTIES COMPILE_FLAGS ${zstd_cflags})