CMake Build: Properly build qtcreatorcdbext

Change-Id: I8b4a58d79124debd877442fe23798c77bff723c5
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2019-09-27 22:52:15 +02:00
parent a19d905ea5
commit 87023db572
4 changed files with 85 additions and 34 deletions

View File

@@ -34,10 +34,6 @@ if (WITH_TESTS)
set(IMPLICIT_DEPENDS Qt5::Test)
endif()
if (BUILD_WITH_PCH)
list(APPEND IMPLICIT_DEPENDS Qt5::Core)
endif()
find_package(Qt5
COMPONENTS Concurrent Core Gui LinguistTools Network PrintSupport Qml Quick
QuickWidgets Sql Widgets Xml ${QT_TEST_COMPONENT}

View File

@@ -329,12 +329,14 @@ function(enable_pch target)
"${PROJECT_SOURCE_DIR}/src/shared/qtcreator_pch.h" Qt5::Core)
endif()
set(PCH_TARGET QtCreatorPchConsole)
unset(PCH_TARGET)
if ("Qt5::Widgets" IN_LIST dependencies)
set(PCH_TARGET QtCreatorPchGui)
elseif ("Qt5::Core" IN_LIST dependencies)
set(PCH_TARGET QtCreatorPchConsole)
endif()
if (TARGET ${PCH_TARGET})
if (TARGET "${PCH_TARGET}")
set_target_properties(${target} PROPERTIES
PRECOMPILE_HEADERS_REUSE_FROM ${PCH_TARGET})
endif()
@@ -364,7 +366,7 @@ endfunction()
#
function(add_qtc_library name)
cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION" ""
cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;BUILD_BY_DEFAULT" "DESTINATION"
"DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;PUBLIC_DEFINES;PUBLIC_DEPENDS;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;PROPERTIES" ${ARGN}
)
@@ -384,8 +386,13 @@ function(add_qtc_library name)
set(library_type OBJECT)
endif()
set(_exclude_from_all EXCLUDE_FROM_ALL)
if (_arg_BUILD_BY_DEFAULT)
unset(_exclude_from_all)
endif()
# Do not just build libraries...
add_library(${name} ${library_type} EXCLUDE_FROM_ALL ${_arg_SOURCES})
add_library(${name} ${library_type} ${_exclude_from_all} ${_arg_SOURCES})
add_library(${IDE_CASED_ID}::${name} ALIAS ${name})
set_public_headers(${name} "${_arg_SOURCES}")
@@ -432,6 +439,11 @@ function(add_qtc_library name)
set(skip_translation ON)
endif()
set(_DESTINATION "${IDE_BIN_PATH}")
if (_arg_DESTINATION)
set(_DESTINATION "${_arg_DESTINATION}")
endif()
qtc_output_binary_dir(_output_binary_dir)
set_target_properties(${name} PROPERTIES
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
@@ -440,7 +452,7 @@ function(add_qtc_library name)
VISIBILITY_INLINES_HIDDEN ON
BUILD_RPATH "${_LIB_RPATH}"
INSTALL_RPATH "${_LIB_RPATH}"
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_BIN_PATH}"
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${_DESTINATION}"
LIBRARY_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_PATH}"
ARCHIVE_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_PATH}"
${_arg_PROPERTIES}
@@ -454,7 +466,7 @@ function(add_qtc_library name)
install(TARGETS ${name}
EXPORT ${IDE_CASED_ID}
RUNTIME DESTINATION "${IDE_BIN_PATH}"
RUNTIME DESTINATION "${_DESTINATION}"
LIBRARY
DESTINATION "${IDE_LIBRARY_PATH}"
${NAMELINK_OPTION}

View File

@@ -16,6 +16,4 @@ add_subdirectory(sqlite)
add_subdirectory(clangsupport)
add_subdirectory(tracing)
if (WIN32)
add_subdirectory(qtcreatorcdbext)
endif()
add_subdirectory(qtcreatorcdbext)

View File

@@ -1,29 +1,41 @@
#todo
# - handle if there is no debug python lib python35_d
# - needs to be tested
if (MINGW)
message(STATUS "MinGW detected. Removing qtcreatorcdbext from build.")
if (NOT WIN32 AND NOT MSVC)
return()
endif()
include(CheckIncludeFile)
check_include_file(wdbgexts.h HAVE_WDBGEXTS_H)
if (NOT HAVE_WDBGEXTS_H)
find_path(WDbgExtsPath wdbgexts.h
HINTS
"$ENV{CDB_PATH}"
"$ENV{ProgramFiles}/Debugging Tools For Windows/sdk"
"$ENV{ProgramFiles}/Debugging Tools For Windows (x86)/sdk"
"$ENV{ProgramFiles}/Debugging Tools For Windows (x64)/sdk"
"$ENV{ProgramFiles}/Debugging Tools For Windows 64-bit/sdk"
"$ENV{ProgramW6432}/Debugging Tools For Windows (x86)/sdk"
"$ENV{ProgramW6432}/Debugging Tools For Windows (x64)/sdk"
"$ENV{ProgramW6432}/Debugging Tools For Windows 64-bit/sdk"
"$ENV{ProgramFiles}/Windows Kits/8.0/Debuggers"
"$ENV{ProgramFiles}/Windows Kits/8.1/Debuggers"
"$ENV{ProgramFiles}/Windows Kits/10/Debuggers"
"$ENV{ProgramFiles\(x86\)}/Windows Kits/8.0/Debuggers/inc"
"$ENV{ProgramFiles\(x86\)}/Windows Kits/8.1/Debuggers/inc"
"$ENV{ProgramFiles\(x86\)}/Windows Kits/10/Debuggers/inc"
)
if (NOT WDbgExtsPath)
message(WARNING "wdbgexts.h not found. Removing qtcreatorcdbext from build.")
return()
endif()
find_package(PythonLibs 3.5)
if (NOT ${PYTHONLIBS_FOUND})
message(WARNING "PythonLibs 3.5 not found. Removing qtcreatorcdbext from build.")
return()
find_library(DbgEngLib dbgeng HINTS ${WDbgExtsPath})
set(ArchSuffix 32)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ArchSuffix 64)
endif()
add_qtc_library(qtcreatorcdbext
DEPENDS ${PYTHON_LIBRARIES}
INCLUDES ${PYTHON_INCLUDE_DIR}
DEFINES WITH_PYTHON=1
BUILD_BY_DEFAULT
DEPENDS ${DbgEngLib}
DESTINATION lib/qtcreatorcdbext${ArchSuffix}/
SOURCES
common.cpp common.h
containers.cpp containers.h
@@ -33,14 +45,47 @@ add_qtc_library(qtcreatorcdbext
iinterfacepointer.h
knowntype.h
outputcallback.cpp outputcallback.h
pycdbextmodule.cpp pycdbextmodule.h
pyfield.cpp pyfield.h
pystdoutredirect.cpp pystdoutredirect.h
pytype.cpp pytype.h
pyvalue.cpp pyvalue.h
qtcreatorcdbext.def
qtcreatorcdbextension.cpp
stringutils.cpp stringutils.h
symbolgroup.cpp symbolgroup.h
symbolgroupnode.cpp symbolgroupnode.h
symbolgroupvalue.cpp symbolgroupvalue.h
)
find_package(PythonLibs 3.5)
if (NOT ${PYTHONLIBS_FOUND})
message(WARNING "PythonLibs (at least version 3.5) not found. qtcreatorcdbext will be built without Python support.")
return()
endif()
extend_qtc_target(qtcreatorcdbext
DEPENDS "${PYTHON_LIBRARIES}"
INCLUDES "${PYTHON_INCLUDE_DIR}"
DEFINES WITH_PYTHON=1
SOURCES
pycdbextmodule.cpp pycdbextmodule.h
pyfield.cpp pyfield.h
pystdoutredirect.cpp pystdoutredirect.h
pytype.cpp pytype.h
pyvalue.cpp pyvalue.h
)
set(PythonRegex "^(.*)/(.*)/(python[0-9]+)${CMAKE_IMPORT_LIBRARY_SUFFIX}$")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PythonRegex "^(.*)/(.*)/(python[0-9]+_d)${CMAKE_IMPORT_LIBRARY_SUFFIX}$")
endif()
foreach(lib IN LISTS PYTHON_LIBRARIES)
if (lib MATCHES ${PythonRegex})
set(PythonDll "${CMAKE_MATCH_1}/${CMAKE_MATCH_3}${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
endforeach()
install(FILES "${PythonDll}" DESTINATION lib/qtcreatorcdbext${ArchSuffix}/)
add_custom_target(copy_python_dll ALL VERBATIM)
add_custom_command(TARGET copy_python_dll POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "${PythonDll}" "${PROJECT_BINARY_DIR}/lib/qtcreatorcdbext${ArchSuffix}/"
VERBATIM
)