From 1075481b2ea74ba1faf98b0ef6d3289110e0ea83 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Mon, 16 Mar 2020 14:10:10 +0100 Subject: [PATCH] move cli/src to src and combine all CMakeLists.txt --- CMakeLists.txt | 91 ++++++++++++++++++++++-- cli/CMakeLists.txt | 81 --------------------- docs/CMakeLists.txt | 7 -- {cli/src => src}/benchmark.cpp | 0 {cli/src => src}/benchmark.h | 0 {cli/src => src}/config.h.in | 0 {cli/src => src}/console.cpp | 0 {cli/src => src}/console.h | 0 {cli/src => src}/console_ansi.cpp | 0 {cli/src => src}/console_win32.cpp | 0 {cli/src => src}/core/dictionary.cpp | 0 {cli/src => src}/core/dictionary.h | 0 {cli/src => src}/core/file.cpp | 0 {cli/src => src}/core/file.h | 0 {cli/src => src}/core/isatty.cpp | 0 {cli/src => src}/core/isatty.h | 0 {cli/src => src}/core/string.cpp | 0 {cli/src => src}/core/string.h | 0 {cli/src => src}/crypto/WIF.cpp | 0 {cli/src => src}/crypto/WIF.h | 0 {cli/src => src}/crypto/base58.cpp | 0 {cli/src => src}/crypto/base58.h | 0 {cli/src => src}/crypto/checksum.h | 0 {cli/src => src}/crypto/ec.h | 0 {cli/src => src}/crypto/hash.h | 0 {cli/src => src}/crypto/openssl/ec.cpp | 0 {cli/src => src}/crypto/openssl/hash.cpp | 0 {cli/src => src}/crypto/types.h | 0 {cli/src => src}/key_search.cpp | 0 {cli/src => src}/key_search.h | 0 {cli/src => src}/key_search_helpers.cpp | 0 {cli/src => src}/key_search_helpers.h | 0 {cli/src => src}/key_search_mt.cpp | 0 {cli/src => src}/main.cpp | 0 34 files changed, 87 insertions(+), 92 deletions(-) delete mode 100644 cli/CMakeLists.txt delete mode 100644 docs/CMakeLists.txt rename {cli/src => src}/benchmark.cpp (100%) rename {cli/src => src}/benchmark.h (100%) rename {cli/src => src}/config.h.in (100%) rename {cli/src => src}/console.cpp (100%) rename {cli/src => src}/console.h (100%) rename {cli/src => src}/console_ansi.cpp (100%) rename {cli/src => src}/console_win32.cpp (100%) rename {cli/src => src}/core/dictionary.cpp (100%) rename {cli/src => src}/core/dictionary.h (100%) rename {cli/src => src}/core/file.cpp (100%) rename {cli/src => src}/core/file.h (100%) rename {cli/src => src}/core/isatty.cpp (100%) rename {cli/src => src}/core/isatty.h (100%) rename {cli/src => src}/core/string.cpp (100%) rename {cli/src => src}/core/string.h (100%) rename {cli/src => src}/crypto/WIF.cpp (100%) rename {cli/src => src}/crypto/WIF.h (100%) rename {cli/src => src}/crypto/base58.cpp (100%) rename {cli/src => src}/crypto/base58.h (100%) rename {cli/src => src}/crypto/checksum.h (100%) rename {cli/src => src}/crypto/ec.h (100%) rename {cli/src => src}/crypto/hash.h (100%) rename {cli/src => src}/crypto/openssl/ec.cpp (100%) rename {cli/src => src}/crypto/openssl/hash.cpp (100%) rename {cli/src => src}/crypto/types.h (100%) rename {cli/src => src}/key_search.cpp (100%) rename {cli/src => src}/key_search.h (100%) rename {cli/src => src}/key_search_helpers.cpp (100%) rename {cli/src => src}/key_search_helpers.h (100%) rename {cli/src => src}/key_search_mt.cpp (100%) rename {cli/src => src}/main.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d714cab..5192dfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,19 +39,102 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") endif() # -------------------------------- -# Additional project dirs +# Program # -------------------------------- -add_subdirectory( cli ) -add_subdirectory( docs ) +set (PROGRAM_EXE ${CMAKE_PROJECT_NAME}) + +set (PROGRAM_SOURCE + src/core/file.cpp + src/core/dictionary.cpp + src/core/string.cpp + src/core/isatty.cpp + src/crypto/base58.cpp + src/crypto/WIF.cpp + src/console.cpp + src/key_search.cpp + src/key_search_helpers.cpp + src/benchmark.cpp + src/main.cpp +) + +if (WIN32 AND NOT FORCE_ANSI) + set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/console_win32.cpp) +else() + # *nix should have ansi support. + set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/console_ansi.cpp) +endif() + +# Libraries +find_package(OpenSSL 1.1 REQUIRED) +set (PROGRAM_SOURCE ${PROGRAM_SOURCE} + src/crypto/openssl/ec.cpp + src/crypto/openssl/hash.cpp +) + +if (USE_THREADS) + find_package(Threads) + if (Threads_FOUND) + # Add preprocessor flag + add_definitions( "-DHAVE_THREADS=1" ) + set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/key_search_mt.cpp) + endif (Threads_FOUND) +endif (USE_THREADS) + +# Project config file +configure_file(src/config.h.in "${PROJECT_BINARY_DIR}/config.h" @ONLY) +include_directories(${PROJECT_BINARY_DIR}) + +# Include OpenSSL headers +include_directories( ${OPENSSL_INCLUDE_DIR} ) + +add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} ) + +target_link_libraries( ${PROGRAM_EXE} + PUBLIC + ${OPENSSL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} +) # -------------------------------- -# Additional install files +# Install # -------------------------------- +install(TARGETS ${PROGRAM_EXE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# Win32 specific. +if (WIN32) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (OPENSSL_LIBCRYPTO_NAME libcrypto-1_1-x64) + else() + set (OPENSSL_LIBCRYPTO_NAME libcrypto-1_1) + endif() + set( OPENSSL_LIBCRYPTO_DLL ${OPENSSL_ROOT_DIR}/bin/${OPENSSL_LIBCRYPTO_NAME}.dll ) + + # Need to copy libcrypto dll to binary folder. + add_custom_command(TARGET ${PROGRAM_EXE} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${OPENSSL_LIBCRYPTO_DLL} + ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR} + ) + + # We also need to copy libcrypto dll during install + install(FILES ${OPENSSL_LIBCRYPTO_DLL} DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif (WIN32) + +# Readme and license install(FILES README.md LICENSE LICENSE.bitcoin DESTINATION ${CMAKE_INSTALL_SHAREDIR}) +# Documentation + +if (UNIX) + configure_file( docs/eosio-keygen.1.in ${PROJECT_BINARY_DIR}/man1/eosio-keygen.1 ) + + install(DIRECTORY ${PROJECT_BINARY_DIR}/man1 + DESTINATION ${CMAKE_INSTALL_MANDIR}) +endif (UNIX) + # -------------------------------- # Package # -------------------------------- diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt deleted file mode 100644 index 469c6c5..0000000 --- a/cli/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -cmake_minimum_required(VERSION 3.15) - -# -------------------------------- -# Program -# -------------------------------- - -set (PROGRAM_EXE ${CMAKE_PROJECT_NAME}) - -set (PROGRAM_SOURCE - src/core/file.cpp - src/core/dictionary.cpp - src/core/string.cpp - src/core/isatty.cpp - src/crypto/base58.cpp - src/crypto/WIF.cpp - src/console.cpp - src/key_search.cpp - src/key_search_helpers.cpp - src/benchmark.cpp - src/main.cpp -) - -if (WIN32 AND NOT FORCE_ANSI) - set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/console_win32.cpp) -else() - # *nix should have ansi support. - set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/console_ansi.cpp) -endif() - -# Libraries -find_package(OpenSSL 1.1 REQUIRED) -set (PROGRAM_SOURCE ${PROGRAM_SOURCE} - src/crypto/openssl/ec.cpp - src/crypto/openssl/hash.cpp -) - -if (USE_THREADS) - find_package(Threads) - if (Threads_FOUND) - # Add preprocessor flag - add_definitions( "-DHAVE_THREADS=1" ) - set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/key_search_mt.cpp) - endif (Threads_FOUND) -endif (USE_THREADS) - -# Project config file -configure_file(src/config.h.in "${PROJECT_BINARY_DIR}/config.h" @ONLY) -include_directories(${PROJECT_BINARY_DIR}) - -# Include OpenSSL headers -include_directories( ${OPENSSL_INCLUDE_DIR} ) - -add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} ) - -target_link_libraries( ${PROGRAM_EXE} - PUBLIC - ${OPENSSL_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} -) - -install(TARGETS ${PROGRAM_EXE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - -# Win32 specific. -if (WIN32) - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (OPENSSL_LIBCRYPTO_NAME libcrypto-1_1-x64) - else() - set (OPENSSL_LIBCRYPTO_NAME libcrypto-1_1) - endif() - set( OPENSSL_LIBCRYPTO_DLL ${OPENSSL_ROOT_DIR}/bin/${OPENSSL_LIBCRYPTO_NAME}.dll ) - - # Need to copy libcrypto dll to binary folder. - add_custom_command(TARGET ${PROGRAM_EXE} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${OPENSSL_LIBCRYPTO_DLL} - ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR} - ) - - # We also need to copy libcrypto dll during install - install(FILES ${OPENSSL_LIBCRYPTO_DLL} DESTINATION ${CMAKE_INSTALL_BINDIR}) -endif (WIN32) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt deleted file mode 100644 index 2ca518c..0000000 --- a/docs/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -if (UNIX) - configure_file( eosio-keygen.1.in ${PROJECT_BINARY_DIR}/man1/eosio-keygen.1 ) - - install(DIRECTORY ${PROJECT_BINARY_DIR}/man1 - DESTINATION ${CMAKE_INSTALL_MANDIR}) -endif (UNIX) diff --git a/cli/src/benchmark.cpp b/src/benchmark.cpp similarity index 100% rename from cli/src/benchmark.cpp rename to src/benchmark.cpp diff --git a/cli/src/benchmark.h b/src/benchmark.h similarity index 100% rename from cli/src/benchmark.h rename to src/benchmark.h diff --git a/cli/src/config.h.in b/src/config.h.in similarity index 100% rename from cli/src/config.h.in rename to src/config.h.in diff --git a/cli/src/console.cpp b/src/console.cpp similarity index 100% rename from cli/src/console.cpp rename to src/console.cpp diff --git a/cli/src/console.h b/src/console.h similarity index 100% rename from cli/src/console.h rename to src/console.h diff --git a/cli/src/console_ansi.cpp b/src/console_ansi.cpp similarity index 100% rename from cli/src/console_ansi.cpp rename to src/console_ansi.cpp diff --git a/cli/src/console_win32.cpp b/src/console_win32.cpp similarity index 100% rename from cli/src/console_win32.cpp rename to src/console_win32.cpp diff --git a/cli/src/core/dictionary.cpp b/src/core/dictionary.cpp similarity index 100% rename from cli/src/core/dictionary.cpp rename to src/core/dictionary.cpp diff --git a/cli/src/core/dictionary.h b/src/core/dictionary.h similarity index 100% rename from cli/src/core/dictionary.h rename to src/core/dictionary.h diff --git a/cli/src/core/file.cpp b/src/core/file.cpp similarity index 100% rename from cli/src/core/file.cpp rename to src/core/file.cpp diff --git a/cli/src/core/file.h b/src/core/file.h similarity index 100% rename from cli/src/core/file.h rename to src/core/file.h diff --git a/cli/src/core/isatty.cpp b/src/core/isatty.cpp similarity index 100% rename from cli/src/core/isatty.cpp rename to src/core/isatty.cpp diff --git a/cli/src/core/isatty.h b/src/core/isatty.h similarity index 100% rename from cli/src/core/isatty.h rename to src/core/isatty.h diff --git a/cli/src/core/string.cpp b/src/core/string.cpp similarity index 100% rename from cli/src/core/string.cpp rename to src/core/string.cpp diff --git a/cli/src/core/string.h b/src/core/string.h similarity index 100% rename from cli/src/core/string.h rename to src/core/string.h diff --git a/cli/src/crypto/WIF.cpp b/src/crypto/WIF.cpp similarity index 100% rename from cli/src/crypto/WIF.cpp rename to src/crypto/WIF.cpp diff --git a/cli/src/crypto/WIF.h b/src/crypto/WIF.h similarity index 100% rename from cli/src/crypto/WIF.h rename to src/crypto/WIF.h diff --git a/cli/src/crypto/base58.cpp b/src/crypto/base58.cpp similarity index 100% rename from cli/src/crypto/base58.cpp rename to src/crypto/base58.cpp diff --git a/cli/src/crypto/base58.h b/src/crypto/base58.h similarity index 100% rename from cli/src/crypto/base58.h rename to src/crypto/base58.h diff --git a/cli/src/crypto/checksum.h b/src/crypto/checksum.h similarity index 100% rename from cli/src/crypto/checksum.h rename to src/crypto/checksum.h diff --git a/cli/src/crypto/ec.h b/src/crypto/ec.h similarity index 100% rename from cli/src/crypto/ec.h rename to src/crypto/ec.h diff --git a/cli/src/crypto/hash.h b/src/crypto/hash.h similarity index 100% rename from cli/src/crypto/hash.h rename to src/crypto/hash.h diff --git a/cli/src/crypto/openssl/ec.cpp b/src/crypto/openssl/ec.cpp similarity index 100% rename from cli/src/crypto/openssl/ec.cpp rename to src/crypto/openssl/ec.cpp diff --git a/cli/src/crypto/openssl/hash.cpp b/src/crypto/openssl/hash.cpp similarity index 100% rename from cli/src/crypto/openssl/hash.cpp rename to src/crypto/openssl/hash.cpp diff --git a/cli/src/crypto/types.h b/src/crypto/types.h similarity index 100% rename from cli/src/crypto/types.h rename to src/crypto/types.h diff --git a/cli/src/key_search.cpp b/src/key_search.cpp similarity index 100% rename from cli/src/key_search.cpp rename to src/key_search.cpp diff --git a/cli/src/key_search.h b/src/key_search.h similarity index 100% rename from cli/src/key_search.h rename to src/key_search.h diff --git a/cli/src/key_search_helpers.cpp b/src/key_search_helpers.cpp similarity index 100% rename from cli/src/key_search_helpers.cpp rename to src/key_search_helpers.cpp diff --git a/cli/src/key_search_helpers.h b/src/key_search_helpers.h similarity index 100% rename from cli/src/key_search_helpers.h rename to src/key_search_helpers.h diff --git a/cli/src/key_search_mt.cpp b/src/key_search_mt.cpp similarity index 100% rename from cli/src/key_search_mt.cpp rename to src/key_search_mt.cpp diff --git a/cli/src/main.cpp b/src/main.cpp similarity index 100% rename from cli/src/main.cpp rename to src/main.cpp