From 64b47a29cfe97fd86ee42fe285902a563817ee8e Mon Sep 17 00:00:00 2001 From: "Francisco Blas (klondike) Izquierdo Riera" Date: Wed, 31 Dec 2014 18:20:23 +0100 Subject: [PATCH 1/3] Fix library compilation --- build/CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 893ce8f7..a7d979e7 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -143,22 +143,23 @@ message(STATUS " LIBRARY : ${WITH_LIBRARY}") message(STATUS " STATIC BUILD : ${WITH_STATIC}") message(STATUS "---------------------------------------") -add_executable ( ${PROJECT_NAME} ${COMMON_SRC} ${DAEMON_SRC}) +add_executable ( "${PROJECT_NAME}-bin" ${COMMON_SRC} ${DAEMON_SRC}) +set_target_properties("${PROJECT_NAME}-bin" PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") if (WITH_HARDENING AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-z relro -z now" ) + set_target_properties("${PROJECT_NAME}-bin" PROPERTIES LINK_FLAGS "-z relro -z now" ) endif () if (WITH_STATIC) set(BUILD_SHARED_LIBS OFF) - set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static" ) + set_target_properties("${PROJECT_NAME}-bin" PROPERTIES LINK_FLAGS "-static" ) endif () -target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) +target_link_libraries( "${PROJECT_NAME}-bin" ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) -install(TARGETS i2pd RUNTIME DESTINATION "bin") +install(TARGETS "${PROJECT_NAME}-bin" RUNTIME DESTINATION "bin") if (WITH_LIBRARY) - add_library("lib${PROJECT_NAME}" SHARED ${COMMON_SRC} ${LIBRARY_SRC}) - install(TARGETS "lib${PROJECT_NAME}" LIBRARY DESTINATION "lib") + add_library(${PROJECT_NAME} SHARED ${COMMON_SRC} ${LIBRARY_SRC}) + install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION "lib") endif () From 9e7e0a456ddca39493f1dec4dd87a1f348691a18 Mon Sep 17 00:00:00 2001 From: "Francisco Blas (klondike) Izquierdo Riera" Date: Wed, 31 Dec 2014 19:05:54 +0100 Subject: [PATCH 2/3] Use better install paths --- build/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index a7d979e7..780eb386 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required ( VERSION 2.8 ) +cmake_minimum_required ( VERSION 2.8.5 ) project ( "i2pd" ) # configurale options @@ -143,6 +143,9 @@ message(STATUS " LIBRARY : ${WITH_LIBRARY}") message(STATUS " STATIC BUILD : ${WITH_STATIC}") message(STATUS "---------------------------------------") +#Handle paths nicely +include(GNUInstallDirs) + add_executable ( "${PROJECT_NAME}-bin" ${COMMON_SRC} ${DAEMON_SRC}) set_target_properties("${PROJECT_NAME}-bin" PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") @@ -157,9 +160,9 @@ endif () target_link_libraries( "${PROJECT_NAME}-bin" ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) -install(TARGETS "${PROJECT_NAME}-bin" RUNTIME DESTINATION "bin") +install(TARGETS "${PROJECT_NAME}-bin" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) if (WITH_LIBRARY) add_library(${PROJECT_NAME} SHARED ${COMMON_SRC} ${LIBRARY_SRC}) - install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION "lib") + install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) endif () From 8f7dea698e975ed9adf26666aadbf3833cb6441b Mon Sep 17 00:00:00 2001 From: "Francisco Blas (klondike) Izquierdo Riera" Date: Wed, 31 Dec 2014 19:41:05 +0100 Subject: [PATCH 3/3] Allow disabling binary compilation (useful for multilib builds in Gentoo) --- build/CMakeLists.txt | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 780eb386..bad1daf9 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -5,6 +5,7 @@ project ( "i2pd" ) option(WITH_AESNI "Use AES-NI instructions set" OFF) 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) # paths @@ -140,27 +141,30 @@ message(STATUS "Options:") message(STATUS " AESNI : ${WITH_AESNI}") message(STATUS " HARDENING : ${WITH_HARDENING}") message(STATUS " LIBRARY : ${WITH_LIBRARY}") +message(STATUS " BINARY : ${WITH_BINARY}") message(STATUS " STATIC BUILD : ${WITH_STATIC}") message(STATUS "---------------------------------------") #Handle paths nicely include(GNUInstallDirs) -add_executable ( "${PROJECT_NAME}-bin" ${COMMON_SRC} ${DAEMON_SRC}) -set_target_properties("${PROJECT_NAME}-bin" PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") +if (WITH_BINARY) + add_executable ( "${PROJECT_NAME}-bin" ${COMMON_SRC} ${DAEMON_SRC}) + set_target_properties("${PROJECT_NAME}-bin" PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") -if (WITH_HARDENING AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set_target_properties("${PROJECT_NAME}-bin" PROPERTIES LINK_FLAGS "-z relro -z now" ) -endif () + if (WITH_HARDENING AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set_target_properties("${PROJECT_NAME}-bin" PROPERTIES LINK_FLAGS "-z relro -z now" ) + endif () -if (WITH_STATIC) - set(BUILD_SHARED_LIBS OFF) - set_target_properties("${PROJECT_NAME}-bin" PROPERTIES LINK_FLAGS "-static" ) -endif () + if (WITH_STATIC) + set(BUILD_SHARED_LIBS OFF) + set_target_properties("${PROJECT_NAME}-bin" PROPERTIES LINK_FLAGS "-static" ) + endif () -target_link_libraries( "${PROJECT_NAME}-bin" ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) + target_link_libraries( "${PROJECT_NAME}-bin" ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) -install(TARGETS "${PROJECT_NAME}-bin" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) + install(TARGETS "${PROJECT_NAME}-bin" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) +endif () if (WITH_LIBRARY) add_library(${PROJECT_NAME} SHARED ${COMMON_SRC} ${LIBRARY_SRC})