diff --git a/CMakeLists.txt b/CMakeLists.txt index 13db013..e81fa4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,6 @@ project(eosio-keygen set( PROJECT_MAINTAINER "Henrik Hautakoski ") -# Options -option(FORCE_ANSI "Force ANSI console colors even on windows" OFF) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") # Use installpath from GNUInstallDirs as default. @@ -37,59 +34,25 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_definitions( "-D_CRT_SECURE_NO_WARNINGS=1" ) endif() -# -------------------------------- -# Common code -# -------------------------------- -add_subdirectory( common ) - -# -------------------------------- -# Program -# -------------------------------- - -set (PROGRAM_EXE ${CMAKE_PROJECT_NAME}) - -set (PROGRAM_SOURCE - src/isatty.cpp - src/cli_key_search_result.cpp - src/console.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() - # Project config file -configure_file(src/config.h.in "${PROJECT_BINARY_DIR}/config.h" @ONLY) +configure_file(config.h.in "${PROJECT_BINARY_DIR}/config.h" @ONLY) include_directories(${PROJECT_BINARY_DIR}) -add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} ) +# -------------------------------- +# Subdirectories +# -------------------------------- -target_link_libraries( ${PROGRAM_EXE} PUBLIC common ) +add_subdirectory( common ) +add_subdirectory( cli ) # -------------------------------- # Install # -------------------------------- -install(TARGETS ${PROGRAM_EXE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - # Readme and license install(FILES README.md LICENSE 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 new file mode 100644 index 0000000..9080728 --- /dev/null +++ b/cli/CMakeLists.txt @@ -0,0 +1,42 @@ +# Options +option(FORCE_ANSI "Force ANSI console colors even on windows" OFF) + +# -------------------------------- +# Program +# -------------------------------- + +set (PROGRAM_EXE ${CMAKE_PROJECT_NAME}) + +set (PROGRAM_SOURCE + isatty.cpp + cli_key_search_result.cpp + console.cpp + benchmark.cpp + main.cpp +) + +if (WIN32 AND NOT FORCE_ANSI) + set (PROGRAM_SOURCE ${PROGRAM_SOURCE} console_win32.cpp) +else() + # *nix should have ansi support. + set (PROGRAM_SOURCE ${PROGRAM_SOURCE} console_ansi.cpp) +endif() + +add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} ) + +target_link_libraries( ${PROGRAM_EXE} PUBLIC common ) + +# -------------------------------- +# Install +# -------------------------------- + +install(TARGETS ${PROGRAM_EXE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +# 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) diff --git a/src/benchmark.cpp b/cli/benchmark.cpp similarity index 100% rename from src/benchmark.cpp rename to cli/benchmark.cpp diff --git a/src/benchmark.h b/cli/benchmark.h similarity index 100% rename from src/benchmark.h rename to cli/benchmark.h diff --git a/src/cli_key_search_result.cpp b/cli/cli_key_search_result.cpp similarity index 100% rename from src/cli_key_search_result.cpp rename to cli/cli_key_search_result.cpp diff --git a/src/cli_key_search_result.h b/cli/cli_key_search_result.h similarity index 100% rename from src/cli_key_search_result.h rename to cli/cli_key_search_result.h diff --git a/src/console.cpp b/cli/console.cpp similarity index 100% rename from src/console.cpp rename to cli/console.cpp diff --git a/src/console.h b/cli/console.h similarity index 100% rename from src/console.h rename to cli/console.h diff --git a/src/console_ansi.cpp b/cli/console_ansi.cpp similarity index 100% rename from src/console_ansi.cpp rename to cli/console_ansi.cpp diff --git a/src/console_win32.cpp b/cli/console_win32.cpp similarity index 100% rename from src/console_win32.cpp rename to cli/console_win32.cpp diff --git a/docs/eosio-keygen.1.in b/cli/docs/eosio-keygen.1.in similarity index 100% rename from docs/eosio-keygen.1.in rename to cli/docs/eosio-keygen.1.in diff --git a/src/isatty.cpp b/cli/isatty.cpp similarity index 100% rename from src/isatty.cpp rename to cli/isatty.cpp diff --git a/src/isatty.h b/cli/isatty.h similarity index 100% rename from src/isatty.h rename to cli/isatty.h diff --git a/src/main.cpp b/cli/main.cpp similarity index 100% rename from src/main.cpp rename to cli/main.cpp diff --git a/src/config.h.in b/config.h.in similarity index 100% rename from src/config.h.in rename to config.h.in