Skip to content
This repository was archived by the owner on Jul 1, 2021. It is now read-only.
61 changes: 21 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.5)
project(poco_vendor VERSION "1.0.0")

project(poco_vendor)

set(PACKAGE_VERSION "1.0.0")

list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
find_package(Poco COMPONENTS Foundation)


function(get_poco)
set(options)
set(oneValueArgs BUILD_TYPE)
set(multiValueArgs)
cmake_parse_arguments(get_poco "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Can work with poco 1.4.1p1 (earliest to use recursive mutexes on Linux)
# 1.6.1 is the first version to ship with PocoConfigVersion.cmake
find_package(Poco "1.6.1" COMPONENTS Foundation QUIET)

if(NOT Poco_FOUND)
# If Poco was not found, download and build from source
set(extra_cmake_args)
if(DEFINED get_poco_BUILD_TYPE)
list(APPEND extra_cmake_args -DCMAKE_BUILD_TYPE=${get_poco_BUILD_TYPE})
else()
set(get_poco_BUILD_TYPE "None")
if(DEFINED CMAKE_BUILD_TYPE)
list(APPEND extra_cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()
if(WIN32)
list(APPEND extra_cmake_args "-DCMAKE_CXX_FLAGS=/wd4244 /wd4530 /wd4577")
else()
list(APPEND extra_cmake_args "-DCMAKE_C_FLAGS=-Wno-shift-negative-value")
list(APPEND extra_cmake_args "-DCMAKE_CXX_FLAGS=-std=c++14")
list(APPEND extra_cmake_args "-DCMAKE_CXX_STANDARD=14")
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND NOT ANDROID)
list(APPEND extra_cmake_args "-DPOCO_UNBUNDLED:BOOL=ON")
endif()
Expand Down Expand Up @@ -58,12 +47,12 @@ function(get_poco)
endif()
endif()
include(ExternalProject)
ExternalProject_Add(poco-1.7.7-${get_poco_BUILD_TYPE}
URL https://github.com/pocoproject/poco/archive/poco-1.7.7-release.tar.gz
URL_MD5 247b97b545715dc38c8619e412fbcd96

ExternalProject_Add(poco-1.8.0.1-release
URL https://github.com/pocoproject/poco/archive/poco-1.8.0.1-release.tar.gz
URL_MD5 07aa03d7976d0dbc141d95821c104c10
TIMEOUT 600
CMAKE_ARGS
-DENABLE_CPPUNIT:BOOL=OFF
-DENABLE_CRYPTO:BOOL=OFF
-DENABLE_DATA:BOOL=OFF
-DENABLE_JSON:BOOL=OFF
Expand All @@ -76,33 +65,25 @@ function(get_poco)
-DENABLE_UTIL:BOOL=OFF
-DENABLE_XML:BOOL=OFF
-DENABLE_ZIP:BOOL=OFF
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/poco_install_${get_poco_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/poco_external_project_install
${extra_cmake_args}
-Wno-dev
)

# The external project will install to the build folder, but we'll install that on make install.
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/poco_install_${get_poco_BUILD_TYPE}/
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/poco_external_project_install/
DESTINATION ${CMAKE_INSTALL_PREFIX})
endfunction()

if(NOT Poco_FOUND)
# Always build a debug and a release version of poco
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
get_poco(BUILD_TYPE Release)
else()
get_poco(BUILD_TYPE Debug)
endif()

get_poco(BUILD_TYPE ${CMAKE_BUILD_TYPE})
else()
message(STATUS "Found Poco ${Poco_VERSION}")
endif()

configure_file(poco_vendorConfig.cmake.in
"${PROJECT_BINARY_DIR}/poco_vendorConfig.cmake" @ONLY)
configure_file(poco_vendorConfig-version.cmake.in
"${PROJECT_BINARY_DIR}/poco_vendorConfig-version.cmake" @ONLY)

install(DIRECTORY cmake DESTINATION share/${PROJECT_NAME})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/poco_vendorConfig-version.cmake"
COMPATIBILITY AnyNewerVersion)

install(FILES
"${PROJECT_BINARY_DIR}/poco_vendorConfig.cmake"
Expand Down
231 changes: 0 additions & 231 deletions cmake/Modules/FindPoco.cmake

This file was deleted.

13 changes: 0 additions & 13 deletions poco_vendorConfig-version.cmake.in

This file was deleted.

3 changes: 0 additions & 3 deletions poco_vendorConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ set(_@PROJECT_NAME@_CONFIG_INCLUDED TRUE)
if(NOT @PROJECT_NAME@_FIND_QUIETLY)
message(STATUS "Found @PROJECT_NAME@: @PACKAGE_VERSION@ (${@PROJECT_NAME@_DIR})")
endif()

# add the local Modules directory to the modules path, so FindPoco.cmake is considered.
list(INSERT CMAKE_MODULE_PATH 0 "${@PROJECT_NAME@_DIR}/Modules")