diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 2dc7622f46..a1a6cd4519 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -37,6 +37,11 @@ if(${BUILD_WITH_ICONV}) cat("${TD_SUPPORT_DIR}/iconv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif() +# jemalloc +if(${JEMALLOC_ENABLED}) + cat("${TD_SUPPORT_DIR}/jemalloc_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif() + # msvc regex if(${BUILD_MSVCREGEX}) cat("${TD_SUPPORT_DIR}/msvcregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) @@ -258,6 +263,19 @@ if(${BUILD_PTHREAD}) target_link_libraries(pthread INTERFACE libpthreadVC3) endif() +# jemalloc +if(${JEMALLOC_ENABLED}) + include(ExternalProject) + ExternalProject_Add(jemalloc + PREFIX "jemalloc" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ --disable-initial-exec-tls + BUILD_COMMAND ${MAKE} + ) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include) +endif() + # crashdump if(${BUILD_CRASHDUMP}) add_executable(dumper "crashdump/dumper/dumper.c") diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index 45bef7f98e..581686ba90 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -14,7 +14,4 @@ target_include_directories( taosd PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/node_mgmt/inc" ) -IF (TD_LINUX_64 AND JEMALLOC_ENABLED) - add_dependencies(taosd jemalloc) -ENDIF () target_link_libraries(taosd dnode) diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index 2a9d0c8535..b7cb20896b 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -52,3 +52,7 @@ else() os PUBLIC dl m rt ) endif() + +IF (JEMALLOC_ENABLED) + target_link_libraries(os PUBLIC -ljemalloc) +ENDIF () \ No newline at end of file diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 45a6f8c16f..552b77e6e9 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -28,7 +28,4 @@ target_include_directories( PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) -IF (TD_LINUX_64 AND JEMALLOC_ENABLED) - add_dependencies(taosd jemalloc) -ENDIF () SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)