Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build editline #16

Merged
merged 4 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 51 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,54 @@ else ( MSVC )
endif ( MSVC )
# End configure secp256k1-zkp

# Configure editline
if ( MSVC )
# autoconf won't work here, hard code the defines
set( EDITLINE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline" )

file( GLOB EDITLINE_SOURCES "${EDITLINE_DIR}/src/editline.c" )
add_library( editline ${EDITLINE_SOURCES} )

target_include_directories( editline PRIVATE "${EDITLINE_DIR}" PUBLIC "${EDITLINE_DIR}/include" )

set_target_properties( editline PROPERTIES COMPILE_DEFINITIONS LINKER_LANGUAGE C )
else ( MSVC )
include(ExternalProject)
if ( MINGW )
ExternalProject_Add( project_editline
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/vendor/editline
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/vendor/editline --host=x86_64-w64-mingw32
BUILD_COMMAND make
INSTALL_COMMAND true
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/vendor/editline/src/project_editline-build/.libs/libeditline.a
)
else ( MINGW )
ExternalProject_Add( project_editline
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/vendor/editline
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/vendor/editline
BUILD_COMMAND make
INSTALL_COMMAND true
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/vendor/editline/src/project_editline-build/.libs/libeditline.a
)
endif ( MINGW )
ExternalProject_Add_Step(project_editline autogen
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline/autogen.sh
DEPENDERS configure
)

ExternalProject_Get_Property(project_editline binary_dir)

add_library(editline STATIC IMPORTED)
set_property(TARGET editline PROPERTY IMPORTED_LOCATION ${binary_dir}/src/.libs/libeditline${CMAKE_STATIC_LIBRARY_SUFFIX})
set_property(TARGET editline PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline/include)
add_dependencies(editline project_editline)
install( FILES ${binary_dir}/src/.libs/libeditline${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION lib/cryptonomex )
endif ( MSVC )
# End configure editline

IF( WIN32 )
MESSAGE(STATUS "Configuring fc to build on Win32")

Expand Down Expand Up @@ -252,20 +300,8 @@ setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC )
install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include )

# begin editline stuff
#find_package(Curses)
set(EDITLINE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline" )
find_package(Editline)

file(GLOB HEADERS "include/bts/cli/*.hpp")

if (EDITLINE_FOUND)
target_compile_definitions (fc PRIVATE HAVE_EDITLINE)
set(editline_libraries ${Editline_LIBRARY})
#if (CURSES_FOUND)
# list(APPEND editline_libraries ${CURSES_LIBRARY})
#endif()
set(editline_includes ${Editline_INCLUDE_DIR})
endif()
target_compile_definitions (fc PRIVATE HAVE_EDITLINE)
set(editline_libraries editline)
if(WIN32)
target_compile_definitions( fc PRIVATE _CRT_NONSTDC_NO_DEPRECATE )
endif(WIN32)
Expand Down Expand Up @@ -363,7 +399,6 @@ target_include_directories(fc
${OPENSSL_INCLUDE_DIR}
"vendor/diff-match-patch-cpp-stl"
${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp
"${editline_includes}"

PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost_1.51/include
Expand All @@ -374,7 +409,7 @@ target_include_directories(fc
IF(NOT WIN32)
set(LINK_USR_LOCAL_LIB -L/usr/local/lib)
ENDIF()
target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} )
target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${editline_libraries} ${ECC_LIB} )

if(MSVC)
set_source_files_properties( src/network/http/websocket.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
Expand Down
50 changes: 0 additions & 50 deletions CMakeModules/FindEditline.cmake

This file was deleted.