Updating cmake so it exit if libraries are missing. Adding FindBoost and upating FindCryptoPP.

This commit is contained in:
Meeh 2014-04-04 01:54:21 +02:00
parent f7b3e9c933
commit e38f7c884c
3 changed files with 1240 additions and 26 deletions

View File

@ -1,11 +1,12 @@
cmake_minimum_required ( VERSION 2.8 ) cmake_minimum_required ( VERSION 2.8 )
project ( i2pd ) project ( i2pd )
set ( SRC_DIR ".." ) set ( SRC_DIR ".." )
set ( INC_DIR ".." ) set ( INC_DIR ".." )
add_definitions ( "-std=c++0x -Wall" ) add_definitions ( "-std=c++0x -Wall" )
set ( SOURCES set ( SOURCES
@ -70,10 +71,35 @@ find_package ( Threads REQUIRED )
find_package ( Boost COMPONENTS system filesystem regex program_options REQUIRED ) find_package ( Boost COMPONENTS system filesystem regex program_options REQUIRED )
find_package(Crypto++ QUIET)
# Check for libraries
if(!Boost_FOUND)
message(FATAL_ERROR "Boost is not found, or your boost version was bellow 1.46. Please download Boost!")
return()
else()
# Adding boost directories
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS})
endif()
if(!CRYPTO++_FOUND)
message(FATAL_ERROR "Could not find Crypto++. Please download and install it first!")
return()
else()
# Adding Crypto++ directories
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${CRYPTO++_INCLUDE_DIR})
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${CRYPTO++_LIBRARIES})
endif()
# End checks
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
find_package ( CryptoPP REQUIRED ) find_package ( CryptoPP REQUIRED )
include_directories ( ${Boost_INCLUDE_DIRS} ${CryptoPP_INCLUDE_DIRS}) include_directories ( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR})
unset ( TMP ) unset ( TMP )
@ -91,4 +117,4 @@ set ( HEADERS ${TMP} )
add_executable ( ${PROJECT_NAME} WIN32 ${HEADERS} ${SOURCES} ) add_executable ( ${PROJECT_NAME} WIN32 ${HEADERS} ${SOURCES} )
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CryptoPP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,35 @@
# Find Crypto++ library # - Find Crypto++
#
# Output variables :
# CryptoPP_FOUND
# CryptoPP_INCLUDE_DIRS
# CryptoPP_LIBRARIES
#
if(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
set(CRYPTO++_FOUND TRUE)
FIND_PATH( CryptoPP_INCLUDE_DIR cryptopp/dsa.h ) else(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
find_path(CRYPTO++_INCLUDE_DIR cryptlib.h
/usr/include/crypto++
/usr/include/cryptopp
/usr/local/include/crypto++
/usr/local/include/cryptopp
/opt/local/include/crypto++
/opt/local/include/cryptopp
$ENV{SystemDrive}/Crypto++/include
)
FIND_LIBRARY( CryptoPP_LIBRARY NAMES cryptopp ) find_library(CRYPTO++_LIBRARIES NAMES cryptopp
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
$ENV{SystemDrive}/Crypto++/lib
)
# handle the QUIETLY and REQUIRED arguments and set CRYPTOPP_FOUND to TRUE if if(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
# all listed variables are TRUE set(CRYPTO++_FOUND TRUE)
INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) message(STATUS "Found Crypto++: ${CRYPTO++_INCLUDE_DIR}, ${CRYPTO++_LIBRARIES}")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CryptoPP DEFAULT_MSG CryptoPP_LIBRARY CryptoPP_INCLUDE_DIR) else(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
set(CRYPTO++_FOUND FALSE)
message(STATUS "Crypto++ not found.")
endif(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
set ( CryptoPP_FOUND FALSE ) mark_as_advanced(CRYPTO++_INCLUDE_DIR CRYPTO++_LIBRARIES)
if ( ${CRYPTOPP_FOUND} )
set ( CryptoPP_FOUND TRUE )
set ( CryptoPP_INCLUDE_DIRS ${CryptoPP_INCLUDE_DIR} )
set ( CryptoPP_LIBRARIES ${CryptoPP_LIBRARY} )
endif ()
MARK_AS_ADVANCED(CryptoPP_INCLUDE_DIR CryptoPP_LIBRARY)
endif(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)