mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 01:12:43 +00:00
qt ctest (#14968)
* [cpp-qt-client] Fix warning about deprecated count() method * [cpp-qt-client] Ignore build directory * [cpp-qt-client] Use ctest * Fix CMakeLists.txt for cpp-qt-client
This commit is contained in:
1
samples/client/petstore/cpp-qt/.gitignore
vendored
Normal file
1
samples/client/petstore/cpp-qt/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build
|
||||
@@ -1,20 +1,25 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(cpp-qt5-petstore)
|
||||
project(cpp-qt-petstore)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network Gui Test)
|
||||
|
||||
add_subdirectory(client)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Test)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
add_executable(cpp-qt-petstore
|
||||
PetStore/main.cpp
|
||||
PetStore/PetApiTests.cpp
|
||||
PetStore/StoreApiTests.cpp
|
||||
PetStore/UserApiTests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE CppQtPetstoreClient Qt${QT_VERSION_MAJOR}::Test)
|
||||
target_link_libraries(cpp-qt-petstore PRIVATE CppQtPetstoreClient Qt${QT_VERSION_MAJOR}::Test)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(NAME cpp-qt-petstore-test COMMAND cpp-qt-petstore)
|
||||
|
||||
@@ -8,14 +8,14 @@ cd build
|
||||
|
||||
cmake ..
|
||||
|
||||
make
|
||||
cmake --build .
|
||||
|
||||
if [[ -z "${RUN_VALGRIND_TESTS}" ]]; then
|
||||
echo "Running Qt5 Petstore Tests"
|
||||
./cpp-qt5-petstore
|
||||
echo "Running Qt Petstore Tests"
|
||||
ctest
|
||||
else
|
||||
echo "Running Qt5 Petstore Tests with Valgrind"
|
||||
valgrind --leak-check=full ./cpp-qt5-petstore |& tee result.log || exit 1
|
||||
echo "Running Qt Petstore Tests with Valgrind"
|
||||
valgrind --leak-check=full ./cpp-qt-petstore |& tee result.log || exit 1
|
||||
testCount=$(cat result.log | grep 'Finished testing of' | wc -l)
|
||||
if [ $testCount == 3 ]
|
||||
then
|
||||
|
||||
@@ -2,39 +2,51 @@ cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(CppQtPetstoreClient)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network Gui)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network Gui)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
file(GLOB_RECURSE HEADER_FILES "*.h")
|
||||
file(GLOB_RECURSE SOURCE_FILES "*.cpp")
|
||||
|
||||
add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Wall -Wno-unused-variable>
|
||||
)
|
||||
add_library(${PROJECT_NAME}
|
||||
PFXApiResponse.h
|
||||
PFXCategory.h
|
||||
PFXOrder.h
|
||||
PFXPet.h
|
||||
PFXTag.h
|
||||
PFXTestAnyType.h
|
||||
PFXUser.h
|
||||
PFXPetApi.h
|
||||
PFXPrimitivesApi.h
|
||||
PFXStoreApi.h
|
||||
PFXUserApi.h
|
||||
PFXHelpers.h
|
||||
PFXHttpRequest.h
|
||||
PFXObject.h
|
||||
PFXEnum.h
|
||||
PFXHttpFileElement.h
|
||||
PFXServerConfiguration.h
|
||||
PFXServerVariable.h
|
||||
PFXOauth.h
|
||||
PFXApiResponse.cpp
|
||||
PFXCategory.cpp
|
||||
PFXOrder.cpp
|
||||
PFXPet.cpp
|
||||
PFXTag.cpp
|
||||
PFXTestAnyType.cpp
|
||||
PFXUser.cpp
|
||||
PFXPetApi.cpp
|
||||
PFXPrimitivesApi.cpp
|
||||
PFXStoreApi.cpp
|
||||
PFXUserApi.cpp
|
||||
PFXHelpers.cpp
|
||||
PFXHttpRequest.cpp
|
||||
PFXHttpFileElement.cpp
|
||||
PFXOauth.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
@@ -46,11 +58,6 @@ target_link_libraries(${PROJECT_NAME}
|
||||
|
||||
)
|
||||
|
||||
if(NOT APPLE)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ssl crypto)
|
||||
endif()
|
||||
|
||||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
|
||||
@@ -233,7 +233,7 @@ bool fromStringValue(const QString &inStr, QByteArray &value) {
|
||||
} else {
|
||||
value.clear();
|
||||
value.append(inStr.toUtf8());
|
||||
return value.count() > 0;
|
||||
return value.size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user