fix(Data):

adjust make and CMake for SQLParser and DataTest lib
separate samples from tests in CMake
remove unused StatementImpl from Data testsuite
This commit is contained in:
Alex Fabijanic
2023-11-04 23:11:38 +01:00
parent a7a6f869c1
commit 81d7307fa7
47 changed files with 488 additions and 425 deletions

View File

@@ -24,7 +24,7 @@
"${POCO_BASE}/MongoDB/include", "${POCO_BASE}/MongoDB/include",
"${POCO_BASE}/ApacheConnector/include", "${POCO_BASE}/ApacheConnector/include",
"${POCO_BASE}/Data/src", "${POCO_BASE}/Data/src",
"${POCO_BASE}/Data/testsuite/include" "${POCO_BASE}/Data/testsuite/DataTest/include"
] ]
}, },
"configurations": [ "configurations": [

View File

@@ -21,6 +21,6 @@ target_include_directories(mod_poco
) )
target_link_libraries(mod_poco PUBLIC Poco::Util Poco::Net Apache::Apr Apache::Aprutil) target_link_libraries(mod_poco PUBLIC Poco::Util Poco::Net Apache::Apr Apache::Aprutil)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif() endif()

View File

@@ -204,7 +204,10 @@ if(ENABLE_ACTIVERECORD AND NOT ENABLE_XML)
endif() endif()
option(ENABLE_TESTS 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 option(POCO_UNBUNDLED
"Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF) "Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF)
@@ -393,7 +396,13 @@ if(OPENSSL_FOUND)
endif() endif()
endif(OPENSSL_FOUND) endif(OPENSSL_FOUND)
option(POCO_DATA_NO_SQL_PARSER "Disable SQL parser" OFF)
if(EXISTS ${PROJECT_SOURCE_DIR}/Data AND ENABLE_DATA) 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) add_subdirectory(Data)
list(APPEND Poco_COMPONENTS "Data") list(APPEND Poco_COMPONENTS "Data")
endif() endif()

View File

@@ -38,3 +38,6 @@ elseif(MINGW)
PUBLIC PUBLIC
_DLL) _DLL)
endif() endif()
POCO_INSTALL(CppUnit)
POCO_GENERATE_PACKAGE(CppUnit)

View File

@@ -11,6 +11,6 @@ objects = CppUnitException TestDecorator TestResult TestSuite \
target = CppUnit target = CppUnit
target_version = 1 target_version = 1
target_libs = target_libs = PocoFoundation
include $(POCO_BASE)/build/rules/lib include $(POCO_BASE)/build/rules/lib

View File

@@ -0,0 +1,3 @@
include(CMakeFindDependencyMacro)
find_dependency(PocoFoundation)
include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTargets.cmake")

1
CppUnit/dependencies Normal file
View File

@@ -0,0 +1 @@
Foundation

View File

@@ -40,7 +40,10 @@ endif()
POCO_INSTALL(Crypto) POCO_INSTALL(Crypto)
POCO_GENERATE_PACKAGE(Crypto) POCO_GENERATE_PACKAGE(Crypto)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -1,6 +1,11 @@
# Sources # Sources
file(GLOB SRCS_G "src/*.cpp") file(GLOB SRCS_G "src/*.cpp")
POCO_SOURCES_AUTO(SRCS ${SRCS_G}) 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 # Headers
file(GLOB_RECURSE HDRS_G "include/*.h") file(GLOB_RECURSE HDRS_G "include/*.h")
@@ -30,6 +35,7 @@ target_link_libraries(Data PUBLIC Poco::Foundation)
target_include_directories(Data target_include_directories(Data
PUBLIC PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
) )
@@ -37,6 +43,10 @@ target_include_directories(Data
POCO_INSTALL(Data) POCO_INSTALL(Data)
POCO_GENERATE_PACKAGE(Data) POCO_GENERATE_PACKAGE(Data)
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()
if(ENABLE_DATA_SQLITE) if(ENABLE_DATA_SQLITE)
# SQlite3 is built in any case # SQlite3 is built in any case
message(STATUS "SQLite Support Enabled") message(STATUS "SQLite Support Enabled")
@@ -66,7 +76,6 @@ else()
message(STATUS "ODBC Support Disabled") message(STATUS "ODBC Support Disabled")
endif() endif()
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
add_subdirectory(testsuite)
endif() endif()

View File

@@ -25,4 +25,5 @@ else()
) )
set_tests_properties(DataMySQL PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) set_tests_properties(DataMySQL PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif() 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/)

View File

@@ -25,4 +25,6 @@ else()
) )
set_tests_properties(DataODBC PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) set_tests_properties(DataODBC PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif() 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/)

View File

