CMake build: Add unittest CMake build files

On MinGW 8.1 I get the following after running ctest -j 40

99% tests passed, 35 tests failed out of 2631

Change-Id: I2c3ce7940b036e52ef393feab5837886355e7b5a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Cristian Adam
2019-05-29 14:55:17 +02:00
committed by Cristian Adam
parent 0bbc5ef574
commit f50859e856
17 changed files with 841 additions and 108 deletions

View File

@@ -0,0 +1,82 @@
#.rst:
# FindGoogleBenchmark
# -----------------
#
# Try to locate the GoogleBenchmark source files, and then build them as a
# static library.
#
# The ``GOOGLEBENCHMARK_DIR`` (CMake or Environment) variable should be used
# to pinpoint the GoogleBenchmark source files.
#
# If found, this will define the following variables:
#
# ``GoogleBenchmark_FOUND``
# True if the GoogleBenchmark source package has been found.
#
# ``GoogleBenchmark``
# Target compiled as static library.
#
find_path(GOOGLE_BENCHMARK_INCLUDE_DIR
NAMES benchmark/benchmark.h
PATH_SUFFIXES include
HINTS
"${GOOGLEBENCHMARK_DIR}" ENV GOOGLEBENCHMARK_DIR
"${CMAKE_SOURCE_DIR}/../benchmark"
"${CMAKE_SOURCE_DIR}/../../benchmark"
)
find_path(GOOGLE_BENCHMARK_SRC_DIR
NAMES benchmark.cc
PATH_SUFFIXES src
HINTS
"${GOOGLEBENCHMARK_DIR}" ENV GOOGLEBENCHMARK_DIR
"${CMAKE_SOURCE_DIR}/../benchmark"
"${CMAKE_SOURCE_DIR}/../../benchmark"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GoogleBenchmark
DEFAULT_MSG
GOOGLE_BENCHMARK_INCLUDE_DIR GOOGLE_BENCHMARK_SRC_DIR
)
if(GoogleBenchmark_FOUND AND NOT TARGET GoogleBenchmark)
add_library(GoogleBenchmark STATIC
"${GOOGLE_BENCHMARK_SRC_DIR}/benchmark.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/benchmark_api_internal.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/benchmark_name.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/benchmark_register.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/benchmark_runner.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/colorprint.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/commandlineflags.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/complexity.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/console_reporter.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/counter.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/csv_reporter.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/json_reporter.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/reporter.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/sleep.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/statistics.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/string_util.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/sysinfo.cc"
"${GOOGLE_BENCHMARK_SRC_DIR}/timers.cc"
)
target_include_directories(GoogleBenchmark
PUBLIC
"${GOOGLE_BENCHMARK_INCLUDE_DIR}"
PRIVATE
"${GOOGLE_BENCHMARK_SRC_DIR}"
)
target_compile_definitions(GoogleBenchmark PRIVATE HAVE_STD_REGEX WITH_BENCHMARKS)
if (WIN32)
target_link_libraries(GoogleBenchmark PRIVATE shlwapi)
endif()
endif()
mark_as_advanced(GOOGLE_BENCHMARK_INCLUDE_DIR GOOGLE_BENCHMARK_SRC_DIR)
include(FeatureSummary)
set_package_properties(GoogleBenchmark PROPERTIES
URL "https://github.com/google/benchmark"
DESCRIPTION "A microbenchmark support library")

102
cmake/FindGoogletest.cmake Normal file
View File

@@ -0,0 +1,102 @@
#.rst:
# FindGoogletest
# -----------------
#
# Try to locate the Googletest source files, and then build them as a
# static library.
#
# The ``GOOGLETEST_DIR`` (CMake or Environment) variable should be used
# to pinpoint the Googletest source files.
#
# If found, this will define the following variables:
#
# ``Googletest_FOUND``
# True if the Googletest source package has been found.
#
# ``Googletest``
# Target compiled as static library.
#
find_path(GOOGLE_TEST_INCLUDE_DIR
NAMES gtest/gtest.h
PATH_SUFFIXES googletest/include
HINTS
"${GOOGLETEST_DIR}" ENV GOOGLETEST_DIR
"${CMAKE_SOURCE_DIR}/../googletest"
"${CMAKE_SOURCE_DIR}/../../googletest"
)
find_path(GOOGLE_TEST_SRC_ALL
NAMES gtest-all.cc
PATH_SUFFIXES googletest/src
HINTS
"${GOOGLETEST_DIR}" ENV GOOGLETEST_DIR
"${CMAKE_SOURCE_DIR}/../googletest"
"${CMAKE_SOURCE_DIR}/../../googletest"
)
find_path(GOOGLE_MOCK_INCLUDE_DIR
NAMES gmock/gmock.h
PATH_SUFFIXES googlemock/include
HINTS
"${GOOGLETEST_DIR}" ENV GOOGLETEST_DIR
"${CMAKE_SOURCE_DIR}/../googletest"
"${CMAKE_SOURCE_DIR}/../../googletest"
)
find_path(GOOGLE_MOCK_SRC_ALL
NAMES gmock-all.cc
PATH_SUFFIXES googlemock/src
HINTS
"${GOOGLETEST_DIR}" ENV GOOGLETEST_DIR
"${CMAKE_SOURCE_DIR}/../googletest"
"${CMAKE_SOURCE_DIR}/../../googletest"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Googletest
DEFAULT_MSG
GOOGLE_TEST_INCLUDE_DIR GOOGLE_MOCK_INCLUDE_DIR
GOOGLE_TEST_SRC_ALL GOOGLE_MOCK_SRC_ALL
)
if(Googletest_FOUND AND NOT TARGET Googletest)
add_library(Googletest STATIC
"${GOOGLE_TEST_SRC_ALL}/gtest-all.cc"
"${GOOGLE_MOCK_SRC_ALL}/gmock-all.cc"
)
target_include_directories(Googletest
PUBLIC
"${GOOGLE_TEST_INCLUDE_DIR}"
"${GOOGLE_MOCK_INCLUDE_DIR}"
PRIVATE
"${GOOGLE_TEST_SRC_ALL}/.."
"${GOOGLE_MOCK_SRC_ALL}/.."
)
target_compile_definitions(Googletest
PRIVATE
GTEST_HAS_STD_INITIALIZER_LIST_
GTEST_LANG_CXX11
GTEST_HAS_STD_TUPLE_
GTEST_HAS_STD_TYPE_TRAITS_
GTEST_HAS_STD_FUNCTION_
GTEST_HAS_RTTI
GTEST_HAS_STD_BEGIN_AND_END_
GTEST_HAS_STD_UNIQUE_PTR_
GTEST_HAS_EXCEPTIONS
GTEST_HAS_STREAM_REDIRECTION
GTEST_HAS_TYPED_TEST
GTEST_HAS_TYPED_TEST_P
GTEST_HAS_PARAM_TEST
GTEST_HAS_DEATH_TEST
)
endif()
mark_as_advanced(GOOGLE_TEST_INCLUDE_DIR GOOGLE_MOCK_INCLUDE_DIR
GOOGLE_TEST_SRC_ALL GOOGLE_MOCK_SRC_ALL)
include(FeatureSummary)
set_package_properties(Googletest PROPERTIES
URL "https://github.com/google/googletest"
DESCRIPTION "Google Testing and Mocking Framework")

