From 2f4e84c42ec82437c5b6a1edca767661db73fd0d Mon Sep 17 00:00:00 2001 From: Khachik Shahzadyan Date: Sat, 19 Oct 2024 21:17:53 +0400 Subject: [PATCH] Enable and fix for windows build by cmake project file --- .gitignore | 3 +++ _CMakeLists.txt => CMakeLists.txt | 12 ++++++++---- {_cmake => cmake}/config.h.in | 5 +++++ {_cmake => cmake}/utils.cmake | 0 {_cmake => cmake}/wallycore-config.cmake.in | 0 src/{_CMakeLists.txt => CMakeLists.txt} | 2 +- src/ccan/ccan/tap/tap.c | 5 +++-- src/ctest/{_CMakeLists.txt => CMakeLists.txt} | 10 ++++++---- 8 files changed, 26 insertions(+), 11 deletions(-) rename _CMakeLists.txt => CMakeLists.txt (83%) rename {_cmake => cmake}/config.h.in (94%) rename {_cmake => cmake}/utils.cmake (100%) rename {_cmake => cmake}/wallycore-config.cmake.in (100%) rename src/{_CMakeLists.txt => CMakeLists.txt} (98%) rename src/ctest/{_CMakeLists.txt => CMakeLists.txt} (84%) diff --git a/.gitignore b/.gitignore index 77dc28fad..3264bcde5 100644 --- a/.gitignore +++ b/.gitignore @@ -100,3 +100,6 @@ wallycore.wasm *.pdb *.ilk *.exp + +.idea +cmake-build-* \ No newline at end of file diff --git a/_CMakeLists.txt b/CMakeLists.txt similarity index 83% rename from _CMakeLists.txt rename to CMakeLists.txt index a159e2d60..13dd26b6e 100644 --- a/_CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ option(WALLYCORE_INSTALL "Enable install" OFF) option(WALLYCORE_COVERAGE "Enable coverage" OFF) option(WALLYCORE_BUILD_ELEMENTS "Build elements" ON) +if (NOT BUILD_SHARED_LIBS) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + include(cmake/utils.cmake) generate_config_file() configure_file(src/ccan_config.h ccan_config.h COPYONLY) @@ -23,15 +27,15 @@ set(SECP256K1_ENABLE_MODULE_ECDH ON) set(SECP256K1_ENABLE_MODULE_RECOVERY ON) set(SECP256K1_ENABLE_MODULE_EXTRAKEYS ON) set(SECP256K1_ENABLE_MODULE_SCHNORRSIG ON) -set(SECP256K1_ENABLE_MODULE_ELLSWIFT OFF) +set(SECP256K1_ENABLE_MODULE_ELLSWIFT ON) set(SECP256K1_ENABLE_MODULE_GENERATOR ON) set(SECP256K1_ENABLE_MODULE_RANGEPROOF ON) set(SECP256K1_ENABLE_MODULE_SURJECTIONPROOF ON) set(SECP256K1_ENABLE_MODULE_WHITELIST ON) -set(SECP256K1_ENABLE_MODULE_MUSIG OFF) -set(SECP256K1_ENABLE_MODULE_ECDSA_ADAPTOR OFF) +set(SECP256K1_ENABLE_MODULE_MUSIG ON) +set(SECP256K1_ENABLE_MODULE_ECDSA_ADAPTOR ON) set(SECP256K1_ENABLE_MODULE_ECDSA_S2C ON) -set(SECP256K1_ENABLE_MODULE_BPPP OFF) +set(SECP256K1_ENABLE_MODULE_BPPP ON) set(SECP256K1_BUILD_BENCHMARK OFF) set(SECP256K1_BUILD_TESTS OFF) set(SECP256K1_BUILD_EXHAUSTIVE_TESTS OFF) diff --git a/_cmake/config.h.in b/cmake/config.h.in similarity index 94% rename from _cmake/config.h.in rename to cmake/config.h.in index d295a82dd..6bcee039f 100644 --- a/_cmake/config.h.in +++ b/cmake/config.h.in @@ -77,6 +77,11 @@ # endif #endif +#ifdef _WIN32 + #if (!defined(_SSIZE_T_DECLARED)) && (!defined(_ssize_t)) && (!defined(ssize_t)) + #define ssize_t long long + #endif +#endif #include "ccan_config.h" #endif /*LIBWALLYCORE_CONFIG_H*/ diff --git a/_cmake/utils.cmake b/cmake/utils.cmake similarity index 100% rename from _cmake/utils.cmake rename to cmake/utils.cmake diff --git a/_cmake/wallycore-config.cmake.in b/cmake/wallycore-config.cmake.in similarity index 100% rename from _cmake/wallycore-config.cmake.in rename to cmake/wallycore-config.cmake.in diff --git a/src/_CMakeLists.txt b/src/CMakeLists.txt similarity index 98% rename from src/_CMakeLists.txt rename to src/CMakeLists.txt index eac4b999c..1c17e5a08 100644 --- a/src/_CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,7 @@ file( ) # wallycore -add_library(wallycore) +add_library(wallycore STATIC) target_sources(wallycore PRIVATE ${ccan_srcs} ${wallycore_srcs}) set_target_properties(wallycore PROPERTIES PUBLIC_HEADER "${wallycore_public_headers}") target_include_directories( diff --git a/src/ccan/ccan/tap/tap.c b/src/ccan/ccan/tap/tap.c index bf8a276c7..8bb476b83 100644 --- a/src/ccan/ccan/tap/tap.c +++ b/src/ccan/ccan/tap/tap.c @@ -28,8 +28,9 @@ #include #include #include -#include - +#ifndef _WIN32 + #include +#endif #include "tap.h" static int no_plan = 0; diff --git a/src/ctest/_CMakeLists.txt b/src/ctest/CMakeLists.txt similarity index 84% rename from src/ctest/_CMakeLists.txt rename to src/ctest/CMakeLists.txt index 785081d84..a8214bdea 100644 --- a/src/ctest/_CMakeLists.txt +++ b/src/ctest/CMakeLists.txt @@ -5,10 +5,12 @@ target_include_directories(test_bech32 PRIVATE ${CMAKE_BINARY_DIR}) target_link_libraries(test_bech32 PRIVATE wallycore) add_test(test_bech32 test_bech32) -add_executable(test_clear test_clear.c) -target_include_directories(test_clear PRIVATE ${CMAKE_BINARY_DIR}) -target_link_libraries(test_clear PRIVATE wallycore pthread) -add_test(test_clear test_clear) +if(NOT WIN32) + add_executable(test_clear test_clear.c) + target_include_directories(test_clear PRIVATE ${CMAKE_BINARY_DIR}) + target_link_libraries(test_clear PRIVATE wallycore pthread) + add_test(test_clear test_clear) +endif() add_executable(test_coinselection test_coinselection.c) target_include_directories(test_coinselection PRIVATE ${CMAKE_BINARY_DIR})