Skip to content

Commit

Permalink
build: add libunwind as external project (OpenAtomFoundation#1316)
Browse files Browse the repository at this point in the history

Co-authored-by: liuzhen3 <[email protected]>
  • Loading branch information
kernelai and liuzhen3 authored Mar 8, 2023
1 parent e1e9d7a commit c250203
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 28 deletions.
82 changes: 62 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 3.10)

# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

set(CMAKE_CXX_STANDARD 17)
project(pika)
set(CMAKE_CXX_FLAGS "-pthread -Wl,--no-as-needed -ldl")
Expand All @@ -20,9 +25,9 @@ execute_process(COMMAND sh ${CMAKE_UTILS_DIR}/Get_OS_Version.sh
OUTPUT_VARIABLE OS_VERSION)

message(STATUS "${PROJECT_NAME} staged install: ${STAGED_INSTALL_PREFIX}")
message(STATUS "current platform: ${OS_VERSION} ")
message(STATUS "Current platform: ${OS_VERSION} ")
cmake_host_system_information(RESULT CPU_CORE QUERY NUMBER_OF_LOGICAL_CORES)
message("cpu core ${CPU_CORE}")
message(STATUS "Cpu core ${CPU_CORE}")

include(protogen.cmake)
include(ExternalProject)
Expand Down Expand Up @@ -82,13 +87,42 @@ ExternalProject_Add(gflags
make -j${CPU_CORE}
)

