diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 7c595068a..acbacaf3c 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -24,7 +24,7 @@ "${POCO_BASE}/MongoDB/include", "${POCO_BASE}/ApacheConnector/include", "${POCO_BASE}/Data/src", - "${POCO_BASE}/Data/testsuite/include" + "${POCO_BASE}/Data/testsuite/DataTest/include" ] }, "configurations": [ diff --git a/ApacheConnector/CMakeLists.txt b/ApacheConnector/CMakeLists.txt index 544904fe2..022772d77 100644 --- a/ApacheConnector/CMakeLists.txt +++ b/ApacheConnector/CMakeLists.txt @@ -21,6 +21,6 @@ target_include_directories(mod_poco ) target_link_libraries(mod_poco PUBLIC Poco::Util Poco::Net Apache::Apr Apache::Aprutil) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 422957fd4..a03458de9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,10 @@ if(ENABLE_ACTIVERECORD AND NOT ENABLE_XML) endif() option(ENABLE_TESTS - "Set to OFF|ON (default is OFF) to control build of POCO tests & samples" OFF) + "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_UNBUNDLED "Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF) @@ -393,7 +396,13 @@ if(OPENSSL_FOUND) endif() endif(OPENSSL_FOUND) + +option(POCO_DATA_NO_SQL_PARSER "Disable SQL parser" OFF) + if(EXISTS ${PROJECT_SOURCE_DIR}/Data AND ENABLE_DATA) + if(POCO_DATA_NO_SQL_PARSER) + add_definitions(-DPOCO_DATA_NO_SQL_PARSER=1) + endif() add_subdirectory(Data) list(APPEND Poco_COMPONENTS "Data") endif() diff --git a/CppUnit/CMakeLists.txt b/CppUnit/CMakeLists.txt index 78b89d442..8a9badec2 100644 --- a/CppUnit/CMakeLists.txt +++ b/CppUnit/CMakeLists.txt @@ -38,3 +38,6 @@ elseif(MINGW) PUBLIC _DLL) endif() + +POCO_INSTALL(CppUnit) +POCO_GENERATE_PACKAGE(CppUnit) diff --git a/CppUnit/Makefile b/CppUnit/Makefile index bcd73ff8c..4890fe667 100644 --- a/CppUnit/Makefile +++ b/CppUnit/Makefile @@ -11,6 +11,6 @@ objects = CppUnitException TestDecorator TestResult TestSuite \ target = CppUnit target_version = 1 -target_libs = +target_libs = PocoFoundation include $(POCO_BASE)/build/rules/lib diff --git a/CppUnit/cmake/CppUnitConfig.cmake b/CppUnit/cmake/CppUnitConfig.cmake new file mode 100644 index 000000000..f78f247b0 --- /dev/null +++ b/CppUnit/cmake/CppUnitConfig.cmake @@ -0,0 +1,3 @@ +include(CMakeFindDependencyMacro) +find_dependency(PocoFoundation) +include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTargets.cmake") diff --git a/CppUnit/dependencies b/CppUnit/dependencies new file mode 100644 index 000000000..2e8175e4e --- /dev/null +++ b/CppUnit/dependencies @@ -0,0 +1 @@ +Foundation diff --git a/Crypto/CMakeLists.txt b/Crypto/CMakeLists.txt index 0a3b620df..5a69cf83e 100644 --- a/Crypto/CMakeLists.txt +++ b/Crypto/CMakeLists.txt @@ -40,7 +40,10 @@ endif() POCO_INSTALL(Crypto) POCO_GENERATE_PACKAGE(Crypto) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index 0772af648..4da7d5979 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -1,6 +1,11 @@ # Sources file(GLOB SRCS_G "src/*.cpp") POCO_SOURCES_AUTO(SRCS ${SRCS_G}) +if (NOT POCO_DATA_NO_SQL_PARSER) + file(GLOB_RECURSE SRCS_PARSER "src/sql-parser/src/*.cpp") + LIST(REMOVE_ITEM SRCS_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/src/sql-parser/src/parser/conflict_test.cpp") + POCO_SOURCES_AUTO(SRCS ${SRCS_PARSER}) +endif() # Headers file(GLOB_RECURSE HDRS_G "include/*.h") @@ -30,6 +35,7 @@ target_link_libraries(Data PUBLIC Poco::Foundation) target_include_directories(Data PUBLIC $ + $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) @@ -37,6 +43,10 @@ target_include_directories(Data POCO_INSTALL(Data) POCO_GENERATE_PACKAGE(Data) +if(ENABLE_TESTS) + add_subdirectory(testsuite) +endif() + if(ENABLE_DATA_SQLITE) # SQlite3 is built in any case message(STATUS "SQLite Support Enabled") @@ -66,7 +76,6 @@ else() message(STATUS "ODBC Support Disabled") endif() -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) - add_subdirectory(testsuite) endif() diff --git a/Data/MySQL/testsuite/CMakeLists.txt b/Data/MySQL/testsuite/CMakeLists.txt index 04b57b4cf..6b979517e 100644 --- a/Data/MySQL/testsuite/CMakeLists.txt +++ b/Data/MySQL/testsuite/CMakeLists.txt @@ -25,4 +25,5 @@ else() ) set_tests_properties(DataMySQL PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) endif() -target_link_libraries(DataMySQL-testrunner PUBLIC Poco::DataMySQL CppUnit) +target_link_libraries(DataMySQL-testrunner PUBLIC Poco::DataMySQL Poco::DataTest CppUnit) +target_include_directories(DataMySQL-testrunner PUBLIC ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/) diff --git a/Data/ODBC/testsuite/CMakeLists.txt b/Data/ODBC/testsuite/CMakeLists.txt index f2938060f..80d0af09f 100644 --- a/Data/ODBC/testsuite/CMakeLists.txt +++ b/Data/ODBC/testsuite/CMakeLists.txt @@ -25,4 +25,6 @@ else() ) set_tests_properties(DataODBC PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) endif() -target_link_libraries(DataODBC-testrunner PUBLIC Poco::DataODBC CppUnit) + +target_link_libraries(DataODBC-testrunner PUBLIC Poco::DataTest Poco::DataODBC Poco::Data CppUnit) +target_include_directories(DataODBC-testrunner PUBLIC ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/) diff --git a/Data/ODBC/testsuite/Makefile b/Data/ODBC/testsuite/Makefile index 17efd307d..b17f82c86 100644 --- a/Data/ODBC/testsuite/Makefile +++ b/Data/ODBC/testsuite/Makefile @@ -35,13 +35,13 @@ ifeq ($(POCO_CONFIG),MinGW) objects += ODBCAccessTest endif -target_includes = $(POCO_BASE)/Data/testsuite/include ifndef POCO_DATA_NO_SQL_PARSER target_includes += $(POCO_BASE)/Data/src endif -target = testrunner -target_version = 1 -target_libs = PocoDataODBC PocoDataTest PocoData PocoFoundation CppUnit +target = testrunner +target_version = 1 +target_libs = PocoDataODBC PocoDataTest PocoData PocoFoundation CppUnit +target_includes += $(POCO_BASE)/Data/testsuite/DataTest/include include $(POCO_BASE)/build/rules/exec diff --git a/Data/PostgreSQL/testsuite/CMakeLists.txt b/Data/PostgreSQL/testsuite/CMakeLists.txt index 8afd77ded..f97bb9c7c 100644 --- a/Data/PostgreSQL/testsuite/CMakeLists.txt +++ b/Data/PostgreSQL/testsuite/CMakeLists.txt @@ -17,4 +17,5 @@ add_test( COMMAND DataPostgreSQL-testrunner -ignore ${CMAKE_SOURCE_DIR}/cppignore.lnx -all ) set_tests_properties(DataPostgreSQL PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) -target_link_libraries(DataPostgreSQL-testrunner PUBLIC Poco::DataPostgreSQL CppUnit) +target_link_libraries(DataPostgreSQL-testrunner PUBLIC Poco::DataPostgreSQL Poco::DataTest CppUnit) +target_include_directories(DataPostgreSQL-testrunner PUBLIC ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/) diff --git a/Data/SQLite/testsuite/CMakeLists.txt b/Data/SQLite/testsuite/CMakeLists.txt index 73b8d5252..2c04c2212 100644 --- a/Data/SQLite/testsuite/CMakeLists.txt +++ b/Data/SQLite/testsuite/CMakeLists.txt @@ -4,7 +4,8 @@ POCO_SOURCES_AUTO(TEST_SRCS ${SRCS_G}) # Headers file(GLOB_RECURSE HDRS_G "src/*.h") -POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_G}) +file(GLOB HDRS_E ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/*.h) +POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_E}) POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF src/WinDriver.cpp @@ -29,4 +30,6 @@ else() ) set_tests_properties(DataSQLite PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) endif() -target_link_libraries(DataSQLite-testrunner PUBLIC Poco::DataSQLite CppUnit) + +target_link_libraries(DataSQLite-testrunner PUBLIC Poco::DataSQLite Poco::DataTest CppUnit) +target_include_directories(DataSQLite-testrunner PUBLIC ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/) diff --git a/Data/include/Poco/Data/Statement.h b/Data/include/Poco/Data/Statement.h index 272c4afd4..7aeba69b3 100644 --- a/Data/include/Poco/Data/Statement.h +++ b/Data/include/Poco/Data/Statement.h @@ -544,7 +544,7 @@ private: /// Returns true if the statement is of the argument type. Poco::SharedPtr _pParseResult; - + std::string _parseError; #endif // POCO_DATA_NO_SQL_PARSER StatementImpl::Ptr _pImpl; @@ -557,7 +557,6 @@ private: std::vector _arguments; RowFormatter::Ptr _pRowFormatter; mutable std::string _stmtString; - std::string _parseError; }; // @@ -571,7 +570,12 @@ inline std::size_t Statement::subTotalRowCount(int dataSet) const inline const std::string& Statement::parseError() { +#ifdef POCO_DATA_NO_SQL_PARSER + static std::string empty; + return empty; +#else return _parseError; +#endif } diff --git a/Data/src/Statement.cpp b/Data/src/Statement.cpp index 570f13078..efb9b02cc 100644 --- a/Data/src/Statement.cpp +++ b/Data/src/Statement.cpp @@ -48,6 +48,7 @@ Statement::Statement(Session& session): Statement::Statement(const Statement& stmt): #ifndef POCO_DATA_NO_SQL_PARSER _pParseResult(stmt._pParseResult), + _parseError(stmt._parseError), #endif _pImpl(stmt._pImpl), _async(stmt._async), @@ -55,8 +56,7 @@ Statement::Statement(const Statement& stmt): _pAsyncExec(stmt._pAsyncExec), _arguments(stmt._arguments), _pRowFormatter(stmt._pRowFormatter), - _stmtString(stmt._stmtString), - _parseError(stmt._parseError) + _stmtString(stmt._stmtString) { } @@ -64,6 +64,7 @@ Statement::Statement(const Statement& stmt): Statement::Statement(Statement&& stmt) noexcept: #ifndef POCO_DATA_NO_SQL_PARSER _pParseResult(std::move(stmt._pParseResult)), + _parseError(std::move(stmt._parseError)), #endif _pImpl(std::move(stmt._pImpl)), _async(std::move(stmt._async)), @@ -71,8 +72,7 @@ Statement::Statement(Statement&& stmt) noexcept: _pAsyncExec(std::move(stmt._pAsyncExec)), _arguments(std::move(stmt._arguments)), _pRowFormatter(std::move(stmt._pRowFormatter)), - _stmtString(std::move(stmt._stmtString)), - _parseError(std::move(stmt._parseError)) + _stmtString(std::move(stmt._stmtString)) { stmt._pImpl = nullptr; stmt._async = false; @@ -81,7 +81,9 @@ Statement::Statement(Statement&& stmt) noexcept: stmt._arguments.clear(); stmt._pRowFormatter = nullptr; _stmtString.clear(); +#ifndef POCO_DATA_NO_SQL_PARSER _parseError.clear(); +#endif } @@ -102,6 +104,8 @@ Statement& Statement::operator = (Statement&& stmt) noexcept { #ifndef POCO_DATA_NO_SQL_PARSER _pParseResult = std::move(stmt._pParseResult); + _parseError = std::move(stmt._parseError); + _parseError.clear(); #endif _pImpl = std::move(stmt._pImpl); stmt._pImpl = nullptr; @@ -117,8 +121,6 @@ Statement& Statement::operator = (Statement&& stmt) noexcept stmt._pRowFormatter = nullptr; _stmtString = std::move(stmt._stmtString); _stmtString.clear(); - _parseError = std::move(stmt._parseError); - _parseError.clear(); return *this; } @@ -128,6 +130,7 @@ void Statement::swap(Statement& other) noexcept using std::swap; #ifndef POCO_DATA_NO_SQL_PARSER swap(_pParseResult, other._pParseResult); + swap(_parseError, other._parseError); #endif swap(_pImpl, other._pImpl); swap(_async, other._async); @@ -136,7 +139,6 @@ void Statement::swap(Statement& other) noexcept _arguments.swap(other._arguments); swap(_pRowFormatter, other._pRowFormatter); swap(_stmtString, other._stmtString); - swap(_parseError, other._parseError); } diff --git a/Data/testsuite/CMakeLists.txt b/Data/testsuite/CMakeLists.txt index f7226d31d..a6e0a9b87 100644 --- a/Data/testsuite/CMakeLists.txt +++ b/Data/testsuite/CMakeLists.txt @@ -1,9 +1,10 @@ # Sources file(GLOB SRCS_G "src/*.cpp") +LIST(REMOVE_ITEM SRCS_G "${CMAKE_CURRENT_SOURCE_DIR}/src/SQLExecutor.cpp") POCO_SOURCES_AUTO(TEST_SRCS ${SRCS_G}) # Headers -file(GLOB_RECURSE HDRS_G "src/*.h") +file(GLOB HDRS_G "src/*.h") POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_G}) POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF @@ -14,11 +15,6 @@ POCO_SOURCES_AUTO_PLAT(TEST_SRCS WINCE src/WinCEDriver.cpp ) -#TODO: Why is this file there? It doesn't compile if it is include in the sources -POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF - src/StatementImpl.cpp -) - add_executable(Data-testrunner ${TEST_SRCS}) if(ANDROID) add_test( @@ -35,3 +31,5 @@ else() set_tests_properties(Data PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) endif() target_link_libraries(Data-testrunner PUBLIC Poco::Data CppUnit) + +add_subdirectory(DataTest) diff --git a/Data/testsuite/DataTest/CMakeLists.txt b/Data/testsuite/DataTest/CMakeLists.txt new file mode 100644 index 000000000..13f93a6ec --- /dev/null +++ b/Data/testsuite/DataTest/CMakeLists.txt @@ -0,0 +1,34 @@ +# Sources +file(GLOB SRCS_G ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) +POCO_SOURCES_AUTO(DATA_TEST_LIB_SRCS ${SRCS_G}) + +# Headers +file(GLOB HDRS_G ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h) +POCO_HEADERS_AUTO(DATA_TEST_LIB_SRCS ${HDRS_G}) + +# Version Resource +if(MSVC AND BUILD_SHARED_LIBS) + source_group("Resources" FILES ${PROJECT_SOURCE_DIR}/DLLVersion.rc) + list(APPEND DATA_TEST_LIB_SRCS ${PROJECT_SOURCE_DIR}/DLLVersion.rc) +endif() + +add_library(DataTest ${DATA_TEST_LIB_SRCS}) +add_library(Poco::DataTest ALIAS DataTest) +set_target_properties(DataTest + PROPERTIES + VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION} + OUTPUT_NAME PocoDataTest + DEFINE_SYMBOL DataTest_EXPORTS +) + +target_link_libraries(DataTest PUBLIC Poco::Data CppUnit) +target_include_directories(DataTest + PUBLIC + $ + $ + $ + $ +) + +POCO_INSTALL(DataTest) +POCO_GENERATE_PACKAGE(DataTest) diff --git a/Data/testsuite/DataTest/Makefile b/Data/testsuite/DataTest/Makefile new file mode 100644 index 000000000..61a309c7b --- /dev/null +++ b/Data/testsuite/DataTest/Makefile @@ -0,0 +1,16 @@ +# +# Makefile +# +# Makefile for Poco Data testsuite library +# + +include $(POCO_BASE)/build/rules/global + +objects = SQLExecutor + +target = PocoDataTest +target_version = 1 +target_libs = PocoData PocoFoundation CppUnit +target_includes = $(POCO_BASE)/Data/src $(POCO_BASE)/Data/testsuite/DataTest/include + +include $(POCO_BASE)/build/rules/lib diff --git a/Data/testsuite/DataTest/cmake/PocoDataTestConfig.cmake b/Data/testsuite/DataTest/cmake/PocoDataTestConfig.cmake new file mode 100644 index 000000000..5a497122e --- /dev/null +++ b/Data/testsuite/DataTest/cmake/PocoDataTestConfig.cmake @@ -0,0 +1,5 @@ +include(CMakeFindDependencyMacro) +find_dependency(PocoFoundation) +find_dependency(PocoData) +find_dependency(CppUnit) +include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTestTargets.cmake") diff --git a/Data/testsuite/DataTest/dependencies b/Data/testsuite/DataTest/dependencies new file mode 100644 index 000000000..bef728c9a --- /dev/null +++ b/Data/testsuite/DataTest/dependencies @@ -0,0 +1,2 @@ +Foundation +Data diff --git a/Data/testsuite/DataTest/include/Poco/Data/Test/DataTest.h b/Data/testsuite/DataTest/include/Poco/Data/Test/DataTest.h new file mode 100644 index 000000000..e3c520b65 --- /dev/null +++ b/Data/testsuite/DataTest/include/Poco/Data/Test/DataTest.h @@ -0,0 +1,62 @@ +// +// DataTest.h +// +// Library: DataTest +// Package: DataTestCore +// Module: DataTest +// +// Basic definitions for the Poco DataTest library. +// This file must be the first file included by every other DataTest +// header file. +// +// Copyright (c) 2006, Applied Informatics Software Engineering GmbH., +// Aleph ONE Software Engineering d.o.o., and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DataTest_DataTest_INCLUDED +#define DataTest_DataTest_INCLUDED + + +#include "Poco/Foundation.h" + + +// +// The following block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the DataTest_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// DataTest_API functions as being imported from a DLL, wheras this DLL sees symbols +// defined with this macro as being exported. +// +#if defined(_WIN32) && defined(POCO_DLL) + #if defined(DataTest_EXPORTS) + #define DataTest_API __declspec(dllexport) + #else + #define DataTest_API __declspec(dllimport) + #endif +#endif + + +#if !defined(DataTest_API) + #if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4) + #define DataTest_API __attribute__ ((visibility ("default"))) + #else + #define DataTest_API + #endif +#endif + + +// +// Automatically link DataTest library. +// +#if defined(_MSC_VER) + #if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(DataTest_EXPORTS) + #pragma comment(lib, "PocoDataTest" POCO_LIB_SUFFIX) + #endif +#endif + + +#endif // DataTest_DataTest_INCLUDED diff --git a/Data/testsuite/include/Poco/Data/Test/SQLExecutor.h b/Data/testsuite/DataTest/include/Poco/Data/Test/SQLExecutor.h similarity index 95% rename from Data/testsuite/include/Poco/Data/Test/SQLExecutor.h rename to Data/testsuite/DataTest/include/Poco/Data/Test/SQLExecutor.h index 3b88b113b..281dd51dc 100644 --- a/Data/testsuite/include/Poco/Data/Test/SQLExecutor.h +++ b/Data/testsuite/DataTest/include/Poco/Data/Test/SQLExecutor.h @@ -3,18 +3,18 @@ // // Definition of the SQLExecutor class. // -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. +// Copyright (c) 2006, Applied Informatics Software Engineering GmbH., +// Aleph ONE Software Engineering d.o.o., and Contributors. // // SPDX-License-Identifier: BSL-1.0 // -#ifndef Data_SQLExecutor_INCLUDED -#define Data_SQLExecutor_INCLUDED +#ifndef DataTest_SQLExecutor_INCLUDED +#define DataTest_SQLExecutor_INCLUDED -#include "Poco/Data/Data.h" +#include "Poco/Data/Test/DataTest.h" #include "Poco/Data/Session.h" #include "Poco/Data/BulkExtraction.h" #include "Poco/Data/BulkBinding.h" @@ -24,6 +24,11 @@ #include +namespace Poco { +namespace Data { +namespace Test { + + #define poco_data_using_keywords using Poco::Data::Keywords::now; \ using Poco::Data::Keywords::into; \ using Poco::Data::Keywords::use; \ @@ -33,12 +38,7 @@ using Poco::Data::CLOB; -namespace Poco { -namespace Data { -namespace Test { - - -class SQLExecutor: public CppUnit::TestCase +class DataTest_API SQLExecutor: public CppUnit::TestCase { public: enum DataBinding @@ -238,4 +238,4 @@ private: } } } // Poco::Data::Test -#endif // Data_SQLExecutor_INCLUDED +#endif // DataTest_SQLExecutor_INCLUDED diff --git a/Data/testsuite/src/SQLExecutor.cpp b/Data/testsuite/DataTest/src/SQLExecutor.cpp similarity index 100% rename from Data/testsuite/src/SQLExecutor.cpp rename to Data/testsuite/DataTest/src/SQLExecutor.cpp diff --git a/Data/testsuite/Makefile b/Data/testsuite/Makefile index b60c67fe0..f5397e1b7 100644 --- a/Data/testsuite/Makefile +++ b/Data/testsuite/Makefile @@ -8,4 +8,4 @@ clean distclean all: projects projects: $(MAKE) -f Makefile-testrunner $(MAKECMDGOALS) - $(MAKE) -f Makefile-library $(MAKECMDGOALS) + $(MAKE) -C DataTest $(MAKECMDGOALS) diff --git a/Data/testsuite/Makefile-library b/Data/testsuite/Makefile-library deleted file mode 100644 index afc360f99..000000000 --- a/Data/testsuite/Makefile-library +++ /dev/null @@ -1,21 +0,0 @@ -# -# Makefile -# -# Makefile for Poco Data testsuite library -# - -include $(POCO_BASE)/build/rules/global - -objects = SQLExecutor - -target_includes = $(POCO_BASE)/Data/testsuite/include -ifndef POCO_DATA_NO_SQL_PARSER - objects += SQLParserTest - target_includes += $(POCO_BASE)/Data/src -endif - -target = PocoDataTest -target_version = 1 -target_libs = PocoData PocoFoundation CppUnit - -include $(POCO_BASE)/build/rules/lib diff --git a/Data/testsuite/src/DataTest.cpp b/Data/testsuite/src/DataTest.cpp index c7f6899a9..6fb0ce49c 100644 --- a/Data/testsuite/src/DataTest.cpp +++ b/Data/testsuite/src/DataTest.cpp @@ -1504,6 +1504,8 @@ void DataTest::testSQLParse() assertTrue (!stmt.isDelete().isSpecified()); assertTrue (!stmt.hasDelete().isSpecified()); +#else + std::cout << "[NOT ENABLED]"; #endif // POCO_DATA_NO_SQL_PARSER } diff --git a/Data/testsuite/src/StatementImpl.cpp b/Data/testsuite/src/StatementImpl.cpp deleted file mode 100644 index 5c19c05a7..000000000 --- a/Data/testsuite/src/StatementImpl.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -// StatementImpl.cpp -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "StatementImpl.h" - - -namespace Poco { -namespace Data { -namespace Test { - - -StatementImpl::StatementImpl() -{ -} - - -StatementImpl::~StatementImpl() -{ -} - - -void StatementImpl::compileImpl() -{ - // prepare binding - _ptrBinder = new Binder; - _ptrExtractor = new Extractor; - _ptrPrepare = new Preparation(); -} - - -bool StatementImpl::canBind() const -{ - return false; -} - - -void StatementImpl::bindImpl() -{ - // bind - typedef Poco::Data::AbstractBindingVec Bindings; - Bindings& binds = bindings(); - if (binds.empty()) - return; - - Bindings::iterator it = binds.begin(); - Bindings::iterator itEnd = binds.end(); - std::size_t pos = 0; - for (; it != itEnd && (*it)->canBind(); ++it) - { - (*it)->bind(pos); - pos += (*it)->numOfColumnsHandled(); - } -} - - -bool StatementImpl::hasNext() -{ - return false; -} - - -void StatementImpl::next() -{ - Poco::Data::AbstractExtractionVec::iterator it = extractions().begin(); - Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end(); - std::size_t pos = 0; - for (; it != itEnd; ++it) - { - (*it)->extract(pos); - pos += (*it)->numOfColumnsHandled(); - } -} - - -} } } // namespace Poco::Data::Test diff --git a/Data/testsuite/src/StatementImpl.h b/Data/testsuite/src/StatementImpl.h deleted file mode 100644 index e7df70f89..000000000 --- a/Data/testsuite/src/StatementImpl.h +++ /dev/null @@ -1,91 +0,0 @@ -// -// StatementImpl.h -// -// Definition of the StatementImpl class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Data_Test_StatementImpl_INCLUDED -#define Data_Test_StatementImpl_INCLUDED - - -#include "Poco/Data/StatementImpl.h" -#include "Poco/SharedPtr.h" -#include "Binder.h" -#include "Extractor.h" -#include "Preparator.h" - - -struct sqlite3; -struct sqlite3_stmt; - - -namespace Poco { -namespace Data { -namespace Test { - - -class StatementImpl: public Poco::Data::StatementImpl - /// A no-op implementation of StatementImpl for testing. -{ -public: - StatementImpl(); - /// Creates the StatementImpl. - - ~StatementImpl(); - /// Destroys the StatementImpl. - -protected: - bool hasNext(); - /// Returns true if a call to next() will return data. - - void next(); - /// Retrieves the next row from the resultset. - /// Will throw, if the resultset is empty. - - bool canBind() const; - /// Returns true if a valid statement is set and we can bind. - - void compileImpl(); - /// Compiles the statement, doesn't bind yet - - void bindImpl(); - /// Binds parameters - - AbstractExtractor& extractor(); - /// Returns the concrete extractor used by the statement. - - AbstractBinder& binder(); - /// Returns the concrete binder used by the statement. - -private: - Poco::SharedPtr _ptrBinder; - Poco::SharedPtr _ptrExtractor; - Poco::SharedPtr _ptrPrepare; -}; - - -// -// inlines -// -inline AbstractExtractor& StatementImpl::extractor() -{ - return *_ptrExtractor; -} - - -inline AbstractBinder& StatementImpl::binder() -{ - return *_ptrBinder; -} - - -} } } // namespace Poco::Data::Test - - -#endif // Data_Test_StatementImpl_INCLUDED diff --git a/Data/testsuite/testsuite.cmake b/Data/testsuite/testsuite.cmake new file mode 100644 index 000000000..5e7334dea --- /dev/null +++ b/Data/testsuite/testsuite.cmake @@ -0,0 +1,33 @@ +# Sources +file(GLOB SRCS_G "src/*.cpp") +LIST(REMOVE_ITEM SRCS_G "${CMAKE_CURRENT_SOURCE_DIR}/src/SQLExecutor.cpp") +POCO_SOURCES_AUTO(TEST_SRCS ${SRCS_G}) + +# Headers +file(GLOB HDRS_G "src/*.h") +POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_G}) + +POCO_SOURCES_AUTO_PLAT(TEST_SRCS WIN + src/WinDriver.cpp +) + +POCO_SOURCES_AUTO_PLAT(TEST_SRCS WINCE + src/WinCEDriver.cpp +) + +add_executable(Data-testrunner ${TEST_SRCS}) +if(ANDROID) + add_test( + NAME Data + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/Data-testrunner -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake + ) +else() + add_test( + NAME Data + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND Data-testrunner -ignore ${CMAKE_SOURCE_DIR}/cppignore.lnx -all + ) + set_tests_properties(Data PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) +endif() +target_link_libraries(Data-testrunner PUBLIC Poco::Data CppUnit) diff --git a/Encodings/CMakeLists.txt b/Encodings/CMakeLists.txt index 0a484e2d7..eb72f498c 100644 --- a/Encodings/CMakeLists.txt +++ b/Encodings/CMakeLists.txt @@ -32,7 +32,10 @@ target_include_directories(Encodings POCO_INSTALL(Encodings) POCO_GENERATE_PACKAGE(Encodings) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index c3e28fde8..748b30b8b 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -234,10 +234,13 @@ endif() POCO_INSTALL(Foundation) POCO_GENERATE_PACKAGE(Foundation) +if(ENABLE_SAMPLES) + add_subdirectory(samples) +endif() + if(ENABLE_TESTS) if(NOT BUILD_SHARED_LIBS) set_property(TARGET Foundation PROPERTY POSITION_INDEPENDENT_CODE ON) # This is needed to build TestLibrary.so as shared. endif() - add_subdirectory(samples) add_subdirectory(testsuite) endif() diff --git a/JSON/CMakeLists.txt b/JSON/CMakeLists.txt index f8f478a4b..86d6ed312 100644 --- a/JSON/CMakeLists.txt +++ b/JSON/CMakeLists.txt @@ -41,7 +41,10 @@ endif() POCO_INSTALL(JSON) POCO_GENERATE_PACKAGE(JSON) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/MongoDB/CMakeLists.txt b/MongoDB/CMakeLists.txt index 2d4cb08a8..771567194 100644 --- a/MongoDB/CMakeLists.txt +++ b/MongoDB/CMakeLists.txt @@ -32,8 +32,11 @@ target_include_directories(MongoDB POCO_INSTALL(MongoDB) POCO_GENERATE_PACKAGE(MongoDB) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/Net/CMakeLists.txt b/Net/CMakeLists.txt index 237df1c3b..04799325c 100644 --- a/Net/CMakeLists.txt +++ b/Net/CMakeLists.txt @@ -46,8 +46,11 @@ target_include_directories(Net POCO_INSTALL(Net) POCO_GENERATE_PACKAGE(Net) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/NetSSL_OpenSSL/CMakeLists.txt b/NetSSL_OpenSSL/CMakeLists.txt index d5e61b88c..eb7f56227 100644 --- a/NetSSL_OpenSSL/CMakeLists.txt +++ b/NetSSL_OpenSSL/CMakeLists.txt @@ -36,8 +36,11 @@ endif() POCO_INSTALL(NetSSL) POCO_GENERATE_PACKAGE(NetSSL) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/NetSSL_Win/CMakeLists.txt b/NetSSL_Win/CMakeLists.txt index c6325eb4f..c0e17689d 100644 --- a/NetSSL_Win/CMakeLists.txt +++ b/NetSSL_Win/CMakeLists.txt @@ -32,9 +32,12 @@ target_include_directories(NetSSLWin POCO_INSTALL(NetSSLWin) POCO_GENERATE_PACKAGE(NetSSLWin) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) #TODO: Looks like the samples use crypto somehow? #add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) #add_subdirectory(testsuite) endif() diff --git a/PDF/CMakeLists.txt b/PDF/CMakeLists.txt index 2c565ad17..f0c16350e 100644 --- a/PDF/CMakeLists.txt +++ b/PDF/CMakeLists.txt @@ -146,8 +146,11 @@ target_include_directories(PDF POCO_INSTALL(PDF) POCO_GENERATE_PACKAGE(PDF) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/Prometheus/CMakeLists.txt b/Prometheus/CMakeLists.txt index f9186f579..f10a0ce46 100644 --- a/Prometheus/CMakeLists.txt +++ b/Prometheus/CMakeLists.txt @@ -32,8 +32,11 @@ target_include_directories(Prometheus POCO_INSTALL(Prometheus) POCO_GENERATE_PACKAGE(Prometheus) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/Redis/CMakeLists.txt b/Redis/CMakeLists.txt index 875f49ab9..da8bd9dba 100644 --- a/Redis/CMakeLists.txt +++ b/Redis/CMakeLists.txt @@ -34,6 +34,5 @@ POCO_GENERATE_PACKAGE(Redis) if(ENABLE_TESTS) add_subdirectory(testsuite) -# add_subdirectory(samples) endif() diff --git a/SevenZip/CMakeLists.txt b/SevenZip/CMakeLists.txt index 118ded71b..1babc0ef7 100644 --- a/SevenZip/CMakeLists.txt +++ b/SevenZip/CMakeLists.txt @@ -75,7 +75,5 @@ POCO_GENERATE_PACKAGE(SevenZip) if(ENABLE_TESTS) add_subdirectory(samples) - # TODO: Add tests - #add_subdirectory(testsuite) endif() diff --git a/Util/CMakeLists.txt b/Util/CMakeLists.txt index 5f3f7c1fd..f206ac040 100644 --- a/Util/CMakeLists.txt +++ b/Util/CMakeLists.txt @@ -49,7 +49,10 @@ target_include_directories(Util POCO_INSTALL(Util) POCO_GENERATE_PACKAGE(Util) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/XML/CMakeLists.txt b/XML/CMakeLists.txt index 123657a0c..a51d906c3 100644 --- a/XML/CMakeLists.txt +++ b/XML/CMakeLists.txt @@ -65,8 +65,11 @@ endif() POCO_INSTALL(XML) POCO_GENERATE_PACKAGE(XML) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/Zip/CMakeLists.txt b/Zip/CMakeLists.txt index abe577653..796898cf6 100644 --- a/Zip/CMakeLists.txt +++ b/Zip/CMakeLists.txt @@ -32,8 +32,11 @@ target_include_directories(Zip POCO_INSTALL(Zip) POCO_GENERATE_PACKAGE(Zip) -if(ENABLE_TESTS) +if(ENABLE_SAMPLES) add_subdirectory(samples) +endif() + +if(ENABLE_TESTS) add_subdirectory(testsuite) endif() diff --git a/cmake/PocoMacros.cmake b/cmake/PocoMacros.cmake index e37473e2d..fc2891033 100644 --- a/cmake/PocoMacros.cmake +++ b/cmake/PocoMacros.cmake @@ -53,155 +53,155 @@ endif(WIN32) # Macros for Source file management # # POCO_SOURCES_PLAT - Adds a list of files to the sources of a components -# Usage: POCO_SOURCES_PLAT( out name platform sources) -# INPUT: -# out the variable the sources are added to -# name: the name of the components -# platform: the platform this sources are for (ON = All, OFF = None, WIN32, UNIX ...) -# sources: a list of files to add to ${out} -# Example: POCO_SOURCES_PLAT( SRCS Foundation ON src/Foundation.cpp ) +# Usage: POCO_SOURCES_PLAT( out name platform sources) +# INPUT: +# out the variable the sources are added to +# name: the name of the components +# platform: the platform this sources are for (ON = All, OFF = None, WIN32, UNIX ...) +# sources: a list of files to add to ${out} +# Example: POCO_SOURCES_PLAT( SRCS Foundation ON src/Foundation.cpp ) # # POCO_SOURCES - Like POCO_SOURCES_PLAT with platform = ON (Built on all platforms) -# Usage: POCO_SOURCES( out name sources) -# Example: POCO_SOURCES( SRCS Foundation src/Foundation.cpp) +# Usage: POCO_SOURCES( out name sources) +# Example: POCO_SOURCES( SRCS Foundation src/Foundation.cpp) # # POCO_SOURCES_AUTO - Like POCO_SOURCES but the name is read from the file header // Package: X -# Usage: POCO_SOURCES_AUTO( out sources) -# Example: POCO_SOURCES_AUTO( SRCS src/Foundation.cpp) +# Usage: POCO_SOURCES_AUTO( out sources) +# Example: POCO_SOURCES_AUTO( SRCS src/Foundation.cpp) # # POCO_SOURCES_AUTO_PLAT - Like POCO_SOURCES_PLAT but the name is read from the file header // Package: X -# Usage: POCO_SOURCES_AUTO_PLAT(out platform sources) -# Example: POCO_SOURCES_AUTO_PLAT( SRCS WIN32 src/Foundation.cpp) +# Usage: POCO_SOURCES_AUTO_PLAT(out platform sources) +# Example: POCO_SOURCES_AUTO_PLAT( SRCS WIN32 src/Foundation.cpp) # # # POCO_HEADERS - Adds a list of files to the headers of a components -# Usage: POCO_HEADERS( out name headers) -# INPUT: -# out the variable the headers are added to -# name: the name of the components -# headers: a list of files to add to HDRSt -# Example: POCO_HEADERS( HDRS Foundation include/Poco/Foundation.h ) +# Usage: POCO_HEADERS( out name headers) +# INPUT: +# out the variable the headers are added to +# name: the name of the components +# headers: a list of files to add to HDRSt +# Example: POCO_HEADERS( HDRS Foundation include/Poco/Foundation.h ) # # POCO_HEADERS_AUTO - Like POCO_HEADERS but the name is read from the file header // Package: X -# Usage: POCO_HEADERS_AUTO( out headers) -# Example: POCO_HEADERS_AUTO( HDRS src/Foundation.cpp) +# Usage: POCO_HEADERS_AUTO( out headers) +# Example: POCO_HEADERS_AUTO( HDRS src/Foundation.cpp) # # # POCO_MESSAGES - Adds a list of files to the messages of a components -# and adds the generated headers to the header list of the component. -# On platforms other then Windows this does nothing -# Usage: POCO_MESSAGES( out name messages) -# INPUT: -# out the variable the message and the resulting headers are added to -# name: the name of the components -# messages: a list of files to add to MSGS -# Example: POCO_MESSAGES( HDRS Foundation include/Poco/Foundation.mc ) +# and adds the generated headers to the header list of the component. +# On platforms other then Windows this does nothing +# Usage: POCO_MESSAGES( out name messages) +# INPUT: +# out the variable the message and the resulting headers are added to +# name: the name of the components +# messages: a list of files to add to MSGS +# Example: POCO_MESSAGES( HDRS Foundation include/Poco/Foundation.mc ) # macro(POCO_SOURCES_PLAT out name platform) - source_group("${name}\\Source Files" FILES ${ARGN}) - list(APPEND ${out} ${ARGN}) - if(NOT(${platform})) - set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) - endif() + source_group("${name}\\Source Files" FILES ${ARGN}) + list(APPEND ${out} ${ARGN}) + if(NOT(${platform})) + set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) + endif() endmacro() macro(POCO_SOURCES out name) - POCO_SOURCES_PLAT( ${out} ${name} ON ${ARGN}) + POCO_SOURCES_PLAT( ${out} ${name} ON ${ARGN}) endmacro() macro(POCO_SOURCES_AUTO out) - POCO_SOURCES_AUTO_PLAT( ${out} ON ${ARGN}) + POCO_SOURCES_AUTO_PLAT( ${out} ON ${ARGN}) endmacro() macro(POCO_SOURCES_AUTO_PLAT out platform) - foreach(f ${ARGN}) - get_filename_component(fname ${f} NAME) + foreach(f ${ARGN}) + get_filename_component(fname ${f} NAME) - # Read the package name from the source file - file(STRINGS ${f} package REGEX "// Package: (.*)") - if(package) - string(REGEX REPLACE ".*: (.*)" "\\1" name ${package}) + # Read the package name from the source file + file(STRINGS ${f} package REGEX "// Package: (.*)") + if(package) + string(REGEX REPLACE ".*: (.*)" "\\1" name ${package}) - # Files of the Form X_UNIX.cpp are treated as headers - if(${fname} MATCHES ".*_.*\\..*") - #message(STATUS "Platform: ${name} ${f} ${platform}") - POCO_SOURCES_PLAT( ${out} ${name} OFF ${f}) - else() - #message(STATUS "Source: ${name} ${f} ${platform}") - POCO_SOURCES_PLAT( ${out} ${name} ${platform} ${f}) - endif() - else() - #message(STATUS "Source: Unknown ${f} ${platform}") - POCO_SOURCES_PLAT( ${out} Unknown ${platform} ${f}) - endif() - endforeach() + # Files of the Form X_UNIX.cpp are treated as headers + if(${fname} MATCHES ".*_.*\\..*") + #message(STATUS "Platform: ${name} ${f} ${platform}") + POCO_SOURCES_PLAT( ${out} ${name} OFF ${f}) + else() + #message(STATUS "Source: ${name} ${f} ${platform}") + POCO_SOURCES_PLAT( ${out} ${name} ${platform} ${f}) + endif() + else() + #message(STATUS "Source: Unknown ${f} ${platform}") + POCO_SOURCES_PLAT( ${out} Unknown ${platform} ${f}) + endif() + endforeach() endmacro() macro(POCO_HEADERS_AUTO out) - foreach(f ${ARGN}) - get_filename_component(fname ${f} NAME) + foreach(f ${ARGN}) + get_filename_component(fname ${f} NAME) - # Read the package name from the source file - file(STRINGS ${f} package REGEX "// Package: (.*)") - if(package) - string(REGEX REPLACE ".*: (.*)" "\\1" name ${package}) - #message(STATUS "Header: ${name} ${f}") - POCO_HEADERS( ${out} ${name} ${f}) - else() - #message(STATUS "Header: Unknown ${f}") - POCO_HEADERS( ${out} Unknown ${f}) - endif() - endforeach() + # Read the package name from the source file + file(STRINGS ${f} package REGEX "// Package: (.*)") + if(package) + string(REGEX REPLACE ".*: (.*)" "\\1" name ${package}) + #message(STATUS "Header: ${name} ${f}") + POCO_HEADERS( ${out} ${name} ${f}) + else() + #message(STATUS "Header: Unknown ${f}") + POCO_HEADERS( ${out} Unknown ${f}) + endif() + endforeach() endmacro() macro(POCO_HEADERS out name) - set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) - source_group("${name}\\Header Files" FILES ${ARGN}) - list(APPEND ${out} ${ARGN}) + set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) + source_group("${name}\\Header Files" FILES ${ARGN}) + list(APPEND ${out} ${ARGN}) endmacro() macro(POCO_MESSAGES out name) - if(WIN32) - foreach(msg ${ARGN}) - get_filename_component(msg_name ${msg} NAME) - get_filename_component(msg_path ${msg} ABSOLUTE) - string(REPLACE ".mc" ".h" hdr ${msg_name}) - set_source_files_properties(${hdr} PROPERTIES GENERATED TRUE) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${hdr} - DEPENDS ${msg} - COMMAND ${CMAKE_MC_COMPILER} - ARGS - -h ${CMAKE_CURRENT_BINARY_DIR} - -r ${CMAKE_CURRENT_BINARY_DIR} - ${msg_path} - VERBATIM # recommended: p260 - ) + if(WIN32) + foreach(msg ${ARGN}) + get_filename_component(msg_name ${msg} NAME) + get_filename_component(msg_path ${msg} ABSOLUTE) + string(REPLACE ".mc" ".h" hdr ${msg_name}) + set_source_files_properties(${hdr} PROPERTIES GENERATED TRUE) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${hdr} + DEPENDS ${msg} + COMMAND ${CMAKE_MC_COMPILER} + ARGS + -h ${CMAKE_CURRENT_BINARY_DIR} + -r ${CMAKE_CURRENT_BINARY_DIR} + ${msg_path} + VERBATIM # recommended: p260 + ) - # Add the generated file to the include directory - include_directories(${CMAKE_CURRENT_BINARY_DIR}) + # Add the generated file to the include directory + include_directories(${CMAKE_CURRENT_BINARY_DIR}) - # Add the generated headers to POCO_HEADERS of the component - POCO_HEADERS( ${out} ${name} ${CMAKE_CURRENT_BINARY_DIR}/${hdr}) + # Add the generated headers to POCO_HEADERS of the component + POCO_HEADERS( ${out} ${name} ${CMAKE_CURRENT_BINARY_DIR}/${hdr}) - endforeach() + endforeach() - set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) - source_group("${name}\\Message Files" FILES ${ARGN}) - list(APPEND ${out} ${ARGN}) + set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) + source_group("${name}\\Message Files" FILES ${ARGN}) + list(APPEND ${out} ${ARGN}) - endif(WIN32) + endif(WIN32) endmacro() #=============================================================================== # Macros for Package generation # # POCO_GENERATE_PACKAGE - Generates *Config.cmake -# Usage: POCO_GENERATE_PACKAGE(target_name) -# INPUT: -# target_name the name of the target. e.g. Foundation for PocoFoundation -# Example: POCO_GENERATE_PACKAGE(Foundation) +# Usage: POCO_GENERATE_PACKAGE(target_name) +# INPUT: +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_GENERATE_PACKAGE(Foundation) macro(POCO_GENERATE_PACKAGE target_name) include(CMakePackageConfigHelpers) write_basic_package_version_file( @@ -214,18 +214,25 @@ if("${CMAKE_VERSION}" VERSION_LESS "3.0.0") export(TARGETS "${target_name}" APPEND FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake" NAMESPACE "${PROJECT_NAME}::" - ) - endif() + ) + endif() else() export(EXPORT "${target_name}Targets" FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake" NAMESPACE "${PROJECT_NAME}::" - ) + ) endif() -configure_file("cmake/Poco${target_name}Config.cmake" +if("${target_name}" STREQUAL "CppUnit") + configure_file("cmake/${target_name}Config.cmake" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" @ONLY -) + ) +else() + configure_file("cmake/Poco${target_name}Config.cmake" + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" + @ONLY + ) +endif() # Set config script install location in a location that find_package() will # look for, which is different on MS Windows than for UNIX @@ -237,18 +244,18 @@ else() endif() install( - EXPORT "${target_name}Targets" - FILE "${PROJECT_NAME}${target_name}Targets.cmake" - NAMESPACE "${PROJECT_NAME}::" - DESTINATION "${PocoConfigPackageLocation}" + EXPORT "${target_name}Targets" + FILE "${PROJECT_NAME}${target_name}Targets.cmake" + NAMESPACE "${PROJECT_NAME}::" + DESTINATION "${PocoConfigPackageLocation}" ) install( - FILES - "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" - "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake" - DESTINATION "${PocoConfigPackageLocation}" - COMPONENT Devel + FILES + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake" + DESTINATION "${PocoConfigPackageLocation}" + COMPONENT Devel ) endmacro() @@ -257,25 +264,25 @@ endmacro() # Macros for simplified installation # # POCO_INSTALL - Install the given target -# Usage: POCO_INSTALL(target_name) -# INPUT: -# target_name the name of the target. e.g. Foundation for PocoFoundation -# Example: POCO_INSTALL(Foundation) +# Usage: POCO_INSTALL(target_name) +# INPUT: +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_INSTALL(Foundation) macro(POCO_INSTALL target_name) install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE + DIRECTORY include/Poco + DESTINATION include + COMPONENT Devel + PATTERN ".svn" EXCLUDE ) install( - TARGETS "${target_name}" EXPORT "${target_name}Targets" - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + TARGETS "${target_name}" EXPORT "${target_name}Targets" + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if(MSVC) @@ -286,20 +293,20 @@ endif() endmacro() # POCO_INSTALL_PDB - Install the given target's companion pdb file (if present) -# Usage: POCO_INSTALL_PDB(target_name) -# INPUT: -# target_name the name of the target. e.g. Foundation for PocoFoundation -# Example: POCO_INSTALL_PDB(Foundation) +# Usage: POCO_INSTALL_PDB(target_name) +# INPUT: +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_INSTALL_PDB(Foundation) # -# This is an internal macro meant only to be used by POCO_INSTALL. +# This is an internal macro meant only to be used by POCO_INSTALL. macro(POCO_INSTALL_PDB target_name) - get_property(type TARGET ${target_name} PROPERTY TYPE) - if("${type}" STREQUAL "SHARED_LIBRARY" OR "${type}" STREQUAL "EXECUTABLE") - install( - FILES $ - DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT Devel - OPTIONAL - ) + get_property(type TARGET ${target_name} PROPERTY TYPE) + if("${type}" STREQUAL "SHARED_LIBRARY" OR "${type}" STREQUAL "EXECUTABLE") + install( + FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT Devel + OPTIONAL + ) endif() endmacro() diff --git a/doc/00200-GettingStarted.page b/doc/00200-GettingStarted.page index cefe4e05f..7732b8743 100644 --- a/doc/00200-GettingStarted.page +++ b/doc/00200-GettingStarted.page @@ -389,6 +389,7 @@ Here an overview of POCO build options: * ENABLE_PAGECOMPILER_FILE2PAGE Set to OFF|ON (default is ON) to build File2Page * ENABLE_POCODOC Set to OFF|ON (default is OFF) to build Poco Documentation Generator * ENABLE_TESTS Set to OFF|ON (default is OFF) to build Unit tests + * ENABLE_SAMPLES Set to OFF|ON (default is OFF) to build samples * ENABLE_LONG_RUNNING_TESTS Set to OFF|ON (default is ON) to use long running test * POCO_UNBUNDLED Set to OFF|ON (default is OFF) to control linking dependencies as external diff --git a/runLibTests.sh b/runLibTests.sh index 4f4143b9b..fb761eb5f 100755 --- a/runLibTests.sh +++ b/runLibTests.sh @@ -1,20 +1,32 @@ #!/bin/bash # -# Script to rebuild a library and dependencies +# Script to rebuild libraries and dependencies # (with or without a sanitizer) and run the tests. -# Currently works only for top-level libs -# dependent on Foundation only. # -# Usage: ./runLibTests.sh library [address | undefined | thread ] +# The use case of the script is mainly for development purposes - +# to clean and rebuild a single library, with all of its dependencies, +# and run the tests. +# +# Usage: ./runLibTests.sh library [address | undefined | thread ] +# +# Example: ./runLibTests.sh Data/SQLite address +# (distcleans, rebuilds and runs tests for Data/SQLite with address sanitizer) # -library=$1 -if [ -z "${library}" ]; then +# g++ does not like empty quoted arguments, but +# the shellcheck wants them quoted to remain quiet +# shellcheck disable=SC2086 + +path=$1 +if [ -z "${path}" ]; then echo "Library not specified" - echo "Usage: $0 library [address | undefined | thread ]" + echo "Usage: $0 path [address | undefined | thread ]" exit 1 fi +libraries= +IFS='/' read -r -a libraries <<< "$path" + self="${BASH_SOURCE[0]}" if [ -d "$self" ] ; then @@ -27,30 +39,41 @@ fi . "$basedir"/poco_env.bash flag=$2 - -make distclean -C CppUnit -make distclean -C Foundation -if [[ "$library" != "Foundation" ]]; then - make distclean -C "$library" -fi -make distclean -C "$library"/testsuite - +flags= if [ -n "${flag}" ]; then - make -s -j4 -C "$POCO_BASE"/CppUnit SANITIZEFLAGS+=-fsanitize="$flag" - make -s -j4 -C "$POCO_BASE"/Foundation SANITIZEFLAGS+=-fsanitize="$flag" - if [[ "$library" != "Foundation" ]]; then - make -s -j4 -C "$POCO_BASE"/"$library" SANITIZEFLAGS+=-fsanitize="$flag" - fi - make -s -j4 -C "$POCO_BASE"/"$library"/testsuite SANITIZEFLAGS+=-fsanitize="$flag" -else - make -s -j4 -C "$POCO_BASE"/CppUnit - make -s -j4 -C "$POCO_BASE"/Foundation - if [[ "$library" != "Foundation" ]]; then - make -s -j4 -C "$POCO_BASE"/"$library" - fi - make -s -j4 -C "$POCO_BASE"/"$library"/testsuite + flags=SANITIZEFLAGS+=-fsanitize="$flag" fi -cd "$basedir"/"$library"/testsuite/bin/"$OSNAME"/"$OSARCH"/ || exit -./testrunner -all -./testrunnerd -all +path="$basedir"/"${libraries[0]}" + +make distclean -C "$basedir"/Foundation +make distclean -C "$basedir"/CppUnit + +make -s -j4 -C "$basedir"/Foundation $flags +make -s -j4 -C "$basedir"/CppUnit $flags + +# Foundation requested, build/run tests and exit +if [[ "$path" == "$basedir"/"Foundation" ]]; then + cd "$path/testsuite/" || exit + make -s -j4 -C ./ $flags + cd "bin/$OSNAME/$OSARCH/" || exit + ./testrunner -all + ./testrunnerd -all + echo "$path $flags done." + exit 0 +fi + +for library in "${libraries[@]}" +do + cd "$library" || exit + make distclean + make -s -j4 -C ./ $flags + cd testsuite || exit + make distclean + make -s -j4 -C ./ $flags + cd bin/"$OSNAME"/"$OSARCH"/ || exit + ./testrunner -all + ./testrunnerd -all + echo "$1 $flags done." + cd ../../../../ || exit +done