Skip to content

Commit

Permalink
Fixed C++20 and macos build (#1976)
Browse files Browse the repository at this point in the history
* added BEAM_CPP_20_STANDARD option

* WIP

* wip
  • Loading branch information
anatolse authored May 25, 2024
1 parent bdbedba commit afbf31f
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 20 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/libbitcoin/src/chain/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ bool transaction::all_inputs_final() const

bool transaction::is_final(size_t block_height, uint32_t block_time) const
{
const auto max_locktime = [=, this]()
const auto max_locktime = [=]()
{
return locktime_ < locktime_threshold ?
safe_unsigned<uint32_t>(block_height) : block_time;
Expand Down
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ target_include_directories(beam INTERFACE
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/3rdparty)

target_compile_features(beam INTERFACE cxx_std_20)


file(WRITE ${PROJECT_SOURCE_DIR}/beam_version.gen "${PROJECT_VERSION}")
add_definitions(-DBEAM_LIB_VERSION="${BEAM_VERSION}")
Expand All @@ -121,7 +119,20 @@ endif()

include(AddTest)

set(CMAKE_CXX_STANDARD 20)
option(BEAM_CPP_20_STANDARD "Build wallet with C++20 standard" OFF)
message("BEAM_CPP_20_STANDARD is ${BEAM_CPP_20_STANDARD}")


if (BEAM_CPP_20_STANDARD)
set(CMAKE_CXX_STANDARD 20)
set(BEAM_INTERFACE_STANDARD, cxx_std_20)
else()
set(CMAKE_CXX_STANDARD 17)
set(BEAM_INTERFACE_STANDARD, cxx_std_17)
endif()

target_compile_features(beam INTERFACE ${BEAM_INTERFACE_STANDARD})

set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(BEAM_USE_AVX FALSE)
Expand Down
6 changes: 5 additions & 1 deletion keykeeper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 3.13)
set(TARGET_NAME wasm-key-keeper)

if(EMSCRIPTEN)
set(CMAKE_CXX_STANDARD 20)
if (BEAM_CPP_20_STANDARD)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

Expand Down
2 changes: 1 addition & 1 deletion utility/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if (MSVC)
endif()

add_library(utility STATIC ${UTILITY_SRC} ${IO_SRC})
target_compile_features(utility PUBLIC cxx_std_20)
target_compile_features(utility PUBLIC ${BEAM_INTERFACE_STANDARD})

if (NOT EMSCRIPTEN)
add_library(cli STATIC ${CLI_SRC})
Expand Down
4 changes: 2 additions & 2 deletions wallet/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ target_link_libraries(wallet_client_no_ipfs
PRIVATE http
)

target_compile_features(wallet_client PUBLIC cxx_std_20)
target_compile_features(wallet_client_no_ipfs PUBLIC cxx_std_20)
target_compile_features(wallet_client PUBLIC ${BEAM_INTERFACE_STANDARD})
target_compile_features(wallet_client_no_ipfs PUBLIC ${BEAM_INTERFACE_STANDARD})

add_subdirectory(extensions)

Expand Down
2 changes: 1 addition & 1 deletion wallet/client/extensions/broadcast_gateway/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ target_link_libraries(broadcast_gateway
wallet_core
)

target_compile_features(broadcast_gateway PUBLIC cxx_std_20)
target_compile_features(broadcast_gateway PUBLIC ${BEAM_INTERFACE_STANDARD})

2 changes: 1 addition & 1 deletion wallet/client/extensions/dex_board/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ target_link_libraries(dex_board
wallet
)

target_compile_features(dex_board PUBLIC cxx_std_20)
target_compile_features(dex_board PUBLIC ${BEAM_INTERFACE_STANDARD})

2 changes: 1 addition & 1 deletion wallet/client/extensions/export/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ if(BEAM_ATOMIC_SWAP_SUPPORT)
target_compile_definitions(export PUBLIC BEAM_ATOMIC_SWAP_SUPPORT)
endif()

target_compile_features(export PUBLIC cxx_std_20)
target_compile_features(export PUBLIC ${BEAM_INTERFACE_STANDARD})

2 changes: 1 addition & 1 deletion wallet/client/extensions/news_channels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ target_link_libraries(news_channels
wallet_core
)

target_compile_features(news_channels PUBLIC cxx_std_20)
target_compile_features(news_channels PUBLIC ${BEAM_INTERFACE_STANDARD})

2 changes: 1 addition & 1 deletion wallet/client/extensions/notifications/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ target_link_libraries(notifications
wallet_core
)

target_compile_features(notifications PUBLIC cxx_std_20)
target_compile_features(notifications PUBLIC ${BEAM_INTERFACE_STANDARD})

2 changes: 1 addition & 1 deletion wallet/client/extensions/offers_board/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ target_link_libraries(swap_offers_board
wallet
)

target_compile_features(swap_offers_board PUBLIC cxx_std_20)
target_compile_features(swap_offers_board PUBLIC ${BEAM_INTERFACE_STANDARD})

2 changes: 1 addition & 1 deletion wallet/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ target_link_libraries(wallet_core
sqlite
)

target_compile_features(wallet_core PUBLIC cxx_std_20)
target_compile_features(wallet_core PUBLIC ${BEAM_INTERFACE_STANDARD})


if (NOT ANDROID AND NOT IOS)
Expand Down
4 changes: 2 additions & 2 deletions wallet/core/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,13 @@ namespace beam::wallet

}

bool TxParameters::operator==(const TxParameters& other)
bool TxParameters::operator==(const TxParameters& other) const
{
return m_ID == other.m_ID &&
m_Parameters == other.m_Parameters;
}

bool TxParameters::operator!=(const TxParameters& other)
bool TxParameters::operator!=(const TxParameters& other) const
{
return !(*this == other);
}
Expand Down
4 changes: 2 additions & 2 deletions wallet/core/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ namespace beam::wallet
public:
TxParameters(const boost::optional<TxID>& txID = {});

bool operator==(const TxParameters& other);
bool operator!=(const TxParameters& other);
bool operator==(const TxParameters& other) const;
bool operator!=(const TxParameters& other) const;

const boost::optional<TxID>& GetTxID() const;

Expand Down
6 changes: 5 additions & 1 deletion wasmclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 3.13)
set(TARGET_NAME wasm-client)

if(EMSCRIPTEN)
set(CMAKE_CXX_STANDARD 20)
if (BEAM_CPP_20_STANDARD)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-value \
-pthread \
Expand Down

0 comments on commit afbf31f

Please sign in to comment.