@@ -35,13 +35,13 @@ ifeq ($(POCO_CONFIG),MinGW)
objects += ODBCAccessTest objects += ODBCAccessTest
endif endif
target_includes = $(POCO_BASE)/Data/testsuite/include
ifndef POCO_DATA_NO_SQL_PARSER ifndef POCO_DATA_NO_SQL_PARSER
target_includes += $(POCO_BASE)/Data/src target_includes += $(POCO_BASE)/Data/src
endif endif
target = testrunner target = testrunner
target_version = 1 target_version = 1
target_libs = PocoDataODBC PocoDataTest PocoData PocoFoundation CppUnit target_libs = PocoDataODBC PocoDataTest PocoData PocoFoundation CppUnit
target_includes += $(POCO_BASE)/Data/testsuite/DataTest/include
include $(POCO_BASE)/build/rules/exec include $(POCO_BASE)/build/rules/exec

View File

@@ -17,4 +17,5 @@ add_test(
COMMAND DataPostgreSQL-testrunner -ignore ${CMAKE_SOURCE_DIR}/cppignore.lnx -all COMMAND DataPostgreSQL-testrunner -ignore ${CMAKE_SOURCE_DIR}/cppignore.lnx -all
) )
set_tests_properties(DataPostgreSQL PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) 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/)

View File

@@ -4,7 +4,8 @@ POCO_SOURCES_AUTO(TEST_SRCS ${SRCS_G})
# Headers # Headers
file(GLOB_RECURSE HDRS_G "src/*.h") 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 POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF
src/WinDriver.cpp src/WinDriver.cpp
@@ -29,4 +30,6 @@ else()
) )
set_tests_properties(DataSQLite PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) set_tests_properties(DataSQLite PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif() 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/)

View File

@@ -544,7 +544,7 @@ private:
/// Returns true if the statement is of the argument type. /// Returns true if the statement is of the argument type.
Poco::SharedPtr<Parser::SQLParserResult> _pParseResult; Poco::SharedPtr<Parser::SQLParserResult> _pParseResult;
std::string _parseError;
#endif // POCO_DATA_NO_SQL_PARSER #endif // POCO_DATA_NO_SQL_PARSER
StatementImpl::Ptr _pImpl; StatementImpl::Ptr _pImpl;
@@ -557,7 +557,6 @@ private:
std::vector<Any> _arguments; std::vector<Any> _arguments;
RowFormatter::Ptr _pRowFormatter; RowFormatter::Ptr _pRowFormatter;
mutable std::string _stmtString; 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() inline const std::string& Statement::parseError()
{ {
#ifdef POCO_DATA_NO_SQL_PARSER
static std::string empty;
return empty;
#else
return _parseError; return _parseError;
#endif
} }

View File

