2020-05-20 09:17:54 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
2015-11-25 20:06:26 +00:00
|
|
|
# this addresses CMP0059 with CMake > 3.3 for PCH flags
|
2020-05-20 09:17:54 +00:00
|
|
|
cmake_policy(VERSION 2.8.12)
|
|
|
|
project("i2pd")
|
2014-04-03 19:54:43 +00:00
|
|
|
|
2016-07-13 01:01:47 +00:00
|
|
|
# for debugging
|
|
|
|
#set(CMAKE_VERBOSE_MAKEFILE on)
|
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
# Win32 build with cmake is not supported
|
|
|
|
if(WIN32 OR MSVC OR MSYS OR MINGW)
|
|
|
|
message(SEND_ERROR "cmake build for windows is not supported. Please use MSYS2 with makefiles in project root.")
|
|
|
|
endif()
|
|
|
|
|
2020-11-14 22:31:20 +00:00
|
|
|
# configurable options
|
|
|
|
option(WITH_AESNI "Use AES-NI instructions set" ON)
|
2020-05-20 09:17:54 +00:00
|
|
|
option(WITH_HARDENING "Use hardening compiler flags" OFF)
|
|
|
|
option(WITH_LIBRARY "Build library" ON)
|
|
|
|
option(WITH_BINARY "Build binary" ON)
|
|
|
|
option(WITH_STATIC "Static build" OFF)
|
|
|
|
option(WITH_UPNP "Include support for UPnP client" OFF)
|
|
|
|
option(WITH_PCH "Use precompiled header" OFF)
|
|
|
|
option(WITH_MESHNET "Build for cjdns test network" OFF)
|
|
|
|
option(WITH_ADDRSANITIZER "Build with address sanitizer unix only" OFF)
|
|
|
|
option(WITH_THREADSANITIZER "Build with thread sanitizer unix only" OFF)
|
2016-10-20 13:12:15 +00:00
|
|
|
|
2014-09-17 00:16:39 +00:00
|
|
|
# paths
|
2020-05-20 09:17:54 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
|
|
|
|
set(CMAKE_SOURCE_DIR "..")
|
2014-09-17 00:16:39 +00:00
|
|
|
|
2017-12-20 13:49:47 +00:00
|
|
|
# architecture
|
2017-12-20 13:54:02 +00:00
|
|
|
include(TargetArch)
|
2017-12-20 13:49:47 +00:00
|
|
|
target_architecture(ARCHITECTURE)
|
|
|
|
|
2017-04-21 10:33:45 +00:00
|
|
|
set(LIBI2PD_SRC_DIR ../libi2pd)
|
|
|
|
set(LIBI2PD_CLIENT_SRC_DIR ../libi2pd_client)
|
2021-05-23 12:39:29 +00:00
|
|
|
set(LANG_SRC_DIR ../i18n)
|
2020-05-20 09:17:54 +00:00
|
|
|
set(DAEMON_SRC_DIR ../daemon)
|
2017-04-21 10:33:45 +00:00
|
|
|
|
|
|
|
include_directories(${LIBI2PD_SRC_DIR})
|
|
|
|
include_directories(${LIBI2PD_CLIENT_SRC_DIR})
|
2021-05-23 12:39:29 +00:00
|
|
|
include_directories(${LANG_SRC_DIR})
|
2020-05-20 09:17:54 +00:00
|
|
|
include_directories(${DAEMON_SRC_DIR})
|
2017-04-21 10:33:45 +00:00
|
|
|
|
2021-05-26 10:15:17 +00:00
|
|
|
FILE(GLOB LIBI2PD_SRC ${LIBI2PD_SRC_DIR}/*.cpp)
|
2015-11-12 03:24:53 +00:00
|
|
|
add_library(libi2pd ${LIBI2PD_SRC})
|
2016-03-08 22:58:51 +00:00
|
|
|
set_target_properties(libi2pd PROPERTIES PREFIX "")
|
2018-03-11 16:20:47 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_LIBRARY)
|
2018-03-11 16:20:47 +00:00
|
|
|
install(TARGETS libi2pd
|
|
|
|
EXPORT libi2pd
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
COMPONENT Libraries)
|
2015-12-12 02:15:48 +00:00
|
|
|
# TODO Make libi2pd available to 3rd party projects via CMake as imported target
|
|
|
|
# FIXME This pulls stdafx
|
|
|
|
# install(EXPORT libi2pd DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2018-03-11 16:20:47 +00:00
|
|
|
endif()
|
2015-05-11 09:56:13 +00:00
|
|
|
|
2021-05-26 10:15:17 +00:00
|
|
|
FILE(GLOB CLIENT_SRC ${LIBI2PD_CLIENT_SRC_DIR}/*.cpp)
|
2018-03-05 13:55:54 +00:00
|
|
|
add_library(libi2pdclient ${CLIENT_SRC})
|
|
|
|
set_target_properties(libi2pdclient PROPERTIES PREFIX "")
|
2018-03-11 16:20:47 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_LIBRARY)
|
2018-03-11 16:20:47 +00:00
|
|
|
install(TARGETS libi2pdclient
|
|
|
|
EXPORT libi2pdclient
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
COMPONENT Libraries)
|
|
|
|
endif()
|
2015-11-12 03:24:53 +00:00
|
|
|
|
2021-05-26 10:15:17 +00:00
|
|
|
FILE(GLOB LANG_SRC ${LANG_SRC_DIR}/*.cpp)
|
2021-06-26 20:59:34 +00:00
|
|
|
add_library(libi2pdlang ${LANG_SRC})
|
|
|
|
set_target_properties(libi2pdlang PROPERTIES PREFIX "")
|
|
|
|
|
|
|
|
if(WITH_LIBRARY)
|
|
|
|
install(TARGETS libi2pdlang
|
|
|
|
EXPORT libi2pdlang
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
COMPONENT Libraries)
|
|
|
|
endif()
|
2021-05-23 12:39:29 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
set(DAEMON_SRC
|
2017-04-21 10:33:45 +00:00
|
|
|
"${DAEMON_SRC_DIR}/Daemon.cpp"
|
|
|
|
"${DAEMON_SRC_DIR}/HTTPServer.cpp"
|
|
|
|
"${DAEMON_SRC_DIR}/I2PControl.cpp"
|
|
|
|
"${DAEMON_SRC_DIR}/i2pd.cpp"
|
|
|
|
"${DAEMON_SRC_DIR}/UPnP.cpp"
|
2014-12-12 13:46:07 +00:00
|
|
|
)
|
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_MESHNET)
|
2016-06-29 13:37:38 +00:00
|
|
|
add_definitions(-DMESHNET)
|
2020-05-20 09:17:54 +00:00
|
|
|
endif()
|
2016-06-29 13:37:38 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_UPNP)
|
2015-06-06 18:53:22 +00:00
|
|
|
add_definitions(-DUSE_UPNP)
|
2020-05-20 09:17:54 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Winvalid-pch -Wno-unused-parameter")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pedantic")
|
|
|
|
# TODO: The following is incompatible with static build and enabled hardening for OpenWRT.
|
|
|
|
# Multiple definitions of __stack_chk_fail(libssp & libc)
|
|
|
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -flto -s -ffunction-sections -fdata-sections")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-Wl,--gc-sections") # -flto is added from above
|
2014-09-22 22:36:06 +00:00
|
|
|
|
2020-02-28 20:05:26 +00:00
|
|
|
# check for c++17 & c++11 support
|
2014-09-22 22:36:06 +00:00
|
|
|
include(CheckCXXCompilerFlag)
|
2020-02-28 20:05:26 +00:00
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++17" CXX17_SUPPORTED)
|
2014-09-22 22:36:06 +00:00
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" CXX11_SUPPORTED)
|
2020-02-28 20:28:41 +00:00
|
|
|
if(CXX17_SUPPORTED)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
|
|
|
elseif(CXX11_SUPPORTED)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
else()
|
2020-02-28 20:05:26 +00:00
|
|
|
message(SEND_ERROR "C++17 nor C++11 standard not seems to be supported by compiler. Too old version?")
|
2020-02-28 20:28:41 +00:00
|
|
|
endif()
|
2014-09-22 22:36:06 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe")
|
|
|
|
if(WITH_HARDENING)
|
|
|
|
add_definitions("-D_FORTIFY_SOURCE=2")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security -Werror=format-security")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector --param ssp-buffer-size=4")
|
|
|
|
endif()
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
2014-09-22 22:36:06 +00:00
|
|
|
# more tweaks
|
2020-05-20 09:17:54 +00:00
|
|
|
if(LINUX)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -stdlib=libstdc++") # required for <atomic>
|
2017-10-08 22:32:15 +00:00
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "stdc++") # required to link with -stdlib=libstdc++
|
2018-06-27 14:47:22 +00:00
|
|
|
endif()
|
2020-05-20 09:17:54 +00:00
|
|
|
if(NOT APPLE)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-const-variable -Wno-overloaded-virtual -Wno-c99-extensions")
|
2017-10-08 22:32:15 +00:00
|
|
|
endif()
|
2020-05-20 09:17:54 +00:00
|
|
|
endif()
|
2015-12-07 02:45:44 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
# compiler flags customization(by system)
|
|
|
|
if(UNIX)
|
|
|
|
list(APPEND DAEMON_SRC "${DAEMON_SRC_DIR}/UnixDaemon.cpp")
|
|
|
|
if(NOT(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR APPLE))
|
2018-01-05 13:20:31 +00:00
|
|
|
# "'sleep_for' is not a member of 'std::this_thread'" in gcc 4.7/4.8
|
2020-05-20 09:17:54 +00:00
|
|
|
add_definitions("-D_GLIBCXX_USE_NANOSLEEP=1")
|
|
|
|
endif()
|
2014-09-17 00:16:39 +00:00
|
|
|
endif()
|
2014-04-04 23:52:40 +00:00
|
|
|
|
2020-11-14 22:31:20 +00:00
|
|
|
# Note: AES-NI and AVX is available on x86-based CPU's.
|
|
|
|
# Here also ARM64 implementation, but currently we don't support it.
|
|
|
|
if(WITH_AESNI AND (ARCHITECTURE MATCHES "x86_64" OR ARCHITECTURE MATCHES "i386"))
|
2020-05-20 09:17:54 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
|
2020-11-14 22:31:20 +00:00
|
|
|
add_definitions(-D__AES__)
|
2020-05-20 09:17:54 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_ADDRSANITIZER)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
2016-09-17 08:00:21 +00:00
|
|
|
endif()
|
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_THREADSANITIZER)
|
|
|
|
if(WITH_ADDRSANITIZER)
|
|
|
|
message(FATAL_ERROR "thread sanitizer option cannot be combined with address sanitizer")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
|
2016-10-03 20:24:22 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2014-09-17 00:16:39 +00:00
|
|
|
# libraries
|
2015-06-10 06:07:39 +00:00
|
|
|
# TODO: once CMake 3.1+ becomes mainstream, see e.g. http://stackoverflow.com/a/29871891/673826
|
|
|
|
# use imported Threads::Threads instead
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
2020-05-20 09:17:54 +00:00
|
|
|
if(IOS)
|
2016-09-06 19:26:59 +00:00
|
|
|
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
|
|
|
set(CMAKE_HAVE_THREADS_LIBRARY 1)
|
|
|
|
set(CMAKE_USE_WIN32_THREADS_INIT 0)
|
|
|
|
set(CMAKE_USE_PTHREADS_INIT 1)
|
|
|
|
else()
|
2020-05-20 09:17:54 +00:00
|
|
|
find_package(Threads REQUIRED)
|
2016-09-06 19:26:59 +00:00
|
|
|
endif()
|
2015-06-10 06:07:39 +00:00
|
|
|
if(THREADS_HAVE_PTHREAD_ARG) # compile time flag
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
|
|
|
endif()
|
2014-04-03 19:54:43 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_STATIC)
|
2015-06-06 08:33:15 +00:00
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
2015-06-10 06:07:39 +00:00
|
|
|
set(Boost_USE_STATIC_RUNTIME ON)
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
2020-05-20 09:17:54 +00:00
|
|
|
if(${CMAKE_CXX_COMPILER} MATCHES ".*-openwrt-.*")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
|
|
|
# set(CMAKE_THREAD_LIBS_INIT "gcc_eh -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
|
|
|
|
set(CMAKE_THREAD_LIBS_INIT "gcc_eh -Wl,-u,pthread_create,-u,pthread_once,-u,pthread_mutex_lock,-u,pthread_mutex_unlock,-u,pthread_join,-u,pthread_equal,-u,pthread_detach,-u,pthread_cond_wait,-u,pthread_cond_signal,-u,pthread_cond_destroy,-u,pthread_cond_broadcast,-u,pthread_cancel")
|
|
|
|
endif()
|
2015-06-10 06:07:39 +00:00
|
|
|
else()
|
2020-05-20 09:17:54 +00:00
|
|
|
# TODO: Consider separate compilation for LIBI2PD_SRC for library.
|
|
|
|
# No need in -fPIC overhead for binary if not interested in library
|
|
|
|
# HINT: revert c266cff CMakeLists.txt: compilation speed up
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
2015-12-13 00:06:11 +00:00
|
|
|
add_definitions(-DBOOST_SYSTEM_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_REGEX_DYN_LINK)
|
2020-05-20 09:17:54 +00:00
|
|
|
endif()
|
2015-06-06 08:33:15 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_PCH)
|
2016-02-04 13:49:07 +00:00
|
|
|
include_directories(BEFORE ${CMAKE_BINARY_DIR})
|
2017-04-21 10:33:45 +00:00
|
|
|
add_library(stdafx STATIC "${LIBI2PD_SRC_DIR}/stdafx.cpp")
|
2020-05-20 09:17:54 +00:00
|
|
|
string(TOUPPER ${CMAKE_BUILD_TYPE} BTU)
|
|
|
|
get_directory_property(DEFS DEFINITIONS)
|
|
|
|
string(REPLACE " " ";" FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTU}} ${DEFS}")
|
|
|
|
add_custom_command(TARGET stdafx PRE_BUILD
|
|
|
|
COMMAND ${CMAKE_CXX_COMPILER} ${FLAGS} -c ${CMAKE_CURRENT_SOURCE_DIR}/../libi2pd/stdafx.h -o ${CMAKE_BINARY_DIR}/stdafx.h.gch
|
|
|
|
)
|
|
|
|
target_compile_options(libi2pd PRIVATE -include libi2pd/stdafx.h)
|
|
|
|
target_compile_options(libi2pdclient PRIVATE -include libi2pd/stdafx.h)
|
2021-06-26 20:59:34 +00:00
|
|
|
target_compile_options(libi2pdlang PRIVATE -include libi2pd/stdafx.h)
|
2015-11-12 03:24:53 +00:00
|
|
|
target_link_libraries(libi2pd stdafx)
|
2015-06-10 06:04:33 +00:00
|
|
|
endif()
|
|
|
|
|
2021-06-26 20:59:34 +00:00
|
|
|
target_link_libraries(libi2pdclient libi2pd libi2pdlang)
|
2015-11-25 20:06:26 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
find_package(Boost COMPONENTS system filesystem program_options date_time REQUIRED)
|
2014-04-04 23:52:40 +00:00
|
|
|
if(NOT DEFINED Boost_INCLUDE_DIRS)
|
2018-07-10 09:39:21 +00:00
|
|
|
message(SEND_ERROR "Boost is not found, or your boost version was below 1.46. Please download Boost!")
|
2014-04-03 23:54:21 +00:00
|
|
|
endif()
|
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
find_package(OpenSSL REQUIRED)
|
2015-11-11 19:46:29 +00:00
|
|
|
if(NOT DEFINED OPENSSL_INCLUDE_DIR)
|
|
|
|
message(SEND_ERROR "Could not find OpenSSL. Please download and install it first!")
|
2014-04-03 23:54:21 +00:00
|
|
|
endif()
|
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_UPNP)
|
|
|
|
find_package(MiniUPnPc REQUIRED)
|
|
|
|
if(NOT MINIUPNPC_FOUND)
|
|
|
|
message(SEND_ERROR "Could not find MiniUPnPc. Please download and install it first!")
|
2015-12-07 20:53:38 +00:00
|
|
|
else()
|
2020-05-20 09:17:54 +00:00
|
|
|
include_directories(SYSTEM ${MINIUPNPC_INCLUDE_DIR})
|
2015-12-07 20:53:38 +00:00
|
|
|
endif()
|
2020-05-20 09:17:54 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(ZLIB)
|
|
|
|
if(ZLIB_FOUND)
|
2018-01-05 13:20:31 +00:00
|
|
|
link_directories(${ZLIB_ROOT}/lib)
|
2020-05-20 09:17:54 +00:00
|
|
|
endif()
|
2015-11-11 19:46:29 +00:00
|
|
|
|
2014-09-17 00:16:39 +00:00
|
|
|
# load includes
|
2020-05-20 09:17:54 +00:00
|
|
|
include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
|
2016-06-29 13:37:38 +00:00
|
|
|
|
|
|
|
# warn if for meshnet
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_MESHNET)
|
2016-06-29 13:37:38 +00:00
|
|
|
message(STATUS "Building for testnet")
|
2017-04-08 16:51:35 +00:00
|
|
|
message(WARNING "This build will NOT work on mainline i2p")
|
2016-06-29 13:37:38 +00:00
|
|
|
endif()
|
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(NOT MSYS)
|
|
|
|
include(CheckAtomic)
|
|
|
|
endif()
|
2016-06-29 13:37:38 +00:00
|
|
|
|
2014-09-17 00:16:39 +00:00
|
|
|
# show summary
|
|
|
|
message(STATUS "---------------------------------------")
|
|
|
|
message(STATUS "Build type : ${CMAKE_BUILD_TYPE}")
|
2014-09-17 03:00:18 +00:00
|
|
|
message(STATUS "Compiler vendor : ${CMAKE_CXX_COMPILER_ID}")
|
2014-09-22 22:36:29 +00:00
|
|
|
message(STATUS "Compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
|
2014-09-17 03:00:18 +00:00
|
|
|
message(STATUS "Compiler path : ${CMAKE_CXX_COMPILER}")
|
2017-12-20 13:49:47 +00:00
|
|
|
message(STATUS "Architecture : ${ARCHITECTURE}")
|
2014-09-17 00:16:39 +00:00
|
|
|
message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}")
|
|
|
|
message(STATUS "Options:")
|
|
|
|
message(STATUS " AESNI : ${WITH_AESNI}")
|
|
|
|
message(STATUS " HARDENING : ${WITH_HARDENING}")
|
2014-12-12 13:46:07 +00:00
|
|
|
message(STATUS " LIBRARY : ${WITH_LIBRARY}")
|
2014-12-31 18:41:05 +00:00
|
|
|
message(STATUS " BINARY : ${WITH_BINARY}")
|
2014-12-12 13:46:07 +00:00
|
|
|
message(STATUS " STATIC BUILD : ${WITH_STATIC}")
|
2015-06-06 18:53:22 +00:00
|
|
|
message(STATUS " UPnP : ${WITH_UPNP}")
|
2015-06-10 06:04:33 +00:00
|
|
|
message(STATUS " PCH : ${WITH_PCH}")
|
2016-06-29 13:37:38 +00:00
|
|
|
message(STATUS " MESHNET : ${WITH_MESHNET}")
|
2016-09-17 08:00:21 +00:00
|
|
|
message(STATUS " ADDRSANITIZER : ${WITH_ADDRSANITIZER}")
|
2017-09-18 19:24:53 +00:00
|
|
|
message(STATUS " THREADSANITIZER : ${WITH_THREADSANITIZER}")
|
2014-09-17 00:16:39 +00:00
|
|
|
message(STATUS "---------------------------------------")
|
2014-04-03 23:54:21 +00:00
|
|
|
|
2014-12-31 18:05:54 +00:00
|
|
|
#Handle paths nicely
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_BINARY)
|
2021-06-26 20:59:34 +00:00
|
|
|
add_executable("${PROJECT_NAME}" ${DAEMON_SRC})
|
2020-05-20 09:17:54 +00:00
|
|
|
|
|
|
|
if(WITH_STATIC)
|
|
|
|
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-static")
|
2016-03-10 06:12:46 +00:00
|
|
|
endif()
|
2014-04-03 19:54:43 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_PCH)
|
|
|
|
target_compile_options("${PROJECT_NAME}" PRIVATE -include libi2pd/stdafx.h)
|
2015-06-10 06:04:33 +00:00
|
|
|
endif()
|
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_HARDENING AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-z relro -z now")
|
|
|
|
endif()
|
2014-04-03 19:54:43 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
if(WITH_UPNP)
|
|
|
|
set(UPNP_LIB ${MINIUPNPC_LIBRARY})
|
|
|
|
endif()
|
2016-06-27 01:12:20 +00:00
|
|
|
|
2015-06-10 06:07:39 +00:00
|
|
|
# FindBoost pulls pthread for thread which is broken for static linking at least on Ubuntu 15.04
|
|
|
|
list(GET Boost_LIBRARIES -1 LAST_Boost_LIBRARIES)
|
|
|
|
if(${LAST_Boost_LIBRARIES} MATCHES ".*pthread.*")
|
|
|
|
list(REMOVE_AT Boost_LIBRARIES -1)
|
|
|
|
endif()
|
2015-11-25 20:06:26 +00:00
|
|
|
|
2020-05-20 09:17:54 +00:00
|
|
|
|
|
|
|
if(WITH_STATIC)
|
2016-08-16 14:25:56 +00:00
|
|
|
set(DL_LIB ${CMAKE_DL_LIBS})
|
|
|
|
endif()
|
2020-05-20 09:17:54 +00:00
|
|
|
|
2019-06-01 11:57:09 +00:00
|
|
|
target_link_libraries(libi2pd ${Boost_LIBRARIES} ${ZLIB_LIBRARY})
|
2021-06-26 20:59:34 +00:00
|
|
|
target_link_libraries("${PROJECT_NAME}" libi2pd libi2pdclient libi2pdlang ${DL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${UPNP_LIB} ${ZLIB_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MINGW_EXTRA} ${DL_LIB} ${CMAKE_REQUIRED_LIBRARIES})
|
2014-09-17 00:16:39 +00:00
|
|
|
|
2015-12-12 02:15:48 +00:00
|
|
|
install(TARGETS "${PROJECT_NAME}" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime)
|
2020-05-20 09:17:54 +00:00
|
|
|
set(APPS "\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
|
|
|
set(DIRS "${Boost_LIBRARY_DIR};${OPENSSL_INCLUDE_DIR}/../bin;${ZLIB_INCLUDE_DIR}/../bin;/mingw32/bin")
|
2015-12-12 02:15:48 +00:00
|
|
|
endif()
|