Skip to content

Commit

Permalink
cmake: enable TESTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnnng committed Apr 14, 2018
1 parent b728917 commit 2429f03
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project(Zilliqa)
# detect operating system
message(STATUS "We are on a ${CMAKE_SYSTEM_NAME} system")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#
# check dependencies
#
Expand All @@ -34,6 +35,11 @@ endif()
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})

find_package(LevelDB REQUIRED)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

# export compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down Expand Up @@ -63,4 +69,4 @@ if(TESTS)
endif()

# add clang-format and clang-tidy targets lastly
include(cmake/LLVMExtraTools.cmake)
include(LLVMExtraTools)
27 changes: 27 additions & 0 deletions cmake/FindLevelDB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Find LevelDB

find_path(
LEVELDB_INCLUDE_DIR
NAMES leveldb/db.h
DOC "LevelDB include directory"
)

find_library(
LEVELDB_LIBRARY
NAMES leveldb
DOC "LevelDB library"
)

set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR})
set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY})

if (NOT BUILD_SHARED_LIBS AND APPLE)
find_path(SNAPPY_INCLUDE_DIR snappy.h PATH_SUFFIXES snappy)
find_library(SNAPPY_LIBRARY snappy)
set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR} ${SNAPPY_INCLUDE_DIR})
set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY} ${SNAPPY_LIBRARY})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(leveldb DEFAULT_MSG
LEVELDB_LIBRARY LEVELDB_INCLUDE_DIR)
4 changes: 3 additions & 1 deletion scripts/ci_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

# The script is supposed to be run in project root directory

if [ "$1" = "lookup" ]
Expand All @@ -8,7 +10,7 @@ then
fi

mkdir build && cd build
cmake ${CMAKE_EXTRA_OPTIONS} -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
cmake ${CMAKE_EXTRA_OPTIONS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTESTS=ON ..
make -j$(nproc)
make clang-format

2 changes: 1 addition & 1 deletion src/depends/libDatabase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
add_library (Database LevelDB.cpp MemoryDB.cpp OverlayDB.cpp)
target_include_directories (Database PUBLIC ${PROJECT_SOURCE_DIR}/src)
target_link_libraries (Database PUBLIC Common ${LevelDB_LIBRARIES} ${SNAPPY_LIBRARIES} Utils)
target_link_libraries (Database PUBLIC Common ${LEVELDB_LIBRARIES} Utils Threads::Threads)
6 changes: 3 additions & 3 deletions src/libUtils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include_directories(${Boost_INCLUDE_DIRS})
add_library (Utils DataConversion.cpp Logger.cpp SanityChecks.cpp Scheduler.cpp TimeUtils.cpp TxnRootComputationLight.cpp)
target_include_directories (Utils PUBLIC ${PROJECT_SOURCE_DIR}/src Crypto)
add_library(Utils DataConversion.cpp Logger.cpp SanityChecks.cpp Scheduler.cpp TimeUtils.cpp TxnRootComputationLight.cpp)
target_include_directories(Utils PUBLIC ${PROJECT_SOURCE_DIR}/src Crypto Boost)
target_link_libraries(Utils INTERFACE Threads::Threads)

0 comments on commit 2429f03

Please sign in to comment.