Skip to content

Bring up android+coreclr windows build. #112256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
Minimum target OS versions, keep in sync with:
- eng/native/configurecompiler.cmake
- eng/native/build-commons.sh
- eng/native/gen-buildsys.cmd
- src/native/libs/build-native.sh
- src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs
- src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
Expand Down
3 changes: 2 additions & 1 deletion eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<PropertyGroup>
<DefaultSubsets>clr+mono+libs+tools+host+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsMobile)' == 'true'">mono+libs+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsAndroid)' == 'true' and '$(CoreCLRSupported)' == 'true'">clr.runtime+clr.alljits+clr.corelib+clr.nativecorelib+clr.tools+clr.packages+mono+libs+host+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsAndroid)' == 'true' and '$(CoreCLRSupported)' == 'true'">clr+mono+libs+host+packs</DefaultSubsets>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need mono in the default subsets?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still need to build mono runtime packs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, I suppose these are use for internal builds?
Is this also part of the DotNetBuildAllRuntimePacks logic?

<DefaultSubsets Condition="'$(TargetsAppleMobile)' == 'true'">clr.nativeaotruntime+clr.nativeaotlibs+mono+libs+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsLinuxBionic)' == 'true' and '$(MonoSupported)' == 'true'">clr.nativeaotruntime+clr.nativeaotlibs+mono+libs+host+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsLinuxBionic)' == 'true' and '$(MonoSupported)' != 'true'">clr.nativeaotruntime+clr.nativeaotlibs+libs+packs</DefaultSubsets>
Expand Down Expand Up @@ -100,6 +100,7 @@
<PropertyGroup>
<DefaultCoreClrSubsets>clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools+host.native</DefaultCoreClrSubsets>
<DefaultCoreClrSubsets Condition="'$(PackageRID)' == 'linux-armel'">clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools</DefaultCoreClrSubsets>
<DefaultCoreClrSubsets Condition="'$(TargetsAndroid)' == 'true'">clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools</DefaultCoreClrSubsets>
<!-- Even on platforms that do not support the CoreCLR runtime, we still want to build ilasm/ildasm. -->
<DefaultCoreClrSubsets Condition="'$(RuntimeFlavor)' != 'CoreCLR'">clr.iltools+clr.packages</DefaultCoreClrSubsets>

Expand Down
5 changes: 1 addition & 4 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ build_native()
exit 1
fi

# cmake cache scripts can't see command line args
export ANDROID_BUILD=1

cmakeArgs="-C $__RepoRootDir/eng/native/tryrun.cmake $cmakeArgs"
cmakeArgs="-DANDROID_BUILD=1 -C $__RepoRootDir/eng/native/tryrun.cmake $cmakeArgs"
cmakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-${ANDROID_API_LEVEL} -DANDROID_NATIVE_API_LEVEL=${ANDROID_API_LEVEL} $cmakeArgs"

# Don't try to set CC/CXX in init-compiler.sh - it's handled in android.toolchain.cmake already
Expand Down
7 changes: 6 additions & 1 deletion eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ if(CLR_CMAKE_HOST_LINUX_MUSL OR CLR_CMAKE_TARGET_OS STREQUAL alpine)
set(CLR_CMAKE_TARGET_LINUX_MUSL 1)
endif(CLR_CMAKE_HOST_LINUX_MUSL OR CLR_CMAKE_TARGET_OS STREQUAL alpine)

macro(set_cache_value)
set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE)
set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE)
endmacro()

if(CLR_CMAKE_TARGET_OS STREQUAL android)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)
Expand Down Expand Up @@ -471,7 +476,7 @@ if(CLR_CMAKE_TARGET_OS STREQUAL windows)
endif()

# check if host & target os/arch combination are valid
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI)
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_ANDROID)
if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
endif()
Expand Down
15 changes: 11 additions & 4 deletions eng/native/configuretools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,17 @@ endif()

