2015-06-10 09:04:33 +03:00
|
|
|
cmake_minimum_required ( VERSION 2.8.12 )
|
2014-09-17 04:16:39 +04:00
|
|
|
project ( "i2pd" )
|
2014-04-03 23:54:43 +04:00
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
# configurale options
|
|
|
|
option(WITH_AESNI "Use AES-NI instructions set" OFF)
|
|
|
|
option(WITH_HARDENING "Use hardening compiler flags" OFF)
|
2014-12-12 16:46:07 +03:00
|
|
|
option(WITH_LIBRARY "Build library" ON)
|
2014-12-31 21:41:05 +03:00
|
|
|
option(WITH_BINARY "Build binary" ON)
|
2014-12-12 16:46:07 +03:00
|
|
|
option(WITH_STATIC "Static build" OFF)
|
2015-06-06 21:53:22 +03:00
|
|
|
option(WITH_UPNP "Include support for UPnP client" OFF)
|
2015-06-10 09:04:33 +03:00
|
|
|
option(WITH_PCH "Use precompiled header" OFF)
|
2014-04-03 23:54:43 +04:00
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
# paths
|
|
|
|
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
|
|
|
|
set ( CMAKE_SOURCE_DIR ".." )
|
|
|
|
|
2015-11-12 06:24:53 +03:00
|
|
|
set (LIBI2PD_SRC
|
2015-11-11 22:46:29 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/Crypto.cpp"
|
2014-09-17 04:16:39 +04:00
|
|
|
"${CMAKE_SOURCE_DIR}/Garlic.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/I2NPProtocol.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/Identity.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/LeaseSet.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/Log.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/NTCPSession.cpp"
|
2015-04-09 19:45:00 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/NetDbRequests.cpp"
|
2014-09-17 04:16:39 +04:00
|
|
|
"${CMAKE_SOURCE_DIR}/NetDb.cpp"
|
2015-03-24 19:47:57 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/Profiling.cpp"
|
2014-09-17 04:16:39 +04:00
|
|
|
"${CMAKE_SOURCE_DIR}/Reseed.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/RouterContext.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/RouterInfo.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/SSU.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/SSUData.cpp"
|
2014-12-12 16:46:07 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/SSUSession.cpp"
|
2014-09-17 04:16:39 +04:00
|
|
|
"${CMAKE_SOURCE_DIR}/Streaming.cpp"
|
2014-10-05 16:54:59 +04:00
|
|
|
"${CMAKE_SOURCE_DIR}/Destination.cpp"
|
2014-09-17 04:16:39 +04:00
|
|
|
"${CMAKE_SOURCE_DIR}/TransitTunnel.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/Tunnel.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/TunnelGateway.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/Transports.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/TunnelEndpoint.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/TunnelPool.cpp"
|
2015-11-11 22:46:29 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/Base.cpp"
|
2014-09-17 04:16:39 +04:00
|
|
|
"${CMAKE_SOURCE_DIR}/util.cpp"
|
2015-04-08 20:21:49 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/Datagram.cpp"
|
2015-05-11 12:56:13 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/Signature.cpp"
|
2015-11-12 06:24:53 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/api.cpp"
|
2014-12-12 16:46:07 +03:00
|
|
|
)
|
|
|
|
|
2015-06-06 11:33:15 +03:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
2015-11-12 06:24:53 +03:00
|
|
|
list (APPEND LIBI2PD_SRC "${CMAKE_SOURCE_DIR}/I2PEndian.cpp")
|
2015-06-06 11:33:15 +03:00
|
|
|
endif ()
|
|
|
|
|
2015-11-12 06:24:53 +03:00
|
|
|
add_library(libi2pd ${LIBI2PD_SRC})
|
2015-05-11 12:56:13 +03:00
|
|
|
|
2015-11-12 06:24:53 +03:00
|
|
|
set (CLIENT_SRC
|
|
|
|
"${CMAKE_SOURCE_DIR}/AddressBook.cpp"
|
2014-12-02 18:34:02 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/BOB.cpp"
|
2014-10-22 23:30:25 +04:00
|
|
|
"${CMAKE_SOURCE_DIR}/ClientContext.cpp"
|
2014-12-12 16:46:07 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/I2PTunnel.cpp"
|
2015-11-12 06:24:53 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/I2PService.cpp"
|
2014-12-12 16:46:07 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/SAM.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/SOCKS.cpp"
|
2015-11-12 06:24:53 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/HTTPProxy.cpp"
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(i2pdclient ${CLIENT_SRC})
|
|
|
|
|
|
|
|
set (DAEMON_SRC
|
|
|
|
"${CMAKE_SOURCE_DIR}/Daemon.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/HTTPServer.cpp"
|
|
|
|
"${CMAKE_SOURCE_DIR}/I2PControl.cpp"
|
2015-11-11 22:46:29 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/i2pd.cpp"
|
2015-11-12 06:24:53 +03:00
|
|
|
"${CMAKE_SOURCE_DIR}/UPnP.cpp"
|
2014-12-12 16:46:07 +03:00
|
|
|
)
|
|
|
|
|
2015-06-06 21:53:22 +03:00
|
|
|
if (WITH_UPNP)
|
|
|
|
add_definitions(-DUSE_UPNP)
|
2015-06-20 19:48:48 +03:00
|
|
|
if (NOT MSVC)
|
|
|
|
set(DL_LIB ${CMAKE_DL_LIBS})
|
|
|
|
endif ()
|
2015-06-06 21:53:22 +03:00
|
|
|
endif ()
|
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
# Default build is Debug
|
2015-06-10 09:07:39 +03:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
2014-09-17 04:16:39 +04:00
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
2014-04-23 22:48:02 +04:00
|
|
|
endif ()
|
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
# compiler flags customization (by vendor)
|
2015-11-11 22:46:29 +03:00
|
|
|
if (MSVC)
|
|
|
|
add_definitions( -D_WIN32_WINNT=_WIN32_WINNT_WINXP -DWIN32_LEAN_AND_MEAN -DNOMINMAX ) #-DOPENSSL_NO_SSL2 -DOPENSSL_USE_DEPRECATED
|
|
|
|
else()
|
2015-06-10 09:04:33 +03:00
|
|
|
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Winvalid-pch" )
|
2015-06-10 09:07:39 +03:00
|
|
|
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
|
2015-06-06 11:33:15 +03:00
|
|
|
endif ()
|
2014-09-23 02:36:06 +04:00
|
|
|
|
|
|
|
# check for c++11 support
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" CXX11_SUPPORTED)
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++0x" CXX0X_SUPPORTED)
|
|
|
|
if (CXX11_SUPPORTED)
|
2014-09-17 07:30:12 +04:00
|
|
|
add_definitions( "-std=c++11" )
|
2014-09-23 02:36:06 +04:00
|
|
|
elseif (CXX0X_SUPPORTED) # gcc 4.6
|
|
|
|
add_definitions( "-std=c++0x" )
|
2015-06-06 11:33:15 +03:00
|
|
|
elseif (NOT MSVC)
|
2014-09-23 02:36:06 +04:00
|
|
|
message(SEND_ERROR "C++11 standart not seems to be supported by compiler. Too old version?")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2014-09-17 04:16:39 +04:00
|
|
|
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-23 02:36:06 +04:00
|
|
|
# more tweaks
|
2014-09-17 04:16:39 +04:00
|
|
|
endif ()
|
2014-04-23 22:48:02 +04:00
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
# compiler flags customization (by system)
|
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
2014-12-12 16:46:07 +03:00
|
|
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
|
2015-03-27 05:48:26 +03:00
|
|
|
# "'sleep_for' is not a member of 'std::this_thread'" in gcc 4.7/4.8
|
|
|
|
add_definitions( "-D_GLIBCXX_USE_NANOSLEEP=1" )
|
2014-09-17 04:16:39 +04:00
|
|
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
2014-12-12 16:46:07 +03:00
|
|
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
|
2014-09-17 09:10:03 +04:00
|
|
|
# "'sleep_for' is not a member of 'std::this_thread'" in gcc 4.7/4.8
|
|
|
|
add_definitions( "-D_GLIBCXX_USE_NANOSLEEP=1" )
|
2014-12-12 16:46:07 +03:00
|
|
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
|
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
|
2015-11-20 17:55:34 +03:00
|
|
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
|
|
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonLinux.cpp")
|
2014-09-17 04:16:39 +04:00
|
|
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
2014-12-12 16:46:07 +03:00
|
|
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/DaemonWin32.cpp")
|
2015-06-06 11:33:15 +03:00
|
|
|
list (APPEND DAEMON_SRC "${CMAKE_SOURCE_DIR}/Win32/Win32Service.cpp")
|
2014-09-17 04:16:39 +04:00
|
|
|
endif ()
|
2014-04-23 22:48:02 +04:00
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
if (WITH_AESNI)
|
|
|
|
add_definitions ( "-maes -DAESNI" )
|
|
|
|
endif()
|
2014-04-05 03:52:40 +04:00
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
# libraries
|
2015-06-10 09:07:39 +03: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)
|
2014-04-03 23:54:43 +04:00
|
|
|
find_package ( Threads REQUIRED )
|
2015-06-10 09:07:39 +03:00
|
|
|
if(THREADS_HAVE_PTHREAD_ARG) # compile time flag
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
|
|
|
endif()
|
2014-04-03 23:54:43 +04:00
|
|
|
|
2015-06-06 11:33:15 +03:00
|
|
|
if (WITH_STATIC)
|
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
2015-06-10 09:07:39 +03:00
|
|
|
set(Boost_USE_STATIC_RUNTIME ON)
|
|
|
|
if (WIN32)
|
|
|
|
# http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace
|
|
|
|
# Note that you might need to rebuild Crypto++
|
|
|
|
foreach(flag_var
|
|
|
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
|
|
if(${flag_var} MATCHES "/MD")
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
|
|
endif(${flag_var} MATCHES "/MD")
|
|
|
|
endforeach(flag_var)
|
|
|
|
else ()
|
|
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
|
|
|
endif ()
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
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 ()
|
|
|
|
else()
|
|
|
|
if (NOT WIN32)
|
2015-11-12 06:24:53 +03:00
|
|
|
# TODO: Consider separate compilation for LIBI2PD_SRC for library.
|
2015-06-10 09:07:39 +03:00
|
|
|
# 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" )
|
|
|
|
endif ()
|
|
|
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
2015-06-06 11:33:15 +03:00
|
|
|
endif ()
|
|
|
|
|
2015-06-10 09:04:33 +03:00
|
|
|
if (WITH_PCH)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
|
|
|
add_library(stdafx STATIC "${CMAKE_SOURCE_DIR}/stdafx.cpp")
|
|
|
|
if(MSVC)
|
|
|
|
target_compile_options(stdafx PRIVATE /Ycstdafx.h /Zm135)
|
|
|
|
add_custom_command(TARGET stdafx POST_BUILD
|
2015-11-12 06:24:53 +03:00
|
|
|
COMMAND xcopy /y stdafx.dir\\$<CONFIG>\\*.pdb libi2pd.dir\\$<CONFIG>\\
|
|
|
|
COMMAND xcopy /y stdafx.dir\\$<CONFIG>\\*.pdb i2pdclient.dir\\$<CONFIG>\\
|
2015-06-10 09:04:33 +03:00
|
|
|
COMMAND xcopy /y stdafx.dir\\$<CONFIG>\\*.pdb i2pd.dir\\$<CONFIG>\\
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
)
|
2015-11-12 06:24:53 +03:00
|
|
|
target_compile_options(libi2pd PRIVATE /FIstdafx.h /Yustdafx.h /Zm135 "/Fp${CMAKE_BINARY_DIR}/stdafx.dir/$<CONFIG>/stdafx.pch")
|
|
|
|
target_compile_options(i2pdclient PRIVATE /FIstdafx.h /Yustdafx.h /Zm135 "/Fp${CMAKE_BINARY_DIR}/stdafx.dir/$<CONFIG>/stdafx.pch")
|
2015-06-10 09:04:33 +03:00
|
|
|
else()
|
|
|
|
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}/../stdafx.h
|
|
|
|
)
|
2015-11-12 06:24:53 +03:00
|
|
|
target_compile_options(libi2pd PRIVATE -include stdafx.h)
|
|
|
|
target_compile_options(i2pdclient PRIVATE -include stdafx.h)
|
2015-06-10 09:04:33 +03:00
|
|
|
endif()
|
2015-11-12 06:24:53 +03:00
|
|
|
target_link_libraries(libi2pd stdafx)
|
|
|
|
target_link_libraries(i2pdclient stdafx)
|
2015-06-10 09:04:33 +03:00
|
|
|
endif()
|
|
|
|
|
2015-06-06 21:53:22 +03:00
|
|
|
find_package ( Boost COMPONENTS system filesystem regex program_options date_time thread chrono REQUIRED )
|
2014-04-05 03:52:40 +04:00
|
|
|
if(NOT DEFINED Boost_INCLUDE_DIRS)
|
2014-09-17 04:16:39 +04:00
|
|
|
message(SEND_ERROR "Boost is not found, or your boost version was bellow 1.46. Please download Boost!")
|
2014-04-04 03:54:21 +04:00
|
|
|
endif()
|
|
|
|
|
2015-11-11 22:46:29 +03:00
|
|
|
find_package ( OpenSSL REQUIRED )
|
|
|
|
if(NOT DEFINED OPENSSL_INCLUDE_DIR)
|
|
|
|
message(SEND_ERROR "Could not find OpenSSL. Please download and install it first!")
|
2014-04-04 03:54:21 +04:00
|
|
|
endif()
|
|
|
|
|
2015-06-06 21:53:22 +03:00
|
|
|
find_package ( MiniUPnPc )
|
2015-11-11 22:46:29 +03:00
|
|
|
if (MINIUPNPC_FOUND)
|
|
|
|
include_directories( ${MINIUPNPC_INCLUDE_DIR} )
|
|
|
|
else ()
|
2015-06-06 21:53:22 +03:00
|
|
|
set(WITH_UPNP OFF)
|
|
|
|
endif()
|
|
|
|
|
2015-11-11 22:46:29 +03:00
|
|
|
find_package ( ZLIB )
|
2015-11-12 06:24:53 +03:00
|
|
|
if (NOT ZLIB_FOUND )
|
|
|
|
# We are probably on Windows
|
2015-11-11 22:46:29 +03:00
|
|
|
include( ExternalProject )
|
2015-11-12 06:24:53 +03:00
|
|
|
ExternalProject_Add(zlib-project
|
2015-11-11 22:46:29 +03:00
|
|
|
URL http://zlib.net/zlib-1.2.8.tar.gz
|
|
|
|
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/zlib
|
|
|
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
2015-11-12 06:24:53 +03:00
|
|
|
)
|
|
|
|
if (WITH_PCH)
|
|
|
|
add_dependencies( stdafx zlib-project )
|
|
|
|
else ()
|
|
|
|
add_dependencies( libi2pd zlib-project )
|
|
|
|
endif ()
|
|
|
|
# ExternalProject_Get_Property(zlib-project install_dir)
|
|
|
|
set ( ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib/include" CACHE FILEPATH "zlib include dir" FORCE)
|
|
|
|
set ( ZLIB_LIBRARY debug zlibd optimized zlib CACHE STRING "zlib libraries" FORCE)
|
2015-11-11 22:46:29 +03:00
|
|
|
endif ()
|
2015-11-12 06:24:53 +03:00
|
|
|
link_directories("${CMAKE_CURRENT_BINARY_DIR}/zlib/lib")
|
2015-11-11 22:46:29 +03:00
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
# load includes
|
2015-11-11 22:46:29 +03:00
|
|
|
include_directories( ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
|
2014-04-04 03:54:21 +04:00
|
|
|
|
2014-09-17 04:16:39 +04:00
|
|
|
# show summary
|
|
|
|
message(STATUS "---------------------------------------")
|
|
|
|
message(STATUS "Build type : ${CMAKE_BUILD_TYPE}")
|
2014-09-17 07:00:18 +04:00
|
|
|
message(STATUS "Compiler vendor : ${CMAKE_CXX_COMPILER_ID}")
|
2014-09-23 02:36:29 +04:00
|
|
|
message(STATUS "Compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
|
2014-09-17 07:00:18 +04:00
|
|
|
message(STATUS "Compiler path : ${CMAKE_CXX_COMPILER}")
|
2014-09-17 04:16:39 +04:00
|
|
|
message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}")
|
|
|
|
message(STATUS "Options:")
|
|
|
|
message(STATUS " AESNI : ${WITH_AESNI}")
|
|
|
|
message(STATUS " HARDENING : ${WITH_HARDENING}")
|
2014-12-12 16:46:07 +03:00
|
|
|
message(STATUS " LIBRARY : ${WITH_LIBRARY}")
|
2014-12-31 21:41:05 +03:00
|
|
|
message(STATUS " BINARY : ${WITH_BINARY}")
|
2014-12-12 16:46:07 +03:00
|
|
|
message(STATUS " STATIC BUILD : ${WITH_STATIC}")
|
2015-06-06 21:53:22 +03:00
|
|
|
message(STATUS " UPnP : ${WITH_UPNP}")
|
2015-06-10 09:04:33 +03:00
|
|
|
message(STATUS " PCH : ${WITH_PCH}")
|
2014-09-17 04:16:39 +04:00
|
|
|
message(STATUS "---------------------------------------")
|
2014-04-04 03:54:21 +04:00
|
|
|
|
2014-12-31 21:05:54 +03:00
|
|
|
#Handle paths nicely
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2014-12-31 21:41:05 +03:00
|
|
|
if (WITH_BINARY)
|
2015-11-12 06:24:53 +03:00
|
|
|
add_executable ( "${PROJECT_NAME}" ${DAEMON_SRC} )
|
2015-06-06 11:33:15 +03:00
|
|
|
if(NOT MSVC) # FIXME: incremental linker file name (.ilk) collision for dll & exe
|
2015-06-10 09:07:39 +03:00
|
|
|
if (WITH_STATIC)
|
2015-11-12 06:24:53 +03:00
|
|
|
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-static" )
|
2015-06-10 09:07:39 +03:00
|
|
|
endif ()
|
2015-06-06 11:33:15 +03:00
|
|
|
endif()
|
2014-04-03 23:54:43 +04:00
|
|
|
|
2015-06-10 09:04:33 +03:00
|
|
|
if (WITH_PCH)
|
|
|
|
if (MSVC)
|
2015-11-12 06:24:53 +03:00
|
|
|
target_compile_options("${PROJECT_NAME}" PRIVATE /FIstdafx.h /Yustdafx.h /Zm135 "/Fp${CMAKE_BINARY_DIR}/stdafx.dir/$<CONFIG>/stdafx.pch")
|
2015-06-10 09:04:33 +03:00
|
|
|
else()
|
2015-11-12 06:24:53 +03:00
|
|
|
target_compile_options("${PROJECT_NAME}" PRIVATE -include stdafx.h)
|
2015-06-10 09:04:33 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2014-12-31 21:41:05 +03:00
|
|
|
if (WITH_HARDENING AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2015-11-12 06:24:53 +03:00
|
|
|
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-z relro -z now" )
|
2014-12-31 21:41:05 +03:00
|
|
|
endif ()
|
2014-04-03 23:54:43 +04:00
|
|
|
|
2015-06-10 09:07:39 +03: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-12 06:24:53 +03:00
|
|
|
target_link_libraries( "${PROJECT_NAME}" libi2pd i2pdclient ${DL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} )
|
2014-09-17 04:16:39 +04:00
|
|
|
|
2015-11-12 06:24:53 +03:00
|
|
|
install(TARGETS "${PROJECT_NAME}" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
|
2015-06-06 22:16:29 +03:00
|
|
|
if (MSVC)
|
2015-11-12 06:24:53 +03:00
|
|
|
install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}> DESTINATION "bin" CONFIGURATIONS DEBUG)
|
2015-06-06 22:16:29 +03:00
|
|
|
endif ()
|
2014-12-31 21:41:05 +03:00
|
|
|
endif ()
|