2009-02-02 14:44:46 +00:00
project ( libssh C )
# Required cmake version
cmake_minimum_required ( VERSION 2.6.0 )
# global needed variables
set ( APPLICATION_NAME ${ PROJECT_NAME } )
set ( APPLICATION_VERSION_MAJOR "0" )
2014-05-19 22:41:30 +01:00
set ( APPLICATION_VERSION_MINOR "7" )
set ( APPLICATION_VERSION_PATCH "0" )
2009-02-02 14:44:46 +00:00
2009-12-21 15:56:21 +01:00
set ( APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}" )
2010-05-12 19:01:25 +02:00
# SOVERSION scheme: CURRENT.AGE.REVISION
2010-03-25 13:24:59 +01:00
# If there was an incompatible interface change:
# Increment CURRENT. Set AGE and REVISION to 0
2010-05-12 19:01:25 +02:00
# If there was a compatible interface change:
# Increment AGE. Set REVISION to 0
# If the source code was changed, but there were no interface changes:
# Increment REVISION.
2011-05-30 12:38:17 +02:00
set ( LIBRARY_VERSION "4.3.0" )
2010-08-18 23:18:57 +02:00
set ( LIBRARY_SOVERSION "4" )
2009-02-02 14:44:46 +00:00
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set ( CMAKE_MODULE_PATH
$ { C M A K E _ S O U R C E _ D I R } / c m a k e / M o d u l e s
)
# add definitions
include ( DefineCMakeDefaults )
2010-09-08 11:19:22 +02:00
include ( DefinePlatformDefaults )
2009-02-02 14:44:46 +00:00
include ( DefineCompilerFlags )
include ( DefineInstallationPaths )
include ( DefineOptions.cmake )
include ( CPackConfig.cmake )
# disallow in-source build
include ( MacroEnsureOutOfSourceBuild )
macro_ensure_out_of_source_build ( "${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." )
# search for libraries
2011-09-23 08:00:25 +02:00
if ( WITH_ZLIB )
2010-06-11 10:43:02 +02:00
find_package ( ZLIB REQUIRED )
2011-09-23 08:00:25 +02:00
endif ( WITH_ZLIB )
2009-02-02 14:44:46 +00:00
2009-09-25 23:31:48 +02:00
if ( WITH_GCRYPT )
2012-02-04 20:10:04 +01:00
find_package ( GCrypt 1.5.0 REQUIRED )
2009-05-07 15:07:54 +00:00
if ( NOT GCRYPT_FOUND )
2009-09-25 23:31:48 +02:00
message ( FATAL_ERROR "Could not find GCrypt" )
2009-05-07 15:07:54 +00:00
endif ( NOT GCRYPT_FOUND )
2009-09-25 23:31:48 +02:00
else ( WITH_GCRYPT )
find_package ( OpenSSL )
2010-04-20 13:25:46 +02:00
if ( NOT OPENSSL_FOUND )
2009-09-25 23:31:48 +02:00
find_package ( GCrypt )
if ( NOT GCRYPT_FOUND )
message ( FATAL_ERROR "Could not find OpenSSL or GCrypt" )
endif ( NOT GCRYPT_FOUND )
2010-04-20 13:25:46 +02:00
endif ( NOT OPENSSL_FOUND )
2009-09-25 23:31:48 +02:00
endif ( WITH_GCRYPT )
2009-02-02 14:44:46 +00:00
2010-09-01 15:15:17 +02:00
# Find out if we have threading available
set ( CMAKE_THREAD_PREFER_PTHREADS ON )
find_package ( Threads )
2013-07-13 15:46:23 +02:00
if ( WITH_GSSAPI )
2013-07-13 15:50:57 +02:00
find_package ( GSSAPI )
2013-07-13 15:46:23 +02:00
endif ( WITH_GSSAPI )
2013-02-20 23:14:59 +01:00
2013-09-21 23:32:51 +02:00
if ( WITH_NACL )
find_package ( NaCl )
if ( NOT NACL_FOUND )
set ( WITH_NACL OFF )
endif ( NOT NACL_FOUND )
endif ( WITH_NACL )
2009-02-02 14:44:46 +00:00
# config.h checks
include ( ConfigureChecks.cmake )
configure_file ( config.h.cmake ${ CMAKE_CURRENT_BINARY_DIR } /config.h )
# check subdirectories
2009-02-03 10:43:45 +00:00
add_subdirectory ( doc )
2009-02-02 14:44:46 +00:00
add_subdirectory ( include )
2010-09-06 14:28:38 +02:00
add_subdirectory ( src )
2009-02-02 14:44:46 +00:00
2009-12-30 13:34:17 +08:00
# pkg-config file
configure_file ( libssh.pc.cmake ${ CMAKE_CURRENT_BINARY_DIR } /libssh.pc )
2011-06-14 13:47:04 +02:00
configure_file ( libssh_threads.pc.cmake ${ CMAKE_CURRENT_BINARY_DIR } /libssh_threads.pc )
2009-12-30 13:34:17 +08:00
install (
F I L E S
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / l i b s s h . p c
2011-06-14 13:47:04 +02:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / l i b s s h _ t h r e a d s . p c
2009-12-30 13:34:17 +08:00
D E S T I N A T I O N
$ { L I B _ I N S T A L L _ D I R } / p k g c o n f i g
C O M P O N E N T
p k g c o n f i g
)
2013-02-12 13:31:42 +01:00
# cmake config files
2014-05-22 14:52:52 +02:00
set ( LIBSSH_LIBRARY_NAME @CMAKE_SHARED_LIBRARY_PREFIX@ssh@CMAKE_SHARED_LIBRARY_SUFFIX@ )
set ( LIBSSH_THREADS_LIBRARY_NAME @CMAKE_SHARED_LIBRARY_PREFIX@ssh@CMAKE_SHARED_LIBRARY_SUFFIX@ )
configure_file ( ${ PROJECT_NAME } -config.cmake.in ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } -config.cmake @ONLY )
configure_file ( ${ PROJECT_NAME } -config-version.cmake.in ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } -config-version.cmake @ONLY )
2013-02-12 13:31:42 +01:00
install (
F I L E S
2014-05-22 14:52:52 +02:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { P R O J E C T _ N A M E } - c o n f i g . c m a k e
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { P R O J E C T _ N A M E } - c o n f i g - v e r s i o n . c m a k e
2013-02-12 13:31:42 +01:00
D E S T I N A T I O N
2014-05-22 14:52:52 +02:00
$ { C M A K E _ I N S T A L L _ D I R } / $ { P R O J E C T _ N A M E }
2013-02-12 13:31:42 +01:00
C O M P O N E N T
d e v e l
)
2014-05-22 14:52:52 +02:00
2013-02-12 13:31:42 +01:00
# in tree build settings
configure_file ( libssh-build-tree-settings.cmake.in ${ CMAKE_CURRENT_BINARY_DIR } /libssh-build-tree-settings.cmake @ONLY )
2013-09-16 08:21:12 +02:00
if ( WITH_EXAMPLES )
add_subdirectory ( examples )
endif ( WITH_EXAMPLES )
2010-03-02 13:47:14 +01:00
2010-03-15 16:09:16 +01:00
if ( WITH_TESTING )
2012-10-07 11:10:27 +02:00
find_package ( CMocka REQUIRED )
include ( AddCMockaTest )
2010-03-02 13:47:14 +01:00
add_subdirectory ( tests )
2010-03-15 16:09:16 +01:00
endif ( WITH_TESTING )
2010-03-02 13:47:14 +01:00
2010-12-19 17:29:17 +01:00
2010-03-02 23:37:49 +01:00
message ( STATUS "********************************************" )
message ( STATUS "********** ${PROJECT_NAME} build options : **********" )
2010-02-08 16:55:03 +01:00
2011-09-23 08:00:25 +02:00
message ( STATUS "zlib support: ${WITH_ZLIB}" )
2010-03-02 23:37:49 +01:00
message ( STATUS "libgcrypt support: ${WITH_GCRYPT}" )
2013-09-21 23:32:51 +02:00
message ( STATUS "libnacl support: ${WITH_NACL}" )
2010-03-02 23:37:49 +01:00
message ( STATUS "SSH-1 support: ${WITH_SSH1}" )
message ( STATUS "SFTP support: ${WITH_SFTP}" )
message ( STATUS "Server support : ${WITH_SERVER}" )
2013-02-20 23:14:59 +01:00
message ( STATUS "GSSAPI support : ${WITH_GSSAPI}" )
2010-03-02 23:37:49 +01:00
message ( STATUS "Pcap debugging support : ${WITH_PCAP}" )
2012-10-15 11:55:42 +02:00
message ( STATUS "With static library: ${WITH_STATIC_LIB}" )
2010-03-02 23:37:49 +01:00
message ( STATUS "Unit testing: ${WITH_TESTING}" )
2010-07-23 11:04:09 +02:00
message ( STATUS "Client code Unit testing: ${WITH_CLIENT_TESTING}" )
2010-02-08 16:55:03 +01:00
if ( WITH_INTERNAL_DOC )
2010-03-02 23:37:49 +01:00
message ( STATUS "Internal documentation generation" )
2010-02-08 16:55:03 +01:00
else ( WITH_INTERNAL_DOC )
2010-03-02 23:37:49 +01:00
message ( STATUS "Public API documentation generation" )
2010-02-08 16:55:03 +01:00
endif ( WITH_INTERNAL_DOC )
2010-12-19 17:29:17 +01:00
message ( STATUS "Benchmarks: ${WITH_BENCHMARKS}" )
2010-03-02 23:37:49 +01:00
message ( STATUS "********************************************" )
2010-02-08 16:55:03 +01:00