@@ -48,6 +48,7 @@ Statement::Statement(Session& session):
Statement::Statement(const Statement& stmt): Statement::Statement(const Statement& stmt):
#ifndef POCO_DATA_NO_SQL_PARSER #ifndef POCO_DATA_NO_SQL_PARSER
_pParseResult(stmt._pParseResult), _pParseResult(stmt._pParseResult),
_parseError(stmt._parseError),
#endif #endif
_pImpl(stmt._pImpl), _pImpl(stmt._pImpl),
_async(stmt._async), _async(stmt._async),
@@ -55,8 +56,7 @@ Statement::Statement(const Statement& stmt):
_pAsyncExec(stmt._pAsyncExec), _pAsyncExec(stmt._pAsyncExec),
_arguments(stmt._arguments), _arguments(stmt._arguments),
_pRowFormatter(stmt._pRowFormatter), _pRowFormatter(stmt._pRowFormatter),
_stmtString(stmt._stmtString), _stmtString(stmt._stmtString)
_parseError(stmt._parseError)
{ {
} }
@@ -64,6 +64,7 @@ Statement::Statement(const Statement& stmt):
Statement::Statement(Statement&& stmt) noexcept: Statement::Statement(Statement&& stmt) noexcept:
#ifndef POCO_DATA_NO_SQL_PARSER #ifndef POCO_DATA_NO_SQL_PARSER
_pParseResult(std::move(stmt._pParseResult)), _pParseResult(std::move(stmt._pParseResult)),
_parseError(std::move(stmt._parseError)),
#endif #endif
_pImpl(std::move(stmt._pImpl)), _pImpl(std::move(stmt._pImpl)),
_async(std::move(stmt._async)), _async(std::move(stmt._async)),
@@ -71,8 +72,7 @@ Statement::Statement(Statement&& stmt) noexcept:
_pAsyncExec(std::move(stmt._pAsyncExec)), _pAsyncExec(std::move(stmt._pAsyncExec)),
_arguments(std::move(stmt._arguments)), _arguments(std::move(stmt._arguments)),
_pRowFormatter(std::move(stmt._pRowFormatter)), _pRowFormatter(std::move(stmt._pRowFormatter)),
_stmtString(std::move(stmt._stmtString)), _stmtString(std::move(stmt._stmtString))
_parseError(std::move(stmt._parseError))
{ {
stmt._pImpl = nullptr; stmt._pImpl = nullptr;
stmt._async = false; stmt._async = false;
@@ -81,7 +81,9 @@ Statement::Statement(Statement&& stmt) noexcept:
stmt._arguments.clear(); stmt._arguments.clear();
stmt._pRowFormatter = nullptr; stmt._pRowFormatter = nullptr;
_stmtString.clear(); _stmtString.clear();
#ifndef POCO_DATA_NO_SQL_PARSER
_parseError.clear(); _parseError.clear();
#endif
} }
@@ -102,6 +104,8 @@ Statement& Statement::operator = (Statement&& stmt) noexcept
{ {
#ifndef POCO_DATA_NO_SQL_PARSER #ifndef POCO_DATA_NO_SQL_PARSER
_pParseResult = std::move(stmt._pParseResult); _pParseResult = std::move(stmt._pParseResult);
_parseError = std::move(stmt._parseError);
_parseError.clear();
#endif #endif
_pImpl = std::move(stmt._pImpl); _pImpl = std::move(stmt._pImpl);
stmt._pImpl = nullptr; stmt._pImpl = nullptr;
@@ -117,8 +121,6 @@ Statement& Statement::operator = (Statement&& stmt) noexcept
stmt._pRowFormatter = nullptr; stmt._pRowFormatter = nullptr;
_stmtString = std::move(stmt._stmtString); _stmtString = std::move(stmt._stmtString);
_stmtString.clear(); _stmtString.clear();
_parseError = std::move(stmt._parseError);
_parseError.clear();
return *this; return *this;
} }
@@ -128,6 +130,7 @@ void Statement::swap(Statement& other) noexcept
using std::swap; using std::swap;
#ifndef POCO_DATA_NO_SQL_PARSER #ifndef POCO_DATA_NO_SQL_PARSER
swap(_pParseResult, other._pParseResult); swap(_pParseResult, other._pParseResult);
swap(_parseError, other._parseError);
#endif #endif
swap(_pImpl, other._pImpl); swap(_pImpl, other._pImpl);
swap(_async, other._async); swap(_async, other._async);
@@ -136,7 +139,6 @@ void Statement::swap(Statement& other) noexcept
_arguments.swap(other._arguments); _arguments.swap(other._arguments);
swap(_pRowFormatter, other._pRowFormatter); swap(_pRowFormatter, other._pRowFormatter);
swap(_stmtString, other._stmtString); swap(_stmtString, other._stmtString);
swap(_parseError, other._parseError);
} }

View File

