Skip to content

Commit

Permalink
fix(Data):
Browse files Browse the repository at this point in the history
adjust make and CMake for SQLParser and DataTest lib
separate samples from tests in CMake
remove unused StatementImpl from Data testsuite
  • Loading branch information
aleks-f committed Nov 4, 2023
1 parent a7a6f86 commit 81d7307
Show file tree
Hide file tree
Showing 47 changed files with 487 additions and 424 deletions.
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion ApacheConnector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions CppUnit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ elseif(MINGW)
PUBLIC
_DLL)
endif()

POCO_INSTALL(CppUnit)
POCO_GENERATE_PACKAGE(CppUnit)
2 changes: 1 addition & 1 deletion CppUnit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions CppUnit/cmake/CppUnitConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(CMakeFindDependencyMacro)
find_dependency(PocoFoundation)
include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTargets.cmake")
1 change: 1 addition & 0 deletions CppUnit/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Foundation
5 changes: 4 additions & 1 deletion Crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
13 changes: 11 additions & 2 deletions Data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -30,13 +35,18 @@ target_link_libraries(Data PUBLIC Poco::Foundation)
target_include_directories(Data
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
)

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")
Expand Down Expand Up @@ -66,7 +76,6 @@ else()
message(STATUS "ODBC Support Disabled")
endif()

if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
add_subdirectory(testsuite)
endif()
3 changes: 2 additions & 1 deletion Data/MySQL/testsuite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
4 changes: 3 additions & 1 deletion Data/ODBC/testsuite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
8 changes: 4 additions & 4 deletions Data/ODBC/testsuite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion Data/PostgreSQL/testsuite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
7 changes: 5 additions & 2 deletions Data/SQLite/testsuite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/)
8 changes: 6 additions & 2 deletions Data/include/Poco/Data/Statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ class Data_API Statement
/// Returns true if the statement is of the argument type.

Poco::SharedPtr<Parser::SQLParserResult> _pParseResult;

std::string _parseError;
#endif // POCO_DATA_NO_SQL_PARSER

StatementImpl::Ptr _pImpl;
Expand All @@ -557,7 +557,6 @@ class Data_API Statement
std::vector<Any> _arguments;
RowFormatter::Ptr _pRowFormatter;
mutable std::string _stmtString;
std::string _parseError;
};

//
Expand All @@ -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
}


Expand Down
16 changes: 9 additions & 7 deletions Data/src/Statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,31 @@ 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),
_pResult(stmt._pResult),
_pAsyncExec(stmt._pAsyncExec),
_arguments(stmt._arguments),
_pRowFormatter(stmt._pRowFormatter),
_stmtString(stmt._stmtString),
_parseError(stmt._parseError)
_stmtString(stmt._stmtString)
{
}


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)),
_pResult(std::move(stmt._pResult)),
_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;
Expand All @@ -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
}


Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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);
Expand All @@ -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);
}


Expand Down
10 changes: 4 additions & 6 deletions Data/testsuite/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand All @@ -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)
34 changes: 34 additions & 0 deletions Data/testsuite/DataTest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions Data/testsuite/DataTest/Makefile
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions Data/testsuite/DataTest/cmake/PocoDataTestConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)
find_dependency(PocoFoundation)
find_dependency(PocoData)
find_dependency(CppUnit)
include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTestTargets.cmake")
2 changes: 2 additions & 0 deletions Data/testsuite/DataTest/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Foundation
Data
Loading

0 comments on commit 81d7307

Please sign in to comment.