View File

@@ -85,7 +85,14 @@ function(add_qtc_depends target_name)
public_depends object_public_depends object_public_depends_objects)
target_sources(${target_name} PRIVATE ${object_lib_depends_objects} ${object_public_depends_objects})
target_link_libraries(${target_name} PRIVATE ${depends} PUBLIC ${public_depends})
get_target_property(target_type ${target_name} TYPE)
if (NOT target_type STREQUAL "OBJECT_LIBRARY")
target_link_libraries(${target_name} PRIVATE ${depends} PUBLIC ${public_depends})
else()
list(APPEND object_lib_depends ${depends})
list(APPEND object_public_depends ${public_depends})
endif()
foreach(obj_lib IN LISTS object_lib_depends)
target_compile_definitions(${target_name} PRIVATE $<TARGET_PROPERTY:${obj_lib},INTERFACE_COMPILE_DEFINITIONS>)
@@ -152,6 +159,7 @@ function(add_qtc_library name)
endforeach()
set_target_properties(${name} PROPERTIES
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
VERSION "${PROJECT_VERSION}"
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
@@ -315,7 +323,6 @@ function(add_qtc_plugin target_name)
set(TEST_DEFINES WITH_TESTS SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
endif()
target_link_libraries(${target_name} PRIVATE ${_DEP_PLUGINS} ${_TEST_DEPENDS})
target_include_directories(${target_name}
PRIVATE ${_arg_INCLUDES} "${CMAKE_CURRENT_SOURCE_DIR}/.." "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/src"
@@ -326,7 +333,7 @@ function(add_qtc_plugin target_name)
)
add_qtc_depends(${target_name}
PRIVATE ${_arg_DEPENDS}
PRIVATE ${_arg_DEPENDS} ${_DEP_PLUGINS} ${_TEST_DEPENDS}
PUBLIC ${_arg_PUBLIC_DEPENDS}
)
@@ -336,6 +343,7 @@ function(add_qtc_plugin target_name)
endif()
set_target_properties(${target_name} PROPERTIES
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
_arg_DEPENDS "${_arg_PLUGIN_DEPENDS}"
@@ -387,8 +395,11 @@ function(extend_qtc_target target_name)
target_include_directories(${target_name} PRIVATE ${_arg_INCLUDES} PUBLIC ${_arg_PUBLIC_INCLUDES})
if (_arg_SOURCES_PREFIX)
list(TRANSFORM _arg_SOURCES PREPEND "${_arg_SOURCES_PREFIX}/")
foreach(source IN LISTS _arg_SOURCES)
list(APPEND prefixed_sources "${_arg_SOURCES_PREFIX}/${source}")
endforeach()
target_include_directories(${target_name} PUBLIC "${_arg_SOURCES_PREFIX}")
set(_arg_SOURCES ${prefixed_sources})
endif()
target_sources(${target_name} PRIVATE ${_arg_SOURCES})
@@ -470,8 +481,21 @@ function(extend_qtc_executable name)
endif()
endfunction()
function(fix_test_environment test_name)
if (WIN32)
list(APPEND env_path $ENV{PATH})
list(APPEND env_path ${CMAKE_BINARY_DIR}/${IDE_PLUGIN_PATH})
list(APPEND env_path ${CMAKE_BINARY_DIR}/${IDE_BIN_PATH})
string(REPLACE "/" "\\" env_path "${env_path}")
string(REPLACE ";" "\\;" env_path "${env_path}")
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "PATH=${env_path}")
endif()
endfunction()
function(add_qtc_test name)
cmake_parse_arguments(_arg "" "" "DEFINES;DEPENDS;INCLUDES;SOURCES" ${ARGN})
cmake_parse_arguments(_arg "GTEST" "" "DEFINES;DEPENDS;INCLUDES;SOURCES" ${ARGN})
if ($_arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "add_qtc_test had unparsed arguments!")
@@ -496,20 +520,22 @@ function(add_qtc_test name)
INSTALL_RPATH "${_RPATH_BASE}/${_RPATH}"
)
add_test(NAME ${name} COMMAND ${name})
if (WIN32)
list(APPEND env_path $ENV{PATH})
list(APPEND env_path ${CMAKE_BINARY_DIR}/${IDE_PLUGIN_PATH})
list(APPEND env_path ${CMAKE_BINARY_DIR}/${IDE_BIN_PATH})
string(REPLACE "/" "\\" env_path "${env_path}")
string(REPLACE ";" "\\;" env_path "${env_path}")
set_tests_properties(${name} PROPERTIES ENVIRONMENT "PATH=${env_path}")
if (NOT _arg_GTEST)
add_test(NAME ${name} COMMAND ${name})
fix_test_environment(${name})
endif()
endfunction()
function(finalize_qtc_gtest test_name)
get_target_property(test_sources ${test_name} SOURCES)
include(GoogleTest)
gtest_add_tests(TARGET ${test_name} SOURCES ${test_sources} TEST_LIST test_list)
foreach(test IN LISTS test_list)
fix_test_environment(${test})
endforeach()
endfunction()
add_library(app_version INTERFACE)
target_include_directories(app_version INTERFACE ${CMAKE_CURRENT_BINARY_DIR})

View File

@@ -193,13 +193,12 @@ extend_qtc_target(Utils CONDITION UNIX AND NOT APPLE
touchbar/touchbar.cpp
)
add_executable(qtcreator_process_stub)
if (WIN32)
target_sources(qtcreator_process_stub PRIVATE process_stub_win.c)
target_link_libraries(qtcreator_process_stub shell32)
target_compile_definitions(qtcreator_process_stub PRIVATE
_UNICODE UNICODE _CRT_SECURE_NO_WARNINGS)
add_qtc_executable(qtcreator_process_stub
SOURCES process_stub_win.c
DEPENDS shell32
DEFINES _UNICODE UNICODE _CRT_SECURE_NO_WARNINGS
)
else()
target_sources(qtcreator_process_stub PRIVATE process_stub_unix.c)
add_qtc_executable(qtcreator_process_stub SOURCES process_stub_unix.c)
endif()
install(TARGETS qtcreator_process_stub DESTINATION ${IDE_LIBEXEC_PATH})

View File

@@ -1,6 +1,6 @@
add_qtc_plugin(CppTools
DEPENDS Qt5::Network Qt5::Xml
PUBLIC_DEPENDS CPlusPlus
PUBLIC_DEPENDS CPlusPlus Qt5::Widgets
PLUGIN_DEPENDS Core ProjectExplorer TextEditor
SOURCES
abstracteditorsupport.cpp abstracteditorsupport.h

View File

@@ -23,8 +23,7 @@ add_qtc_library(ProParser SHARED
WINDOWS_EXPORT_ALL_SYMBOLS ON
)
if (WIN32)
target_compile_definitions(ProParser PRIVATE _UNICODE UNICODE)
endif()
target_include_directories(ProParser PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
extend_qtc_target(ProParser
CONDITION WIN32
DEFINES _UNICODE UNICODE
)

View File

@@ -4,10 +4,10 @@ if (NOT Clang_FOUND)
message(WARNING "Could not find Clang installation - disabling clangbackend.")
else ()
add_subdirectory(clangbackend)
add_subdirectory(clangrefactoringbackend)
add_subdirectory(clangpchmanagerbackend)
endif ()
# add_subdirectory(clangrefactoringbackend) ## not building this at this time!
option(BUILD_CPLUSPLUS_TOOLS "Build CPlusPlus tools" OFF)
function(add_qtc_cpp_tool name)

View File

@@ -1,67 +1,8 @@
add_subdirectory(source)
add_qtc_executable(clangbackend
DEPENDS ClangSupport libclang Sqlite Qt5::Core Qt5::Network
INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/source" ${CLANG_INCLUDE_DIRS}
DEPENDS Qt5::Core Qt5::Network clangbackend_lib Sqlite ClangSupport libclang
SOURCES
../qtcreatorcrashhandler/crashhandlersetup.cpp ../qtcreatorcrashhandler/crashhandlersetup.h
clangbackendmain.cpp
source/clangasyncjob.h
source/clangbackend_global.h
source/clangclock.h
source/clangcodecompleteresults.cpp source/clangcodecompleteresults.h
source/clangcodemodelserver.cpp source/clangcodemodelserver.h
source/clangcompletecodejob.cpp source/clangcompletecodejob.h
source/clangdocument.cpp source/clangdocument.h
source/clangdocumentjob.h
source/clangdocumentprocessor.cpp source/clangdocumentprocessor.h
source/clangdocumentprocessors.cpp source/clangdocumentprocessors.h
source/clangdocuments.cpp source/clangdocuments.h
source/clangdocumentsuspenderresumer.cpp source/clangdocumentsuspenderresumer.h
source/clangexceptions.cpp source/clangexceptions.h
source/clangfilepath.cpp source/clangfilepath.h
source/clangfilesystemwatcher.cpp source/clangfilesystemwatcher.h
source/clangfollowsymbol.cpp source/clangfollowsymbol.h
source/clangfollowsymboljob.cpp source/clangfollowsymboljob.h
source/clangiasyncjob.cpp source/clangiasyncjob.h
source/clangjobcontext.cpp source/clangjobcontext.h
source/clangjobqueue.cpp source/clangjobqueue.h
source/clangjobrequest.cpp source/clangjobrequest.h
source/clangjobs.cpp source/clangjobs.h
source/clangparsesupportivetranslationunitjob.cpp source/clangparsesupportivetranslationunitjob.h
source/clangreferencescollector.cpp source/clangreferencescollector.h
source/clangrequestannotationsjob.cpp source/clangrequestannotationsjob.h
source/clangrequestreferencesjob.cpp source/clangrequestreferencesjob.h
source/clangrequesttooltipjob.cpp source/clangrequesttooltipjob.h
source/clangresumedocumentjob.cpp source/clangresumedocumentjob.h
source/clangstring.h
source/clangsupportivetranslationunitinitializer.cpp source/clangsupportivetranslationunitinitializer.h
source/clangsuspenddocumentjob.cpp source/clangsuspenddocumentjob.h
source/clangtooltipinfocollector.cpp source/clangtooltipinfocollector.h
source/clangtranslationunit.cpp source/clangtranslationunit.h
source/clangtranslationunits.cpp source/clangtranslationunits.h
source/clangtranslationunitupdater.cpp source/clangtranslationunitupdater.h
source/clangtype.cpp source/clangtype.h
source/clangunsavedfilesshallowarguments.cpp source/clangunsavedfilesshallowarguments.h
source/clangupdateannotationsjob.cpp source/clangupdateannotationsjob.h
source/clangupdateextraannotationsjob.cpp source/clangupdateextraannotationsjob.h
source/codecompleter.cpp source/codecompleter.h
source/codecompletionchunkconverter.cpp source/codecompletionchunkconverter.h
source/codecompletionsextractor.cpp source/codecompletionsextractor.h
source/commandlinearguments.cpp source/commandlinearguments.h
source/cursor.cpp source/cursor.h
source/diagnostic.cpp source/diagnostic.h
source/diagnosticset.cpp source/diagnosticset.h
source/diagnosticsetiterator.h
source/fixit.cpp source/fixit.h
source/fulltokeninfo.cpp source/fulltokeninfo.h
source/skippedsourceranges.cpp source/skippedsourceranges.h
source/sourcelocation.cpp source/sourcelocation.h
source/sourcerange.cpp source/sourcerange.h
source/token.cpp source/token.h
source/tokeninfo.cpp source/tokeninfo.h
source/tokenprocessor.h
source/tokenprocessoriterator.h
source/unsavedfile.cpp source/unsavedfile.h
source/unsavedfiles.cpp source/unsavedfiles.h
source/utf8positionfromlinecolumn.cpp source/utf8positionfromlinecolumn.h
)

View File

@@ -0,0 +1,66 @@
add_qtc_library(clangbackend_lib STATIC
DEPENDS libclang Sqlite ClangSupport
DEFINES CLANGSUPPORT_BUILD_LIB
PUBLIC_INCLUDES
${CLANG_INCLUDE_DIRS}
SOURCES
clangasyncjob.h
clangbackend_global.h
clangclock.h
clangcodecompleteresults.cpp clangcodecompleteresults.h
clangcodemodelserver.cpp clangcodemodelserver.h
clangcompletecodejob.cpp clangcompletecodejob.h
clangdocument.cpp clangdocument.h
clangdocumentjob.h
clangdocumentprocessor.cpp clangdocumentprocessor.h
clangdocumentprocessors.cpp clangdocumentprocessors.h
clangdocuments.cpp clangdocuments.h
clangdocumentsuspenderresumer.cpp clangdocumentsuspenderresumer.h
clangexceptions.cpp clangexceptions.h
clangfilepath.cpp clangfilepath.h
clangfilesystemwatcher.cpp clangfilesystemwatcher.h
clangfollowsymbol.cpp clangfollowsymbol.h
clangfollowsymboljob.cpp clangfollowsymboljob.h
clangiasyncjob.cpp clangiasyncjob.h
clangjobcontext.cpp clangjobcontext.h
clangjobqueue.cpp clangjobqueue.h
clangjobrequest.cpp clangjobrequest.h
clangjobs.cpp clangjobs.h
clangparsesupportivetranslationunitjob.cpp clangparsesupportivetranslationunitjob.h
clangreferencescollector.cpp clangreferencescollector.h
clangrequestannotationsjob.cpp clangrequestannotationsjob.h
clangrequestreferencesjob.cpp clangrequestreferencesjob.h
clangrequesttooltipjob.cpp clangrequesttooltipjob.h
clangresumedocumentjob.cpp clangresumedocumentjob.h
clangstring.h
clangsupportivetranslationunitinitializer.cpp clangsupportivetranslationunitinitializer.h
clangsuspenddocumentjob.cpp clangsuspenddocumentjob.h
clangtooltipinfocollector.cpp clangtooltipinfocollector.h
clangtranslationunit.cpp clangtranslationunit.h
clangtranslationunits.cpp clangtranslationunits.h
clangtranslationunitupdater.cpp clangtranslationunitupdater.h
clangtype.cpp clangtype.h
clangunsavedfilesshallowarguments.cpp clangunsavedfilesshallowarguments.h
clangupdateannotationsjob.cpp clangupdateannotationsjob.h
clangupdateextraannotationsjob.cpp clangupdateextraannotationsjob.h
codecompleter.cpp codecompleter.h
codecompletionchunkconverter.cpp codecompletionchunkconverter.h
codecompletionsextractor.cpp codecompletionsextractor.h
commandlinearguments.cpp commandlinearguments.h
cursor.cpp cursor.h
diagnostic.cpp diagnostic.h
diagnosticset.cpp diagnosticset.h
diagnosticsetiterator.h
fixit.cpp fixit.h
fulltokeninfo.cpp fulltokeninfo.h
skippedsourceranges.cpp skippedsourceranges.h
sourcelocation.cpp sourcelocation.h
sourcerange.cpp sourcerange.h
token.cpp token.h
tokeninfo.cpp tokeninfo.h
tokenprocessor.h
tokenprocessoriterator.h
unsavedfile.cpp unsavedfile.h
unsavedfiles.cpp unsavedfiles.h
utf8positionfromlinecolumn.cpp utf8positionfromlinecolumn.h
)

View File

@@ -0,0 +1,9 @@
add_subdirectory(source)
add_qtc_executable(clangpchmanagerbackend
DEPENDS
clangrefactoringbackend_lib clangpchmanagerbackend_lib
clangTooling libclang Sqlite ClangSupport clangToolingRefactor clangQuery clangIndex
SOURCES
clangpchmanagerbackendmain.cpp
)

View File

@@ -0,0 +1,49 @@
add_qtc_library(clangpchmanagerbackend_lib STATIC
DEPENDS clangrefactoringbackend_lib ClangSupport
PUBLIC_DEPENDS libclang
DEFINES CLANGSUPPORT_BUILD_LIB
PUBLIC_INCLUDES
${CLANG_INCLUDE_DIRS}
SOURCES
builddependenciesprovider.cpp builddependenciesprovider.h
builddependenciesproviderinterface.h
builddependenciesstorage.h
builddependenciesstorageinterface.h
builddependency.h
builddependencycollector.cpp builddependencycollector.h
builddependencygeneratorinterface.h
clangpchmanagerbackend_global.h
collectbuilddependencyaction.h
collectbuilddependencypreprocessorcallbacks.h
collectbuilddependencytoolaction.h
collectusedmacroactionfactory.h
collectusedmacrosaction.h
collectusedmacrosandsourcespreprocessorcallbacks.h
generatepchactionfactory.h
pchcreator.cpp pchcreator.h
pchcreatorinterface.h
pchmanagerserver.cpp pchmanagerserver.h
pchnotcreatederror.h
pchtask.h
pchtaskgenerator.cpp pchtaskgenerator.h
pchtaskgeneratorinterface.h
pchtaskqueue.cpp
pchtaskqueue.h
pchtaskqueueinterface.h
pchtasksmerger.cpp
pchtasksmerger.h
pchtasksmergerinterface.h
precompiledheaderstorage.h
precompiledheaderstorageinterface.h
processorinterface.h
processormanager.h
processormanagerinterface.h
projectpartsmanager.cpp projectpartsmanager.h
projectpartsmanagerinterface.h
queueinterface.h
taskscheduler.h
taskschedulerinterface.h
toolchainargumentscache.h
usedmacrofilter.h
usedmacrosandsourcescollector.cpp usedmacrosandsourcescollector.h
)

View File

@@ -1,18 +1,9 @@
add_subdirectory(source)
add_qtc_executable(clangrefactoringbackend
DEPENDS clangbackendipc
INCLUDES source
DEPENDS
clangrefactoringbackend_lib Sqlite ClangSupport
libclang clangTooling clangIndex clangQuery clangToolingRefactor
SOURCES
clangrefactoringbackendmain.cpp
source/clangquery.cpp source/clangquery.h
source/clangrefactoringbackend_global.h
source/clangtool.cpp source/clangtool.h
source/findcursorusr.h
source/findlocationsofusrs.h
source/findusrforcursoraction.cpp source/findusrforcursoraction.h
source/macropreprocessorcallbacks.cpp source/macropreprocessorcallbacks.h
source/refactoringcompilationdatabase.cpp source/refactoringcompilationdatabase.h
source/refactoringserver.cpp source/refactoringserver.h
source/sourcelocationsutils.h
source/symbolfinder.cpp source/symbolfinder.h
source/symbollocationfinderaction.cpp source/symbollocationfinderaction.h
)

View File

@@ -0,0 +1,47 @@
add_qtc_library(clangrefactoringbackend_lib STATIC
DEPENDS libclang clangTooling clangIndex clangQuery ClangSupport
DEFINES CLANGSUPPORT_BUILD_LIB
PUBLIC_INCLUDES
${CLANG_INCLUDE_DIRS}
"../../clangpchmanagerbackend/source"
SOURCES
clangquery.cpp clangquery.h
clangquerygatherer.cpp clangquerygatherer.h
clangrefactoringbackend_global.h
clangtool.cpp clangtool.h
collectmacrospreprocessorcallbacks.h
collectmacrossourcefilecallbacks.cpp collectmacrossourcefilecallbacks.h
collectsymbolsaction.cpp collectsymbolsaction.h
filestatus.h
filestatuscache.cpp filestatuscache.h
findcursorusr.h
findlocationsofusrs.h
findusrforcursoraction.cpp findusrforcursoraction.h
indexdataconsumer.cpp indexdataconsumer.h
locationsourcefilecallbacks.cpp locationsourcefilecallbacks.h
macropreprocessorcallbacks.cpp macropreprocessorcallbacks.h
projectpartentry.h
refactoringcompilationdatabase.cpp refactoringcompilationdatabase.h
refactoringserver.cpp refactoringserver.h
sourcedependency.h
sourcelocationentry.h
sourcelocationsutils.h
sourcerangeextractor.cpp sourcerangeextractor.h
sourcerangefilter.cpp sourcerangefilter.h
sourcesmanager.h
symbolentry.h
symbolfinder.cpp symbolfinder.h
symbolindexer.cpp symbolindexer.h
symbolindexertask.h
symbolindexertaskqueue.h
symbolindexertaskqueueinterface.h
symbolindexing.cpp symbolindexing.h
symbolindexinginterface.h
symbollocationfinderaction.cpp symbollocationfinderaction.h
symbolscollector.cpp symbolscollector.h
symbolscollectorinterface.h
symbolstorage.h
symbolstorageinterface.h
symbolsvisitorbase.h
usedmacro.h
)

View File

@@ -1,4 +1,4 @@
add_subdirectory(auto)
# add_subdirectory(manual)
# add_subdirectory(tools)
# add_subdirectory(unit)
add_subdirectory(unit)

View File

@@ -0,0 +1,2 @@
add_subdirectory(echoserver)
add_subdirectory(unittest)

View File

@@ -0,0 +1,7 @@
add_qtc_executable(echo
DEPENDS Qt5::Core Qt5::Network ClangSupport
DEFINES CLANGSUPPORT_TESTS DONT_CHECK_MESSAGE_COUNTER
SOURCES
echoclangcodemodelserver.cpp echoclangcodemodelserver.h
echoserverprocessmain.cpp
)

View File

@@ -0,0 +1,413 @@
find_package(Googletest MODULE)
find_package(GoogleBenchmark MODULE)
if (NOT Googletest_FOUND)
message(STATUS "Googletest was not found. Please set GOOGLETEST_DIR (CMake or Environment) variable.")
message(STATUS "Have a look at cmake/FindGoogletest.cmake file for more details.")
message(STATUS "unittest module will be skipped.")
return()
endif()
add_qtc_test(unittest GTEST
INCLUDES
BEFORE "../mockup"
DEPENDS
Qt5::Core Qt5::Network Qt5::Widgets
Qt5::Xml Qt5::Concurrent Qt5::Qml Qt5::Gui
Googletest
clangrefactoringbackend_lib clangbackend_lib clangpchmanagerbackend_lib
CPlusPlus Sqlite Utils
DEFINES
QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII
QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION
UNIT_TESTS
DONT_CHECK_MESSAGE_COUNTER
QTC_RESOURCE_DIR="${CMAKE_SOURCE_DIR}/share/qtcreator"
TESTDATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data"
ECHOSERVER="$<TARGET_FILE_DIR:echo>/echo"
CPPTOOLS_JSON="${CMAKE_CURRENT_BINARY_DIR}/CppTools.json"
SOURCES
builddependenciesprovider-test.cpp
builddependenciesstorage-test.cpp
changedfilepathcompressor-test.cpp
clangpathwatcher-test.cpp
clangqueryexamplehighlightmarker-test.cpp
clangqueryhighlightmarker-test.cpp
clientserverinprocess-test.cpp
clientserveroutsideprocess-test.cpp
commandlinebuilder-test.cpp
compare-operators.h
compilationdatabaseutils-test.cpp
compileroptionsbuilder-test.cpp
conditionally-disabled-tests.h
cppprojectfilecategorizer-test.cpp
cppprojectinfogenerator-test.cpp
cppprojectpartchooser-test.cpp
dummyclangipcclient.h
dynamicastmatcherdiagnosticcontainer-matcher.h
eventspy.cpp eventspy.h
fakeprocess.cpp fakeprocess.h
filepathcache-test.cpp
filepathstoragesqlitestatementfactory-test.cpp
filepathstorage-test.cpp
filepath-test.cpp
filepathview-test.cpp
filestatuscache-test.cpp
filesystem-utilities.h
generatedfiles-test.cpp
googletest.h
google-using-declarations.h
gtest-creator-printing.cpp gtest-creator-printing.h
gtest-llvm-printing.h
gtest-qt-printing.cpp gtest-qt-printing.h
headerpathfilter-test.cpp
highlightingresultreporter-test.cpp
lineprefixer-test.cpp
locatorfilter-test.cpp
matchingtext-test.cpp
mimedatabase-utilities.cpp mimedatabase-utilities.h
mockbuilddependenciesprovider.h
mockbuilddependenciesstorage.h
mockbuilddependencygenerator.h
mockclangcodemodelclient.h
mockclangcodemodelserver.h
mockclangpathwatcher.h
mockclangpathwatchernotifier.h
mockcppmodelmanager.h
mockeditormanager.h
mockfilepathcaching.h
mockfilepathstorage.h
mockfutureinterface.h
mockgeneratedfiles.h
mockmodifiedtimechecker.h
mockmutex.h
mockpchcreator.h
mockpchmanagerclient.h
mockpchmanagernotifier.h
mockpchmanagerserver.h
mockpchtaskgenerator.h
mockpchtaskqueue.h
mockpchtasksmerger.h
mockprecompiledheaderstorage.h
mockprocessor.h
mockprocessormanager.h
mockprogressmanager.h
mockprojectpartprovider.h
mockprojectpartqueue.h
mockprojectpartsmanager.h
mockprojectpartsstorage.h
mockqfilesystemwatcher.h
mockqueue.h
mocksearch.h
mocksearchhandle.h
mocksearchresult.h
mocksqlitedatabase.h
mocksqlitereadstatement.cpp
mocksqlitereadstatement.h
mocksqlitestatement.h
mocksqlitetransactionbackend.h
mocksqlitewritestatement.h
mocksymbolindexertaskqueue.h
mocksymbolindexing.h
mocksymbolquery.h
mocksymbolscollector.h
mocksymbolstorage.h
mocksyntaxhighligher.h
mocktaskscheduler.h
mocktimer.cpp mocktimer.h
modifiedtimechecker-test.cpp
nativefilepath-test.cpp
nativefilepathview-test.cpp
pchmanagerclientserverinprocess-test.cpp
pchmanagerclient-test.cpp
pchmanagerserver-test.cpp
pchtaskgenerator-test.cpp
pchtaskqueue-test.cpp
pchtasksmerger-test.cpp
precompiledheaderstorage-test.cpp
processcreator-test.cpp
processevents-utilities.cpp processevents-utilities.h
processormanager-test.cpp
progresscounter-test.cpp
projectpartartefact-test.cpp
projectpartsmanager-test.cpp
projectpartsstorage-test.cpp
projectupdater-test.cpp
readandwritemessageblock-test.cpp
refactoringdatabaseinitializer-test.cpp
refactoringprojectupdater-test.cpp
rundocumentparse-utility.h
sizedarray-test.cpp
smallstring-test.cpp
sourcerangecontainer-matcher.h
sourcerangefilter-test.cpp
sourcesmanager-test.cpp
spydummy.cpp spydummy.h
sqliteindex-test.cpp
sqliteteststatement.h
sqlitetransaction-test.cpp
stringcache-test.cpp
symbolindexertaskqueue-test.cpp
symbolindexer-test.cpp
symbolquery-test.cpp
symbolsfindfilter-test.cpp
symbolstorage-test.cpp
taskscheduler-test.cpp
testenvironment.h
tokenprocessor-test.cpp
toolchainargumentscache-test.cpp
unittests-main.cpp
unittest-utility-functions.h
usedmacrofilter-test.cpp
utf8-test.cpp
)
# Do not work on the source directory data
add_custom_command(TARGET unittest POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/data"
"${CMAKE_CURRENT_BINARY_DIR}/data"
)
# create fake CppTools.json for the mime type definitions
file(READ "${CMAKE_SOURCE_DIR}/src/plugins/cpptools/CppTools.json.in" plugin_json_in)
string(REPLACE "\\\"" "\"" plugin_json_in ${plugin_json_in})
string(REPLACE "\\'" "'" plugin_json_in ${plugin_json_in})
string(REPLACE "$$QTCREATOR_VERSION" "${IDE_VERSION}" plugin_json_in ${plugin_json_in})
string(REPLACE "$$QTCREATOR_COMPAT_VERSION" "${IDE_VERSION_COMPAT}" plugin_json_in ${plugin_json_in})
string(REPLACE "$$QTCREATOR_COPYRIGHT_YEAR" "${IDE_COPYRIGHT_YEAR}" plugin_json_in ${plugin_json_in})
string(REPLACE "$$dependencyList" "\"Dependencies\" : []" plugin_json_in ${plugin_json_in})
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CppTools.json" ${plugin_json_in}})
if (TARGET libclang)
target_sources(unittest PRIVATE
activationsequencecontextprocessor-test.cpp
activationsequenceprocessor-test.cpp
chunksreportedmonitor.cpp
clangasyncjob-base.cpp
clangcodecompleteresults-test.cpp
clangcodemodelserver-test.cpp
clangcompletecodejob-test.cpp
clangcompletioncontextanalyzer-test.cpp
clangdiagnosticfilter-test.cpp
clangdocumentprocessors-test.cpp
clangdocumentprocessor-test.cpp
clangdocuments-test.cpp
clangdocumentsuspenderresumer-test.cpp
clangdocument-test.cpp
clangfixitoperation-test.cpp
clangfollowsymbol-test.cpp
clangisdiagnosticrelatedtolocation-test.cpp
clangjobqueue-test.cpp
clangjobs-test.cpp
clangparsesupportivetranslationunitjob-test.cpp
clangreferencescollector-test.cpp
clangrequestannotationsjob-test.cpp
clangrequestreferencesjob-test.cpp
clangresumedocumentjob-test.cpp
clangstring-test.cpp
clangsupportivetranslationunitinitializer-test.cpp
clangsuspenddocumentjob-test.cpp
clangtooltipinfo-test.cpp
clangtranslationunits-test.cpp
clangtranslationunit-test.cpp
clangupdateannotationsjob-test.cpp
codecompleter-test.cpp
codecompletionsextractor-test.cpp
completionchunkstotextconverter-test.cpp
createtablesqlstatementbuilder-test.cpp
cursor-test.cpp
diagnosticset-test.cpp
diagnostic-test.cpp
fixit-test.cpp
senddocumenttracker-test.cpp
skippedsourceranges-test.cpp
sourcelocation-test.cpp
sourcerange-test.cpp
sqlitecolumn-test.cpp
sqlitedatabasebackend-test.cpp
sqlitedatabase-test.cpp
sqlitestatement-test.cpp
sqlitetable-test.cpp
sqlstatementbuilder-test.cpp
token-test.cpp
translationunitupdater-test.cpp
unsavedfiles-test.cpp
unsavedfile-test.cpp
utf8positionfromlinecolumn-test.cpp
chunksreportedmonitor.h
clangasyncjob-base.h
clangcompareoperators.h
diagnosticcontainer-matcher.h
)
target_include_directories(unittest PRIVATE "${CLANG_INCLUDE_DIRS}")
target_link_libraries(unittest PRIVATE libclang)
endif()
if (TARGET clangTooling)
target_compile_definitions(unittest PRIVATE CLANG_UNIT_TESTS)
target_sources(unittest PRIVATE
gtest-llvm-printing.cpp
clangquerygatherer-test.cpp
clangqueryprojectfindfilter-test.cpp
clangquery-test.cpp
gtest-clang-printing.cpp gtest-clang-printing.h
pchcreator-test.cpp
refactoringclientserverinprocess-test.cpp
refactoringclient-test.cpp
refactoringcompilationdatabase-test.cpp
refactoringengine-test.cpp
refactoringserver-test.cpp
sourcerangeextractor-test.cpp
symbolindexing-test.cpp
symbolscollector-test.cpp
symbolfinder-test.cpp
testclangtool.cpp testclangtool.h
usedmacrocollector-test.cpp
builddependencycollector-test.cpp
mockrefactoringclient.h
mockrefactoringserver.h
)
target_link_libraries(unittest
PRIVATE clangTooling clangIndex clangQuery clangToolingRefactor)
endif()
if (TARGET clangFormat)
target_sources(unittest PRIVATE
clangformat-test.cpp
)
target_link_libraries(unittest PRIVATE clangFormat)
endif()
if (TARGET GoogleBenchmark)
target_sources(unittest PRIVATE
smallstring-benchmark.cpp
)
target_link_libraries(unittest PRIVATE GoogleBenchmark)
endif()
finalize_qtc_gtest(unittest)
# Path needs to be before CppTools
target_include_directories(unittest
PRIVATE
BEFORE $<TARGET_PROPERTY:clangrefactoringbackend_lib,INTERFACE_INCLUDE_DIRECTORIES>
BEFORE $<TARGET_PROPERTY:ClangRefactoring,INTERFACE_INCLUDE_DIRECTORIES>
)
get_target_property(ClangSupportSources ClangSupport SOURCES)
get_target_property(ClangSupportSourcesDir ClangSupport SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${ClangSupportSourcesDir}"
SOURCES ${ClangSupportSources}
DEFINES
$<TARGET_PROPERTY:ClangSupport,INTERFACE_COMPILE_DEFINITIONS>
CLANGSUPPORT_BUILD_LIB
INCLUDES
$<TARGET_PROPERTY:ClangSupport,INTERFACE_INCLUDE_DIRECTORIES>
)
get_target_property(ClangCodeModelSourcesDir ClangCodeModel SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${ClangCodeModelSourcesDir}"
SOURCES
clangactivationsequencecontextprocessor.cpp clangactivationsequencecontextprocessor.h
clangactivationsequenceprocessor.cpp clangactivationsequenceprocessor.h
clangcompletionchunkstotextconverter.cpp clangcompletionchunkstotextconverter.h
clangcompletioncontextanalyzer.cpp clangcompletioncontextanalyzer.h
clangdiagnosticfilter.cpp clangdiagnosticfilter.h
clangfixitoperation.cpp clangfixitoperation.h
clanghighlightingresultreporter.cpp clanghighlightingresultreporter.h
clanguiheaderondiskmanager.cpp clanguiheaderondiskmanager.h
clangisdiagnosticrelatedtolocation.h
)
get_target_property(CompilationDatabasePMSourcesDir CompilationDatabaseProjectManager SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${CompilationDatabasePMSourcesDir}"
SOURCES
compilationdatabaseutils.cpp compilationdatabaseutils.h
)
get_target_property(CoreSourcesDir Core SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${CoreSourcesDir}"
DEFINES CORE_STATIC_LIBRARY
SOURCES
coreicons.cpp coreicons.h
id.cpp id.h
find/ifindfilter.cpp find/ifindfilter.h
locator/ilocatorfilter.cpp locator/ilocatorfilter.h
)
get_target_property(CppToolsSourcesDir CppTools SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${CppToolsSourcesDir}"
DEFINES CPPTOOLS_STATIC_LIBRARY
SOURCES
cppprojectfile.cpp cppprojectfile.h
senddocumenttracker.cpp senddocumenttracker.h
projectpart.cpp projectpart.h
compileroptionsbuilder.cpp compileroptionsbuilder.h
cppprojectfilecategorizer.cpp cppprojectfilecategorizer.h
projectinfo.cpp projectinfo.h
cppprojectinfogenerator.cpp cppprojectinfogenerator.cpp
cppprojectpartchooser.cpp cppprojectpartchooser.h
headerpathfilter.cpp headerpathfilter.h
)
get_target_property(ProjectExplorerSourcesDir ProjectExplorer SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${ProjectExplorerSourcesDir}"
DEFINES PROJECTEXPLORER_STATIC_LIBRARY
SOURCES
projectmacro.cpp projectmacro.h
)
get_target_property(ClangRefactoringSourcesDir ClangRefactoring SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${ClangRefactoringSourcesDir}"
SOURCES
clangqueryexamplehighlighter.cpp clangqueryexamplehighlighter.h
clangqueryexamplehighlightmarker.h
clangqueryhighlighter.cpp clangqueryhighlighter.h
clangqueryhighlightmarker.h
clangqueryprojectsfindfilter.cpp clangqueryprojectsfindfilter.h
projectpartutilities.cpp projectpartutilities.h
refactoringclient.cpp refactoringclient.h
refactoringconnectionclient.cpp refactoringconnectionclient.h
refactoringengine.cpp refactoringengine.h
refactoringprojectupdater.cpp refactoringprojectupdater.h
searchinterface.h
searchhandle.cpp searchhandle.h
symbolsfindfilter.cpp symbolsfindfilter.h
symbolqueryinterface.h
symbol.h
projectpartproviderinterface.h
editormanagerinterface.h
locatorfilter.cpp locatorfilter.h
)
get_target_property(ClangPchManagerSourcesDir ClangPchManager SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${ClangPchManagerSourcesDir}"
DEFINES CLANGPCHMANAGER_STATIC_LIB
SOURCES
pchmanagerclient.h pchmanagerclient.cpp
pchmanagernotifierinterface.h pchmanagernotifierinterface.cpp
pchmanagerconnectionclient.h pchmanagerconnectionclient.cpp
clangpchmanager_global.h
projectupdater.h projectupdater.cpp
pchmanagerprojectupdater.h pchmanagerprojectupdater.cpp
progressmanager.h
progressmanagerinterface.h
)
get_target_property(ClangFormatSourcesDir ClangFormat SOURCES_DIR)
extend_qtc_target(unittest
SOURCES_PREFIX "${ClangFormatSourcesDir}"
DEFINES CLANGPCHMANAGER_STATIC_LIB
SOURCES
clangformatconstants.h
clangformatbaseindenter.cpp clangformatbaseindenter.h
)