1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-30 16:14:14 +00:00

* better CMakeLists

This commit is contained in:
hagen 2014-09-17 00:16:39 +00:00
parent ef417eb8d9
commit 1204a5e507

View File

@ -1,135 +1,120 @@
cmake_minimum_required ( VERSION 2.8 ) cmake_minimum_required ( VERSION 2.8 )
project ( i2pd ) project ( "i2pd" )
# Default build is Debug # configurale options
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall") option(WITH_AESNI "Use AES-NI instructions set" OFF)
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall") option(WITH_HARDENING "Use hardening compiler flags" OFF)
set ( SRC_DIR ".." ) # paths
set ( INC_DIR ".." ) set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
set ( CMAKE_SOURCE_DIR ".." )
set (SOURCES
add_definitions ( "-std=c++0x -Wall" ) "${CMAKE_SOURCE_DIR}/AddressBook.cpp"
"${CMAKE_SOURCE_DIR}/CryptoConst.cpp"
set ( SOURCES "${CMAKE_SOURCE_DIR}/Daemon.cpp"
CryptoConst.cpp "${CMAKE_SOURCE_DIR}/Garlic.cpp"
AddressBook.cpp "${CMAKE_SOURCE_DIR}/HTTPProxy.cpp"
Garlic.cpp "${CMAKE_SOURCE_DIR}/HTTPServer.cpp"
HTTPServer.cpp "${CMAKE_SOURCE_DIR}/I2NPProtocol.cpp"
i2p.cpp "${CMAKE_SOURCE_DIR}/I2PTunnel.cpp"
Identity.cpp "${CMAKE_SOURCE_DIR}/Identity.cpp"
Log.cpp "${CMAKE_SOURCE_DIR}/LeaseSet.cpp"
NTCPSession.cpp "${CMAKE_SOURCE_DIR}/Log.cpp"
RouterContext.cpp "${CMAKE_SOURCE_DIR}/NTCPSession.cpp"
SSU.cpp "${CMAKE_SOURCE_DIR}/NetDb.cpp"
SSUData.cpp "${CMAKE_SOURCE_DIR}/Reseed.cpp"
TransitTunnel.cpp "${CMAKE_SOURCE_DIR}/RouterContext.cpp"
Tunnel.cpp "${CMAKE_SOURCE_DIR}/RouterInfo.cpp"
TunnelGateway.cpp "${CMAKE_SOURCE_DIR}/SOCKS.cpp"
UPnP.cpp "${CMAKE_SOURCE_DIR}/SSU.cpp"
base64.cpp "${CMAKE_SOURCE_DIR}/SSUData.cpp"
HTTPProxy.cpp "${CMAKE_SOURCE_DIR}/Streaming.cpp"
I2NPProtocol.cpp "${CMAKE_SOURCE_DIR}/TransitTunnel.cpp"
LeaseSet.cpp "${CMAKE_SOURCE_DIR}/Tunnel.cpp"
NetDb.cpp "${CMAKE_SOURCE_DIR}/TunnelGateway.cpp"
Reseed.cpp "${CMAKE_SOURCE_DIR}/Transports.cpp"
RouterInfo.cpp "${CMAKE_SOURCE_DIR}/TunnelEndpoint.cpp"
Streaming.cpp "${CMAKE_SOURCE_DIR}/TunnelPool.cpp"
Transports.cpp "${CMAKE_SOURCE_DIR}/UPnP.cpp"
TunnelEndpoint.cpp "${CMAKE_SOURCE_DIR}/aes.cpp"
TunnelPool.cpp "${CMAKE_SOURCE_DIR}/base64.cpp"
util.cpp "${CMAKE_SOURCE_DIR}/i2p.cpp"
aes.cpp "${CMAKE_SOURCE_DIR}/util.cpp"
Daemon.cpp
SOCKS.cpp
I2PTunnel.cpp
) )
set ( HEADERS file (GLOB HEADERS "${CMAKE_SOURCE_DIR}/*.h")
CryptoConst.h
AddressBook.h
Garlic.h
HTTPServer.h
Identity.h
Log.h
NTCPSession.h
RouterContext.h
SSU.h
SSUData.h
TransitTunnel.h
Tunnel.h
TunnelGateway.h
UPnP.h
base64.h
HTTPProxy.h
I2NPProtocol.h
LeaseSet.h
NetDb.h
Reseed.h
RouterInfo.h
Streaming.h
Transports.h
TunnelEndpoint.h
TunnelPool.h
util.h
aes.h
Daemon.h
SOCKS.h
I2PTunnel.h
version.h
Signature.h
)
if (WIN32)
list (APPEND SOURCES DeamonWin32.cpp)
else ()
list (APPEND SOURCES DaemonLinux.cpp)
endif ()
# MSVS grouping
source_group ("Header Files" FILES ${HEADERS}) source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES}) source_group ("Source Files" FILES ${SOURCES})
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) # Default build is Debug
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions( "-pedantic" )
else ()
set(CMAKE_BUILD_TYPE Debug)
endif ()
# compiler flags customization (by vendor)
add_definitions ( "-Wall -Wextra" )
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_definitions( "-std=c++0x" )
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" )
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie" )
endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_definitions( "-std=c++11" )
endif ()
# compiler flags customization (by system)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
list (APPEND SOURCES "../DaemonLinux.cpp")
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
list (APPEND SOURCES "../DaemonLinux.cpp")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
list (APPEND SOURCES "../DaemonWin32.cpp")
endif ()
if (WITH_AESNI)
add_definitions ( "-maes -DAESNI" )
endif()
# libraries
find_package ( Threads REQUIRED ) find_package ( Threads REQUIRED )
find_package ( Boost COMPONENTS system filesystem regex program_options REQUIRED ) find_package ( Boost COMPONENTS system filesystem regex program_options REQUIRED )
if(NOT DEFINED Boost_INCLUDE_DIRS)
message(SEND_ERROR "Boost is not found, or your boost version was bellow 1.46. Please download Boost!")
endif()
find_package ( CryptoPP REQUIRED ) find_package ( CryptoPP REQUIRED )
# Check for libraries
if(NOT DEFINED Boost_INCLUDE_DIRS)
message(FATAL_ERROR "Boost is not found, or your boost version was bellow 1.46. Please download Boost!")
return()
endif()
if(NOT DEFINED CRYPTO++_INCLUDE_DIR) if(NOT DEFINED CRYPTO++_INCLUDE_DIR)
message(FATAL_ERROR "Could not find Crypto++. Please download and install it first!") message(SEND_ERROR "Could not find Crypto++. Please download and install it first!")
return()
endif() endif()
# load includes
include_directories( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR})
# End checks # show summary
message(STATUS "---------------------------------------")
message(STATUS "Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS "Compiler : ${CMAKE_CXX_COMPILER}")
message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Options:")
message(STATUS " AESNI : ${WITH_AESNI}")
message(STATUS " HARDENING : ${WITH_HARDENING}")
message(STATUS "---------------------------------------")
add_executable ( ${PROJECT_NAME} ${SOURCES} )
include_directories ( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR}) if (WITH_HARDENING)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-z relro -z now" )
endif ()
unset ( TMP )
foreach ( src ${SOURCES} )
list ( APPEND TMP "${SRC_DIR}/${src}" )
endforeach ()
set ( SOURCES ${TMP} )
unset ( TMP )
foreach ( hdr ${HEADERS} )
list ( APPEND TMP "${INC_DIR}/${hdr}" )
endforeach ()
set ( HEADERS ${TMP} )
add_executable ( ${PROJECT_NAME} WIN32 ${HEADERS} ${SOURCES} )
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
install(TARGETS i2pd RUNTIME DESTINATION "bin")