set(GFLAGS_LIBRARIE ${INSTALL_LIBDIR}/libgflags.a)
set(GFLAGS_LIBRARY ${INSTALL_LIBDIR}/libgflags.a)
set(GFLAGS_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

ExternalProject_Add(unwind
DEPENDS
URL
http://download.savannah.nongnu.org/releases/libunwind/libunwind-1.6.2.tar.gz
URL_HASH
MD5=f625b6a98ac1976116c71708a73dc44a
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
""
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
CONFIGURE_COMMAND
<SOURCE_DIR>/configure --prefix=${STAGED_INSTALL_PREFIX} --enable-minidebuginfo=no --enable-zlibdebuginfo=no
BUILD_IN_SOURCE
1
BUILD_COMMAND
make -j${CPU_CORE}
INSTALL_COMMAND
make install
)
set(LIBUNWIND_LIBRARY ${INSTALL_LIBDIR}/libunwind.a)
set(LIBUNWIND_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

ExternalProject_Add(glog
DEPENDS
gflags
gtest
unwind
URL
https://github.com/google/glog/archive/refs/tags/v0.6.0.tar.gz
URL_HASH
Expand All @@ -109,12 +143,14 @@ ExternalProject_Add(glog
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DWITH_GFLAGS=ON
-DBUILD_TESTING=OFF
-DBUILD_STATIC_LIBS=ON
-DBUILD_SHARED_LIBS=OFF
-DWITH_UNWIND=ON
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
BUILD_COMMAND
make -j${CPU_CORE}
)
set(GLOG_LIBRARY ${INSTALL_LIBDIR}/libglog.a)
set(GLOG_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

ExternalProject_Add(snappy
DEPENDS
Expand Down Expand Up @@ -144,9 +180,9 @@ ExternalProject_Add(snappy
)

if (${OS_VERSION} MATCHES "CentOS")
set(SNAPPY_LIBRARIE ${INSTALL_LIBDIR_64}/libsnappy.a)
set(SNAPPY_LIBRARY ${INSTALL_LIBDIR_64}/libsnappy.a)
else ()
set(SNAPPY_LIBRARIE ${INSTALL_LIBDIR}/libsnappy.a)
set(SNAPPY_LIBRARY ${INSTALL_LIBDIR}/libsnappy.a)
endif ()
set(SNAPPY_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

Expand Down Expand Up @@ -180,9 +216,9 @@ ExternalProject_Add(zstd
)

if (${OS_VERSION} MATCHES "CentOS")
set(ZSTD_LIBRARIE ${INSTALL_LIBDIR_64}/libzstd.a)
set(ZSTD_LIBRARY ${INSTALL_LIBDIR_64}/libzstd.a)
else ()
set(ZSTD_LIBRARIE ${INSTALL_LIBDIR}/libzstd.a)
set(ZSTD_LIBRARY ${INSTALL_LIBDIR}/libzstd.a)
endif ()
set(ZSTD_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

Expand Down Expand Up @@ -216,9 +252,9 @@ ExternalProject_Add(lz4
)

if (${OS_VERSION} MATCHES "CentOS")
set(LZ4_LIBRARIE ${INSTALL_LIBDIR_64}/liblz4.a)
set(LZ4_LIBRARY ${INSTALL_LIBDIR_64}/liblz4.a)
else ()
set(LZ4_LIBRARIE ${INSTALL_LIBDIR}/liblz4.a)
set(LZ4_LIBRARY ${INSTALL_LIBDIR}/liblz4.a)
endif ()
set(LZ4_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

Expand Down Expand Up @@ -246,11 +282,12 @@ ExternalProject_Add(zlib
make -j${CPU_CORE}
)

set(ZLIB_LIBRARIE ${INSTALL_LIBDIR}/libz.a)
set(ZLIB_LIBRARY ${INSTALL_LIBDIR}/libz.a)
set(ZLIB_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

ExternalProject_Add(gperftools
DEPENDS
unwind
URL
https://github.com/gperftools/gperftools/releases/download/gperftools-2.10/gperftools-2.10.tar.gz
URL_HASH
Expand All @@ -274,9 +311,9 @@ ExternalProject_Add(gperftools
)

if (${OS_VERSION} MATCHES "CentOS")
set(TCMALLOC_LIBRARIE ${INSTALL_LIBDIR_64}/liblibtcmalloclz4.a)
set(TCMALLOC_LIBRARY ${INSTALL_LIBDIR_64}/liblibtcmalloclz4.a)
else ()
set(TCMALLOC_LIBRARIE ${INSTALL_LIBDIR}/libtcmalloc.a)
set(TCMALLOC_LIBRARY ${INSTALL_LIBDIR}/libtcmalloc.a)
endif ()
set(TCMALLOC_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

Expand Down Expand Up @@ -308,13 +345,16 @@ ExternalProject_Add(jemalloc
make install
)

set(JEMALLOC_LIBRARIE ${INSTALL_LIBDIR}/libjemalloc.a)
set(JEMALLOC_LIBRARY ${INSTALL_LIBDIR}/libjemalloc.a)
set(JEMALLOC_INCLUDE_DIR ${INSTALL_INCLUDEDIR})

ExternalProject_Add(protobuf
DEPENDS
zlib
URL
https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-cpp-3.17.3.tar.gz
URL_HASH
MD5=3fe4c2647e0991c014a386a896d0a116
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
Expand All @@ -339,7 +379,7 @@ ExternalProject_Add(protobuf
make -j${CPU_CORE}
)

set(PROTOBUF_DIR ${STAGED_INSTALL_PREFIX})
set(PROTOBUF_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
set(PROTOBUF_LIBRARY ${INSTALL_LIBDIR}/libprotobuf.a)
set(PROTOBUF_PROTOC ${STAGED_INSTALL_PREFIX}/bin/protoc)

Expand All @@ -356,8 +396,7 @@ ExternalProject_Add(rocksdb
URL
https://github.com/facebook/rocksdb/archive/refs/tags/v7.7.3.tar.gz
URL_HASH

# MD5=594dd8e0a1e8c1ef8a1b210a1a5aff5b
MD5=3c5d371a8bd8340b1975ad016151709d
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
Expand Down Expand Up @@ -392,9 +431,9 @@ ExternalProject_Add(rocksdb
)

if (${OS_VERSION} MATCHES "CentOS")
set(ROCKSDB_LIBRARIE ${INSTALL_LIBDIR_64}/librocksdb.a)
set(ROCKSDB_LIBRARY ${INSTALL_LIBDIR_64}/librocksdb.a)
else ()
set(ROCKSDB_LIBRARIE ${INSTALL_LIBDIR}/librocksdb.a)
set(ROCKSDB_LIBRARY ${INSTALL_LIBDIR}/librocksdb.a)
endif ()

set(ROCKSDB_INCLUDE_DIR ${INSTALL_INCLUDEDIR})
Expand Down Expand Up @@ -455,6 +494,7 @@ target_link_directories(${PROJECT_NAME}
add_dependencies(${PROJECT_NAME}
gflags
gtest
unwind
glog
snappy
zstd
Expand All @@ -463,6 +503,7 @@ add_dependencies(${PROJECT_NAME}
gperftools
jemalloc
rocksdb
protobuf
slash
pink
blackwidow)
Expand All @@ -479,10 +520,11 @@ target_link_libraries(${PROJECT_NAME}
slash
libglog.a
librocksdb.a
${PROTOBUF_LIBRARY}
libprotobuf.a
libgflags.a
libsnappy.a
libzstd.a
liblz4.a
libz.a
libunwind.a
libjemalloc.a)
12 changes: 6 additions & 6 deletions src/blackwidow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ target_include_directories(blackwidow
)

target_link_libraries(blackwidow
PUBLIC ${ROCKSDB_LIBRARIE}
${SNAPPY_LIBRARIE}
${ZSTD_LIBRARIE}
${LZ4_LIBRARIE}
${ZLIB_LIBRARIE}
${JEMALLOC_LIBRARIE}
PUBLIC ${ROCKSDB_LIBRARY}
${SNAPPY_LIBRARY}
${ZSTD_LIBRARY}
${LZ4_LIBRARY}
${ZLIB_LIBRARY}
${JEMALLOC_LIBRARY}
PUBLIC slash)
2 changes: 1 addition & 1 deletion src/blackwidow/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ foreach(blackwindow_test_source ${BLACKWINDOW_TEST_SOURCE})
target_link_libraries(${blackwindow_test_name}
PUBLIC ${GTEST_LIBRARY}
PUBLIC slash
PUBLIC ${ROCKSDB_LIBRARIE}
PUBLIC ${ROCKSDB_LIBRARY}
PUBLIC blackwidow
)
endforeach(blackwindow_test_source ${BLACKWINDOW_TEST_SOURCE})
9 changes: 8 additions & 1 deletion src/pink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ aux_source_directory(./src DIR_SRCS)

add_library(pink STATIC ${DIR_SRCS} )

target_include_directories(pink PUBLIC ${PROJECT_SOURCE_DIR}/..)
add_dependencies(pink
protobuf
)

message(STATUS "protobuf include dir: ${PROTOBUF_INCLUDE_DIR}")
target_include_directories(pink
PUBLIC ${PROJECT_SOURCE_DIR}/..
PUBLIC ${INSTALL_INCLUDEDIR})

0 comments on commit c250203

Please sign in to comment.