cmake_minimum_required ( VERSION 3.5 )
project ( neroshop ) # tested on Ubuntu 20.04 LTS (focal) with gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
set ( CMAKE_CXX_STANDARD 17 )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
set ( VERSION_MAJOR "0" )
set ( VERSION_MINOR "1" )
set ( VERSION_PATCH "0" )
set ( PROJECT_VERSION ${ VERSION_MAJOR } . ${ VERSION_MINOR } . ${ VERSION_PATCH } )
option ( NEROSHOP_BUILD_TESTS "Build neroshop tests" OFF )
option ( NEROSHOP_BUILD_CLI "Build neroshop CLI" OFF ) # CLI is for testing only. This is a GUI-based ecommerce app so BUILD_CLI will be off by default
option ( NEROSHOP_BUILD_GUI "Build neroshop GUI" ON )
include ( CMakeDependentOption )
cmake_dependent_option ( NEROSHOP_USE_QT "Build neroshop with Qt" ON "NEROSHOP_BUILD_GUI" OFF )
option ( UUID_SYSTEM_GENERATOR "Enable operating system uuid generator" OFF )
option ( UUID_TIME_GENERATOR "Enable experimental time-based uuid generator" OFF )
cmake_dependent_option ( NEROSHOP_USE_SYSTEM_SOCKETS "Build neroshop with system sockets" ON "NOT NEROSHOP_USE_LIBZMQ;NOT NEROSHOP_USE_LIBUV" OFF )
cmake_dependent_option ( NEROSHOP_USE_LIBZMQ "Build neroshop with LibZMQ" ON "NOT NEROSHOP_USE_LIBUV;NOT NEROSHOP_USE_SYSTEM_SOCKETS" OFF )
option ( NEROSHOP_USE_GRPC "Build neroshop with gRPC" OFF )
cmake_dependent_option ( NEROSHOP_USE_SYSTEM_GRPC "Use system installed gRPC" ON "NEROSHOP_USE_GRPC;USE_SYSTEM_GRPC" OFF )
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/external/monero-cpp/external/monero-project/cmake" )
######################################
set ( NEROSHOP_SRC_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /src )
set ( NEROSHOP_CONSOLE_SRC_DIR ${ NEROSHOP_SRC_DIR } /console )
set ( NEROSHOP_CORE_SRC_DIR ${ NEROSHOP_SRC_DIR } /core )
set ( NEROSHOP_DAEMON_SRC_DIR ${ NEROSHOP_SRC_DIR } /daemon )
set ( NEROSHOP_GUI_SRC_DIR ${ NEROSHOP_SRC_DIR } /gui )
######################################
if ( NEROSHOP_BUILD_GUI AND NEROSHOP_USE_QT )
set ( CMAKE_AUTOMOC ON )
#set(CMAKE_AUTORCC ON)
#set(CMAKE_AUTOUIC ON)
if ( CMAKE_VERSION VERSION_LESS "3.7.0" )
set ( CMAKE_INCLUDE_CURRENT_DIR ON )
endif ( )
find_package ( Qt5 COMPONENTS Qml Quick Gui Concurrent #[[QuickControls2]])# REQUIRED) # v5.12.8
# add the qml.qrc file
qt5_add_resources ( neroshop_res qml.qrc ) #qt_add_resources# <= introduced in Qt 5.15 and higher
endif ( )
######################################
if ( NOT WIN32 )
string ( ASCII 27 Esc )
set ( ColourReset "${Esc}[m" )
set ( ColourBold "${Esc}[1m" )
set ( Red "${Esc}[31m" )
set ( Green "${Esc}[32m" )
set ( Yellow "${Esc}[33m" )
set ( Blue "${Esc}[34m" )
set ( Magenta "${Esc}[35m" )
set ( Cyan "${Esc}[36m" )
set ( White "${Esc}[37m" )
set ( BoldRed "${Esc}[1;91m" )
set ( BoldGreen "${Esc}[1;32m" )
set ( BoldYellow "${Esc}[1;33m" )
set ( BoldBlue "${Esc}[1;34m" )
set ( BoldMagenta "${Esc}[1;35m" )
set ( BoldCyan "${Esc}[1;36m" )
set ( BoldWhite "${Esc}[1;37m" )
endif ( )
######################################
if ( WIN32 )
endif ( )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux" )
# Set compiler-specific flags
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -w" ) # -fsanitize=address") #-w=ignores all warnings
message ( STATUS "Building with clang" )
else ( )
message ( STATUS "Building with gcc/g++" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -no-pie -Wno-deprecated-declarations" ) # -w")# -fsanitize=address") # -no-pie=can run outside terminal
endif ( )
endif ( )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
endif ( )
######################################
set ( MONERO_ROOT_DIR "${CMAKE_SOURCE_DIR}/external/monero-cpp/external/monero-project" )
set ( MONERO_SRC_DIR "${MONERO_ROOT_DIR}/src" )
####################
# Extra libraries
if ( APPLE )
if ( DEPENDS )
list ( APPEND EXTRA_LIBRARIES "-framework Foundation -framework IOKit -framework AppKit" )
else ( )
find_library ( COREFOUNDATION CoreFoundation )
find_library ( IOKIT IOKit )
find_library ( APPKIT AppKit )
list ( APPEND EXTRA_LIBRARIES ${ IOKIT } )
list ( APPEND EXTRA_LIBRARIES ${ COREFOUNDATION } )
list ( APPEND EXTRA_LIBRARIES ${ APPKIT } )
endif ( )
endif ( )
if ( WIN32 )
list ( APPEND EXTRA_LIBRARIES setupapi )
endif ( )
message ( STATUS EXTRA_LIBRARIES: ${ EXTRA_LIBRARIES } )
######################################
# Protobuf
include ( FindProtobuf )
find_package ( Protobuf )
message ( STATUS "Protobuf lib: ${Protobuf_LIBRARY}, inc: ${Protobuf_INCLUDE_DIR}, protoc: ${Protobuf_PROTOC_EXECUTABLE}" )
######################################
# LibUSB
find_library ( usb_LIBRARY NAMES usb-1.0 libusb usb )
set ( LibUSB_LIBRARIES ${ usb_LIBRARY } )
######################################
# Boost
set ( Boost_NO_BOOST_CMAKE 1 )
set ( Boost_USE_MULTITHREADED ON )
find_package ( Boost 1.58 QUIET REQUIRED COMPONENTS chrono date_time filesystem program_options regex serialization wserialization system thread )
message ( STATUS "Using Boost include dir at ${Boost_INCLUDE_DIR}" )
######################################
# OpenSSL
if ( APPLE AND NOT IOS )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++14" )
if ( NOT OPENSSL_ROOT_DIR )
EXECUTE_PROCESS ( COMMAND brew --prefix openssl
O U T P U T _ V A R I A B L E O P E N S S L _ R O O T _ D I R
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
message ( STATUS "Using OpenSSL found at ${OPENSSL_ROOT_DIR}" )
endif ( )
endif ( )
find_package ( OpenSSL REQUIRED )
message ( STATUS "Using OpenSSL include dir at ${OPENSSL_INCLUDE_DIR}" )
if ( STATIC AND NOT IOS )
if ( UNIX )
set ( OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES};${CMAKE_DL_LIBS};${CMAKE_THREAD_LIBS_INIT}" )
endif ( )
endif ( )
######################################
# libsodium
find_library ( SODIUM_LIBRARY sodium REQUIRED )
message ( STATUS "Using libsodium: ${SODIUM_LIBRARY}" )
######################################
# HIDAPI
if ( APPLE )
include_directories ( SYSTEM /usr/include/malloc )
if ( POLICY CMP0042 )
cmake_policy ( SET CMP0042 NEW )
endif ( )
endif ( )
find_package ( HIDAPI )
if ( HIDAPI_FOUND )
message ( STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}" )
add_definitions ( -DHAVE_HIDAPI )
link_directories ( ${ LIBHIDAPI_LIBRARY_DIRS } )
endif ( )
if ( NOT HIDAPI_FOUND )
message ( "HIDAPI libraries not found. Will manually set libraries." )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux" )
set ( UDEV_LIBRARY libudev.so )
set ( HIDAPI_LIBRARY ${ UDEV_LIBRARY } libhidapi-libusb.so ) # or libhidapi-hidraw.so # has to be dynamically linked or you'll get "undefined reference to `libusb_get_device_address'" error
endif ( )
endif ( )
######################################
# Unbound
find_package ( Unbound )
if ( "${UNBOUND_LIBRARIES}" MATCHES "libunbound" )
message ( STATUS "Using libunbound: ${UNBOUND_LIBRARIES}" )
add_library ( unbound SHARED IMPORTED )
set_target_properties ( unbound PROPERTIES IMPORTED_LOCATION
$ { U N B O U N D _ L I B R A R I E S } )
endif ( )
######################################
# Monero
set ( MONERO_BUILD_DIR "${MONERO_ROOT_DIR}/build/release" CACHE STRING "Monero project build directory" )
message ( STATUS "Using monero-project build: " ${ MONERO_BUILD_DIR } )
add_library ( wallet STATIC IMPORTED )
set_target_properties ( wallet PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / l i b / l i b w a l l e t . a )
# libwallet-crypto.a provides x86_64 asm for some wallet functions
if ( EXISTS ${ MONERO_BUILD_DIR } /src/crypto/wallet/libwallet-crypto.a )
add_library ( wallet_crypto_lib STATIC IMPORTED )
set_target_properties ( wallet_crypto_lib PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / c r y p t o / w a l l e t / l i b w a l l e t - c r y p t o . a )
set ( wallet_crypto wallet_crypto_lib )
endif ( )
add_library ( lmdb STATIC IMPORTED )
set_target_properties ( lmdb PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / e x t e r n a l / d b _ d r i v e r s / l i b l m d b / l i b l m d b . a )
add_library ( epee STATIC IMPORTED )
set_target_properties ( epee PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / c o n t r i b / e p e e / s r c / l i b e p e e . a )
add_library ( rpc_base STATIC IMPORTED )
set_target_properties ( rpc_base PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / r p c / l i b r p c _ b a s e . a )
add_library ( net STATIC IMPORTED )
set_target_properties ( net PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / n e t / l i b n e t . a )
add_library ( hardforks STATIC IMPORTED )
set_target_properties ( hardforks PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / h a r d f o r k s / l i b h a r d f o r k s . a )
add_library ( easylogging STATIC IMPORTED )
set_target_properties ( easylogging PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / e x t e r n a l / e a s y l o g g i n g + + / l i b e a s y l o g g i n g . a )
add_library ( cryptonote_core STATIC IMPORTED )
set_target_properties ( cryptonote_core PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / c r y p t o n o t e _ c o r e / l i b c r y p t o n o t e _ c o r e . a )
add_library ( cryptonote_protocol STATIC IMPORTED )
set_target_properties ( cryptonote_protocol PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / c r y p t o n o t e _ p r o t o c o l / l i b c r y p t o n o t e _ p r o t o c o l . a )
add_library ( cryptonote_basic STATIC IMPORTED )
set_target_properties ( cryptonote_basic PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / c r y p t o n o t e _ b a s i c / l i b c r y p t o n o t e _ b a s i c . a )
add_library ( cryptonote_format_utils_basic STATIC IMPORTED )
set_target_properties ( cryptonote_format_utils_basic PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / c r y p t o n o t e _ b a s i c / l i b c r y p t o n o t e _ f o r m a t _ u t i l s _ b a s i c . a )
add_library ( mnemonics STATIC IMPORTED )
set_target_properties ( mnemonics PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / m n e m o n i c s / l i b m n e m o n i c s . a )
add_library ( common STATIC IMPORTED )
set_target_properties ( common PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / c o m m o n / l i b c o m m o n . a )
add_library ( cncrypto STATIC IMPORTED )
set_target_properties ( cncrypto PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / c r y p t o / l i b c n c r y p t o . a )
add_library ( ringct STATIC IMPORTED )
set_target_properties ( ringct PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / r i n g c t / l i b r i n g c t . a )
add_library ( ringct_basic STATIC IMPORTED )
set_target_properties ( ringct_basic PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / r i n g c t / l i b r i n g c t _ b a s i c . a )
add_library ( blockchain_db STATIC IMPORTED )
set_target_properties ( blockchain_db PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / b l o c k c h a i n _ d b / l i b b l o c k c h a i n _ d b . a )
add_library ( blocks STATIC IMPORTED )
set_target_properties ( blocks PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / b l o c k s / l i b b l o c k s . a )
add_library ( checkpoints STATIC IMPORTED )
set_target_properties ( checkpoints PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / c h e c k p o i n t s / l i b c h e c k p o i n t s . a )
add_library ( device STATIC IMPORTED )
set_target_properties ( device PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / d e v i c e / l i b d e v i c e . a )
add_library ( device_trezor STATIC IMPORTED )
set_target_properties ( device_trezor PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / d e v i c e _ t r e z o r / l i b d e v i c e _ t r e z o r . a )
add_library ( multisig STATIC IMPORTED )
set_target_properties ( multisig PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / m u l t i s i g / l i b m u l t i s i g . a )
add_library ( version STATIC IMPORTED )
set_target_properties ( version PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / s r c / l i b v e r s i o n . a )
add_library ( randomx STATIC IMPORTED )
set_target_properties ( randomx PROPERTIES IMPORTED_LOCATION
$ { M O N E R O _ B U I L D _ D I R } / e x t e r n a l / r a n d o m x / l i b r a n d o m x . a )
######################################
set ( monero_include_dirs ${ MONERO_ROOT_DIR } /contrib/epee/include
$ { M O N E R O _ R O O T _ D I R } / e x t e r n a l /
$ { M O N E R O _ R O O T _ D I R } / e x t e r n a l / e a s y l o g g i n g + +
$ { M O N E R O _ R O O T _ D I R } / e x t e r n a l / r a p i d j s o n / i n c l u d e
$ { M O N E R O _ S R C _ D I R } /
$ { M O N E R O _ S R C _ D I R } / w a l l e t
$ { M O N E R O _ S R C _ D I R } / w a l l e t / a p i
$ { M O N E R O _ S R C _ D I R } / h a r d f o r k s
$ { M O N E R O _ S R C _ D I R } / c r y p t o
$ { M O N E R O _ S R C _ D I R } / c r y p t o / c r y p t o _ o p s _ b u i l d e r / i n c l u d e /
$ { P r o t o b u f _ I N C L U D E _ D I R }
$ { B o o s t _ I N C L U D E _ D I R }
$ { O P E N S S L _ I N C L U D E _ D I R }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / e x t e r n a l / m o n e r o - c p p / e x t e r n a l / l i b s o d i u m / i n c l u d e / s o d i u m
#[[${CMAKE_CURRENT_SOURCE_DIR}/external/monero-cpp/external/openssl-sdk/include]]
$ { H I D A P I _ I N C L U D E _ D I R }
$ { U N B O U N D _ I N C L U D E _ D I R }
)
set ( monero_src wallet rpc_base net lmdb unbound easylogging cryptonote_core cryptonote_protocol cryptonote_basic cryptonote_format_utils_basic mnemonics ringct ringct_basic common blockchain_db blocks checkpoints device device_trezor cncrypto multisig version randomx epee hardforks ${ wallet_crypto }
$ { U N B O U N D _ L I B R A R I E S } $ { B o o s t _ L I B R A R I E S } $ { P r o t o b u f _ L I B R A R Y } $ { L i b U S B _ L I B R A R I E S } $ { O P E N S S L _ L I B R A R I E S } $ { S O D I U M _ L I B R A R Y } $ { H I D A P I _ L I B R A R Y } $ { E X T R A _ L I B R A R I E S } )
######################################
# monero-cpp (wrapper)
set ( monero_cpp_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/monero-cpp/src/ )
set ( monero_cpp_src ${ CMAKE_CURRENT_SOURCE_DIR } /build/libmonero-cpp.a )
######################################
# sqlite3
set ( sqlite_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/sqlite ) # v3.39.1 (amalgamation - said to run a bit faster)
set ( sqlite_src ${ CMAKE_CURRENT_SOURCE_DIR } /build/libsqlite3.a )
######################################
# QR-Code-generator
set ( qrcodegen_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/QR-Code-generator/cpp ) # v1.8.0
set ( qrcodegen_src ${ CMAKE_CURRENT_SOURCE_DIR } /build/libqrcodegen.a )
######################################
# json
set ( json_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/json/single_include )
######################################
# curl
find_package ( CURL )
if ( CURL_FOUND )
message ( STATUS "Using CURL: ${CURL_LIBRARIES} (v${CURL_VERSION_STRING})" )
set ( curl_include_dirs ${ CURL_INCLUDE_DIRS } )
set ( curl_src ${ CURL_LIBRARIES } )
endif ( )
if ( NOT CURL_FOUND )
set ( curl_include_dirs ${ CMAKE_CURRENT_SOURCE_DIR } /external/curl/include ${ CMAKE_CURRENT_SOURCE_DIR } /external/curl/lib )
set ( curl_src ${ CMAKE_CURRENT_SOURCE_DIR } /external/curl/lib/.libs/libcurl.a ) # In case user chooses to build libcurl themselves instead of installing it on the system
add_definitions ( -DCURL_STATICLIB )
set ( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lldap -llber -lnghttp2 -lpsl -lidn2 -lbrotlidec -lzstd -lrtmp" ) # for Arch (Manjaro)
endif ( )
######################################
# stduuid
set ( stduuid_include_dirs ${ CMAKE_CURRENT_SOURCE_DIR } /external/stduuid ${ CMAKE_CURRENT_SOURCE_DIR } /external/stduuid/catch ${ CMAKE_CURRENT_SOURCE_DIR } /external/stduuid/include )
######################################
# linenoise
set ( linenoise_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/linenoise/ )
set ( linenoise_src ${ CMAKE_CURRENT_SOURCE_DIR } /build/liblinenoise.a )
######################################
# lua
set ( lua_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/lua/src/ ) # v5.4.4
set ( lua_src ${ CMAKE_CURRENT_SOURCE_DIR } /build/liblua.a )
######################################
# cxxopts
set ( cxxopts_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/cxxopts/include/ )
######################################
# zlib
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/build/libz.a" )
set ( zlib_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/zlib/ )
set ( zlib_src ${ CMAKE_CURRENT_SOURCE_DIR } /build/libz.a )
message ( STATUS "Using ZLIB: ${zlib_src}" )
else ( )
find_package ( ZLIB )
if ( ZLIB_FOUND )
message ( STATUS "Using ZLIB: ${ZLIB_LIBRARIES}" )
set ( zlib_include_dir ${ ZLIB_INCLUDE_DIRS } )
set ( zlib_src ${ ZLIB_LIBRARIES } )
endif ( )
endif ( )
######################################
# libi2pd (and i2pd_client)
set ( i2pd_include_dirs ${ CMAKE_CURRENT_SOURCE_DIR } /external/i2pd/daemon ${ CMAKE_CURRENT_SOURCE_DIR } /external/i2pd/i18n ${ CMAKE_CURRENT_SOURCE_DIR } /external/i2pd/libi2pd ${ CMAKE_CURRENT_SOURCE_DIR } /external/i2pd/libi2pd_client ) # v2.50.2
set ( i2pd_src ${ CMAKE_CURRENT_SOURCE_DIR } /build/libi2pdclient.a ${ CMAKE_CURRENT_SOURCE_DIR } /build/libi2pd.a ${ CMAKE_CURRENT_SOURCE_DIR } /build/libi2pdlang.a )
######################################
# i2psam
set ( i2psam_include_dir ${ CMAKE_CURRENT_SOURCE_DIR } /external/i2psam/ )
set ( i2psam_src ${ CMAKE_CURRENT_SOURCE_DIR } /build/libi2psam.a )
######################################
# neroshop link directories
link_directories ( ${ CMAKE_CURRENT_SOURCE_DIR } /build ) # target_link_directories only available in CMake version 3.13 :(
######################################
# neroshop core source files
set ( neroshop_crypto_src
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / c r y p t o / r s a . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / c r y p t o / s h a 2 5 6 . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / c r y p t o / s h a 3 . c p p
)
set ( neroshop_database_src
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / d a t a b a s e / d a t a b a s e . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / d a t a b a s e / s q l i t e 3 / s q l i t e 3 . c p p
)
set ( neroshop_network_src
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / n e t w o r k / i 2 p . c p p
)
set ( neroshop_price_src
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / c o i n c o d e x / c o i n c o d e x . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / c o i n g e c k o / c o i n g e c k o . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / c o i n m a r k e t c a p / c o i n m a r k e t c a p . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / c o i n t e l e g r a p h / c o i n t e l e g r a p h . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / c r y p t o r a n k / c r y p t o r a n k . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / c r y p t o w a t c h / c r y p t o w a t c h . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / f a w a z a h m e d 0 / f a w a z a h m e d 0 . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / k r a k e n / k r a k e n . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r i c e / c u r r e n c y _ c o n v e r t e r . c p p
)
set ( neroshop_protocol_src
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / m e s s a g e s / m s g p a c k . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / p 2 p / k e y _ m a p p e r . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / p 2 p / n o d e . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / p 2 p / r o u t i n g _ t a b l e . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / p 2 p / s e r i a l i z e r . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / r p c / j s o n _ r p c . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / t r a n s p o r t / c l i e n t . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / t r a n s p o r t / i p _ a d d r e s s . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / t r a n s p o r t / s e r v e r . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / t r a n s p o r t / z m q _ c l i e n t . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o t o c o l / t r a n s p o r t / z m q _ s e r v e r . c p p
)
set ( neroshop_tools_src
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / t o o l s / b a s e 6 4 . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / t o o l s / l o g g e r . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / t o o l s / p r o c e s s . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / t o o l s / s c r i p t . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / t o o l s / t i m e s t a m p . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / t o o l s / u p d a t e r . c p p
)
set ( neroshop_wallet_src
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / w a l l e t / w a l l e t . c p p
#[[${NEROSHOP_CORE_SRC_DIR}/wallet/monero/monero.cpp]]
)
set ( neroshop_core_src
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / c a r t . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / e s c r o w . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / l i s t i n g . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / o r d e r . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / p r o d u c t . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / s e l l e r . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / s e t t i n g s . c p p
$ { N E R O S H O P _ C O R E _ S R C _ D I R } / u s e r . c p p
$ { n e r o s h o p _ c r y p t o _ s r c }
$ { n e r o s h o p _ d a t a b a s e _ s r c }
$ { n e r o s h o p _ n e t w o r k _ s r c }
$ { n e r o s h o p _ p r i c e _ s r c }
$ { n e r o s h o p _ p r o t o c o l _ s r c }
$ { n e r o s h o p _ t o o l s _ s r c }
$ { n e r o s h o p _ w a l l e t _ s r c }
)
######################################
# neroshop tests
if ( NEROSHOP_BUILD_TESTS ) # -DNEROSHOP_BUILD_TESTS=1
enable_testing ( )
message ( STATUS "${BoldMagenta}NEROSHOP_BUILD_TESTS option set to ON${ColourReset}" )
add_subdirectory ( tests )
endif ( )
######################################
# neroshop-daemon
set ( daemon_executable "neromon" )
set ( daemon_src ${ neroshop_crypto_src } ${ neroshop_database_src } ${ neroshop_network_src } ${ NEROSHOP_CORE_SRC_DIR } /protocol/messages/msgpack.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/p2p/key_mapper.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/p2p/node.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/p2p/routing_table.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/rpc/json_rpc.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/transport/client.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/transport/ip_address.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/transport/server.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/transport/zmq_client.cpp ${ NEROSHOP_CORE_SRC_DIR } /protocol/transport/zmq_server.cpp ${ NEROSHOP_CORE_SRC_DIR } /tools/base64.cpp ${ NEROSHOP_CORE_SRC_DIR } /tools/logger.cpp ${ NEROSHOP_CORE_SRC_DIR } /tools/timestamp.cpp )
add_executable ( ${ daemon_executable } src/daemon/main.cpp ${ daemon_src } ) #target_link_libraries(daemon ${curl_src} ${OPENSSL_LIBRARIES}) # curl requires both openssl(used in monero) and zlib(used in libi2pd)
install ( TARGETS ${ daemon_executable } DESTINATION bin )
target_compile_definitions ( ${ daemon_executable } PRIVATE NEROSHOP_DEBUG )
target_include_directories ( ${ daemon_executable } PRIVATE #[[${CMAKE_CURRENT_SOURCE_DIR}/src/]] ${monero_include_dirs} ${monero_cpp_include_dir} ${sqlite_include_dir} ${json_include_dir} ${zlib_include_dir} ${i2pd_include_dirs} ${cxxopts_include_dir})
target_link_libraries ( ${ daemon_executable } ${ i2pd_src } ${ monero_cpp_src } ${ sqlite_src } ${ monero_src } ${ zlib_src } ) #set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl") # fixes undefined reference to symbol 'dlsym@@GLIBC_2.2.5' error
######################################
# neroshop-console
if ( NEROSHOP_BUILD_CLI )
set ( neroshop_console "neroshop-console" )
add_executable ( ${ neroshop_console } src/console/main.cpp ${ neroshop_core_src } )
install ( TARGETS ${ neroshop_console } DESTINATION bin )
target_compile_definitions ( ${ neroshop_console } PRIVATE NEROSHOP_DEBUG )
target_include_directories ( ${ neroshop_console } PRIVATE #[[${CMAKE_CURRENT_SOURCE_DIR}/src/]] ${monero_include_dirs} ${monero_cpp_include_dir} ${sqlite_include_dir} ${json_include_dir} ${zlib_include_dir} ${i2pd_include_dirs} ${lua_include_dir} ${curl_include_dirs} ${stduuid_include_dirs} ${linenoise_include_dir})
target_link_libraries ( ${ neroshop_console } ${ i2pd_src } ${ monero_cpp_src } ${ sqlite_src } #[[${qrcodegen_src}]] ${curl_src} ${monero_src} ${zlib_src} ${lua_src} ${linenoise_src})
message ( STATUS "${BoldMagenta}NEROSHOP_BUILD_CLI option set to ON${ColourReset}" )
endif ( )
######################################
# neroshop
if ( NEROSHOP_BUILD_GUI )
set ( neroshop_executable "neroshop" )
add_executable ( ${ neroshop_executable } )
install ( TARGETS ${ neroshop_executable } DESTINATION bin )
target_sources ( ${ neroshop_executable } PRIVATE ${ neroshop_res } src/gui/main.cpp src/gui/script_manager.cpp src/gui/wallet_controller.cpp src/gui/user_controller.cpp src/gui/image_loader.cpp src/gui/image_provider.cpp src/gui/wallet_qr_provider.cpp src/gui/currency_rate_provider.cpp #[[src/gui/table_model.cpp]] src/gui/daemon_manager.cpp src/gui/enum_wrapper.cpp src/gui/proxy_manager.cpp src/gui/backend.cpp ${neroshop_core_src})
target_compile_definitions ( ${ neroshop_executable } PRIVATE NEROSHOP_DEBUG ) #set_target_properties(${neroshop_executable} PROPERTIES COMPILE_DEFINITIONS "NEROSHOP_DEBUG")
target_include_directories ( ${ neroshop_executable } PRIVATE #[[${CMAKE_CURRENT_SOURCE_DIR}/src/]] ${monero_include_dirs} ${monero_cpp_include_dir} ${sqlite_include_dir} ${json_include_dir} ${zlib_include_dir} ${i2pd_include_dirs} ${lua_include_dir} ${qrcodegen_include_dir})
target_link_libraries ( ${ neroshop_executable } ${ i2pd_src } ${ monero_cpp_src } ${ sqlite_src } ${ qrcodegen_src } ${ monero_src } ${ zlib_src } ${ lua_src } )
message ( STATUS "${BoldMagenta}NEROSHOP_BUILD_GUI option set to ON${ColourReset}" )
target_compile_definitions ( ${ neroshop_executable } PRIVATE NEROSHOP_BUILD_GUI )
endif ( )
######################################
add_subdirectory ( assets )
######################################
# suppress boost warnings
add_definitions ( -DBOOST_DISABLE_PRAGMA_MESSAGE )
######################################
# gRPC
if ( NEROSHOP_USE_GRPC )
message ( STATUS "Using gRPC" )
target_compile_definitions ( ${ neroshop_executable } PRIVATE NEROSHOP_USE_GRPC )
target_compile_definitions ( ${ neroshop_console } PRIVATE NEROSHOP_USE_GRPC )
target_compile_definitions ( ${ daemon_executable } PRIVATE NEROSHOP_USE_GRPC )
if ( NEROSHOP_USE_SYSTEM_GRPC )
# Find system-installed gRPC
find_package ( gRPC CONFIG REQUIRED )
message ( STATUS "USE_SYSTEM_GRPC option set to ON" )
target_link_libraries ( ${ neroshop_executable } gRPC::grpc++ )
target_link_libraries ( ${ neroshop_console } gRPC::grpc++ )
target_link_libraries ( ${ daemon_executable } gRPC::grpc++ )
else ( )
# Build gRPC using FetchContent or add_subdirectory
endif ( )
endif ( )
######################################
# system sockets
if ( NOT NEROSHOP_USE_LIBZMQ AND NOT NEROSHOP_USE_LIBUV )
message ( STATUS "${BoldWhite}Using SYSTEM SOCKETS${ColourReset}" )
if ( NEROSHOP_BUILD_GUI )
target_compile_definitions ( ${ neroshop_executable } PRIVATE NEROSHOP_USE_SYSTEM_SOCKETS )
endif ( )
if ( NEROSHOP_BUILD_CLI )
target_compile_definitions ( ${ neroshop_console } PRIVATE NEROSHOP_USE_SYSTEM_SOCKETS )
endif ( )
target_compile_definitions ( ${ daemon_executable } PRIVATE NEROSHOP_USE_SYSTEM_SOCKETS )
endif ( )
######################################
# libzmq
find_package ( ZeroMQ )
if ( ZeroMQ_FOUND )
if ( NEROSHOP_USE_LIBZMQ )
message ( STATUS "${BoldRed}Using LIBZMQ: ${ZeroMQ_LIBRARY} (v${ZeroMQ_VERSION})${ColourReset}" )
if ( NEROSHOP_BUILD_GUI )
target_compile_definitions ( ${ neroshop_executable } PRIVATE NEROSHOP_USE_LIBZMQ )
target_link_libraries ( ${ neroshop_executable } ${ ZeroMQ_LIBRARIES } )
endif ( )
if ( NEROSHOP_BUILD_CLI )
target_compile_definitions ( ${ neroshop_console } PRIVATE NEROSHOP_USE_LIBZMQ )
target_link_libraries ( ${ neroshop_console } ${ ZeroMQ_LIBRARIES } )
endif ( )
target_compile_definitions ( ${ daemon_executable } PRIVATE NEROSHOP_USE_LIBZMQ )
target_link_libraries ( ${ daemon_executable } ${ ZeroMQ_LIBRARIES } )
endif ( )
endif ( )
######################################
if ( UUID_TIME_GENERATOR ) # -DUUID_TIME_GENERATOR=1
if ( NEROSHOP_BUILD_GUI )
target_compile_definitions ( ${ neroshop_executable } PRIVATE UUID_TIME_GENERATOR )
endif ( )
if ( NEROSHOP_BUILD_CLI )
target_compile_definitions ( ${ neroshop_console } PRIVATE UUID_TIME_GENERATOR )
endif ( )
endif ( )
######################################
if ( WIN32 )
set ( winsock2_src ws2_32.lib ) # -lglfw3 -lgdi32 -lopengl32 -limm32
if ( NEROSHOP_BUILD_GUI )
target_link_libraries ( ${ neroshop_executable } ${ winsock2_src } )
endif ( )
if ( NEROSHOP_BUILD_CLI )
target_link_libraries ( ${ neroshop_console } ${ winsock2_src } )
endif ( )
target_link_libraries ( ${ daemon_executable } ${ winsock2_src } )
endif ( )
######################################
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux" )
find_package ( LibUUID ) # optional
if ( UUID_SYSTEM_GENERATOR ) # -DUUID_SYSTEM_GENERATOR=1
message ( STATUS "UUID_SYSTEM_GENERATOR option set to ON" )
if ( LIBUUID_FOUND )
message ( STATUS "Using LibUUID: ${LibUUID_LIBRARY}" )
if ( NEROSHOP_BUILD_GUI )
target_compile_definitions ( ${ neroshop_executable } PRIVATE UUID_SYSTEM_GENERATOR ) # uuids::uuid_system_generator
target_link_libraries ( ${ neroshop_executable } ${ LibUUID_LIBRARY } )
endif ( )
if ( NEROSHOP_BUILD_CLI )
target_compile_definitions ( ${ neroshop_console } PRIVATE UUID_SYSTEM_GENERATOR ) # uuids::uuid_system_generator
target_link_libraries ( ${ neroshop_console } ${ LibUUID_LIBRARY } )
endif ( )
target_compile_definitions ( ${ daemon_executable } PRIVATE UUID_SYSTEM_GENERATOR )
target_link_libraries ( ${ daemon_executable } ${ LibUUID_LIBRARY } )
endif ( )
endif ( )
set ( posix_src libpthread.so libdl.so libm.so )
if ( NEROSHOP_BUILD_GUI )
target_link_libraries ( ${ neroshop_executable } ${ posix_src } )
endif ( )
if ( NEROSHOP_BUILD_CLI )
target_link_libraries ( ${ neroshop_console } ${ posix_src } )
endif ( )
target_link_libraries ( ${ daemon_executable } ${ posix_src } )
endif ( )
######################################
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
find_library ( CFLIB CoreFoundation ) # optional
if ( UUID_SYSTEM_GENERATOR ) # -DUUID_SYSTEM_GENERATOR=1
message ( STATUS "UUID_SYSTEM_GENERATOR option set to ON" )
message ( STATUS "Using CFLIB: ${CFLIB}" )
if ( NEROSHOP_BUILD_GUI )
target_compile_definitions ( ${ neroshop_executable } PRIVATE UUID_SYSTEM_GENERATOR ) # uuids::uuid_system_generator
target_link_libraries ( ${ neroshop_executable } ${ CFLIB } )
endif ( )
if ( NEROSHOP_BUILD_CLI )
target_compile_definitions ( ${ neroshop_console } PRIVATE UUID_SYSTEM_GENERATOR ) # uuids::uuid_system_generator
target_link_libraries ( ${ neroshop_console } ${ CFLIB } )
endif ( )
endif ( )
endif ( )
######################################
# qt5
if ( Qt5_FOUND )
if ( NEROSHOP_BUILD_GUI AND NEROSHOP_USE_QT )
# Some Linux distros require Qt::Widgets due to the lack of a native platform file dialog implementation
if ( NEROSHOP_USE_QT_WIDGETS OR ${ CMAKE_SYSTEM_NAME } MATCHES "Linux" )
message ( STATUS "Using Qt5::Widgets" )
target_compile_definitions ( ${ neroshop_executable } PRIVATE NEROSHOP_USE_QT_WIDGETS )
find_package ( Qt5 COMPONENTS Widgets )
target_link_libraries ( ${ neroshop_executable } Qt5::Widgets )
endif ( )
message ( STATUS "Using Qt5::Qml Qt5::Quick Qt5::Gui Qt5::Concurrent" )
target_compile_definitions ( ${ neroshop_executable } PRIVATE NEROSHOP_USE_QT )
#add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00) # Disable any API deprecated in 5.15 or older Qt versions
#target_include_directories(${neroshop_executable} PRIVATE /usr/include/x86_64-linux-gnu/qt5/)
target_link_libraries ( ${ neroshop_executable } Qt5::Qml Qt5::Quick Qt5::Gui Qt5::Concurrent #[[Qt5::QuickControls2]])
endif ( )
endif ( )
######################################