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) set(IMPLICIT_DEPENDS Qt5::Test)
endif() endif()
if (BUILD_WITH_PCH)
list(APPEND IMPLICIT_DEPENDS Qt5::Core)
endif()
find_package(Qt5 find_package(Qt5
COMPONENTS Concurrent Core Gui LinguistTools Network PrintSupport Qml Quick COMPONENTS Concurrent Core Gui LinguistTools Network PrintSupport Qml Quick
QuickWidgets Sql Widgets Xml ${QT_TEST_COMPONENT} 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) "${PROJECT_SOURCE_DIR}/src/shared/qtcreator_pch.h" Qt5::Core)
endif() endif()
set(PCH_TARGET QtCreatorPchConsole) unset(PCH_TARGET)
if ("Qt5::Widgets" IN_LIST dependencies) if ("Qt5::Widgets" IN_LIST dependencies)
set(PCH_TARGET QtCreatorPchGui) set(PCH_TARGET QtCreatorPchGui)
elseif ("Qt5::Core" IN_LIST dependencies)
set(PCH_TARGET QtCreatorPchConsole)
endif() endif()
if (TARGET ${PCH_TARGET}) if (TARGET "${PCH_TARGET}")
set_target_properties(${target} PROPERTIES set_target_properties(${target} PROPERTIES
PRECOMPILE_HEADERS_REUSE_FROM ${PCH_TARGET}) PRECOMPILE_HEADERS_REUSE_FROM ${PCH_TARGET})
endif() endif()
@@ -364,7 +366,7 @@ endfunction()
# #
function(add_qtc_library name) 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} "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) set(library_type OBJECT)
endif() endif()
set(_exclude_from_all EXCLUDE_FROM_ALL)
if (_arg_BUILD_BY_DEFAULT)
unset(_exclude_from_all)
endif()
# Do not just build libraries... # 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}) add_library(${IDE_CASED_ID}::${name} ALIAS ${name})
set_public_headers(${name} "${_arg_SOURCES}") set_public_headers(${name} "${_arg_SOURCES}")
@@ -432,6 +439,11 @@ function(add_qtc_library name)
set(skip_translation ON) set(skip_translation ON)
endif() endif()
set(_DESTINATION "${IDE_BIN_PATH}")
if (_arg_DESTINATION)
set(_DESTINATION "${_arg_DESTINATION}")
endif()
qtc_output_binary_dir(_output_binary_dir) qtc_output_binary_dir(_output_binary_dir)
set_target_properties(${name} PROPERTIES set_target_properties(${name} PROPERTIES
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}" SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
@@ -440,7 +452,7 @@ function(add_qtc_library name)
VISIBILITY_INLINES_HIDDEN ON VISIBILITY_INLINES_HIDDEN ON
BUILD_RPATH "${_LIB_RPATH}" BUILD_RPATH "${_LIB_RPATH}"
INSTALL_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}" LIBRARY_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_PATH}"
ARCHIVE_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_PATH}" ARCHIVE_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_PATH}"
${_arg_PROPERTIES} ${_arg_PROPERTIES}
@@ -454,7 +466,7 @@ function(add_qtc_library name)
install(TARGETS ${name} install(TARGETS ${name}
EXPORT ${IDE_CASED_ID} EXPORT ${IDE_CASED_ID}
RUNTIME DESTINATION "${IDE_BIN_PATH}" RUNTIME DESTINATION "${_DESTINATION}"
LIBRARY LIBRARY
DESTINATION "${IDE_LIBRARY_PATH}" DESTINATION "${IDE_LIBRARY_PATH}"
${NAMELINK_OPTION} ${NAMELINK_OPTION}

View File

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

View File

@@ -1,29 +1,41 @@
#todo if (NOT WIN32 AND NOT MSVC)
# - handle if there is no debug python lib python35_d
# - needs to be tested
if (MINGW)
message(STATUS "MinGW detected. Removing qtcreatorcdbext from build.")
return() return()
endif() endif()
include(CheckIncludeFile) find_path(WDbgExtsPath wdbgexts.h
check_include_file(wdbgexts.h HAVE_WDBGEXTS_H) HINTS
if (NOT HAVE_WDBGEXTS_H) "$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.") message(WARNING "wdbgexts.h not found. Removing qtcreatorcdbext from build.")
return() return()
endif() endif()
find_package(PythonLibs 3.5) find_library(DbgEngLib dbgeng HINTS ${WDbgExtsPath})
if (NOT ${PYTHONLIBS_FOUND})
message(WARNING "PythonLibs 3.5 not found. Removing qtcreatorcdbext from build.") set(ArchSuffix 32)
return() if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ArchSuffix 64)
endif() endif()
add_qtc_library(qtcreatorcdbext add_qtc_library(qtcreatorcdbext
DEPENDS ${PYTHON_LIBRARIES} BUILD_BY_DEFAULT
INCLUDES ${PYTHON_INCLUDE_DIR} DEPENDS ${DbgEngLib}
DEFINES WITH_PYTHON=1 DESTINATION lib/qtcreatorcdbext${ArchSuffix}/
SOURCES SOURCES
common.cpp common.h common.cpp common.h
containers.cpp containers.h containers.cpp containers.h
@@ -33,14 +45,47 @@ add_qtc_library(qtcreatorcdbext
iinterfacepointer.h iinterfacepointer.h
knowntype.h knowntype.h
outputcallback.cpp outputcallback.h outputcallback.cpp outputcallback.h
pycdbextmodule.cpp pycdbextmodule.h qtcreatorcdbext.def
pyfield.cpp pyfield.h
pystdoutredirect.cpp pystdoutredirect.h
pytype.cpp pytype.h
pyvalue.cpp pyvalue.h
qtcreatorcdbextension.cpp qtcreatorcdbextension.cpp
stringutils.cpp stringutils.h stringutils.cpp stringutils.h
symbolgroup.cpp symbolgroup.h symbolgroup.cpp symbolgroup.h
symbolgroupnode.cpp symbolgroupnode.h symbolgroupnode.cpp symbolgroupnode.h
symbolgroupvalue.cpp symbolgroupvalue.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
)