if (NOT CLR_CMAKE_HOST_WIN32)
# detect linker
execute_process(COMMAND sh -c "${CMAKE_C_COMPILER} ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version | head -1"
ERROR_QUIET
OUTPUT_VARIABLE ldVersionOutput
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
execute_process(COMMAND ${CMAKE_C_COMPILER} -Wl,--version
ERROR_QUIET
OUTPUT_VARIABLE ldVersionOutput
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
execute_process(COMMAND sh -c "${CMAKE_C_COMPILER} ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version | head -1"
ERROR_QUIET
OUTPUT_VARIABLE ldVersionOutput
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

if("${ldVersionOutput}" MATCHES "LLD")
set(LD_LLVM 1)
Expand Down
91 changes: 65 additions & 26 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -338,39 +338,66 @@ function(generate_exports_file)
list(GET INPUT_LIST -1 outputFilename)
list(REMOVE_AT INPUT_LIST -1)

if(CLR_CMAKE_TARGET_APPLE)
set(SCRIPT_NAME generateexportedsymbols.sh)
# Win32 may be false when cross compiling
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateversionscript.ps1)

add_custom_command(
OUTPUT ${outputFilename}
COMMAND powershell -NoProfile -ExecutionPolicy ByPass -File "${SCRIPT_NAME}" ${INPUT_LIST} >${outputFilename}
DEPENDS ${INPUT_LIST} ${SCRIPT_NAME}
COMMENT "Generating exports file ${outputFilename}"
)
else()
set(SCRIPT_NAME generateversionscript.sh)
if(CLR_CMAKE_TARGET_APPLE)
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateexportedsymbols.sh)
else()
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateversionscript.sh)
endif()

add_custom_command(
OUTPUT ${outputFilename}
COMMAND ${SCRIPT_NAME} ${INPUT_LIST} >${outputFilename}
DEPENDS ${INPUT_LIST} ${SCRIPT_NAME}
COMMENT "Generating exports file ${outputFilename}"
)
endif()

add_custom_command(
OUTPUT ${outputFilename}
COMMAND ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME} ${INPUT_LIST} >${outputFilename}
DEPENDS ${INPUT_LIST} ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME}
COMMENT "Generating exports file ${outputFilename}"
)
set_source_files_properties(${outputFilename}
PROPERTIES GENERATED TRUE)
endfunction()

function(generate_exports_file_prefix inputFilename outputFilename prefix)

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(SCRIPT_NAME generateexportedsymbols.sh)
else()
set(SCRIPT_NAME generateversionscript.sh)
# Win32 may be false when cross compiling
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateversionscript.ps1)
else()
set(SCRIPT_NAME ${CLR_ENG_NATIVE_DIR}/generateversionscript.sh)
endif()

if (NOT ${prefix} STREQUAL "")
set(EXTRA_ARGS ${prefix})
endif()
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)

add_custom_command(
OUTPUT ${outputFilename}
COMMAND ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME} ${inputFilename} ${EXTRA_ARGS} >${outputFilename}
DEPENDS ${inputFilename} ${CLR_ENG_NATIVE_DIR}/${SCRIPT_NAME}
COMMENT "Generating exports file ${outputFilename}"
)
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
add_custom_command(
OUTPUT ${outputFilename}
COMMAND powershell -NoProfile -ExecutionPolicy ByPass -File \"${SCRIPT_NAME}\" ${inputFilename} ${EXTRA_ARGS} >${outputFilename}
DEPENDS ${inputFilename} ${SCRIPT_NAME}
COMMENT "Generating exports file ${outputFilename}"
)
else()
add_custom_command(
OUTPUT ${outputFilename}
COMMAND ${SCRIPT_NAME} ${inputFilename} ${EXTRA_ARGS} >${outputFilename}
DEPENDS ${inputFilename} ${SCRIPT_NAME}
COMMENT "Generating exports file ${outputFilename}"
)
endif()
set_source_files_properties(${outputFilename}
PROPERTIES GENERATED TRUE)
endfunction()
Expand Down Expand Up @@ -445,16 +472,28 @@ function(strip_symbols targetName outputFilename)
COMMAND ${strip_command}
)
else (CLR_CMAKE_TARGET_APPLE)

add_custom_command(
TARGET ${targetName}
POST_BUILD
VERBATIM
COMMAND sh -c "echo Stripping symbols from $(basename '${strip_source_file}') into $(basename '${strip_destination_file}')"
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
COMMAND ${CMAKE_OBJCOPY} --strip-debug --strip-unneeded ${strip_source_file}
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
# Win32 may be false when cross compiling
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
add_custom_command(
TARGET ${targetName}
POST_BUILD
VERBATIM
COMMAND powershell -C "echo Stripping symbols from $(Split-Path -Path '${strip_source_file}' -Leaf) into $(Split-Path -Path '${strip_destination_file}' -Leaf)"
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
COMMAND ${CMAKE_OBJCOPY} --strip-debug --strip-unneeded ${strip_source_file}
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
)
else()
add_custom_command(
TARGET ${targetName}
POST_BUILD
VERBATIM
COMMAND sh -c "echo Stripping symbols from $(basename '${strip_source_file}') into $(basename '${strip_destination_file}')"
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file}
COMMAND ${CMAKE_OBJCOPY} --strip-debug --strip-unneeded ${strip_source_file}
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file}
)
endif()
endif (CLR_CMAKE_TARGET_APPLE)
endif(CLR_CMAKE_HOST_UNIX)
endfunction()
Expand Down
28 changes: 28 additions & 0 deletions eng/native/gen-buildsys.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,33 @@ if /i "%__Arch%" == "wasm" (
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0"
)

