diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 5b7cd00f..61d23cb7 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,55 +1,52 @@ remove_definitions( -DQT_NO_KEYWORDS -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_CAST_FROM_ASCII -DQT_USE_QSTRINGBUILDER ) set(FILES_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(KDB_LOCAL_PLUGINS_DIR ${PROJECT_BINARY_DIR}/plugins) add_definitions( -DFILES_OUTPUT_DIR=\"${FILES_OUTPUT_DIR}\" # make plugins work without installing them: -DKDB_LOCAL_PLUGINS_DIR=\"${KDB_LOCAL_PLUGINS_DIR}\" # nonstandard path for sqlite3 extensions, they would work too if we placed them # in ${KDB_LOCAL_PLUGINS_DIR}/sqlite3 but we want to test the "extraSqliteExtensionPaths" # connection option in ConnectionTest::testCreateDb(): -DSQLITE_LOCAL_ICU_EXTENSION_PATH=\"${KDB_LOCAL_PLUGINS_DIR}/sqlite3\" -DYYTOKENTYPE # this removes access to yytokentype enum as we should access KDb::Token instead ) include(ECMAddTests) find_package(Qt5Test REQUIRED) # A helper library for db-related tests add_library(kdbtestutils SHARED KDbTestUtils.cpp - # A hack to show the files in the project even if they don't belong to kdbtestutils: - headers/headers_test.sh - headers/HeadersTestInclude.cmake ) target_link_libraries(kdbtestutils PUBLIC KDb Qt5::Test ) generate_export_header(kdbtestutils) # Tests ecm_add_tests( ConnectionOptionsTest.cpp ConnectionTest.cpp DriverTest.cpp ExpressionsTest.cpp KDbTest.cpp LINK_LIBRARIES kdbtestutils ) if(NOT WIN32) #TODO enable for Windows when headers_test.sh is ported e.g. to python add_subdirectory(headers) endif() add_subdirectory(tools) add_subdirectory(parser) diff --git a/autotests/headers/CMakeLists.txt b/autotests/headers/CMakeLists.txt index ed7ad1b9..eaadf556 100644 --- a/autotests/headers/CMakeLists.txt +++ b/autotests/headers/CMakeLists.txt @@ -1,8 +1,11 @@ # Test if all the installed headers can be included individually. Requires installed headers. add_test( NAME HeadersTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/headers_test.sh ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} KDb kdb . WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) + +# Just show dependent files in the project: +add_custom_target(HeadersTest SOURCES headers_test.sh HeadersTestInclude.cmake) diff --git a/autotests/headers/HeadersTestInclude.cmake b/autotests/headers/HeadersTestInclude.cmake index c294a388..6fe39dc3 100644 --- a/autotests/headers/HeadersTestInclude.cmake +++ b/autotests/headers/HeadersTestInclude.cmake @@ -1,11 +1,10 @@ set(REQUIRED_QT_VERSION "5.2.0") find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets Xml) find_package(KF5 5.7.0 REQUIRED CoreAddons) find_package(KDb REQUIRED) - -# C++ 0x required (at least for nullptr) -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +set(LIB_INSTALL_DIR "lib") +include(KDECMakeSettings NO_POLICY_SCOPE) +include(KDECompilerSettings NO_POLICY_SCOPE) +if(POLICY CMP0063) # Honor visibility properties for all target types (since cmake 3.3) + cmake_policy(SET CMP0063 NEW) endif() diff --git a/autotests/headers/headers_test.sh b/autotests/headers/headers_test.sh index dc4b3794..572fc681 100755 --- a/autotests/headers/headers_test.sh +++ b/autotests/headers/headers_test.sh @@ -1,119 +1,119 @@ #!/bin/sh # # Generates a full project for a HeadersTest app. # This is a compile-time test checking if all the installed headers can be included individually. # # Example for KDb: # % ./headers_test.sh ~/kde/build/kdb ~/kde/src/kdb KDb kdb . # # It is assumed that this script is executed from the current build subdirectory. # Source dir goes to the app/ subdirectory, build dir goes to the app-build subdirectory. # Nothing is cached, both dirs are fully recreated on each run. set -e builddir=$1 current_builddir=`pwd` shift srcdir=$1 if [ ! -d "$builddir" -o ! -d "$srcdir" -o $# -lt 4 ] ; then echo "Usage: $me ..." exit 1 fi test_app_dir=$current_builddir/app rm -rf $test_app_dir mkdir -p $test_app_dir test_app_builddir=$current_builddir/app-build rm -rf $test_app_builddir mkdir -p $test_app_builddir me=headers_test.sh current_srcdir=`dirname $0` shift link_libs=$1 shift prefix=$1 shift cd $srcdir cat < $test_app_dir/CMakeLists.txt # Generated by $current_srcdir/$me # prefix: $prefix # link_libs: $link_libs # subdirs: $@ # # WARNING! All changes made in this file will be lost! # # Test if all the installed headers can be included individually. # This is a compile-time test. cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) find_package(ECM 1.8.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH $current_srcdir $srcdir/cmake/modules \${ECM_MODULE_PATH} \${ECM_KDE_MODULE_DIR}) project(HeadersTest) -include(HeadersTestInclude) +include(HeadersTestInclude NO_POLICY_SCOPE) add_executable( HeadersTest HeadersTest.cpp EOT cat < $test_app_dir/HeadersTest.cpp // Generated by $me // WARNING! All changes made in this file will be lost! // Nothing to do here int main(int, char**) { return 0; } EOT # files to include using , forward headers + some *.h headers find_files() { for subdir in "$@" ; do find "$builddir/src/$subdir" -maxdepth 1 -type f -printf "%f\n" done } for f in `find_files $@ | grep -v "\.h\$" | grep -vE "(\\.|Makefile)" | sort`; do fname=${f}_HeaderTest.cpp echo "#include <$f>" > $test_app_dir/$fname echo " $fname" >> $test_app_dir/CMakeLists.txt done # files to include using , these are .h files for f in `find_files $@ | grep "\.h\$" | grep -vE "(^ui_.*\.h|sqlparser\.h)" | sort`; do fname=${f}_HeaderTest.cpp echo "#include <$f>" > $test_app_dir/$fname echo " $fname" >> $test_app_dir/CMakeLists.txt done cat <> $test_app_dir/CMakeLists.txt ) target_link_libraries(HeadersTest PUBLIC $link_libs ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) EOT # Finally, build: cd $test_app_builddir CXXCOMPILER=`cmake -LA ../../.. | grep CMAKE_CXX_COMPILER` if [ -n "$CXXCOMPILER" ] ; then CXXCOMPILER=-D$CXXCOMPILER ; fi CCOMPILER=`cmake -LA ../../.. | grep CMAKE_C_COMPILER` if [ -n "$CCOMPILER" ] ; then CCOMPILER=-D$CCOMPILER ; fi echo cmake $CXXCOMPILER $CCOMPILER ../app cmake $CXXCOMPILER $CCOMPILER ../app make