explorer/CMakeLists.txt
2020-07-06 10:18:48 +00:00

183 lines
5.4 KiB
CMake

cmake_minimum_required(VERSION 2.8)
set(PROJECT_NAME
xmrblocks)
project(${PROJECT_NAME})
set(CMAKE_CXX_STANDARD 11)
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj -O3")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DPIC -fstack-protector-strong")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -DPIC -fstack-protector-strong")
if (NOT MONERO_DIR)
set(MONERO_DIR ~/monero)
endif()
message(STATUS MONERO_DIR ": ${MONERO_DIR}")
if (NOT MONERO_SOURCE_DIR)
set(MONERO_SOURCE_DIR ${MONERO_DIR}
CACHE PATH "Path to the root directory for Monero")
endif()
if (NOT MONERO_BUILD_DIR)
# set location of monero build tree
set(MONERO_BUILD_DIR ${MONERO_SOURCE_DIR}/build/release/
CACHE PATH "Path to the build directory for Monero")
if (NOT EXISTS ${MONERO_BUILD_DIR})
# try different location
message(STATUS "Trying different folder for monero libraries")
set(MONERO_BUILD_DIR ${MONERO_SOURCE_DIR}/build/Linux/master/release/
CACHE PATH "Path to the build directory for Monero" FORCE)
endif()
endif()
if (NOT EXISTS ${MONERO_BUILD_DIR})
message(FATAL_ERROR "Monero libraries not found in: ${MONERO_BUILD_DIR}")
endif()
set(MY_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake"
CACHE PATH "The path to the cmake directory of the current project")
list(APPEND CMAKE_MODULE_PATH "${MY_CMAKE_DIR}")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${MONERO_BUILD_DIR}"
CACHE PATH "Add Monero directory for library searching")
include(MyUtils)
find_package(Monero)
#info https://github.com/arsenm/sanitizers-cmake
find_package(Sanitizers)
if(APPLE)
include_directories(/usr/local/opt/openssl@1.1/include)
link_directories(/usr/local/opt/openssl@1.1/lib)
link_directories(/usr/local/lib)
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32)
add_library(unbound STATIC IMPORTED)
set_property(TARGET unbound PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/external/unbound/libunbound.a)
endif()
# include boost headers
include_directories(${Boost_INCLUDE_DIRS})
# include monero
include_directories(${MONERO_SOURCE_DIR}/build)
include_directories("ext/mstch/include")
include_directories("ext/mstch/include/src")
include_directories("ext/crow")
include_directories("${MONERO_DIR}/contrib/epee/include" ${MONERO_DIR}/external/easylogging++ ${MONERO_DIR}/src ${MONERO_DIR}/external/db_drivers/liblmdb ${MONERO_DIR}/external ${MONERO_DIR}/external/randomx/src ${MONERO_DIR}/external/boost-libs)
link_directories(${MONERO_BUILD_DIR}/external/boost-libs/install/lib)
# add ext/ subfolder
add_subdirectory(ext/)
# add src/ subfolder
add_subdirectory(src/)
set(SOURCE_FILES
main.cpp)
#ADD_CUSTOM_TARGET(driver DEPENDS src/templates/index.html)
add_executable(${PROJECT_NAME}
${SOURCE_FILES})
add_sanitizers(${PROJECT_NAME})
create_git_version()
configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates ${CMAKE_CURRENT_BINARY_DIR}/templates)
configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/css ${CMAKE_CURRENT_BINARY_DIR}/templates/css)
configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/partials ${CMAKE_CURRENT_BINARY_DIR}/templates/partials)
configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/js ${CMAKE_CURRENT_BINARY_DIR}/templates/js)
set(LIBRARIES
myxrm
myext
mstch
wallet
blockchain_db
cryptonote_core
cc
cryptonote_protocol
cryptonote_basic
multisig
daemonizer
cncrypto
blocks
lmdb
ringct
ringct_basic
device
common
mnemonics
easylogging
checkpoints
version
epee
hardforks
randomx
sodium
${Boost_LIBRARIES}
pthread
unbound
curl
crypto
ssl)
if(APPLE)
set(LIBRARIES ${LIBRARIES} "-framework IOKit -framework Foundation")
else()
set(LIBRARIES ${LIBRARIES} atomic)
endif()
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT WIN32)
set(LIBRARIES ${LIBRARIES} unwind)
endif()
if (WIN32)
set(LIBRARIES ${LIBRARIES}
wsock32
ntdll
ws2_32
Iphlpapi
)
else()
set(LIBRARIES ${LIBRARIES} dl)
endif()
find_package(HIDAPI)
set(LIBRARIES ${LIBRARIES} ${HIDAPI_LIBRARIES})
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_system.a)
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_filesystem.a)
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_thread.a)
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_date_time.a)
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_chrono.a)
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_regex.a)
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_serialization.a)
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_program_options.a)
set(LIBRARIES ${LIBRARIES} ${MONERO_BUILD_DIR}/external/boost-libs/install/lib/libboost_atomic.a)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack")
set(CMAKE_SKIP_RPATH TRUE)
target_link_libraries(${PROJECT_NAME} ${LIBRARIES})