2018-05-16 13:56:51 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.10)
|
|
|
|
|
2018-06-14 14:04:42 +00:00
|
|
|
set(PROJECT_NAME llarpd)
|
|
|
|
project(${PROJECT_NAME})
|
|
|
|
|
2018-06-06 13:17:03 +00:00
|
|
|
macro(add_cflags)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGN}")
|
|
|
|
endmacro(add_cflags)
|
2018-06-06 17:02:57 +00:00
|
|
|
|
2018-06-15 13:42:49 +00:00
|
|
|
macro(add_cxxflags)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGN}")
|
|
|
|
endmacro(add_cxxflags)
|
|
|
|
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
|
|
|
if(COMPILER_SUPPORTS_CXX11)
|
|
|
|
add_cxxflags("-std=c++11")
|
|
|
|
else()
|
|
|
|
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STATIC_LINK)
|
|
|
|
set(STATIC_LINK_LIBS c)
|
|
|
|
add_cflags("-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
|
|
|
|
add_cxxflags("-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
|
|
|
|
endif()
|
|
|
|
|
2018-06-06 17:02:57 +00:00
|
|
|
if(SHADOW)
|
|
|
|
set(WITH_STATIC OFF)
|
|
|
|
else()
|
|
|
|
set(WITH_STATIC ON)
|
|
|
|
endif()
|
|
|
|
|
2018-06-06 12:46:26 +00:00
|
|
|
set(DEBUG_FLAGS "-g")
|
2018-06-01 17:47:37 +00:00
|
|
|
set(OPTIMIZE_FLAGS "-Os")
|
2018-06-15 13:42:49 +00:00
|
|
|
|
2018-05-27 16:45:04 +00:00
|
|
|
if(ASAN)
|
2018-06-06 12:46:26 +00:00
|
|
|
set(DEBUG_FLAGS "${DEBUG_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
2018-06-01 17:47:37 +00:00
|
|
|
set(OPTIMIZE_FLAGS "-O0")
|
2018-05-27 16:45:04 +00:00
|
|
|
endif(ASAN)
|
2018-05-22 15:54:19 +00:00
|
|
|
|
2018-06-06 12:59:15 +00:00
|
|
|
if(SHADOW)
|
2018-06-06 17:02:57 +00:00
|
|
|
if("${SHADOW_ROOT}" STREQUAL "")
|
|
|
|
set(SHADOW_ROOT "$ENV{HOME}/.shadow")
|
|
|
|
endif("${SHADOW_ROOT}" STREQUAL "")
|
|
|
|
if(EXISTS "${SHADOW_ROOT}")
|
|
|
|
message(STATUS "SHADOW_ROOT = ${SHADOW_ROOT}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "SHADOW_ROOT path does not exist: '${SHADOW_ROOT}'")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_MODULE_PATH "${SHADOW_ROOT}/share/cmake/Modules")
|
|
|
|
include_directories(${CMAKE_MODULE_PATH})
|
|
|
|
include(ShadowTools)
|
2018-06-15 13:42:49 +00:00
|
|
|
add_cxxflags("-fno-inline -fno-strict-aliasing")
|
2018-06-06 17:02:57 +00:00
|
|
|
add_cflags("-fno-inline -fno-strict-aliasing")
|
|
|
|
|
2018-06-06 12:59:15 +00:00
|
|
|
add_definitions(-DTESTNET=true)
|
2018-06-06 17:02:57 +00:00
|
|
|
add_definitions(-DSHADOW_TESTNET)
|
|
|
|
include_directories(${SHADOW_ROOT}/include)
|
2018-06-06 12:59:15 +00:00
|
|
|
endif()
|
2018-06-01 17:47:37 +00:00
|
|
|
|
2018-06-18 22:03:50 +00:00
|
|
|
add_cflags("-Wall -Wno-deprecated-declarations ${OPTIMIZE_FLAGS}")
|
|
|
|
add_cxxflags("-Wall -Wno-deprecated-declarations ${OPTIMIZE_FLAGS}")
|
2018-06-15 13:42:49 +00:00
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
|
|
|
|
add_cflags("${DEBUG_FLAGS}")
|
|
|
|
add_cxxflags("${DEBUG_FLAGS}")
|
|
|
|
endif()
|
2018-05-16 13:56:51 +00:00
|
|
|
|
2018-06-06 17:02:57 +00:00
|
|
|
if(SHADOW)
|
|
|
|
add_cflags("-fPIC")
|
2018-06-15 13:42:49 +00:00
|
|
|
add_cxxflags("-fPIC")
|
2018-06-06 17:02:57 +00:00
|
|
|
endif()
|
|
|
|
|
2018-05-28 13:49:44 +00:00
|
|
|
if(NOT GIT_VERSION)
|
|
|
|
exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "rev-parse --short HEAD" OUTPUT_VARIABLE GIT_VERSION)
|
|
|
|
add_definitions(-DGIT_REV="${GIT_VERSION}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(RELEASE_MOTTO)
|
|
|
|
add_definitions(-DLLARP_RELEASE_MOTTO="${RELEASE_MOTTO}")
|
|
|
|
endif()
|
|
|
|
|
2018-05-16 13:56:51 +00:00
|
|
|
set(EXE llarpd)
|
2018-06-06 12:59:15 +00:00
|
|
|
set(EXE_SRC daemon/main.c)
|
2018-05-16 13:56:51 +00:00
|
|
|
|
2018-05-29 14:45:37 +00:00
|
|
|
if(SODIUM_INCLUDE_DIR)
|
|
|
|
include_directories(${SODIUM_INCLUDE_DIR})
|
|
|
|
endif()
|
2018-05-29 14:26:43 +00:00
|
|
|
|
2018-05-29 14:45:37 +00:00
|
|
|
if(SODIUM_LIBRARIES)
|
|
|
|
set(SODIUM_LIB ${SODIUM_LIBRARIES})
|
|
|
|
else()
|
|
|
|
set(SODIUM_LIB sodium)
|
|
|
|
endif()
|
2018-05-29 12:15:48 +00:00
|
|
|
|
2018-06-14 19:28:27 +00:00
|
|
|
set(LIBS ${SODIUM_LIB} pthread)
|
2018-05-22 18:41:38 +00:00
|
|
|
|
2018-05-16 13:56:51 +00:00
|
|
|
set(LIB llarp)
|
2018-05-27 18:03:10 +00:00
|
|
|
set(SHARED_LIB ${LIB})
|
|
|
|
set(STATIC_LIB ${LIB}-static)
|
2018-05-16 13:56:51 +00:00
|
|
|
|
|
|
|
set(LIB_SRC
|
2018-05-22 15:54:19 +00:00
|
|
|
llarp/address_info.cpp
|
2018-06-01 17:47:37 +00:00
|
|
|
llarp/bencode.c
|
2018-05-16 13:56:51 +00:00
|
|
|
llarp/buffer.cpp
|
|
|
|
llarp/config.cpp
|
2018-05-27 17:44:01 +00:00
|
|
|
llarp/context.cpp
|
2018-05-20 14:54:52 +00:00
|
|
|
llarp/crypto_async.cpp
|
2018-05-16 13:56:51 +00:00
|
|
|
llarp/crypto_libsodium.cpp
|
2018-06-01 14:08:54 +00:00
|
|
|
llarp/dht.cpp
|
2018-06-10 14:05:48 +00:00
|
|
|
llarp/encrypted_frame.cpp
|
2018-05-16 13:56:51 +00:00
|
|
|
llarp/ev.cpp
|
2018-05-28 13:49:44 +00:00
|
|
|
llarp/exit_info.cpp
|
2018-05-16 13:56:51 +00:00
|
|
|
llarp/exit_route.c
|
2018-05-18 14:40:06 +00:00
|
|
|
llarp/iwp_link.cpp
|
2018-05-27 13:42:55 +00:00
|
|
|
llarp/logger.cpp
|
2018-05-16 15:49:16 +00:00
|
|
|
llarp/link.c
|
2018-05-16 13:56:51 +00:00
|
|
|
llarp/link_intro.cpp
|
2018-05-25 17:52:10 +00:00
|
|
|
llarp/link_message.cpp
|
2018-05-28 13:49:44 +00:00
|
|
|
llarp/logic.cpp
|
2018-05-16 13:56:51 +00:00
|
|
|
llarp/mem.cpp
|
|
|
|
llarp/net.cpp
|
|
|
|
llarp/nodedb.cpp
|
2018-06-10 14:05:48 +00:00
|
|
|
llarp/path.cpp
|
2018-06-18 22:03:50 +00:00
|
|
|
llarp/pathbuilder.cpp
|
|
|
|
llarp/proofofwork.cpp
|
2018-06-08 13:12:17 +00:00
|
|
|
llarp/relay_ack.cpp
|
2018-06-01 14:08:54 +00:00
|
|
|
llarp/relay_commit.cpp
|
2018-06-08 13:12:17 +00:00
|
|
|
llarp/relay_up_down.cpp
|
2018-05-27 13:42:55 +00:00
|
|
|
llarp/router_contact.cpp
|
2018-05-16 13:56:51 +00:00
|
|
|
llarp/router.cpp
|
|
|
|
llarp/threadpool.cpp
|
2018-06-06 17:02:57 +00:00
|
|
|
llarp/testnet.c
|
2018-05-16 13:56:51 +00:00
|
|
|
llarp/time.cpp
|
|
|
|
llarp/timer.cpp
|
2018-06-14 19:22:26 +00:00
|
|
|
vendor/cppbackport-master/lib/fs/rename.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/filestatus.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/filetype.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/cleanpath.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/perms.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/equivalent.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/current_path.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/basename.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/tempdir.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/create_directory.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/path.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/remove.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/diriter.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/copyfile.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/absolute.cpp
|
|
|
|
vendor/cppbackport-master/lib/fs/direntry.cpp
|
2018-05-16 13:56:51 +00:00
|
|
|
)
|
|
|
|
|
2018-06-14 14:04:42 +00:00
|
|
|
set(TEST_SRC
|
|
|
|
test/main.cpp
|
|
|
|
test/dht_unittest.cpp
|
|
|
|
)
|
|
|
|
set(TEST_EXE testAll)
|
|
|
|
set(GTEST_DIR test/gtest)
|
|
|
|
|
2018-06-15 13:42:49 +00:00
|
|
|
# TODO: exclude this from includes and expose stuff properly for rcutil
|
2018-06-14 19:28:27 +00:00
|
|
|
include_directories(llarp)
|
2018-06-15 13:42:49 +00:00
|
|
|
|
2018-05-16 13:56:51 +00:00
|
|
|
include_directories(include)
|
2018-06-14 19:22:26 +00:00
|
|
|
include_directories(vendor/cppbackport-master/lib)
|
2018-06-06 12:59:15 +00:00
|
|
|
|
2018-06-14 14:04:42 +00:00
|
|
|
|
|
|
|
|
2018-06-06 12:59:15 +00:00
|
|
|
if(SHADOW)
|
2018-06-06 17:02:57 +00:00
|
|
|
add_shadow_plugin(shadow-plugin-${SHARED_LIB} ${EXE_SRC} ${LIB_SRC})
|
|
|
|
target_link_libraries(shadow-plugin-${SHARED_LIB} ${LIBS})
|
|
|
|
install(TARGETS shadow-plugin-${SHARED_LIB} DESTINATION plugins)
|
|
|
|
else()
|
|
|
|
|
|
|
|
add_executable(rcutil daemon/rcutil.cpp)
|
|
|
|
add_executable(${EXE} ${EXE_SRC})
|
|
|
|
|
2018-06-14 14:04:42 +00:00
|
|
|
if(WITH_TESTS)
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(${GTEST_DIR})
|
|
|
|
include_directories(${GTEST_DIR}/include ${GTEST_DIR})
|
|
|
|
add_executable(${TEST_EXE} ${TEST_SRC})
|
|
|
|
add_test(runAllTests ${TEST_EXE})
|
2018-06-15 13:42:49 +00:00
|
|
|
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB})
|
2018-06-14 14:04:42 +00:00
|
|
|
endif()
|
|
|
|
|
2018-06-06 17:02:57 +00:00
|
|
|
if(WITH_STATIC)
|
|
|
|
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
|
|
|
|
target_link_libraries(${STATIC_LIB} ${LIBS})
|
|
|
|
if(NOT WITH_SHARED)
|
2018-06-15 13:42:49 +00:00
|
|
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB})
|
|
|
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB})
|
2018-06-06 17:02:57 +00:00
|
|
|
endif()
|
2018-06-06 13:17:03 +00:00
|
|
|
endif()
|
2018-06-06 17:02:57 +00:00
|
|
|
|
|
|
|
if(WITH_SHARED)
|
|
|
|
add_library(${SHARED_LIB} SHARED ${LIB_SRC})
|
|
|
|
target_link_libraries(${SHARED_LIB} ${LIBS})
|
|
|
|
if(NOT WITH_STATIC)
|
|
|
|
target_link_libraries(rcutil ${SHARED_LIB})
|
|
|
|
target_link_libraries(${EXE} ${SHARED_LIB})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-06-06 12:59:15 +00:00
|
|
|
endif()
|