Skip to content

Cross compiling fixes, improvements and additions #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)$")
Expand Down Expand Up @@ -103,20 +103,24 @@ if (CLANG_FORMAT)
include(cmake/clang-format.cmake)
endif ()

add_subdirectory(deps)
if (BUILD_INTERNAL_DEPS)
add_subdirectory(deps)
endif()

include_directories(
# project includes
${PROJECT_SOURCE_DIR}/core
${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)
Expand Down
11 changes: 5 additions & 6 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)

Expand Down
11 changes: 8 additions & 3 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
)

Expand Down