if /i "%__Os%" == "android" (
:: Keep in sync with $(AndroidApiLevelMin) in Directory.Build.props in the repository rooot
set __ANDROID_API_LEVEL=21
if "%ANDROID_NDK_ROOT%" == "" (
echo Error: You need to set the ANDROID_NDK_ROOT environment variable pointing to the Android NDK root.
exit /B 1
)

set __ExtraCmakeParams=!__ExtraCmakeParams! "-DANDROID_BUILD=1" "-DANDROID_CPP_FEATURES='no-rtti exceptions'"
set __ExtraCmakeParams=!__ExtraCmakeParams! "-DANDROID_PLATFORM=android-!__ANDROID_API_LEVEL!" "-DANDROID_NATIVE_API_LEVEL=!__ANDROID_API_LEVEL!"

if "%__Arch%" == "x64" (
set __ExtraCmakeParams=!__ExtraCmakeParams! "-DANDROID_ABI=x86_64"
)
if "%__Arch%" == "x86" (
set __ExtraCmakeParams=!__ExtraCmakeParams! "-DANDROID_ABI=x86"
)
if "%__Arch%" == "arm64" (
set __ExtraCmakeParams=!__ExtraCmakeParams! "-DANDROID_ABI=arm64-v8a"
)
if "%__Arch%" == "x64" (
set __ExtraCmakeParams=!__ExtraCmakeParams! "-DANDROID_ABI=armeabi-v7a"
)

set __ExtraCmakeParams=!__ExtraCmakeParams! "-DCMAKE_TOOLCHAIN_FILE='%ANDROID_NDK_ROOT:\=/%/build/cmake/android.toolchain.cmake'" "-C %__repoRoot%/eng/native/tryrun.cmake"
)

:loop
if [%6] == [] goto end_loop
set __ExtraCmakeParams=%__ExtraCmakeParams% %6
Expand Down Expand Up @@ -111,6 +138,7 @@ if not "%__ConfigureOnly%" == "1" (
if /i "%__UseEmcmake%" == "1" (
call "!EMSDK_PATH!/emsdk_env.cmd" > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
) else (
echo "%CMakePath% %__ExtraCmakeParams% --no-warn-unused-cli -G %__CmakeGenerator% -B %__IntermediatesDir% -S %__SourceDir%"
"%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
)

Expand Down
34 changes: 34 additions & 0 deletions eng/native/generateversionscript.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
param (
[string]$inputFile,
[string]$prefix
)

# Print the header
Write-Output "V1.0 {"
Write-Output " global:"

# Read the input file line by line
Get-Content $inputFile | ForEach-Object {
$line = $_.Trim()

# Skip empty lines and comment lines starting with semicolon
if ($line -match '^\;.*$' -or $line -match '^[\s]*$') {
return
}

# Remove the CR character in case the sources are mapped from
# a Windows share and contain CRLF line endings
$line = $line -replace "`r", ""

# Only prefix the entries that start with "#"
if ($line -match '^#.*$') {
$line = $line -replace '^#', ''
Write-Output " $prefix$line;"
} else {
Write-Output " $line;"
}
}

# Print the footer
Write-Output " local: *;"
Write-Output "};"
11 changes: 6 additions & 5 deletions eng/native/tryrun.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH})
set(ANDROID_BUILD $ENV{ANDROID_BUILD})

# Also allow building as Android without specifying `-cross`.
if(NOT DEFINED TARGET_ARCH_NAME AND DEFINED ANDROID_BUILD)
Expand Down Expand Up @@ -50,8 +49,8 @@ if(NOT DEFINED ANDROID_BUILD)
endif()
endif()

if(DARWIN)
if(DEFINED ANDROID_BUILD OR TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
if(DARWIN AND NOT DEFINED ANDROID_BUILD)
if(TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 1)
set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1)
set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1)
Expand All @@ -78,7 +77,7 @@ if(DARWIN)
else()
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!")
endif()
elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86|x64)$" OR FREEBSD OR ILLUMOS OR TIZEN OR HAIKU)
elseif(DEFINED ANDROID_BUILD OR TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86|x64)$" OR FREEBSD OR ILLUMOS OR TIZEN OR HAIKU)
set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0)
set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 0)
set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
Expand Down Expand Up @@ -123,8 +122,10 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39
set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1)
elseif(ANDROID_BUILD)
set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS 0)
endif()
else()
elseif(NOT WIN32)
message(FATAL_ERROR "Unsupported platform. OS: ${CMAKE_SYSTEM_NAME}, arch: ${TARGET_ARCH_NAME}")
endif()

