Skip to content

Commit

Permalink
Modularise CMakeLists files and integrate tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Aug 19, 2015
1 parent 4c8b220 commit 8d9eb68
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 1,369 deletions.
32 changes: 20 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,39 @@ else()
endif()

# Figure out environment.
set(CPPETHEREUM_BUILD "${CMAKE_CURRENT_SOURCE_DIR}/../cpp-ethereum/${BUILD_DIR_NAME}" CACHE STRING "The absolute build directory of cpp-ethereum.")
set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/../cpp-ethereum-cmake" CACHE PATH "The the path to the cmake directory")
set(ETH_DIR "${CMAKE_CURRENT_LIST_DIR}/../cpp-ethereum" CACHE PATH "The path to the cpp-ethereum directory")
set(BUILD_DIR_NAME "build" CACHE STRING "The name of the build directory in cpp-ethereum")
set(ETH_BUILD_DIR "${ETH_DIR}/${BUILD_DIR_NAME}")

# A place where should we look for *.cmake files
list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR})

# A place where we should look for ethereum libraries
set(CMAKE_LIBRARY_PATH ${ETH_BUILD_DIR})

# Let's find our dependencies
include(EthDependencies)
include(EthExecutableHelper)

# Figure out what compiler and system are we using
include(EthCompilerSettings)

include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
include_directories(BEFORE ..)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(libsolidity)
# Include helper macros
include(EthExecutableHelper)

# Include a directory with BuildInfo.h
include_directories(${ETH_BUILD_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../cpp-ethereum)
include_directories(${CPPETHEREUM_BUILD})

file(GLOB_RECURSE SRC_LIST "libsolidity/*.cpp")
file(GLOB_RECURSE HEADERS "libsolidity/*.h")
find_package(Eth)

include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
include_directories(BEFORE .)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${ETH_DIR})
include_directories(${CPPETHEREUM_BUILD})

set(EXECUTABLE solidity)
add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
add_subdirectory(libsolidity)
add_subdirectory(solc)
add_subdirectory(test)

# TODO installation and packaging rules
12 changes: 6 additions & 6 deletions libsolidity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB")

aux_source_directory(. SRC_LIST)

include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
include_directories(BEFORE ..)
include_directories(${Boost_INCLUDE_DIRS})

set(EXECUTABLE solidity)

file(GLOB HEADERS "*.h")

include_directories(BEFORE ..)
add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
add_dependencies(${EXECUTABLE} BuildInfo.h)

target_link_libraries(${EXECUTABLE} ${JSONCPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} evmasm)
target_link_libraries(${EXECUTABLE} devcrypto)
target_link_libraries(${EXECUTABLE} ${Boost_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${ETH_DEVCORE_LIBRARY})
target_link_libraries(${EXECUTABLE} ${ETH_EVMCORE_LIBRARY})
target_link_libraries(${EXECUTABLE} ${ETH_EVMASM_LIBRARY})
target_link_libraries(${EXECUTABLE} ${ETH_DEVCRYPTO_LIBRARY})

install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )
Expand Down
85 changes: 8 additions & 77 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,11 @@ macro (add_sources)
endif()
endmacro()

add_subdirectory(fuzzTesting)
add_subdirectory(libdevcore)
add_subdirectory(libdevcrypto)
add_subdirectory(libethcore)
add_subdirectory(libethereum)
add_subdirectory(libevm)
add_subdirectory(libnatspec)
add_subdirectory(libp2p)
add_subdirectory(external-dependencies)

if (JSCONSOLE)
add_subdirectory(libjsengine)
endif()

if (SOLIDITY)
add_subdirectory(libsolidity)
add_subdirectory(contracts)
endif ()
if (JSONRPC)
add_subdirectory(libweb3jsonrpc)
endif ()
add_subdirectory(libwhisper)
add_subdirectory(contracts)
add_subdirectory(libsolidity)

set(SRC_LIST ${SRC_LIST} ${SRC})

include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS})
include_directories(BEFORE ..)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${CRYPTOPP_INCLUDE_DIRS})
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})

if (JSCONSOLE)
include_directories(${V8_INCLUDE_DIRS})
endif()

# search for test names and create ctest tests
enable_testing()
foreach(file ${SRC_LIST})
Expand All @@ -63,59 +33,20 @@ foreach(file ${SRC_LIST})
string(SUBSTRING ${test} 6 -1 TestSuite)
elseif(test MATCHES "^CASE .*")
string(SUBSTRING ${test} 5 -1 TestCase)
add_test(NAME ${TestSuite}/${TestCase} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND testeth -t ${TestSuite}/${TestCase})
add_test(NAME ${TestSuite}/${TestCase} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND test -t ${TestSuite}/${TestCase})
endif(test MATCHES "^SUITE .*")
endforeach(test_raw)
endforeach(file)

file(GLOB HEADERS "*.h")
add_executable(testeth ${SRC_LIST} ${HEADERS})

target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
target_link_libraries(testeth ${CURL_LIBRARIES})
target_link_libraries(testeth ${CRYPTOPP_LIBRARIES})
target_link_libraries(testeth ethereum)
target_link_libraries(testeth ethcore)
if (NOT WIN32)
target_link_libraries(testeth secp256k1)
endif ()

if (JSCONSOLE)
target_link_libraries(testeth jsengine)
endif()
add_executable(test ${SRC_LIST} ${HEADERS})

if (SOLIDITY)
target_link_libraries(testeth solidity)
endif ()

target_link_libraries(testeth testutils)

if (GUI AND NOT JUSTTESTS)
target_link_libraries(testeth webthree)
target_link_libraries(testeth natspec)
endif()

if (JSONRPC)
target_link_libraries(testeth web3jsonrpc)
target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES})
endif()
target_link_libraries(test ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
target_link_libraries(test ${ETH_ETHEREUM_LIBRARY})
target_link_libraries(test ${ETH_ETHCORE_LIBRARY})
target_link_libraries(test solidity)

enable_testing()
set(CTEST_OUTPUT_ON_FAILURE TRUE)

include(EthUtils)

eth_add_test(ClientBase
ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=1
ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=3
ARGS --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=10
ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=1
ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=3
ARGS --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=10
)

eth_add_test(JsonRpc
ARGS --eth_testfile=BlockTests/bcJS_API_Test
ARGS --eth_testfile=BlockTests/bcValidBlockTest
)

Loading

0 comments on commit 8d9eb68

Please sign in to comment.