Warning, /frameworks/kcoreaddons/autotests/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 remove_definitions(-DQT_NO_CAST_FROM_ASCII)
0002 set(KCOREADDONS_INTERNAL_SKIP_PLUGIN_INSTALLATION ON)
0003 
0004 include(ECMAddTests)
0005 include(ConfigureChecks.cmake) #configure checks for QFileSystemWatcher
0006 include(../KF5CoreAddonsMacros.cmake)
0007 
0008 find_package(Qt${QT_MAJOR_VERSION}Test ${REQUIRED_QT_VERSION} CONFIG QUIET)
0009 
0010 if(NOT TARGET Qt${QT_MAJOR_VERSION}::Test)
0011     message(STATUS "QtTest not found, autotests will not be built.")
0012     return()
0013 endif()
0014 
0015 if(NOT CMAKE_BUILD_TYPE MATCHES "[Dd]ebug$")
0016     set(ENABLE_BENCHMARKS 1)
0017 endif()
0018 
0019 add_library(autotests_static STATIC)
0020 # Needed to link this static lib to shared libs
0021 set_property(TARGET autotests_static PROPERTY POSITION_INDEPENDENT_CODE ON)
0022 ecm_qt_declare_logging_category(autotests_static
0023         HEADER kcoreaddons_debug.h
0024         IDENTIFIER KCOREADDONS_DEBUG
0025         CATEGORY_NAME kf.coreaddons
0026         )
0027 target_link_libraries(autotests_static Qt${QT_MAJOR_VERSION}::Core)
0028 
0029 configure_file(config-tests.h.in config-tests.h)
0030 
0031 macro(build_plugin pname)
0032     add_library(${pname} MODULE ${ARGN})
0033     ecm_mark_as_test(${pname})
0034     target_link_libraries(${pname} KF5::CoreAddons autotests_static)
0035 endmacro()
0036 
0037 # Build some sample plugins
0038 build_plugin(jsonplugin jsonplugin.cpp)
0039 build_plugin(jsonplugin2 jsonplugin2.cpp)
0040 build_plugin(versionedplugin versionedplugin.cpp)
0041 build_plugin(unversionedplugin unversionedplugin.cpp)
0042 build_plugin(multiplugin multiplugin.cpp)
0043 build_plugin(alwaysunloadplugin alwaysunloadplugin.cpp)
0044 build_plugin(qtplugin qtplugin.cpp)
0045 
0046 kcoreaddons_add_plugin(jsonplugin_cmake_macro SOURCES kpluginclass.cpp INSTALL_NAMESPACE "namespace")
0047 ecm_mark_as_test(jsonplugin_cmake_macro)
0048 target_link_libraries(jsonplugin_cmake_macro KF5::CoreAddons autotests_static)
0049 
0050 kcoreaddons_add_plugin(pluginwithoutmetadata SOURCES pluginwithoutmetadata.cpp INSTALL_NAMESPACE "namespace")
0051 ecm_mark_as_test(pluginwithoutmetadata)
0052 target_link_libraries(pluginwithoutmetadata KF5::CoreAddons autotests_static)
0053 
0054 add_library(org.kde.test MODULE jsonplugin.cpp)
0055 target_link_libraries(org.kde.test KF5::CoreAddons)
0056 
0057 add_definitions( -DKDELIBS4CONFIGMIGRATOR_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
0058 
0059 if (WIN32)
0060     set(autotests_OPTIONAL_SRCS
0061         ${autotests_OPTIONAL_SRCS}
0062         klistopenfilesjobtest_win.cpp
0063     )
0064 endif ()
0065 
0066 if (UNIX)
0067     set(autotests_OPTIONAL_SRCS
0068         ${autotests_OPTIONAL_SRCS}
0069         klistopenfilesjobtest_unix.cpp
0070     )
0071 endif ()
0072 
0073 if (NOT ${QT_MAJOR_VERSION} STREQUAL "6")
0074     set(autotests_OPTIONAL_SRCS
0075         ${autotests_OPTIONAL_SRCS}
0076         kdelibs4migrationtest.cpp
0077         kdelibs4configmigratortest.cpp
0078     )
0079 endif ()
0080 ecm_add_tests(
0081     kaboutdatatest.cpp
0082     kaboutdataapplicationdatatest.cpp
0083     kautosavefiletest.cpp
0084     kcompositejobtest.cpp
0085     kformattest.cpp
0086     kjobtest.cpp
0087     kosreleasetest.cpp
0088     kpluginfactorytest.cpp
0089     kpluginloadertest.cpp
0090     kpluginmetadatatest.cpp
0091     kprocesstest.cpp
0092     krandomtest.cpp
0093     kshareddatacachetest.cpp
0094     kshelltest.cpp
0095     kurlmimedatatest.cpp
0096     kstringhandlertest.cpp
0097     kmacroexpandertest.cpp
0098     kusertest.cpp
0099     kprocesslisttest.cpp
0100     kfileutilstest.cpp
0101     kfuzzymatchertest.cpp
0102     knetworkmountstestcanonical.cpp
0103     knetworkmountstestnoconfig.cpp
0104     knetworkmountstestpaths.cpp
0105     knetworkmountsteststatic.cpp
0106     klibexectest.cpp
0107     kmemoryinfotest.cpp
0108     kruntimeplatformtest.cpp
0109     ${autotests_OPTIONAL_SRCS}
0110     LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KF5::CoreAddons autotests_static
0111 )
0112 if(TARGET klistopenfilesjobtest_unix AND CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
0113     find_package(Qt${QT_MAJOR_VERSION}Network ${REQUIRED_QT_VERSION} CONFIG QUIET)
0114     target_link_libraries(klistopenfilesjobtest_unix Qt${QT_MAJOR_VERSION}::Network)
0115 endif()
0116 
0117 kcoreaddons_add_plugin(static_jsonplugin_cmake_macro SOURCES statickpluginclass.cpp INSTALL_NAMESPACE "staticnamespace" STATIC)
0118 target_link_libraries(static_jsonplugin_cmake_macro KF5::CoreAddons autotests_static)
0119 
0120 kcoreaddons_add_plugin(static_jsonplugin_cmake_macro_2 SOURCES statickpluginclass_2.cpp INSTALL_NAMESPACE "staticnamespace2" STATIC)
0121 target_link_libraries(static_jsonplugin_cmake_macro_2 KF5::CoreAddons autotests_static)
0122 
0123 kcoreaddons_add_plugin(static_plugin_without_metadata SOURCES staticpluginwithoutmetadata.cpp INSTALL_NAMESPACE "staticnamespace3" STATIC)
0124 target_link_libraries(static_plugin_without_metadata KF5::CoreAddons autotests_static)
0125 
0126 
0127 kcoreaddons_target_static_plugins(kpluginfactorytest "staticnamespace")
0128 kcoreaddons_target_static_plugins(kpluginfactorytest "staticnamespace2")
0129 kcoreaddons_target_static_plugins(kpluginmetadatatest "staticnamespace")
0130 kcoreaddons_target_static_plugins(kpluginmetadatatest "staticnamespace2")
0131 kcoreaddons_target_static_plugins(kpluginmetadatatest "staticnamespace3")
0132 
0133 if(NOT CMAKE_CROSSCOMPILING)
0134     ecm_add_tests(desktoptojsontest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KF5::CoreAddons autotests_static)
0135     target_compile_definitions(desktoptojsontest PRIVATE
0136         DESKTOP_TO_JSON_EXE="$<TARGET_FILE:desktoptojson>"
0137     )
0138 endif()
0139 
0140 add_library(ktexttohtmlteststatic STATIC ${CMAKE_SOURCE_DIR}/src/lib/text/ktexttohtml.cpp)
0141 # include the binary dir in order to get kcoreaddons_export.h
0142 target_include_directories(ktexttohtmlteststatic PUBLIC ${KCoreAddons_BINARY_DIR}/src/lib)
0143 # fake static linking to prevent the export macros on Windows from kicking in
0144 target_compile_definitions(ktexttohtmlteststatic PUBLIC -DKCOREADDONS_STATIC_DEFINE=1)
0145 target_link_libraries(ktexttohtmlteststatic PUBLIC Qt${QT_MAJOR_VERSION}::Test autotests_static)
0146 ecm_add_test(ktexttohtmltest.cpp
0147     TEST_NAME ktexttohtmltest
0148     LINK_LIBRARIES ktexttohtmlteststatic
0149 )
0150 
0151 add_executable(ktexttohtmlbenchmarktest ktexttohtmlbenchmarktest.cpp ${CMAKE_SOURCE_DIR}/src/lib/text/ktexttohtml.cpp)
0152 target_link_libraries(ktexttohtmlbenchmarktest PUBLIC ktexttohtmlteststatic)
0153 
0154 add_executable(kprocesstest_helper kprocesstest_helper.cpp)
0155 target_link_libraries(kprocesstest_helper KF5::CoreAddons)
0156 
0157 target_compile_definitions(kpluginloadertest PRIVATE
0158     JSONPLUGIN_FILE="$<TARGET_FILE:jsonplugin>"
0159     VERSIONEDPLUGIN_FILE="$<TARGET_FILE:versionedplugin>"
0160     UNVERSIONEDPLUGIN_FILE="$<TARGET_FILE:unversionedplugin>"
0161     MULTIPLUGIN_FILE="$<TARGET_FILE:multiplugin>"
0162     ALWAYSUNLOADPLUGIN_FILE="$<TARGET_FILE:alwaysunloadplugin>"
0163 )
0164 
0165 set(KDIRWATCH_BACKENDS_TO_TEST Stat)#Stat is always compiled
0166 
0167 if (HAVE_SYS_INOTIFY_H)
0168     list(APPEND KDIRWATCH_BACKENDS_TO_TEST INotify)
0169 endif()
0170 
0171 if (HAVE_FAM)
0172     list(APPEND KDIRWATCH_BACKENDS_TO_TEST Fam)
0173 endif()
0174 
0175 if (HAVE_QFILESYSTEMWATCHER)
0176     list(APPEND KDIRWATCH_BACKENDS_TO_TEST QFSWatch)
0177 endif()
0178 
0179 foreach(_backendName ${KDIRWATCH_BACKENDS_TO_TEST})
0180     string(TOLOWER ${_backendName} _lowercaseBackendName)
0181     set(BACKEND_TEST_TARGET kdirwatch_${_lowercaseBackendName}_unittest)
0182     set(BACKEND_BENCHMARK_TARGET kdirwatch_${_lowercaseBackendName}_benchmarktest)
0183     add_executable(${BACKEND_TEST_TARGET} kdirwatch_unittest.cpp)
0184     target_link_libraries(${BACKEND_TEST_TARGET} Qt${QT_MAJOR_VERSION}::Test KF5::CoreAddons autotests_static)
0185 
0186     if(FAM_FOUND)
0187         target_include_directories(${BACKEND_TEST_TARGET} PRIVATE ${FAM_INCLUDE_DIR})
0188         target_link_libraries(${BACKEND_TEST_TARGET} ${FAM_LIBRARIES})
0189     endif()
0190 
0191     if(NOT WIN32)
0192         target_link_libraries(${BACKEND_TEST_TARGET} Threads::Threads)
0193     endif()
0194 
0195     ecm_mark_as_test(${BACKEND_TEST_TARGET})
0196     add_test(NAME ${BACKEND_TEST_TARGET} COMMAND ${BACKEND_TEST_TARGET})
0197     target_compile_definitions(${BACKEND_TEST_TARGET} PUBLIC -DKDIRWATCH_TEST_METHOD=\"${_backendName}\")
0198 
0199     add_executable(${BACKEND_BENCHMARK_TARGET} kdirwatch_benchmarktest.cpp)
0200     target_compile_definitions(${BACKEND_BENCHMARK_TARGET} PUBLIC -DKDIRWATCH_TEST_METHOD=\"${_backendName}\")
0201     target_link_libraries(${BACKEND_BENCHMARK_TARGET} Qt${QT_MAJOR_VERSION}::Test KF5::CoreAddons autotests_static)
0202     if(NOT WIN32)
0203         target_link_libraries(${BACKEND_BENCHMARK_TARGET} Threads::Threads)
0204     endif()
0205 
0206 endforeach()