forked from qt-creator/qt-creator
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 <david.schulz@qt.io>
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user