From 10425a9556f274a3bcd193132117132aae983650 Mon Sep 17 00:00:00 2001 From: Sascha Zelzer Date: Wed, 4 Feb 2015 04:35:23 +0100 Subject: [PATCH] Do not overwrite CMAKE_PREFIX_PATH in component config files. This fixes problems when a project adds a directory to CMAKE_PREFIX_PATH, then calls find_package(Poco ...) and afterwards calls find_package() for another project located in one of the directories of the original CMAKE_PREFIX_PATH variable. --- CppParser/cmake/PocoCppParserConfig.cmake | 3 +-- Crypto/cmake/PocoCryptoConfig.cmake | 3 +-- Data/MySQL/cmake/PocoDataMySQLConfig.cmake | 3 +-- Data/ODBC/cmake/PocoDataODBCConfig.cmake | 3 +-- Data/SQLite/cmake/PocoDataSQLiteConfig.cmake | 3 +-- Data/cmake/PocoDataConfig.cmake | 3 +-- JSON/cmake/PocoJSONConfig.cmake | 3 +-- MongoDB/cmake/PocoMongoDBConfig.cmake | 3 +-- Net/cmake/PocoNetConfig.cmake | 3 +-- NetSSL_OpenSSL/cmake/PocoNetSSLConfig.cmake | 3 +-- NetSSL_Win/cmake/PocoNetSSLWinConfig.cmake | 3 +-- PDF/cmake/PocoPDFConfig.cmake | 3 +-- SevenZip/cmake/PocoSevenZipConfig.cmake | 3 +-- Util/cmake/PocoUtilConfig.cmake | 3 +-- XML/cmake/PocoXMLConfig.cmake | 3 +-- Zip/cmake/PocoZipConfig.cmake | 3 +-- cmake/PocoConfig.cmake.in | 7 +++++++ 17 files changed, 23 insertions(+), 32 deletions(-) diff --git a/CppParser/cmake/PocoCppParserConfig.cmake b/CppParser/cmake/PocoCppParserConfig.cmake index 5cab7d89e..b81cb4bb9 100644 --- a/CppParser/cmake/PocoCppParserConfig.cmake +++ b/CppParser/cmake/PocoCppParserConfig.cmake @@ -1,4 +1,3 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) -include("${CMAKE_CURRENT_LIST_DIR}/PocoCppParserTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoCppParserTargets.cmake") diff --git a/Crypto/cmake/PocoCryptoConfig.cmake b/Crypto/cmake/PocoCryptoConfig.cmake index ef43e456b..fe147f3af 100644 --- a/Crypto/cmake/PocoCryptoConfig.cmake +++ b/Crypto/cmake/PocoCryptoConfig.cmake @@ -1,4 +1,3 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) -include("${CMAKE_CURRENT_LIST_DIR}/PocoCryptoTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoCryptoTargets.cmake") diff --git a/Data/MySQL/cmake/PocoDataMySQLConfig.cmake b/Data/MySQL/cmake/PocoDataMySQLConfig.cmake index 687d70f67..092774b3d 100644 --- a/Data/MySQL/cmake/PocoDataMySQLConfig.cmake +++ b/Data/MySQL/cmake/PocoDataMySQLConfig.cmake @@ -1,5 +1,4 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoData) -include("${CMAKE_CURRENT_LIST_DIR}/PocoDataMySQLTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoDataMySQLTargets.cmake") diff --git a/Data/ODBC/cmake/PocoDataODBCConfig.cmake b/Data/ODBC/cmake/PocoDataODBCConfig.cmake index 8795de04f..64b525e93 100644 --- a/Data/ODBC/cmake/PocoDataODBCConfig.cmake +++ b/Data/ODBC/cmake/PocoDataODBCConfig.cmake @@ -1,5 +1,4 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoData) -include("${CMAKE_CURRENT_LIST_DIR}/PocoDataODBCTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoDataODBCTargets.cmake") diff --git a/Data/SQLite/cmake/PocoDataSQLiteConfig.cmake b/Data/SQLite/cmake/PocoDataSQLiteConfig.cmake index 7b27debfc..8d8198c4f 100644 --- a/Data/SQLite/cmake/PocoDataSQLiteConfig.cmake +++ b/Data/SQLite/cmake/PocoDataSQLiteConfig.cmake @@ -1,5 +1,4 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoData) -include("${CMAKE_CURRENT_LIST_DIR}/PocoDataSQLiteTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoDataSQLiteTargets.cmake") diff --git a/Data/cmake/PocoDataConfig.cmake b/Data/cmake/PocoDataConfig.cmake index a598c9f7d..f78f247b0 100644 --- a/Data/cmake/PocoDataConfig.cmake +++ b/Data/cmake/PocoDataConfig.cmake @@ -1,4 +1,3 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) -include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTargets.cmake") diff --git a/JSON/cmake/PocoJSONConfig.cmake b/JSON/cmake/PocoJSONConfig.cmake index 294208f4f..f6c5b81b7 100644 --- a/JSON/cmake/PocoJSONConfig.cmake +++ b/JSON/cmake/PocoJSONConfig.cmake @@ -1,4 +1,3 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) -include("${CMAKE_CURRENT_LIST_DIR}/PocoJSONTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoJSONTargets.cmake") diff --git a/MongoDB/cmake/PocoMongoDBConfig.cmake b/MongoDB/cmake/PocoMongoDBConfig.cmake index 18e1bf7fb..2988635db 100644 --- a/MongoDB/cmake/PocoMongoDBConfig.cmake +++ b/MongoDB/cmake/PocoMongoDBConfig.cmake @@ -1,5 +1,4 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoNet) -include("${CMAKE_CURRENT_LIST_DIR}/PocoMongoDBTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoMongoDBTargets.cmake") diff --git a/Net/cmake/PocoNetConfig.cmake b/Net/cmake/PocoNetConfig.cmake index 635c7cfd6..5e4df49eb 100644 --- a/Net/cmake/PocoNetConfig.cmake +++ b/Net/cmake/PocoNetConfig.cmake @@ -1,4 +1,3 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) -include("${CMAKE_CURRENT_LIST_DIR}/PocoNetTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoNetTargets.cmake") diff --git a/NetSSL_OpenSSL/cmake/PocoNetSSLConfig.cmake b/NetSSL_OpenSSL/cmake/PocoNetSSLConfig.cmake index 65fb88c26..fa52ce0c6 100644 --- a/NetSSL_OpenSSL/cmake/PocoNetSSLConfig.cmake +++ b/NetSSL_OpenSSL/cmake/PocoNetSSLConfig.cmake @@ -1,7 +1,6 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoUtil) find_dependency(PocoNet) find_dependency(PocoCrypto) -include("${CMAKE_CURRENT_LIST_DIR}/PocoNetSSLTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoNetSSLTargets.cmake") diff --git a/NetSSL_Win/cmake/PocoNetSSLWinConfig.cmake b/NetSSL_Win/cmake/PocoNetSSLWinConfig.cmake index 679cde78e..a24d36c72 100644 --- a/NetSSL_Win/cmake/PocoNetSSLWinConfig.cmake +++ b/NetSSL_Win/cmake/PocoNetSSLWinConfig.cmake @@ -1,6 +1,5 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoUtil) find_dependency(PocoNet) -include("${CMAKE_CURRENT_LIST_DIR}/PocoNetSSLWinTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoNetSSLWinTargets.cmake") diff --git a/PDF/cmake/PocoPDFConfig.cmake b/PDF/cmake/PocoPDFConfig.cmake index d12a4c64c..36a69b09d 100644 --- a/PDF/cmake/PocoPDFConfig.cmake +++ b/PDF/cmake/PocoPDFConfig.cmake @@ -1,4 +1,3 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) -include("${CMAKE_CURRENT_LIST_DIR}/PocoPDFTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoPDFTargets.cmake") diff --git a/SevenZip/cmake/PocoSevenZipConfig.cmake b/SevenZip/cmake/PocoSevenZipConfig.cmake index 630b6a5f1..29b66b9dd 100644 --- a/SevenZip/cmake/PocoSevenZipConfig.cmake +++ b/SevenZip/cmake/PocoSevenZipConfig.cmake @@ -1,6 +1,5 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoXML) find_dependency(PocoUtil) -include("${CMAKE_CURRENT_LIST_DIR}/PocoSevenZipTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoSevenZipTargets.cmake") diff --git a/Util/cmake/PocoUtilConfig.cmake b/Util/cmake/PocoUtilConfig.cmake index 223a76c17..ca62b41ec 100644 --- a/Util/cmake/PocoUtilConfig.cmake +++ b/Util/cmake/PocoUtilConfig.cmake @@ -1,6 +1,5 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoXML) find_dependency(PocoJSON) -include("${CMAKE_CURRENT_LIST_DIR}/PocoUtilTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoUtilTargets.cmake") diff --git a/XML/cmake/PocoXMLConfig.cmake b/XML/cmake/PocoXMLConfig.cmake index 3c69ad2df..fd050cf51 100644 --- a/XML/cmake/PocoXMLConfig.cmake +++ b/XML/cmake/PocoXMLConfig.cmake @@ -1,4 +1,3 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) -include("${CMAKE_CURRENT_LIST_DIR}/PocoXMLTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoXMLTargets.cmake") diff --git a/Zip/cmake/PocoZipConfig.cmake b/Zip/cmake/PocoZipConfig.cmake index 360621f8c..3db18126a 100644 --- a/Zip/cmake/PocoZipConfig.cmake +++ b/Zip/cmake/PocoZipConfig.cmake @@ -1,6 +1,5 @@ include(CMakeFindDependencyMacro) -set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}) find_dependency(PocoFoundation) find_dependency(PocoUtil) find_dependency(PocoXML) -include("${CMAKE_CURRENT_LIST_DIR}/PocoZipTargets.cmake") \ No newline at end of file +include("${CMAKE_CURRENT_LIST_DIR}/PocoZipTargets.cmake") diff --git a/cmake/PocoConfig.cmake.in b/cmake/PocoConfig.cmake.in index 7724b5aa9..173eacd8c 100644 --- a/cmake/PocoConfig.cmake.in +++ b/cmake/PocoConfig.cmake.in @@ -21,6 +21,10 @@ get_filename_component(_Poco_install_prefix "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE set(_Poco_NOTFOUND_MESSAGE) +# Let components find each other, but don't overwrite CMAKE_PREFIX_PATH +set(_Poco_CMAKE_PREFIX_PATH_old ${CMAKE_PREFIX_PATH}) +set(CMAKE_PREFIX_PATH ${_Poco_install_prefix}) + foreach(module ${Poco_FIND_COMPONENTS}) find_package(Poco${module} ${_Poco_FIND_PARTS_QUIET} @@ -39,6 +43,9 @@ foreach(module ${Poco_FIND_COMPONENTS}) list(APPEND Poco_LIBRARIES "Poco::${module}") endforeach() +# Restore the original CMAKE_PREFIX_PATH value +set(CMAKE_PREFIX_PATH ${_Poco_CMAKE_PREFIX_PATH_old}) + if (_Poco_NOTFOUND_MESSAGE) set(Poco_NOT_FOUND_MESSAGE "${_Poco_NOTFOUND_MESSAGE}") set(Poco_FOUND False)