2013-09-24 17:14:36 +06:00
|
|
|
# Checking for user explicity defined CMAKE_INSTALL_PREFIX
|
|
|
|
# It must be done before project(...)
|
|
|
|
if(NOT CMAKE_INSTALL_PREFIX)
|
|
|
|
set(QCA_INSTALL_IN_QT_PREFIX ON)
|
|
|
|
endif(NOT CMAKE_INSTALL_PREFIX)
|
|
|
|
|
2013-10-02 00:54:23 +06:00
|
|
|
project(qca)
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2013-09-24 17:29:27 +06:00
|
|
|
cmake_minimum_required(VERSION 2.6.0)
|
2008-05-18 06:50:01 +00:00
|
|
|
|
2008-07-21 20:09:29 +00:00
|
|
|
option(BUILD_TESTS "Create test" ON)
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2006-11-27 18:15:11 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
|
2006-10-08 06:53:40 +00:00
|
|
|
|
2013-04-30 21:17:51 +00:00
|
|
|
option(QT4_BUILD "Force building with Qt4 even if Qt5 is found")
|
|
|
|
if (NOT QT4_BUILD)
|
|
|
|
find_package(Qt5Core QUIET)
|
|
|
|
endif()
|
2013-08-24 21:22:37 +06:00
|
|
|
|
|
|
|
include(QcaMacro)
|
|
|
|
|
2013-02-07 20:19:00 +00:00
|
|
|
if (Qt5Core_FOUND)
|
|
|
|
message(STATUS "Building with Qt5 support")
|
2013-08-27 23:29:17 +06:00
|
|
|
# Got from ECM
|
|
|
|
# Distros have no ECM. So I just copied required cmake modules.
|
2013-02-07 20:19:00 +00:00
|
|
|
find_package(Qt5Transitional REQUIRED Core Network)
|
2013-08-27 23:29:17 +06:00
|
|
|
include(ECMQt4To5Porting)
|
|
|
|
|
2013-02-07 20:19:00 +00:00
|
|
|
include(GNUInstallDirs)
|
2013-08-24 21:22:37 +06:00
|
|
|
setup_qt5_dirs()
|
2013-02-07 20:19:00 +00:00
|
|
|
else()
|
|
|
|
set(QT_MIN_VERSION "4.7.0")
|
|
|
|
find_package(Qt4 REQUIRED)
|
|
|
|
# properly set up compile flags (QT_DEBUG/QT_NO_DEBUG, ...)
|
|
|
|
include(${QT_USE_FILE})
|
|
|
|
endif()
|
|
|
|
|
2013-08-24 23:24:13 +06:00
|
|
|
set(QCA_LIB_MAJOR_VERSION "2")
|
2008-07-21 20:09:29 +00:00
|
|
|
set(QCA_LIB_MINOR_VERSION "0")
|
2010-11-27 20:34:37 +00:00
|
|
|
set(QCA_LIB_PATCH_VERSION "3")
|
2007-08-26 17:05:22 +00:00
|
|
|
|
2013-10-02 22:49:27 +06:00
|
|
|
set(QCA_SUFFIX "" CACHE STRING "QCA common suffix")
|
|
|
|
if(QCA_SUFFIX)
|
|
|
|
set(QCA_LIB_NAME qca-${QCA_SUFFIX})
|
|
|
|
set(QCA_TOOL_NAME qcatool-${QCA_SUFFIX})
|
|
|
|
set(QCA_PC_NAME qca2-${QCA_SUFFIX}.pc)
|
|
|
|
else(QCA_SUFFIX)
|
2013-08-24 23:24:13 +06:00
|
|
|
set(QCA_LIB_NAME qca)
|
2013-10-02 22:49:27 +06:00
|
|
|
set(QCA_TOOL_NAME qcatool)
|
|
|
|
set(QCA_PC_NAME qca2.pc)
|
|
|
|
endif(QCA_SUFFIX)
|
2013-08-24 23:24:13 +06:00
|
|
|
|
2008-07-21 20:09:29 +00:00
|
|
|
set(QCA_LIB_VERSION_STRING "${QCA_LIB_MAJOR_VERSION}.${QCA_LIB_MINOR_VERSION}.${QCA_LIB_PATCH_VERSION}")
|
2007-08-26 17:05:22 +00:00
|
|
|
|
|
|
|
|
2007-09-30 15:54:31 +00:00
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_DEBUG_POSTFIX "d")
|
2010-05-13 17:08:42 +00:00
|
|
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
2007-09-30 15:54:31 +00:00
|
|
|
endif (WIN32)
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2006-11-27 18:15:11 +00:00
|
|
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES Linux)
|
2006-11-27 19:06:32 +00:00
|
|
|
add_definitions (-D_BSD_SOURCE)
|
2006-11-27 18:15:11 +00:00
|
|
|
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
|
|
|
|
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-check-new -fno-common")
|
|
|
|
endif (CMAKE_SYSTEM_NAME MATCHES Linux)
|
|
|
|
endif (CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
|
2006-10-02 09:59:51 +00:00
|
|
|
add_definitions (${QT_DEFINITIONS})
|
2008-07-21 20:09:29 +00:00
|
|
|
include_directories(include/QtCrypto/ ${QT_INCLUDES})
|
2006-10-02 09:59:51 +00:00
|
|
|
|
|
|
|
# Always include srcdir and builddir in include path
|
|
|
|
# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in about every subdir
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
|
|
# put the include dirs which are in the source or build tree
|
|
|
|
# before all other include dirs, so the headers in the sources
|
|
|
|
# are prefered over the already installed ones
|
|
|
|
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
|
|
|
|
|
2008-07-21 20:09:29 +00:00
|
|
|
set(qca_INCLUDEDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
2013-10-01 07:14:49 +06:00
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" )
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2013-07-24 22:08:12 +06:00
|
|
|
if( QCA_INSTALL_IN_QT_PREFIX )
|
|
|
|
set(QCA_PREFIX_INSTALL_DIR "${QT_PREFIX_DIR}" CACHE PATH "Directory where qca will install")
|
2013-09-24 01:37:03 +06:00
|
|
|
set(QCA_PLUGINS_INSTALL_DIR "${QT_PLUGINS_DIR}/crypto" CACHE PATH "Directory where qca plugins will install")
|
2013-07-24 22:08:12 +06:00
|
|
|
set(QCA_BINARY_INSTALL_DIR "${QT_BINARY_DIR}" CACHE PATH "Directory where qca plugins will install")
|
|
|
|
set(QCA_LIBRARY_INSTALL_DIR "${QT_LIBRARY_DIR}" CACHE PATH "Directory where qca library will install")
|
|
|
|
set(QCA_FEATURE_INSTALL_DIR "${QT_MKSPECS_DIR}/features" CACHE PATH "Directory where qca feature file will install")
|
|
|
|
set(QCA_INCLUDE_INSTALL_DIR "${QT_INCLUDE_DIR}" CACHE PATH "Directory where qca public headers will install")
|
|
|
|
set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${QT_INCLUDE_DIR}" CACHE PATH "Directory where qca headers will install")
|
|
|
|
set(QCA_DOC_INSTALL_DIR "${QT_DOC_DIR}/html/qca/" CACHE PATH "Directory where qca documentation will install")
|
|
|
|
set(QCA_MAN_INSTALL_DIR "${QT_DATA_DIR}/man" CACHE PATH "Directory where qca man pages will install")
|
|
|
|
else( QCA_INSTALL_IN_QT_PREFIX )
|
2013-10-02 01:45:15 +06:00
|
|
|
# Cmake says nothing about LIB_SUFFIX
|
|
|
|
# de facto it is a standard way to specify lib suffix on many distros
|
|
|
|
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
|
|
|
|
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "Directory where lib will install")
|
|
|
|
|
2013-07-24 22:08:12 +06:00
|
|
|
set(QCA_PREFIX_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Directory where qca will install")
|
2013-10-02 23:11:10 +06:00
|
|
|
set(QCA_PLUGINS_INSTALL_DIR "${LIB_INSTALL_DIR}/${QCA_LIB_NAME}/crypto" CACHE PATH "Directory where qca plugins will install")
|
2013-10-02 00:51:42 +06:00
|
|
|
set(QCA_BINARY_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Directory where qca plugins will install")
|
|
|
|
set(QCA_LIBRARY_INSTALL_DIR "${LIB_INSTALL_DIR}" CACHE PATH "Directory where qca library will install")
|
2013-09-24 01:37:03 +06:00
|
|
|
set(QCA_FEATURE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/mkspecs/features" CACHE PATH "Directory where qca feature file will install")
|
2013-10-02 00:51:42 +06:00
|
|
|
set(QCA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Directory where qca public headers will install")
|
|
|
|
set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Directory where qca headers will install")
|
2013-10-02 23:11:10 +06:00
|
|
|
set(QCA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${QCA_LIB_NAME}/html" CACHE PATH "Directory where qca documentation will install")
|
2013-10-02 00:51:42 +06:00
|
|
|
set(QCA_MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Directory where qca man pages will install")
|
2013-07-24 22:08:12 +06:00
|
|
|
endif( QCA_INSTALL_IN_QT_PREFIX )
|
|
|
|
|
2013-08-28 14:51:43 +06:00
|
|
|
set(PKGCONFIG_INSTALL_PREFIX "${QCA_LIBRARY_INSTALL_DIR}/pkgconfig" CACHE PATH "Base directory for pkgconfig files")
|
2013-07-24 22:08:12 +06:00
|
|
|
|
2013-10-01 07:07:35 +06:00
|
|
|
if (APPLE)
|
|
|
|
find_package(Carbon REQUIRED)
|
|
|
|
set(CMAKE_INSTALL_NAME_DIR ${QCA_LIBRARY_INSTALL_DIR})
|
|
|
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
|
|
|
endif (APPLE)
|
|
|
|
|
|
|
|
# set up RPATH handling, so the libs are found if they are installed to a non-standard location, Alex
|
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
set(CMAKE_INSTALL_RPATH "${QCA_LIBRARY_INSTALL_DIR}" )
|
|
|
|
endif (UNIX AND NOT APPLE)
|
|
|
|
|
2008-07-21 20:09:29 +00:00
|
|
|
message(STATUS "Checking for certstore..")
|
2006-10-02 09:59:51 +00:00
|
|
|
# fixme add OR mac
|
2008-07-21 20:09:29 +00:00
|
|
|
if( WIN32 )
|
2006-10-02 09:59:51 +00:00
|
|
|
# USE BUILTIN
|
2008-07-21 20:09:29 +00:00
|
|
|
else ( WIN32 )
|
|
|
|
if ( ENV{QC_CERTSTORE_PATH} )
|
|
|
|
if(EXISTS ENV{QC_CERTSTORE_PATH})
|
|
|
|
set( qca_CERTSTORE $ENV{QC_CERTSTORE_PATH})
|
|
|
|
else(EXISTS ENV{QC_CERTSTORE_PATH})
|
|
|
|
# path to try
|
|
|
|
endif(EXISTS ENV{QC_CERTSTORE_PATH})
|
|
|
|
else( ENV{QC_CERTSTORE_PATH} )
|
|
|
|
set( toTry
|
2006-10-02 09:59:51 +00:00
|
|
|
"/etc/ssl/certs/ca-certificates.crt"
|
|
|
|
"/usr/share/ssl/cert.pem"
|
|
|
|
"/usr/share/ssl/certs/ca-bundle.crt"
|
|
|
|
"/etc/pki/tls/cert.pem"
|
2013-09-03 14:41:15 +02:00
|
|
|
"/etc/ssl/ca-bundle.pem"
|
2007-01-05 19:16:06 +00:00
|
|
|
"/usr/share/curl/curl-ca-bundle.crt"
|
2006-10-02 09:59:51 +00:00
|
|
|
)
|
2008-07-21 20:09:29 +00:00
|
|
|
foreach (_current_try ${toTry})
|
|
|
|
if(EXISTS ${_current_try})
|
|
|
|
set( qca_CERTSTORE ${_current_try})
|
|
|
|
endif(EXISTS ${_current_try})
|
|
|
|
endforeach (_current_try)
|
|
|
|
endif( ENV{QC_CERTSTORE_PATH} )
|
|
|
|
endif(WIN32)
|
|
|
|
|
|
|
|
if (qca_CERTSTORE)
|
|
|
|
message(STATUS "Found system certstore")
|
|
|
|
else (qca_CERTSTORE)
|
|
|
|
message(STATUS "Using built in certstore.")
|
|
|
|
set( qca_CERTSTORE "${CMAKE_CURRENT_SOURCE_DIR}/certs/rootcerts.pem")
|
2006-12-21 04:18:17 +00:00
|
|
|
# note that INSTALL_FILES targets are relative to the current installation prefix...
|
2008-07-21 20:09:29 +00:00
|
|
|
install_files( "/certs" FILES "${CMAKE_CURRENT_SOURCE_DIR}/certs/rootcerts.pem" )
|
|
|
|
endif (qca_CERTSTORE)
|
|
|
|
message(STATUS "certstore path: " ${qca_CERTSTORE})
|
2013-09-24 17:29:27 +06:00
|
|
|
add_definitions( -DQCA_SYSTEMSTORE_PATH="${qca_CERTSTORE}" )
|
2006-10-02 09:59:51 +00:00
|
|
|
|
|
|
|
|
2008-07-21 20:09:29 +00:00
|
|
|
set( private_HEADERS ${qca_INCLUDEDIR}/QtCrypto/qca_plugin.h ${qca_INCLUDEDIR}/QtCrypto/qca_systemstore.h )
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2008-07-21 20:09:29 +00:00
|
|
|
set( public_HEADERS
|
2006-10-02 09:59:51 +00:00
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qcaprovider.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/QtCrypto
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_export.h
|
2008-07-21 20:09:29 +00:00
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_support.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_tools.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_core.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_textfilter.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_basic.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_publickey.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_cert.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_keystore.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_securelayer.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qca_securemessage.h
|
|
|
|
${qca_INCLUDEDIR}/QtCrypto/qpipe.h )
|
|
|
|
|
|
|
|
set( qca_HEADERS ${private_HEADERS} ${public_HEADERS} )
|
2006-10-02 09:59:51 +00:00
|
|
|
|
|
|
|
#install public headers only
|
2013-07-24 22:08:12 +06:00
|
|
|
install(FILES ${public_HEADERS} DESTINATION "${QCA_INCLUDE_INSTALL_DIR}/QtCrypto")
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2008-07-21 20:09:29 +00:00
|
|
|
include_directories(${QT_QTCORE_INCLUDE_DIR} "${qca_INCLUDEDIR}/QtCrypto")
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2007-08-14 07:31:41 +00:00
|
|
|
if(NOT WIN32)
|
2013-08-24 23:24:13 +06:00
|
|
|
configure_file("qca2.pc.cmake" "${CMAKE_BINARY_DIR}/${QCA_PC_NAME}" @ONLY)
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/${QCA_PC_NAME}" DESTINATION ${PKGCONFIG_INSTALL_PREFIX})
|
2007-08-14 07:31:41 +00:00
|
|
|
endif(NOT WIN32)
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2008-07-21 20:09:29 +00:00
|
|
|
configure_file("crypto.prf.cmake" "${CMAKE_BINARY_DIR}/crypto.prf" @ONLY)
|
2013-07-24 22:08:12 +06:00
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/crypto.prf" DESTINATION "${QCA_FEATURE_INSTALL_DIR}")
|
2006-10-02 09:59:51 +00:00
|
|
|
|
2013-10-02 22:49:27 +06:00
|
|
|
configure_file(man/qcatool.1 "${CMAKE_BINARY_DIR}/${QCA_TOOL_NAME}.1" COPYONLY)
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/${QCA_TOOL_NAME}.1" DESTINATION "${QCA_MAN_INSTALL_DIR}/man1")
|
2007-10-18 14:31:08 +00:00
|
|
|
|
2006-10-02 09:59:51 +00:00
|
|
|
add_subdirectory(src)
|
|
|
|
add_subdirectory(tools)
|
2006-10-02 15:18:50 +00:00
|
|
|
add_subdirectory(plugins)
|
2008-07-21 20:09:29 +00:00
|
|
|
|
2013-04-05 06:48:10 +00:00
|
|
|
if(BUILD_TESTS)
|
2008-07-21 20:09:29 +00:00
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(unittest)
|
|
|
|
add_subdirectory(examples)
|
2006-10-02 09:59:51 +00:00
|
|
|
endif(BUILD_TESTS)
|
|
|
|
|
2013-09-24 17:14:36 +06:00
|
|
|
# /usr/local is traditional path for installing apps on POSIX-systems.
|
|
|
|
# I consciously break this. Qt by default looks plugins and features only in
|
|
|
|
# own directory. So by default install libs in Qt prefix it is a best choice.
|
|
|
|
# This can be unwanted behaviour for users who don't read INSTALL file or/and
|
|
|
|
# not read cmake reports. I just try to warn their.
|
|
|
|
|
|
|
|
# In really anybody who do cmake . && make && sudo make install do it for own risk.
|
|
|
|
|
|
|
|
if(QCA_INSTALL_IN_QT_PREFIX)
|
2013-10-17 17:40:32 +06:00
|
|
|
string(ASCII 27 ESCAPE)
|
2013-09-24 17:14:36 +06:00
|
|
|
message("")
|
2013-10-17 17:40:32 +06:00
|
|
|
message("${ESCAPE}[31m")
|
2013-09-24 17:14:36 +06:00
|
|
|
message("!!!!!!!!!!!!!!!!!!!!!ATTENTION!!!!!!!!!!!!!!!!!!!!!!")
|
|
|
|
message("!! QCA will be installed in Qt prefix !!")
|
|
|
|
message("!! If you want to install in /usr/local !!")
|
|
|
|
message("!! you MUST explicity define CMAKE_INSTALL_PREFIX !!")
|
|
|
|
message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
2013-10-17 17:40:32 +06:00
|
|
|
message("${ESCAPE}[0m")
|
2013-09-24 17:14:36 +06:00
|
|
|
endif(QCA_INSTALL_IN_QT_PREFIX)
|
|
|
|
|
|
|
|
message("")
|
|
|
|
message("QCA prefix is " ${QCA_PREFIX_INSTALL_DIR})
|
|
|
|
message("Plugins will be installed to " ${QCA_PLUGINS_INSTALL_DIR})
|
|
|
|
message("Binary will be installed to " ${QCA_BINARY_INSTALL_DIR})
|
|
|
|
message("Library will be installed to " ${QCA_LIBRARY_INSTALL_DIR})
|
|
|
|
message("Feature file will be installed to " ${QCA_FEATURE_INSTALL_DIR})
|
|
|
|
message("Public headers will be installed to " ${QCA_INCLUDE_INSTALL_DIR})
|
|
|
|
message("Private headers will be installed to " ${QCA_PRIVATE_INCLUDE_INSTALL_DIR})
|
|
|
|
message("Documentation will be installed to " ${QCA_DOC_INSTALL_DIR})
|
|
|
|
message("Man page will be installed to " ${QCA_MAN_INSTALL_DIR})
|
|
|
|
message("Pkg-config file will be installed to " ${PKGCONFIG_INSTALL_PREFIX})
|
|
|
|
message("")
|