mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-16 11:48:54 +01:00
7bf53d4f3f
* Use appveyor.yaml from c++11 branch so that CI run ok. * Use .travis.yml from the c++ branch so that Travis CI jobs run ok. * Add c++11 scripts and Linux config so that Travis CI jobs are ok. * Use mkdocumentation & mkrelease from c++11 branch. * Use PocoDoc config files from c++11 branch. * define POCO_ENABLE_C11 as the default * CMake: ignore Crypto for now. To be fixed since it fails. * Backport c++11 changes from the c++11 branch * Add Cygwin config with c++11 setup. * Update appveyor.yml from c++11 branch.
375 lines
12 KiB
CMake
375 lines
12 KiB
CMake
# POCO_BUILD_TYPE
|
|
# POCO_STATIC
|
|
# POCO_UNBUNDLED
|
|
# POCO_NO_LOCALE
|
|
#
|
|
# ENABLE_{COMPONENT}
|
|
# ENABLE_TESTS
|
|
# ENABLE_SAMPLES
|
|
|
|
cmake_minimum_required(VERSION 3.1.0)
|
|
|
|
project(Poco)
|
|
|
|
option(POCO_VERBOSE_MESSAGES "Enable informational messages during configure" ON)
|
|
|
|
file(STRINGS "${PROJECT_SOURCE_DIR}/libversion" SHARED_LIBRARY_VERSION)
|
|
|
|
# Read the version information from the VERSION file
|
|
file (STRINGS "${PROJECT_SOURCE_DIR}/VERSION" PACKAGE_VERSION )
|
|
if(POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Poco package version: ${PACKAGE_VERSION}")
|
|
endif()
|
|
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${PACKAGE_VERSION})
|
|
string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" CPACK_PACKAGE_VERSION_MINOR ${PACKAGE_VERSION})
|
|
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_PATCH ${PACKAGE_VERSION})
|
|
|
|
set(COMPLETE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
|
|
set(RELEASE_NAME "Unstable-trunk")
|
|
set(PROJECT_VERSION ${COMPLETE_VERSION})
|
|
|
|
# Put the libaries and binaries that get built into directories at the
|
|
# top of the build tree rather than in hard-to-find leaf
|
|
# directories. This simplifies manual testing and the use of the build
|
|
# tree rather than installed Boost libraries.
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
# Windows DLLs are "runtime" for CMake. Output them to "bin" like the Visual Studio projects do.
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
# Append our module directory to CMake
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
#################################################################################
|
|
# Setup C/C++ compiler options
|
|
#################################################################################
|
|
|
|
option(DISABLE_CPP11 "Disable C++11 if available" OFF)
|
|
option(DISABLE_CPP14 "Disable C++14 if available" OFF)
|
|
|
|
if (DISABLE_CPP11 OR DISABLE_CPP14)
|
|
add_definitions(-DPOCO_DISABLE_CPP11)
|
|
|
|
if (DISABLE_CPP14)
|
|
add_definitions(-DPOCO_DISABLE_CPP14)
|
|
endif()
|
|
else()
|
|
# C++11/14 compiler flags
|
|
include(CXX11)
|
|
check_for_cxx11_compiler(CXX11_COMPILER)
|
|
|
|
# If a C++11 compiler is available, then set the appropriate flags
|
|
if(CXX11_COMPILER)
|
|
enable_cxx11()
|
|
check_for_cxx14_compiler(CXX14_COMPILER)
|
|
|
|
# If a C++14 compiler is available, then set the appropriate flags
|
|
if(CXX14_COMPILER)
|
|
enable_cxx14()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT MSVC_IDE)
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
|
"Choose the type of build, options are: None Debug Release" FORCE)
|
|
endif()
|
|
endif()
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "")
|
|
set( CMAKE_BUILD_TYPE "RelWithDebInfo" )
|
|
endif()
|
|
|
|
# Include some common macros to simpilfy the Poco CMake files
|
|
include(PocoMacros)
|
|
|
|
# Allow enabling and disabling components
|
|
option(ENABLE_CPPUNIT "Enable the CppUnit" ON)
|
|
option(ENABLE_XML "Enable the XML" ON)
|
|
option(ENABLE_JSON "Enable the JSON" ON)
|
|
option(ENABLE_MONGODB "Enable MongoDB" ON)
|
|
option(ENABLE_PDF "Enable PDF" OFF)
|
|
option(ENABLE_UTIL "Enable Util" ON)
|
|
option(ENABLE_NET "Enable Net" ON)
|
|
find_package(OpenSSL QUIET)
|
|
if(OPENSSL_FOUND)
|
|
option(ENABLE_NETSSL "Enable NetSSL" ON)
|
|
option(ENABLE_CRYPTO "Enable Crypto" ON)
|
|
else()
|
|
option(ENABLE_NETSSL "Enable NetSSL" OFF)
|
|
option(ENABLE_CRYPTO "Enable Crypto" OFF)
|
|
endif()
|
|
if(WIN32)
|
|
option(ENABLE_NETSSL_WIN "Enable NetSSL Windows" ON)
|
|
else()
|
|
set(ENABLE_NETSSL_WIN OFF)
|
|
endif()
|
|
option(ENABLE_DATA "Enable Data" ON)
|
|
option(ENABLE_DATA_SQLITE "Enable Data SQlite" ON)
|
|
option(ENABLE_DATA_MYSQL "Enable Data MySQL" ON)
|
|
option(ENABLE_DATA_POSTGRESQL "Enable Data PosgreSQL" ON)
|
|
option(ENABLE_DATA_ODBC "Enable Data ODBC" ON)
|
|
option(ENABLE_SEVENZIP "Enable SevenZip" OFF)
|
|
option(ENABLE_ZIP "Enable Zip" ON)
|
|
option(ENABLE_APACHECONNECTOR "Enable ApacheConnector" OFF)
|
|
option(ENABLE_CPPPARSER "Enable C++ parser" OFF)
|
|
option(ENABLE_POCODOC "Enable Poco Documentation Generator" OFF)
|
|
option(ENABLE_PAGECOMPILER "Enable PageCompiler" ON)
|
|
option(ENABLE_PAGECOMPILER_FILE2PAGE "Enable File2Page" ON)
|
|
option(ENABLE_REDIS "Enable Redis" ON)
|
|
|
|
option(FORCE_OPENSSL "Force usage of OpenSSL even under windows" OFF)
|
|
|
|
option(ENABLE_TESTS
|
|
"Set to OFF|ON (default is OFF) to control build of POCO tests" OFF)
|
|
|
|
option(ENABLE_SAMPLES
|
|
"Set to OFF|ON (default is OFF) to control build of POCO samples" OFF)
|
|
|
|
option(POCO_STATIC
|
|
"Set to OFF|ON (default is OFF) to control build of POCO as STATIC library" OFF)
|
|
|
|
option(POCO_UNBUNDLED
|
|
"Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF)
|
|
|
|
if(MSVC)
|
|
option(POCO_MT
|
|
"Set to OFF|ON (default is OFF) to control build of POCO as /MT instead of /MD" OFF)
|
|
|
|
option(ENABLE_MSVC_MP
|
|
"Set to OFF|ON (default is OFF) to control parallel build of POCO with MSVC" OFF)
|
|
endif()
|
|
|
|
# Uncomment from next two lines to force static or dynamic library, default is autodetection
|
|
if(POCO_STATIC)
|
|
set( LIB_MODE_DEFINITIONS -DPOCO_STATIC -DPOCO_NO_AUTOMATIC_LIBS)
|
|
set( LIB_MODE STATIC )
|
|
if(POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Building static libraries")
|
|
endif()
|
|
else(POCO_STATIC)
|
|
set( LIB_MODE SHARED )
|
|
set( LIB_MODE_DEFINITIONS -DPOCO_NO_AUTOMATIC_LIBS)
|
|
if(POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Building dynamic libraries")
|
|
endif()
|
|
endif(POCO_STATIC)
|
|
|
|
if (ENABLE_TESTS)
|
|
include(CTest)
|
|
enable_testing()
|
|
if(POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Building with tests")
|
|
endif()
|
|
elseif (POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Building without tests")
|
|
endif ()
|
|
|
|
if (ENABLE_SAMPLES)
|
|
if(POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Building with samples")
|
|
endif()
|
|
elseif (POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Building without samples")
|
|
endif ()
|
|
|
|
if (POCO_UNBUNDLED)
|
|
add_definitions( -DPOCO_UNBUNDLED)
|
|
if(POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Build with using external sqlite, libz, pcre, expat ...")
|
|
endif()
|
|
elseif (POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "Build with using internal copy of sqlite, libz, pcre, expat, ...")
|
|
endif ()
|
|
|
|
include(DefinePlatformSpecifc)
|
|
|
|
# Collect the built libraries and include dirs, the will be used to create the PocoConfig.cmake file
|
|
set(Poco_COMPONENTS "")
|
|
|
|
# Pthreads/threads support
|
|
find_package(Threads REQUIRED)
|
|
|
|
if (ENABLE_TESTS OR ENABLE_CPPUNIT)
|
|
add_subdirectory(CppUnit)
|
|
list(APPEND Poco_COMPONENTS "CppUnit")
|
|
endif ()
|
|
|
|
add_subdirectory(Foundation)
|
|
if(ENABLE_XML)
|
|
add_subdirectory(XML)
|
|
list(APPEND Poco_COMPONENTS "XML")
|
|
endif()
|
|
if(ENABLE_JSON)
|
|
add_subdirectory(JSON)
|
|
list(APPEND Poco_COMPONENTS "JSON")
|
|
endif()
|
|
if(ENABLE_MONGODB)
|
|
add_subdirectory(MongoDB)
|
|
list(APPEND Poco_COMPONENTS "MongoDB")
|
|
endif()
|
|
if(ENABLE_PDF)
|
|
add_subdirectory(PDF)
|
|
list(APPEND Poco_COMPONENTS "PDF")
|
|
endif()
|
|
if(ENABLE_UTIL)
|
|
add_subdirectory(Util)
|
|
list(APPEND Poco_COMPONENTS "Util")
|
|
endif()
|
|
if(ENABLE_NET)
|
|
add_subdirectory(Net)
|
|
list(APPEND Poco_COMPONENTS "Net")
|
|
endif()
|
|
|
|
#NetSSL
|
|
|
|
|
|
if(WIN32 AND ENABLE_NETSSL_WIN)
|
|
add_subdirectory(NetSSL_Win)
|
|
list(APPEND Poco_COMPONENTS "NetSSL_Win")
|
|
endif(WIN32 AND ENABLE_NETSSL_WIN)
|
|
|
|
if(ENABLE_NETSSL OR ENABLE_CRYPTO)
|
|
find_package(OpenSSL REQUIRED)
|
|
if(OPENSSL_FOUND)
|
|
if(MSVC)
|
|
option(OPENSSL_IS_STATIC
|
|
"Set to OFF|ON (default is OFF) if OpenSSL has beenbuild as static libraries" OFF)
|
|
if(OPENSSL_IS_STATIC)
|
|
list(APPEND OPENSSL_LIBRARIES ws2_32 Crypt32)
|
|
endif()
|
|
endif()
|
|
include_directories("${OPENSSL_INCLUDE_DIR}")
|
|
if(ENABLE_NETSSL)
|
|
add_subdirectory(NetSSL_OpenSSL)
|
|
list(APPEND Poco_COMPONENTS "NetSSL_OpenSSL")
|
|
endif()
|
|
if(ENABLE_CRYPTO)
|
|
add_subdirectory(Crypto)
|
|
list(APPEND Poco_COMPONENTS "Crypto")
|
|
endif()
|
|
endif(OPENSSL_FOUND)
|
|
endif(ENABLE_NETSSL OR ENABLE_CRYPTO)
|
|
|
|
if(ENABLE_DATA)
|
|
add_subdirectory(Data)
|
|
list(APPEND Poco_COMPONENTS "Data")
|
|
endif()
|
|
if(ENABLE_SEVENZIP)
|
|
add_subdirectory(SevenZip)
|
|
list(APPEND Poco_COMPONENTS "SevenZip")
|
|
endif()
|
|
if(ENABLE_ZIP)
|
|
add_subdirectory(Zip)
|
|
list(APPEND Poco_COMPONENTS "Zip")
|
|
endif()
|
|
if(ENABLE_REDIS)
|
|
add_subdirectory(Redis)
|
|
list(APPEND Poco_COMPONENTS "Redis")
|
|
endif()
|
|
|
|
find_package(APR)
|
|
find_package(Apache2)
|
|
if(APRUTIL_FOUND AND APACHE_FOUND)
|
|
include_directories( "${APACHE_INCLUDE_DIR}" "${APRUTIL_INCLUDE_DIR}" )
|
|
if(ENABLE_APACHECONNECTOR)
|
|
add_subdirectory(ApacheConnector)
|
|
list(APPEND Poco_COMPONENTS "ApacheConnector")
|
|
endif()
|
|
endif(APRUTIL_FOUND AND APACHE_FOUND)
|
|
|
|
if(ENABLE_CPPPARSER)
|
|
add_subdirectory(CppParser)
|
|
list(APPEND Poco_COMPONENTS "CppParser")
|
|
endif()
|
|
|
|
if(ENABLE_POCODOC)
|
|
add_subdirectory(PocoDoc)
|
|
list(APPEND Poco_COMPONENTS "PocoDoc")
|
|
endif()
|
|
|
|
if(ENABLE_PAGECOMPILER)
|
|
add_subdirectory(PageCompiler)
|
|
list(APPEND Poco_COMPONENTS "PageCompiler")
|
|
endif()
|
|
|
|
if(ENABLE_PAGECOMPILER_FILE2PAGE)
|
|
add_subdirectory(PageCompiler/File2Page)
|
|
list(APPEND Poco_COMPONENTS "File2Page")
|
|
endif()
|
|
|
|
#############################################################
|
|
# Uninstall stuff see: http://www.vtk.org/Wiki/CMake_FAQ
|
|
configure_file(
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
IMMEDIATE @ONLY)
|
|
|
|
add_custom_target(uninstall
|
|
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
|
|
|
#############################################################
|
|
# Enable packaging
|
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Poco Libraries")
|
|
set(CPACK_PACKAGE_VENDOR "Applied Informatics Software Engineering GmbH")
|
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr/local")
|
|
|
|
include(CPack)
|
|
|
|
#############################################################
|
|
# cmake config files
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
write_basic_package_version_file(
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
|
|
VERSION ${PROJECT_VERSION}
|
|
COMPATIBILITY AnyNewerVersion
|
|
)
|
|
|
|
configure_file(cmake/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" @ONLY)
|
|
install(
|
|
FILES
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake
|
|
DESTINATION
|
|
"lib/cmake/${PROJECT_NAME}"
|
|
COMPONENT
|
|
Devel
|
|
)
|
|
|
|
# in tree build settings
|
|
#configure_file(PocoBuildTreeSettings.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/PocoBuildTreeSettings.cmake @ONLY)
|
|
|
|
if(POCO_VERBOSE_MESSAGES)
|
|
message(STATUS "CMake ${CMAKE_VERSION} successfully configured ${PROJECT_NAME} using ${CMAKE_GENERATOR} generator")
|
|
message(STATUS "Installation target path: ${CMAKE_INSTALL_PREFIX}")
|
|
|
|
message(STATUS "")
|
|
message(STATUS "Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
|
|
message(STATUS "Setting Poco build type - ${CMAKE_BUILD_TYPE}")
|
|
message(STATUS "")
|
|
|
|
message(STATUS "C_FLAGS: =${CMAKE_C_FLAGS}")
|
|
message(STATUS "CMAKE_C_FLAGS_DEBUG:=${CMAKE_C_FLAGS_DEBUG}")
|
|
message(STATUS "CMAKE_C_FLAGS_RELEASE:=${CMAKE_C_FLAGS_RELEASE}")
|
|
message(STATUS "CMAKE_C_FLAGS_MINSIZEREL:=${CMAKE_C_FLAGS_MINSIZEREL}")
|
|
message(STATUS "CMAKE_C_FLAGS_RELWITHDEBINFO:=${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
|
message(STATUS "")
|
|
message(STATUS "")
|
|
message(STATUS "CXX_FLAGS:=${CMAKE_CXX_FLAGS}")
|
|
message(STATUS "CMAKE_CXX_FLAGS_DEBUG:=${CMAKE_CXX_FLAGS_DEBUG}")
|
|
message(STATUS "CMAKE_CXX_FLAGS_RELEASE:=${CMAKE_CXX_FLAGS_RELEASE}")
|
|
message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL:=${CMAKE_CXX_FLAGS_MINSIZEREL}")
|
|
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO:=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
|
|
|
foreach(component ${Poco_COMPONENTS})
|
|
message(STATUS "Building: ${component}")
|
|
endforeach()
|
|
endif()
|