diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ac568fc71..bd97cb8ba9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,22 +34,13 @@ endif () set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -include(CheckCXXCompilerFlag) -include(cmake/toolchain-util.cmake) -include(cmake/dependencies.cmake) -include(cmake/functions.cmake) -include(cmake/san.cmake) - # export compile commands for clang-tidy to analyse only changed files set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -print("C flags: ${CMAKE_C_FLAGS}") -print("CXX flags: ${CMAKE_CXX_FLAGS}") -print("Using CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") - option(TESTING "Build tests" ON) option(TESTING_PROOFS "Build proofs tests" OFF) option(TESTING_ACTORS "Build actors tests" OFF) +option(BUILD_INTERNAL_DEPS "Build internal dependencies from git submodules" ON) option(CLANG_FORMAT "Enable clang-format target" ON) option(CLANG_TIDY "Enable clang-tidy checks during compilation" OFF) option(COVERAGE "Enable generation of coverage info" OFF) @@ -60,6 +51,15 @@ option(MSAN "Enable memory sanitizer" OFF) option(TSAN "Enable thread sanitizer" OFF) option(UBSAN "Enable UB sanitizer" OFF) +include(CheckCXXCompilerFlag) +include(cmake/toolchain-util.cmake) +include(cmake/dependencies.cmake) +include(cmake/functions.cmake) +include(cmake/san.cmake) + +print("C flags: ${CMAKE_C_FLAGS}") +print("CXX flags: ${CMAKE_CXX_FLAGS}") +print("Using CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") ## setup compilation flags if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(AppleClang|Clang|GNU)$") @@ -103,7 +103,9 @@ if (CLANG_FORMAT) include(cmake/clang-format.cmake) endif () -add_subdirectory(deps) +if (BUILD_INTERNAL_DEPS) + add_subdirectory(deps) +endif() include_directories( # project includes @@ -111,12 +113,14 @@ include_directories( ${PROJECT_SOURCE_DIR}/libs ) -include_directories( - SYSTEM - # system includes - deps/indicators/include - deps/libsecp256k1/include -) +if (BUILD_INTERNAL_DEPS) + include_directories( + SYSTEM + # system includes + deps/indicators/include + deps/libsecp256k1/include + ) +endif() add_subdirectory(libs) add_subdirectory(core) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 69b2a92caf..f209e8ae11 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -1,9 +1,11 @@ # hunter dependencies # https://docs.hunter.sh/en/latest/packages/ -# https://docs.hunter.sh/en/latest/packages/pkg/GTest.html -hunter_add_package(GTest) -find_package(GTest CONFIG REQUIRED) +if (TESTING) + # https://docs.hunter.sh/en/latest/packages/pkg/GTest.html + hunter_add_package(GTest) + find_package(GTest CONFIG REQUIRED) +endif() # https://docs.hunter.sh/en/latest/packages/pkg/Boost.html hunter_add_package(Boost COMPONENTS date_time filesystem iostreams random program_options thread) @@ -45,9 +47,6 @@ find_package(leveldb CONFIG REQUIRED) hunter_add_package(libp2p) find_package(libp2p CONFIG REQUIRED) -hunter_add_package(c-ares) -find_package(c-ares CONFIG REQUIRED) - hunter_add_package(soralog) find_package(soralog CONFIG REQUIRED) diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 178b7cce52..e2fc4cafed 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -46,8 +46,13 @@ function(add_flag flag) endfunction() function(compile_proto_to_cpp PB_H PB_CC PROTO) - get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc IMPORTED_LOCATION_RELEASE) + if (NOT Protobuf_INCLUDE_DIR) + get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) + endif() + if (NOT Protobuf_PROTOC_EXECUTABLE) + get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc IMPORTED_LOCATION_RELEASE) + set(PROTOBUF_DEPENDS protobuf::protoc) + endif() if (NOT Protobuf_PROTOC_EXECUTABLE) message(FATAL_ERROR "Protobuf_PROTOC_EXECUTABLE is empty") @@ -73,7 +78,7 @@ function(compile_proto_to_cpp PB_H PB_CC PROTO) COMMAND ${GEN_COMMAND} ARGS -I${PROJECT_SOURCE_DIR}/core -I${GEN_ARGS} -I${CMAKE_CURRENT_SOURCE_DIR} --cpp_out=${SCHEMA_OUT_DIR} ${PROTO_ABS} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - DEPENDS protobuf::protoc + DEPENDS ${PROTOBUF_DEPENDS} VERBATIM )