diff --git a/CMakeLists.txt b/CMakeLists.txt index 91aac5d..2066de2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,33 +28,6 @@ if (WIN32) set( CMAKE_INSTALL_MANDIR "." ) endif (WIN32) -# -------------------------------- -# 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() - # Configure the compiler options set( CMAKE_CXX_STANDARD 11 ) set( CMAKE_CXX_STANDARD_REQUIRED ON ) @@ -66,58 +39,16 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_definitions( "-D_CRT_SECURE_NO_WARNINGS=1" ) endif() -# Libraries -find_package(OpenSSL 1.1 REQUIRED) -set (PROGRAM_SOURCE ${PROGRAM_SOURCE} - src/crypto/openssl/ec.cpp - src/crypto/openssl/hash.cpp -) +# -------------------------------- +# Additional project dirs +# -------------------------------- -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) +add_subdirectory( cli ) +add_subdirectory( docs ) -# Project config file -configure_file(src/config.h.in "${CMAKE_CURRENT_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) +if (UNIX AND EXTRAS) + add_subdirectory( extras ) +endif() # -------------------------------- # Additional install files @@ -125,25 +56,3 @@ endif (WIN32) install(FILES README.md LICENSE LICENSE.bitcoin DESTINATION ${CMAKE_INSTALL_SHAREDIR}) - -configure_file( docs/eosio-keygen.1.in - ${PROJECT_BINARY_DIR}/man1/eosio-keygen.1 ) - -if (UNIX) -install(DIRECTORY ${PROJECT_BINARY_DIR}/man1 - DESTINATION ${CMAKE_INSTALL_MANDIR}) -endif (UNIX) - -# -------------------------------- -# Extras -# -------------------------------- - -if (UNIX AND EXTRAS) - add_subdirectory(extras) -endif() - -# -------------------------------- -# Misc -# -------------------------------- - -include( package ) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt new file mode 100644 index 0000000..9d9a555 --- /dev/null +++ b/cli/CMakeLists.txt @@ -0,0 +1,83 @@ +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) + +include( package ) diff --git a/debian_control.in b/cli/debian_control.in similarity index 100% rename from debian_control.in rename to cli/debian_control.in diff --git a/src/benchmark.cpp b/cli/src/benchmark.cpp similarity index 100% rename from src/benchmark.cpp rename to cli/src/benchmark.cpp diff --git a/src/benchmark.h b/cli/src/benchmark.h similarity index 100% rename from src/benchmark.h rename to cli/src/benchmark.h diff --git a/src/config.h.in b/cli/src/config.h.in similarity index 100% rename from src/config.h.in rename to cli/src/config.h.in diff --git a/src/console.cpp b/cli/src/console.cpp similarity index 100% rename from src/console.cpp rename to cli/src/console.cpp diff --git a/src/console.h b/cli/src/console.h similarity index 100% rename from src/console.h rename to cli/src/console.h diff --git a/src/console_ansi.cpp b/cli/src/console_ansi.cpp similarity index 100% rename from src/console_ansi.cpp rename to cli/src/console_ansi.cpp diff --git a/src/console_win32.cpp b/cli/src/console_win32.cpp similarity index 100% rename from src/console_win32.cpp rename to cli/src/console_win32.cpp diff --git a/src/core/dictionary.cpp b/cli/src/core/dictionary.cpp similarity index 100% rename from src/core/dictionary.cpp rename to cli/src/core/dictionary.cpp diff --git a/src/core/dictionary.h b/cli/src/core/dictionary.h similarity index 100% rename from src/core/dictionary.h rename to cli/src/core/dictionary.h diff --git a/src/core/file.cpp b/cli/src/core/file.cpp similarity index 100% rename from src/core/file.cpp rename to cli/src/core/file.cpp diff --git a/src/core/file.h b/cli/src/core/file.h similarity index 100% rename from src/core/file.h rename to cli/src/core/file.h diff --git a/src/core/isatty.cpp b/cli/src/core/isatty.cpp similarity index 100% rename from src/core/isatty.cpp rename to cli/src/core/isatty.cpp diff --git a/src/core/isatty.h b/cli/src/core/isatty.h similarity index 100% rename from src/core/isatty.h rename to cli/src/core/isatty.h diff --git a/src/core/string.cpp b/cli/src/core/string.cpp similarity index 100% rename from src/core/string.cpp rename to cli/src/core/string.cpp diff --git a/src/core/string.h b/cli/src/core/string.h similarity index 100% rename from src/core/string.h rename to cli/src/core/string.h diff --git a/src/crypto/WIF.cpp b/cli/src/crypto/WIF.cpp similarity index 100% rename from src/crypto/WIF.cpp rename to cli/src/crypto/WIF.cpp diff --git a/src/crypto/WIF.h b/cli/src/crypto/WIF.h similarity index 100% rename from src/crypto/WIF.h rename to cli/src/crypto/WIF.h diff --git a/src/crypto/base58.cpp b/cli/src/crypto/base58.cpp similarity index 100% rename from src/crypto/base58.cpp rename to cli/src/crypto/base58.cpp diff --git a/src/crypto/base58.h b/cli/src/crypto/base58.h similarity index 100% rename from src/crypto/base58.h rename to cli/src/crypto/base58.h diff --git a/src/crypto/checksum.h b/cli/src/crypto/checksum.h similarity index 100% rename from src/crypto/checksum.h rename to cli/src/crypto/checksum.h diff --git a/src/crypto/ec.h b/cli/src/crypto/ec.h similarity index 100% rename from src/crypto/ec.h rename to cli/src/crypto/ec.h diff --git a/src/crypto/hash.h b/cli/src/crypto/hash.h similarity index 100% rename from src/crypto/hash.h rename to cli/src/crypto/hash.h diff --git a/src/crypto/openssl/ec.cpp b/cli/src/crypto/openssl/ec.cpp similarity index 100% rename from src/crypto/openssl/ec.cpp rename to cli/src/crypto/openssl/ec.cpp diff --git a/src/crypto/openssl/hash.cpp b/cli/src/crypto/openssl/hash.cpp similarity index 100% rename from src/crypto/openssl/hash.cpp rename to cli/src/crypto/openssl/hash.cpp diff --git a/src/crypto/types.h b/cli/src/crypto/types.h similarity index 100% rename from src/crypto/types.h rename to cli/src/crypto/types.h diff --git a/src/key_search.cpp b/cli/src/key_search.cpp similarity index 100% rename from src/key_search.cpp rename to cli/src/key_search.cpp diff --git a/src/key_search.h b/cli/src/key_search.h similarity index 100% rename from src/key_search.h rename to cli/src/key_search.h diff --git a/src/key_search_helpers.cpp b/cli/src/key_search_helpers.cpp similarity index 100% rename from src/key_search_helpers.cpp rename to cli/src/key_search_helpers.cpp diff --git a/src/key_search_helpers.h b/cli/src/key_search_helpers.h similarity index 100% rename from src/key_search_helpers.h rename to cli/src/key_search_helpers.h diff --git a/src/key_search_mt.cpp b/cli/src/key_search_mt.cpp similarity index 100% rename from src/key_search_mt.cpp rename to cli/src/key_search_mt.cpp diff --git a/src/main.cpp b/cli/src/main.cpp similarity index 100% rename from src/main.cpp rename to cli/src/main.cpp diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 0000000..2ca518c --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1,7 @@ + +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)