Expand Down
27 changes: 27 additions & 0 deletions eng/native/version/copy_version_files.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$VersionFolder = $PSScriptRoot
$RepoRoot = (Resolve-Path "$VersionFolder/../../../").Path.TrimEnd("\")

Get-ChildItem -Path "$VersionFolder" -Filter "_version.*" | ForEach-Object {
$path = $_.FullName
if ($_.Name -eq "_version.c") {
# For _version.c, update the commit ID if it has changed from the last build.
$commit = (git rev-parse HEAD 2>$null)
if (-not $commit) { $commit = "N/A" }
$substitute = "static char sccsid[] __attribute__((used)) = `"@(#)Version N/A @Commit: $commit`";"
$version_file_contents = Get-Content -Path $path | ForEach-Object { $_ -replace "^static.*", $substitute }
$version_file_destination = "$RepoRoot\\artifacts\\obj\\_version.c"
$current_contents = ""
$is_placeholder_file = $false
if (Test-Path -Path $version_file_destination) {
$current_contents = Get-Content -Path $version_file_destination -Raw
$is_placeholder_file = $current_contents -match "@\(#\)Version N/A @Commit:"
} else {
$is_placeholder_file = $true
}
if ($is_placeholder_file -and $version_file_contents -ne $current_contents) {
$version_file_contents | Set-Content -Path $version_file_destination
}
} elseif (-not (Test-Path -Path "$RepoRoot\\artifacts\\obj\\$($_.Name)")) {
Copy-Item -Path $path -Destination "$RepoRoot\\artifacts\\obj\\"
}
}
31 changes: 23 additions & 8 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ if(CLR_CMAKE_HOST_UNIX)

set (NATIVE_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nativeresources)
include_directories(${NATIVE_RESOURCE_DIR})
set (PROCESS_RC_SCRIPT ${NATIVE_RESOURCE_DIR}/processrc.sh)

# Win32 may be false when cross compiling
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set (PROCESS_RC_SCRIPT ${NATIVE_RESOURCE_DIR}/processrc.ps1)
else()
set (PROCESS_RC_SCRIPT ${NATIVE_RESOURCE_DIR}/processrc.sh)
endif()
set (RESOURCE_STRING_HEADER_DIR ${NATIVE_RESOURCE_DIR})

# Create a command to create a C++ source file containing an array of
Expand All @@ -230,16 +236,25 @@ if(CLR_CMAKE_HOST_UNIX)

set(RESOURCE_ENTRY_ARRAY_CPP ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.cpp)

add_custom_command(
OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP}
# Convert the preprocessed .rc file to a C++ file which will be used to make a static lib.
COMMAND ${PROCESS_RC_SCRIPT} ${PREPROCESSED_SOURCE} ${TARGET_NAME} >${RESOURCE_ENTRY_ARRAY_CPP}
DEPENDS ${PREPROCESSED_SOURCE} ${PROCESS_RC_SCRIPT}
)
# Win32 may be false when cross compiling
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
add_custom_command(
OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP}
# Convert the preprocessed .rc file to a C++ file which will be used to make a static lib.
COMMAND powershell -NoProfile -ExecutionPolicy ByPass -File \"${PROCESS_RC_SCRIPT}\" ${PREPROCESSED_SOURCE} ${TARGET_NAME} >${RESOURCE_ENTRY_ARRAY_CPP}
DEPENDS ${PREPROCESSED_SOURCE} ${PROCESS_RC_SCRIPT}
)
else()
add_custom_command(
OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP}
# Convert the preprocessed .rc file to a C++ file which will be used to make a static lib.
COMMAND ${PROCESS_RC_SCRIPT} ${PREPROCESSED_SOURCE} ${TARGET_NAME} >${RESOURCE_ENTRY_ARRAY_CPP}
DEPENDS ${PREPROCESSED_SOURCE} ${PROCESS_RC_SCRIPT}
)
endif()

include_directories(${RESOURCE_STRING_HEADER_DIR})
set(${TARGET_FILE} ${RESOURCE_ENTRY_ARRAY_CPP} PARENT_SCOPE)

endfunction()

add_subdirectory(nativeresources)
Expand Down
Loading
Loading