From bfe1258d1b94f2c5ef6cfdb8022818c59bd0ce30 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 10 Jul 2024 18:57:56 +0200 Subject: CMake: Bump minimum CMake version to 3.20 In order to get the policy CMP0116 set to NEW. See https://cmake.org/cmake/help/latest/policy/CMP0116.html This should prevent rebuilds due to AUTOMOC. Change-Id: I242c44b2969c6caccf61b7d5ba5c3a0335744ee7 Reviewed-by: Eike Ziller --- src/libs/qtcreatorcdbext/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libs/qtcreatorcdbext') diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index 47eca2cd163..a431f8f32a4 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.20) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake") -- cgit v1.2.3 From 4cbede6fd16791c7b7b657d318eea2defdae67ce Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Mon, 5 Aug 2024 18:09:24 +0200 Subject: qtcreatorcdbext: Build for x86, x64 and arm64 at once When the qtcreatorcdbext is opened standalone, then the build will build itself with MSBuild for x86, x64 and amr64 architectures. The architecture list can be specified with the QTCREATORCDBEXT_BUILD_ARCHS (arm64 win32 x64) CMake parameter. Task-number: QTCREATORBUG-31345 Change-Id: I6174e005d0664f444eacd8f7544edf49af5639e9 Reviewed-by: David Schulz --- src/libs/qtcreatorcdbext/CMakeLists.txt | 66 +++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) (limited to 'src/libs/qtcreatorcdbext') diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index 47eca2cd163..bdda6a1f78f 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -13,14 +13,55 @@ if (NOT QT_CREATOR_API_DEFINED) include(QtCreatorIDEBranding) include(QtCreatorAPI) qtc_handle_compiler_cache_support() + + # Compile for x86, x64 and arm64 + if (NOT ${PROJECT_NAME}-MultiBuild AND NOT MINGW) + include(ExternalProject) + + set(generator "Visual Studio 16 2019") + if(CMAKE_CXX_COMPILER MATCHES "Microsoft Visual Studio/2022/") + set(generator "Visual Studio 17 2022") + endif() + + macro (setup_library arch) + ExternalProject_Add(${arch}-bld + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" + CMAKE_GENERATOR "${generator}" + CMAKE_GENERATOR_PLATFORM "${arch}" + CMAKE_ARGS + -D${PROJECT_NAME}-MultiBuild=ON + BUILD_COMMAND + ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} + INSTALL_COMMAND + ${CMAKE_COMMAND} --install . --config ${CMAKE_BUILD_TYPE} + --prefix "${CMAKE_BINARY_DIR}" --component qtcreatorcdbext + ) + endmacro() + + if (NOT QTCREATORCDBEXT_BUILD_ARCHS) + set(QTCREATORCDBEXT_BUILD_ARCHS arm64 win32 x64) + endif() + foreach(arch IN LISTS QTCREATORCDBEXT_BUILD_ARCHS) + setup_library(${arch}) + endforeach() + + list(LENGTH QTCREATORCDBEXT_BUILD_ARCHS build_archs_length) + if (build_archs_length GREATER 0) + install( + DIRECTORY "${CMAKE_BINARY_DIR}/lib" + DESTINATION . + COMPONENT qtcreatorcdbext + ) + endif() + + return() + endif() endif() if (NOT WIN32 OR NOT MSVC) return() endif() -find_library(DbgEngLib dbgeng) - set(ArchSuffix "32") if (CMAKE_SIZEOF_VOID_P EQUAL 8) set(ArchSuffix "64") @@ -30,9 +71,13 @@ if (MSVC_CXX_ARCHITECTURE_ID MATCHES "^ARM") set(ArchSuffix "arm${ArchSuffix}") endif() +if (NOT EXISTS "${CMAKE_BINARY_DIR}/lib/qtcreatorcdbext${ArchSuffix}") + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/qtcreatorcdbext${ArchSuffix}") +endif() + add_qtc_library(qtcreatorcdbext SHARED COMPONENT qtcreatorcdbext - DEPENDS ${DbgEngLib} + DEPENDS dbgeng DESTINATION lib/qtcreatorcdbext${ArchSuffix}/ SOURCES common.cpp common.h @@ -95,18 +140,25 @@ if (_library_enabled) endif() # Support for cross-compilation for arm64 on a x64 system - if (MSVC_CXX_ARCHITECTURE_ID MATCHES "^ARM" AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^AMD") + if (NOT MSVC_CXX_ARCHITECTURE_ID STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR) find_program(dumpbin_executable dumpbin) find_program(lib_executable lib) string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} lower_arch_name) + if (lower_arch_name STREQUAL "arm64") + set(python_suffix "arm64") + elseif (lower_arch_name STREQUAL "x64") + set(python_suffix "amd64") + else() + set(python_suffix "win32") + endif() if (NOT dumpbin_executable OR NOT lib_executable) message(WARNING "Couldn't locate dumpbin.exe or lib.exe executables") return() endif() - if (Python3_VERSION VERSION_LESS "3.11.0") + if (Python3_VERSION VERSION_LESS "3.11.0" AND lower_arch_name STREQUAL "arm64") message(WARNING "Python 3.11.0 needs to be installed. This version is the first version that has arm64 Windows support") return() endif() @@ -129,7 +181,7 @@ if (_library_enabled) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PythonNameWithVersion}.def "${pythondef}") execute_process( - COMMAND ${lib_executable} + COMMAND "${lib_executable}" /def:${CMAKE_CURRENT_BINARY_DIR}/${PythonNameWithVersion}.def /out:${CMAKE_CURRENT_BINARY_DIR}/${PythonNameWithVersion}.lib /machine:${lower_arch_name} /nologo) set(Python3_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/${PythonNameWithVersion}.lib") @@ -139,7 +191,7 @@ if (_library_enabled) endif() if (NOT PythonTargetArchDll) - set(python_embed_url "https://www.python.org/ftp/python/${Python3_VERSION}/python-${Python3_VERSION}-embed-${lower_arch_name}.zip") + set(python_embed_url "https://www.python.org/ftp/python/${Python3_VERSION}/python-${Python3_VERSION}-embed-${python_suffix}.zip") message(STATUS "Downloading ${python_embed_url}") foreach(retry RANGE 10) -- cgit v1.2.3 From 2568988dab15402668351f69c9bf0067b53937f7 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 23 Aug 2024 12:41:38 +0200 Subject: qtcreatorcdbext: Improve cross-compilation check It was failing on x64 since the values are x64 and AMD64 and were failing the check. Arm has both values ARM64. Change-Id: I404b85d9c499464797ece912ee5b83f93c21d04d Reviewed-by: David Schulz --- src/libs/qtcreatorcdbext/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/libs/qtcreatorcdbext') diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index bdda6a1f78f..b1d77c6c218 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -140,7 +140,14 @@ if (_library_enabled) endif() # Support for cross-compilation for arm64 on a x64 system - if (NOT MSVC_CXX_ARCHITECTURE_ID STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR) + if (MSVC_CXX_ARCHITECTURE_ID STREQUAL "ARM64" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "ARM64") + set(arm64_on_arm64 ON) + endif() + if (MSVC_CXX_ARCHITECTURE_ID STREQUAL "x64" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64") + set(x64_on_x64 ON) + endif() + + if (NOT arm64_on_arm64 AND NOT x64_on_x64) find_program(dumpbin_executable dumpbin) find_program(lib_executable lib) -- cgit v1.2.3 From 243a489060b1c5d4cce843282311feeb826a1665 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 28 Aug 2024 10:01:02 +0200 Subject: qtcreatorcdbext: Forward PythonTargetArchDll in multi-config In setups where no internet is available (Coin CI) we need to specify the path to the python target arch dll. This was done in single configuration mode via the CMake parameter PythonTargetArchDll. But in order to build all architectures we have now: * PythonTargetarm64Dll * PythonTargetwin32Dll * PythonTargetx64Dll And Python3_ROOT_DIR is also forwarded, in order to fix one specific host Python version. Fixes: QTCREATORBUG-31496 Change-Id: I754720f90a4b1fc7d7434ee285c7e300dd77734e Reviewed-by: Eike Ziller --- src/libs/qtcreatorcdbext/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libs/qtcreatorcdbext') diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index b1d77c6c218..9f5e3f4ef49 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -30,6 +30,8 @@ if (NOT QT_CREATOR_API_DEFINED) CMAKE_GENERATOR_PLATFORM "${arch}" CMAKE_ARGS -D${PROJECT_NAME}-MultiBuild=ON + -DPythonTargetArchDll=${PythonTarget${arch}Dll} + -DPython3_ROOT_DIR=${Python3_ROOT_DIR} BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} INSTALL_COMMAND -- cgit v1.2.3 From a99c3c88cdb685f1c2faed90e976590bc7bdde94 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 6 Sep 2024 11:44:13 +0200 Subject: Cdbext: Fix build when not passing drive letters to CMake Pass native path to Python DLL to dumpbin, because otherwise if the path doesn't contain a drive letter but starts with a / it gets confused with a command line option. Change-Id: I5ba58db0075c3463991aab973f377e7f30637400 Reviewed-by: David Schulz --- src/libs/qtcreatorcdbext/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libs/qtcreatorcdbext') diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index b62bdf9b317..bca1753476f 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -172,8 +172,9 @@ if (_library_enabled) return() endif() + file(TO_NATIVE_PATH ${PythonDll} NativePythonDll) execute_process( - COMMAND ${dumpbin_executable} /exports ${PythonDll} + COMMAND ${dumpbin_executable} /exports ${NativePythonDll} OUTPUT_VARIABLE dumpbin_output RESULT_VARIABLE dumpbin_result) -- cgit v1.2.3 From 0685a30ddee9e4c6832859d5c01d2e0c55795808 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Mon, 9 Sep 2024 11:58:23 +0200 Subject: qtcreatorcdbext: Forward CMAKE_PREFIX_PATH to the subprojects Otherwise find_package(Clang) will not find the LLVM installation and lldb.exe will not be deployed in multi-arch configurations. Change-Id: I7c067ea68cd047f45b7cca48f2d3798f04010586 Reviewed-by: Eike Ziller --- src/libs/qtcreatorcdbext/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libs/qtcreatorcdbext') diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index 9f5e3f4ef49..4e21f5ab9d4 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -23,15 +23,19 @@ if (NOT QT_CREATOR_API_DEFINED) set(generator "Visual Studio 17 2022") endif() + string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}") + macro (setup_library arch) ExternalProject_Add(${arch}-bld SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CMAKE_GENERATOR "${generator}" CMAKE_GENERATOR_PLATFORM "${arch}" + LIST_SEPARATOR | CMAKE_ARGS -D${PROJECT_NAME}-MultiBuild=ON -DPythonTargetArchDll=${PythonTarget${arch}Dll} -DPython3_ROOT_DIR=${Python3_ROOT_DIR} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP} BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} INSTALL_COMMAND @@ -54,6 +58,12 @@ if (NOT QT_CREATOR_API_DEFINED) DESTINATION . COMPONENT qtcreatorcdbext ) + install(CODE + "if (EXISTS \"${CMAKE_BINARY_DIR}/bin\") + file(COPY \"${CMAKE_BINARY_DIR}/bin\" DESTINATION \"${CMAKE_INSTALL_PREFIX}\") + endif()" + COMPONENT qtcreatorcdbext + ) endif() return() -- cgit v1.2.3 From a8f9f742c95d6489ab58c5d3d1be40d0a1b62855 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 11 Oct 2024 09:47:52 +0200 Subject: qtcreatorcdbext: Deploy LLVM only once In the multi-architecture build we don't need to copy LLVM multiple times. Otherwise it copies files from the same source to the same target multiple times in parallel, which can lead to failures. Change-Id: I7e3f478560ebbb53690cff21d85b881d047a111d Reviewed-by: David Schulz --- src/libs/qtcreatorcdbext/CMakeLists.txt | 44 ++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'src/libs/qtcreatorcdbext') diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index 98cc0c2acf6..fb405758414 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -8,6 +8,10 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +if (NOT DEFINED QTCREATORCDBEXT_INSTALL_LLVM) + set(QTCREATORCDBEXT_INSTALL_LLVM YES) # default +endif() + if (NOT QT_CREATOR_API_DEFINED) # standalone build include(QtCreatorIDEBranding) @@ -25,7 +29,7 @@ if (NOT QT_CREATOR_API_DEFINED) string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}") - macro (setup_library arch) + macro (setup_library arch install_llvm) ExternalProject_Add(${arch}-bld SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CMAKE_GENERATOR "${generator}" @@ -36,6 +40,7 @@ if (NOT QT_CREATOR_API_DEFINED) -DPythonTargetArchDll=${PythonTarget${arch}Dll} -DPython3_ROOT_DIR=${Python3_ROOT_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP} + -DQTCREATORCDBEXT_INSTALL_LLVM=${install_llvm} BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} INSTALL_COMMAND @@ -47,8 +52,10 @@ if (NOT QT_CREATOR_API_DEFINED) if (NOT QTCREATORCDBEXT_BUILD_ARCHS) set(QTCREATORCDBEXT_BUILD_ARCHS arm64 win32 x64) endif() + set(install_llvm YES) foreach(arch IN LISTS QTCREATORCDBEXT_BUILD_ARCHS) - setup_library(${arch}) + setup_library(${arch} ${install_llvm}) + set(install_llvm NO) endforeach() list(LENGTH QTCREATORCDBEXT_BUILD_ARCHS build_archs_length) @@ -60,6 +67,7 @@ if (NOT QT_CREATOR_API_DEFINED) ) install(CODE "if (EXISTS \"${CMAKE_BINARY_DIR}/bin\") + message(\"Copying ${CMAKE_BINARY_DIR}/bin to ${CMAKE_INSTALL_PREFIX}\") file(COPY \"${CMAKE_BINARY_DIR}/bin\" DESTINATION \"${CMAKE_INSTALL_PREFIX}\") endif()" COMPONENT qtcreatorcdbext @@ -274,22 +282,24 @@ if (_library_enabled) VERBATIM ) - # Deploy lldb.exe and its Python dependency - find_package(Clang QUIET) - if (LLVM_TOOLS_BINARY_DIR AND LLVM_LIBRARY_DIRS) - foreach(lldb_file lldb.exe lldb-dap.exe liblldb.dll python311.zip python311.dll) - if (EXISTS ${LLVM_TOOLS_BINARY_DIR}/${lldb_file}) - install(FILES ${LLVM_TOOLS_BINARY_DIR}/${lldb_file} - DESTINATION bin/clang/bin - COMPONENT qtcreatorcdbext) - endif() - endforeach() + if (QTCREATORCDBEXT_INSTALL_LLVM) + # Deploy lldb.exe and its Python dependency + find_package(Clang QUIET) + if (LLVM_TOOLS_BINARY_DIR AND LLVM_LIBRARY_DIRS) + foreach(lldb_file lldb.exe lldb-dap.exe liblldb.dll python311.zip python311.dll) + if (EXISTS ${LLVM_TOOLS_BINARY_DIR}/${lldb_file}) + install(FILES ${LLVM_TOOLS_BINARY_DIR}/${lldb_file} + DESTINATION bin/clang/bin + COMPONENT qtcreatorcdbext) + endif() + endforeach() - if (EXISTS ${LLVM_LIBRARY_DIRS}/site-packages) - install(DIRECTORY ${LLVM_LIBRARY_DIRS}/site-packages - DESTINATION bin/clang/lib - COMPONENT qtcreatorcdbext - PATTERN _lldb.cp311-win_amd64.pyd EXCLUDE) + if (EXISTS ${LLVM_LIBRARY_DIRS}/site-packages) + install(DIRECTORY ${LLVM_LIBRARY_DIRS}/site-packages + DESTINATION bin/clang/lib + COMPONENT qtcreatorcdbext + PATTERN _lldb.cp311-win_amd64.pyd EXCLUDE) + endif() endif() endif() -- cgit v1.2.3