@@ -1,9 +1,10 @@
# Sources # Sources
file(GLOB SRCS_G "src/*.cpp") 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}) POCO_SOURCES_AUTO(TEST_SRCS ${SRCS_G})
# Headers # Headers
file(GLOB_RECURSE HDRS_G "src/*.h") file(GLOB HDRS_G "src/*.h")
POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_G}) POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_G})
POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF
@@ -14,11 +15,6 @@ POCO_SOURCES_AUTO_PLAT(TEST_SRCS WINCE
src/WinCEDriver.cpp 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}) add_executable(Data-testrunner ${TEST_SRCS})
if(ANDROID) if(ANDROID)
add_test( add_test(
@@ -35,3 +31,5 @@ else()
set_tests_properties(Data PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) set_tests_properties(Data PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif() endif()
target_link_libraries(Data-testrunner PUBLIC Poco::Data CppUnit) target_link_libraries(Data-testrunner PUBLIC Poco::Data CppUnit)
add_subdirectory(DataTest)

View File

@@ -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
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Data/include>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Data/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
POCO_INSTALL(DataTest)
POCO_GENERATE_PACKAGE(DataTest)

View File

@@ -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

View File

@@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)
find_dependency(PocoFoundation)
find_dependency(PocoData)
find_dependency(CppUnit)
include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTestTargets.cmake")

View File

@@ -0,0 +1,2 @@
Foundation
Data

View File

@@ -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

View File

@@ -3,18 +3,18 @@
// //
// Definition of the SQLExecutor class. // Definition of the SQLExecutor class.
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.,
// and Contributors. // Aleph ONE Software Engineering d.o.o., and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#ifndef Data_SQLExecutor_INCLUDED #ifndef DataTest_SQLExecutor_INCLUDED
#define Data_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/Session.h"
#include "Poco/Data/BulkExtraction.h" #include "Poco/Data/BulkExtraction.h"
#include "Poco/Data/BulkBinding.h" #include "Poco/Data/BulkBinding.h"
@@ -24,6 +24,11 @@
#include <iostream> #include <iostream>
namespace Poco {
namespace Data {
namespace Test {
#define poco_data_using_keywords using Poco::Data::Keywords::now; \ #define poco_data_using_keywords using Poco::Data::Keywords::now; \
using Poco::Data::Keywords::into; \ using Poco::Data::Keywords::into; \
using Poco::Data::Keywords::use; \ using Poco::Data::Keywords::use; \
@@ -33,12 +38,7 @@
using Poco::Data::CLOB; using Poco::Data::CLOB;
namespace Poco { class DataTest_API SQLExecutor: public CppUnit::TestCase
namespace Data {
namespace Test {
class SQLExecutor: public CppUnit::TestCase
{ {
public: public:
enum DataBinding enum DataBinding
@@ -238,4 +238,4 @@ private:
} } } // Poco::Data::Test } } } // Poco::Data::Test
#endif // Data_SQLExecutor_INCLUDED #endif // DataTest_SQLExecutor_INCLUDED

View File

@@ -8,4 +8,4 @@
clean distclean all: projects clean distclean all: projects
projects: projects:
$(MAKE) -f Makefile-testrunner $(MAKECMDGOALS) $(MAKE) -f Makefile-testrunner $(MAKECMDGOALS)
$(MAKE) -f Makefile-library $(MAKECMDGOALS) $(MAKE) -C DataTest $(MAKECMDGOALS)

View File

@@ -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

View File

@@ -1504,6 +1504,8 @@ void DataTest::testSQLParse()
assertTrue (!stmt.isDelete().isSpecified()); assertTrue (!stmt.isDelete().isSpecified());
assertTrue (!stmt.hasDelete().isSpecified()); assertTrue (!stmt.hasDelete().isSpecified());
#else
std::cout << "[NOT ENABLED]";
#endif // POCO_DATA_NO_SQL_PARSER #endif // POCO_DATA_NO_SQL_PARSER
} }

View File

@@ -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

View File

@@ -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<Binder> _ptrBinder;
Poco::SharedPtr<Extractor> _ptrExtractor;
Poco::SharedPtr<Preparation> _ptrPrepare;
};
//
// inlines
//
inline AbstractExtractor& StatementImpl::extractor()
{
return *_ptrExtractor;
}
inline AbstractBinder& StatementImpl::binder()
{
return *_ptrBinder;
}
} } } // namespace Poco::Data::Test
#endif // Data_Test_StatementImpl_INCLUDED

View File

@@ -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)

View File

