Skip to content

Commit

Permalink
Only link the library when it's existed (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk authored and ShooterIT committed Jul 19, 2021
1 parent 3d0d59a commit 9e6a989
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ configure_file(src/version.h.in ${PROJECT_BINARY_DIR}/version.h)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
endif()

find_library(UNWIND_LIB unwind)

add_executable(kvrocks )
target_compile_features(kvrocks PRIVATE cxx_std_11)
target_compile_options(kvrocks PRIVATE -Wall -Wpedantic -g -Wsign-compare -Wreturn-type -fno-omit-frame-pointer -lunwind -O0)
target_compile_options(kvrocks PRIVATE -Wall -Wpedantic -g -Wsign-compare -Wreturn-type -fno-omit-frame-pointer -O0)
option(ENABLE_ASAN "enable ASAN santinizer" OFF)
if(ENBALE_ASAN)
target_compile_options(kvrocks PRIVATE -fsanitize=address)
Expand All @@ -70,6 +73,9 @@ if(CMAKE_THREAD_LIBS_INIT)
endif()
target_link_libraries(kvrocks PRIVATE -fno-omit-frame-pointer)
target_link_libraries(kvrocks ${EXTERNAL_LIBS})
if(UNWIND_LIB)
target_link_libraries(kvrocks PRIVATE -lunwind)
endif()
target_sources(kvrocks PRIVATE
src/cluster.cc
src/cluster.h
Expand Down Expand Up @@ -149,7 +155,7 @@ target_sources(kvrocks PRIVATE
# kvrocks2redis sync tool
add_executable(kvrocks2redis)
target_compile_features(kvrocks2redis PRIVATE cxx_std_11)
target_compile_options(kvrocks2redis PRIVATE -Wall -Wpedantic -g -Wsign-compare -Wreturn-type -lunwind)
target_compile_options(kvrocks2redis PRIVATE -Wall -Wpedantic -g -Wsign-compare -Wreturn-type)
option(ENABLE_ASAN "enable ASAN santinizer" OFF)
if(ENBALE_ASAN)
target_compile_options(kvrocks2redis PRIVATE -fno-omit-frame-pointer -fsanitize=address)
Expand All @@ -158,6 +164,9 @@ endif()
add_dependencies(kvrocks2redis libevent glog rocksdb)
target_include_directories(kvrocks2redis PRIVATE ${PROJECT_BINARY_DIR})
target_include_directories(kvrocks2redis ${EXTERNAL_INCS})
if(UNWIND_LIB)
target_link_libraries(kvrocks2redis PRIVATE -lunwind)
endif()

find_package(Threads REQUIRED)
if(THREADS_HAVE_PTHREAD_ARG)
Expand Down Expand Up @@ -332,9 +341,11 @@ add_executable(unittest

add_dependencies(unittest glog rocksdb snappy jemalloc)
target_compile_features(unittest PRIVATE cxx_std_11)
target_compile_options(unittest PRIVATE -lunwind)
message(${snappy_LIBRARIES})
target_link_libraries(unittest PRIVATE ${EXTERNAL_LIBS} -lgtest)
if(UNWIND_LIB)
target_link_libraries(unittest PRIVATE -lunwind)
endif()
target_include_directories(unittest PRIVATE ${PROJECT_BINARY_DIR})
target_include_directories(unittest ${EXTERNAL_INCS})
target_include_directories(unittest PRIVATE src)

0 comments on commit 9e6a989

Please sign in to comment.