@@ -32,7 +32,10 @@ target_include_directories(Encodings
POCO_INSTALL(Encodings) POCO_INSTALL(Encodings)
POCO_GENERATE_PACKAGE(Encodings) POCO_GENERATE_PACKAGE(Encodings)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -234,10 +234,13 @@ endif()
POCO_INSTALL(Foundation) POCO_INSTALL(Foundation)
POCO_GENERATE_PACKAGE(Foundation) POCO_GENERATE_PACKAGE(Foundation)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS) if(ENABLE_TESTS)
if(NOT BUILD_SHARED_LIBS) if(NOT BUILD_SHARED_LIBS)
set_property(TARGET Foundation PROPERTY POSITION_INDEPENDENT_CODE ON) # This is needed to build TestLibrary.so as shared. set_property(TARGET Foundation PROPERTY POSITION_INDEPENDENT_CODE ON) # This is needed to build TestLibrary.so as shared.
endif() endif()
add_subdirectory(samples)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -41,7 +41,10 @@ endif()
POCO_INSTALL(JSON) POCO_INSTALL(JSON)
POCO_GENERATE_PACKAGE(JSON) POCO_GENERATE_PACKAGE(JSON)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -32,8 +32,11 @@ target_include_directories(MongoDB
POCO_INSTALL(MongoDB) POCO_INSTALL(MongoDB)
POCO_GENERATE_PACKAGE(MongoDB) POCO_GENERATE_PACKAGE(MongoDB)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -46,8 +46,11 @@ target_include_directories(Net
POCO_INSTALL(Net) POCO_INSTALL(Net)
POCO_GENERATE_PACKAGE(Net) POCO_GENERATE_PACKAGE(Net)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -36,8 +36,11 @@ endif()
POCO_INSTALL(NetSSL) POCO_INSTALL(NetSSL)
POCO_GENERATE_PACKAGE(NetSSL) POCO_GENERATE_PACKAGE(NetSSL)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -32,9 +32,12 @@ target_include_directories(NetSSLWin
POCO_INSTALL(NetSSLWin) POCO_INSTALL(NetSSLWin)
POCO_GENERATE_PACKAGE(NetSSLWin) POCO_GENERATE_PACKAGE(NetSSLWin)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
#TODO: Looks like the samples use crypto somehow? #TODO: Looks like the samples use crypto somehow?
#add_subdirectory(samples) #add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
#add_subdirectory(testsuite) #add_subdirectory(testsuite)
endif() endif()

View File

@@ -146,8 +146,11 @@ target_include_directories(PDF
POCO_INSTALL(PDF) POCO_INSTALL(PDF)
POCO_GENERATE_PACKAGE(PDF) POCO_GENERATE_PACKAGE(PDF)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -32,8 +32,11 @@ target_include_directories(Prometheus
POCO_INSTALL(Prometheus) POCO_INSTALL(Prometheus)
POCO_GENERATE_PACKAGE(Prometheus) POCO_GENERATE_PACKAGE(Prometheus)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -34,6 +34,5 @@ POCO_GENERATE_PACKAGE(Redis)
if(ENABLE_TESTS) if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
# add_subdirectory(samples)
endif() endif()

View File

@@ -75,7 +75,5 @@ POCO_GENERATE_PACKAGE(SevenZip)
if(ENABLE_TESTS) if(ENABLE_TESTS)
add_subdirectory(samples) add_subdirectory(samples)
# TODO: Add tests
#add_subdirectory(testsuite)
endif() endif()

View File

@@ -49,7 +49,10 @@ target_include_directories(Util
POCO_INSTALL(Util) POCO_INSTALL(Util)
POCO_GENERATE_PACKAGE(Util) POCO_GENERATE_PACKAGE(Util)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -65,8 +65,11 @@ endif()
POCO_INSTALL(XML) POCO_INSTALL(XML)
POCO_GENERATE_PACKAGE(XML) POCO_GENERATE_PACKAGE(XML)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -32,8 +32,11 @@ target_include_directories(Zip
POCO_INSTALL(Zip) POCO_INSTALL(Zip)
POCO_GENERATE_PACKAGE(Zip) POCO_GENERATE_PACKAGE(Zip)
if(ENABLE_TESTS) if(ENABLE_SAMPLES)
add_subdirectory(samples) add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite) add_subdirectory(testsuite)
endif() endif()

View File

@@ -53,155 +53,155 @@ endif(WIN32)
# Macros for Source file management # Macros for Source file management
# #
# POCO_SOURCES_PLAT - Adds a list of files to the sources of a components # POCO_SOURCES_PLAT - Adds a list of files to the sources of a components
# Usage: POCO_SOURCES_PLAT( out name platform sources) # Usage: POCO_SOURCES_PLAT( out name platform sources)
# INPUT: # INPUT:
# out the variable the sources are added to # out the variable the sources are added to
# name: the name of the components # name: the name of the components
# platform: the platform this sources are for (ON = All, OFF = None, WIN32, UNIX ...) # platform: the platform this sources are for (ON = All, OFF = None, WIN32, UNIX ...)
# sources: a list of files to add to ${out} # sources: a list of files to add to ${out}
# Example: POCO_SOURCES_PLAT( SRCS Foundation ON src/Foundation.cpp ) # Example: POCO_SOURCES_PLAT( SRCS Foundation ON src/Foundation.cpp )
# #
# POCO_SOURCES - Like POCO_SOURCES_PLAT with platform = ON (Built on all platforms) # POCO_SOURCES - Like POCO_SOURCES_PLAT with platform = ON (Built on all platforms)
# Usage: POCO_SOURCES( out name sources) # Usage: POCO_SOURCES( out name sources)
# Example: POCO_SOURCES( SRCS Foundation src/Foundation.cpp) # 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 # POCO_SOURCES_AUTO - Like POCO_SOURCES but the name is read from the file header // Package: X
# Usage: POCO_SOURCES_AUTO( out sources) # Usage: POCO_SOURCES_AUTO( out sources)
# Example: POCO_SOURCES_AUTO( SRCS src/Foundation.cpp) # 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 # 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) # Usage: POCO_SOURCES_AUTO_PLAT(out platform sources)
# Example: POCO_SOURCES_AUTO_PLAT( SRCS WIN32 src/Foundation.cpp) # Example: POCO_SOURCES_AUTO_PLAT( SRCS WIN32 src/Foundation.cpp)
# #
# #
# POCO_HEADERS - Adds a list of files to the headers of a components # POCO_HEADERS - Adds a list of files to the headers of a components
# Usage: POCO_HEADERS( out name headers) # Usage: POCO_HEADERS( out name headers)
# INPUT: # INPUT:
# out the variable the headers are added to # out the variable the headers are added to
# name: the name of the components # name: the name of the components
# headers: a list of files to add to HDRSt # headers: a list of files to add to HDRSt
# Example: POCO_HEADERS( HDRS Foundation include/Poco/Foundation.h ) # 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 # POCO_HEADERS_AUTO - Like POCO_HEADERS but the name is read from the file header // Package: X
# Usage: POCO_HEADERS_AUTO( out headers) # Usage: POCO_HEADERS_AUTO( out headers)
# Example: POCO_HEADERS_AUTO( HDRS src/Foundation.cpp) # Example: POCO_HEADERS_AUTO( HDRS src/Foundation.cpp)
# #
# #
# POCO_MESSAGES - Adds a list of files to the messages of a components # 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. # and adds the generated headers to the header list of the component.
# On platforms other then Windows this does nothing # On platforms other then Windows this does nothing
# Usage: POCO_MESSAGES( out name messages) # Usage: POCO_MESSAGES( out name messages)
# INPUT: # INPUT:
# out the variable the message and the resulting headers are added to # out the variable the message and the resulting headers are added to
# name: the name of the components # name: the name of the components
# messages: a list of files to add to MSGS # messages: a list of files to add to MSGS
# Example: POCO_MESSAGES( HDRS Foundation include/Poco/Foundation.mc ) # Example: POCO_MESSAGES( HDRS Foundation include/Poco/Foundation.mc )
# #
macro(POCO_SOURCES_PLAT out name platform) macro(POCO_SOURCES_PLAT out name platform)
source_group("${name}\\Source Files" FILES ${ARGN}) source_group("${name}\\Source Files" FILES ${ARGN})
list(APPEND ${out} ${ARGN}) list(APPEND ${out} ${ARGN})
if(NOT(${platform})) if(NOT(${platform}))
set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE)
endif() endif()
endmacro() endmacro()
macro(POCO_SOURCES out name) macro(POCO_SOURCES out name)
POCO_SOURCES_PLAT( ${out} ${name} ON ${ARGN}) POCO_SOURCES_PLAT( ${out} ${name} ON ${ARGN})
endmacro() endmacro()
macro(POCO_SOURCES_AUTO out) macro(POCO_SOURCES_AUTO out)
POCO_SOURCES_AUTO_PLAT( ${out} ON ${ARGN}) POCO_SOURCES_AUTO_PLAT( ${out} ON ${ARGN})
endmacro() endmacro()
macro(POCO_SOURCES_AUTO_PLAT out platform) macro(POCO_SOURCES_AUTO_PLAT out platform)
foreach(f ${ARGN}) foreach(f ${ARGN})
get_filename_component(fname ${f} NAME) get_filename_component(fname ${f} NAME)
# Read the package name from the source file # Read the package name from the source file
file(STRINGS ${f} package REGEX "// Package: (.*)") file(STRINGS ${f} package REGEX "// Package: (.*)")
if(package) if(package)
string(REGEX REPLACE ".*: (.*)" "\\1" name ${package}) string(REGEX REPLACE ".*: (.*)" "\\1" name ${package})
# Files of the Form X_UNIX.cpp are treated as headers # Files of the Form X_UNIX.cpp are treated as headers
if(${fname} MATCHES ".*_.*\\..*") if(${fname} MATCHES ".*_.*\\..*")
#message(STATUS "Platform: ${name} ${f} ${platform}") #message(STATUS "Platform: ${name} ${f} ${platform}")
POCO_SOURCES_PLAT( ${out} ${name} OFF ${f}) POCO_SOURCES_PLAT( ${out} ${name} OFF ${f})
else() else()
#message(STATUS "Source: ${name} ${f} ${platform}") #message(STATUS "Source: ${name} ${f} ${platform}")
POCO_SOURCES_PLAT( ${out} ${name} ${platform} ${f}) POCO_SOURCES_PLAT( ${out} ${name} ${platform} ${f})
endif() endif()
else() else()
#message(STATUS "Source: Unknown ${f} ${platform}") #message(STATUS "Source: Unknown ${f} ${platform}")
POCO_SOURCES_PLAT( ${out} Unknown ${platform} ${f}) POCO_SOURCES_PLAT( ${out} Unknown ${platform} ${f})
endif() endif()
endforeach() endforeach()
endmacro() endmacro()
macro(POCO_HEADERS_AUTO out) macro(POCO_HEADERS_AUTO out)
foreach(f ${ARGN}) foreach(f ${ARGN})
get_filename_component(fname ${f} NAME) get_filename_component(fname ${f} NAME)
# Read the package name from the source file # Read the package name from the source file
file(STRINGS ${f} package REGEX "// Package: (.*)") file(STRINGS ${f} package REGEX "// Package: (.*)")
if(package) if(package)
string(REGEX REPLACE ".*: (.*)" "\\1" name ${package}) string(REGEX REPLACE ".*: (.*)" "\\1" name ${package})
#message(STATUS "Header: ${name} ${f}") #message(STATUS "Header: ${name} ${f}")
POCO_HEADERS( ${out} ${name} ${f}) POCO_HEADERS( ${out} ${name} ${f})
else() else()
#message(STATUS "Header: Unknown ${f}") #message(STATUS "Header: Unknown ${f}")
POCO_HEADERS( ${out} Unknown ${f}) POCO_HEADERS( ${out} Unknown ${f})
endif() endif()
endforeach() endforeach()
endmacro() endmacro()
macro(POCO_HEADERS out name) macro(POCO_HEADERS out name)
set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE)
source_group("${name}\\Header Files" FILES ${ARGN}) source_group("${name}\\Header Files" FILES ${ARGN})
list(APPEND ${out} ${ARGN}) list(APPEND ${out} ${ARGN})
endmacro() endmacro()
macro(POCO_MESSAGES out name) macro(POCO_MESSAGES out name)
if(WIN32) if(WIN32)
foreach(msg ${ARGN}) foreach(msg ${ARGN})
get_filename_component(msg_name ${msg} NAME) get_filename_component(msg_name ${msg} NAME)
get_filename_component(msg_path ${msg} ABSOLUTE) get_filename_component(msg_path ${msg} ABSOLUTE)
string(REPLACE ".mc" ".h" hdr ${msg_name}) string(REPLACE ".mc" ".h" hdr ${msg_name})
set_source_files_properties(${hdr} PROPERTIES GENERATED TRUE) set_source_files_properties(${hdr} PROPERTIES GENERATED TRUE)
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${hdr} OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${hdr}
DEPENDS ${msg} DEPENDS ${msg}
COMMAND ${CMAKE_MC_COMPILER} COMMAND ${CMAKE_MC_COMPILER}
ARGS ARGS
-h ${CMAKE_CURRENT_BINARY_DIR} -h ${CMAKE_CURRENT_BINARY_DIR}
-r ${CMAKE_CURRENT_BINARY_DIR} -r ${CMAKE_CURRENT_BINARY_DIR}
${msg_path} ${msg_path}
VERBATIM # recommended: p260 VERBATIM # recommended: p260
) )
# Add the generated file to the include directory # Add the generated file to the include directory
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Add the generated headers to POCO_HEADERS of the component # Add the generated headers to POCO_HEADERS of the component
POCO_HEADERS( ${out} ${name} ${CMAKE_CURRENT_BINARY_DIR}/${hdr}) POCO_HEADERS( ${out} ${name} ${CMAKE_CURRENT_BINARY_DIR}/${hdr})
endforeach() endforeach()
set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE)
source_group("${name}\\Message Files" FILES ${ARGN}) source_group("${name}\\Message Files" FILES ${ARGN})
list(APPEND ${out} ${ARGN}) list(APPEND ${out} ${ARGN})
endif(WIN32) endif(WIN32)
endmacro() endmacro()
#=============================================================================== #===============================================================================
# Macros for Package generation # Macros for Package generation
# #
# POCO_GENERATE_PACKAGE - Generates *Config.cmake # POCO_GENERATE_PACKAGE - Generates *Config.cmake
# Usage: POCO_GENERATE_PACKAGE(target_name) # Usage: POCO_GENERATE_PACKAGE(target_name)
# INPUT: # INPUT:
# target_name the name of the target. e.g. Foundation for PocoFoundation # target_name the name of the target. e.g. Foundation for PocoFoundation
# Example: POCO_GENERATE_PACKAGE(Foundation) # Example: POCO_GENERATE_PACKAGE(Foundation)
macro(POCO_GENERATE_PACKAGE target_name) macro(POCO_GENERATE_PACKAGE target_name)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file( write_basic_package_version_file(
@@ -214,18 +214,25 @@ if("${CMAKE_VERSION}" VERSION_LESS "3.0.0")
export(TARGETS "${target_name}" APPEND export(TARGETS "${target_name}" APPEND
FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake" FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake"
NAMESPACE "${PROJECT_NAME}::" NAMESPACE "${PROJECT_NAME}::"
) )
endif() endif()
else() else()
export(EXPORT "${target_name}Targets" export(EXPORT "${target_name}Targets"
FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake" FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake"
NAMESPACE "${PROJECT_NAME}::" NAMESPACE "${PROJECT_NAME}::"
) )
endif() 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" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake"
@ONLY @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 # Set config script install location in a location that find_package() will
# look for, which is different on MS Windows than for UNIX # look for, which is different on MS Windows than for UNIX
@@ -237,18 +244,18 @@ else()
endif() endif()
install( install(
EXPORT "${target_name}Targets" EXPORT "${target_name}Targets"
FILE "${PROJECT_NAME}${target_name}Targets.cmake" FILE "${PROJECT_NAME}${target_name}Targets.cmake"
NAMESPACE "${PROJECT_NAME}::" NAMESPACE "${PROJECT_NAME}::"
DESTINATION "${PocoConfigPackageLocation}" DESTINATION "${PocoConfigPackageLocation}"
) )
install( install(
FILES FILES
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake"
DESTINATION "${PocoConfigPackageLocation}" DESTINATION "${PocoConfigPackageLocation}"
COMPONENT Devel COMPONENT Devel
) )
endmacro() endmacro()
@@ -257,25 +264,25 @@ endmacro()
# Macros for simplified installation # Macros for simplified installation
# #
# POCO_INSTALL - Install the given target # POCO_INSTALL - Install the given target
# Usage: POCO_INSTALL(target_name) # Usage: POCO_INSTALL(target_name)
# INPUT: # INPUT:
# target_name the name of the target. e.g. Foundation for PocoFoundation # target_name the name of the target. e.g. Foundation for PocoFoundation
# Example: POCO_INSTALL(Foundation) # Example: POCO_INSTALL(Foundation)
macro(POCO_INSTALL target_name) macro(POCO_INSTALL target_name)
install( install(
DIRECTORY include/Poco DIRECTORY include/Poco
DESTINATION include DESTINATION include
COMPONENT Devel COMPONENT Devel
PATTERN ".svn" EXCLUDE PATTERN ".svn" EXCLUDE
) )
install( install(
TARGETS "${target_name}" EXPORT "${target_name}Targets" TARGETS "${target_name}" EXPORT "${target_name}Targets"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
) )
if(MSVC) if(MSVC)
@@ -286,20 +293,20 @@ endif()
endmacro() endmacro()
# POCO_INSTALL_PDB - Install the given target's companion pdb file (if present) # POCO_INSTALL_PDB - Install the given target's companion pdb file (if present)
# Usage: POCO_INSTALL_PDB(target_name) # Usage: POCO_INSTALL_PDB(target_name)
# INPUT: # INPUT:
# target_name the name of the target. e.g. Foundation for PocoFoundation # target_name the name of the target. e.g. Foundation for PocoFoundation
# Example: POCO_INSTALL_PDB(Foundation) # 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) macro(POCO_INSTALL_PDB target_name)
get_property(type TARGET ${target_name} PROPERTY TYPE) get_property(type TARGET ${target_name} PROPERTY TYPE)
if("${type}" STREQUAL "SHARED_LIBRARY" OR "${type}" STREQUAL "EXECUTABLE") if("${type}" STREQUAL "SHARED_LIBRARY" OR "${type}" STREQUAL "EXECUTABLE")
install( install(
FILES $<TARGET_PDB_FILE:${target_name}> FILES $<TARGET_PDB_FILE:${target_name}>
DESTINATION ${CMAKE_INSTALL_BINDIR} DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Devel COMPONENT Devel
OPTIONAL OPTIONAL
) )
endif() endif()
endmacro() endmacro()

View File

@@ -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_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_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_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 * 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 * POCO_UNBUNDLED Set to OFF|ON (default is OFF) to control linking dependencies as external

View File

@@ -1,20 +1,32 @@
#!/bin/bash #!/bin/bash
# #
# Script to rebuild a library and dependencies # Script to rebuild libraries and dependencies
# (with or without a sanitizer) and run the tests. # (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 # g++ does not like empty quoted arguments, but
if [ -z "${library}" ]; then # the shellcheck wants them quoted to remain quiet
# shellcheck disable=SC2086
path=$1
if [ -z "${path}" ]; then
echo "Library not specified" echo "Library not specified"
echo "Usage: $0 library [address | undefined | thread ]" echo "Usage: $0 path [address | undefined | thread ]"
exit 1 exit 1
fi fi
libraries=
IFS='/' read -r -a libraries <<< "$path"
self="${BASH_SOURCE[0]}" self="${BASH_SOURCE[0]}"
if [ -d "$self" ] ; then if [ -d "$self" ] ; then
@@ -27,30 +39,41 @@ fi
. "$basedir"/poco_env.bash . "$basedir"/poco_env.bash
flag=$2 flag=$2
flags=
make distclean -C CppUnit
make distclean -C Foundation
if [[ "$library" != "Foundation" ]]; then
make distclean -C "$library"
fi
make distclean -C "$library"/testsuite
if [ -n "${flag}" ]; then if [ -n "${flag}" ]; then
make -s -j4 -C "$POCO_BASE"/CppUnit SANITIZEFLAGS+=-fsanitize="$flag" flags=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
fi fi
cd "$basedir"/"$library"/testsuite/bin/"$OSNAME"/"$OSARCH"/ || exit path="$basedir"/"${libraries[0]}"
./testrunner -all
./testrunnerd -all 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