Skip to content

Commit 2f20812

Browse files
authored
Fix MSBuild integration for the host build with CMake 3.26 (#88208)
1 parent b41893b commit 2f20812

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

eng/native/ijw/IJW.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ if (CLR_CMAKE_HOST_WIN32)
3131
set_target_properties(${targetName} PROPERTIES COMPILE_OPTIONS "${compileOptions}")
3232
endfunction()
3333

34+
function(add_ijw_msbuild_project_properties targetName ijwhost_target)
35+
# When we're building with MSBuild, we need to set some project properties
36+
# in case CMake has decided to use the SDK support.
37+
# We're dogfooding things, so we need to set settings in ways that the product doesn't quite support.
38+
# We don't actually need an installed/available target framework version here
39+
# since we are disabling implicit framework references. We just need a valid value, and net8.0 is valid.
40+
set_target_properties(${targetName} PROPERTIES
41+
DOTNET_TARGET_FRAMEWORK net8.0
42+
VS_GLOBAL_DisableImplicitFrameworkReferences true
43+
VS_GLOBAL_GenerateRuntimeConfigurationFiles false
44+
VS_PROJECT_IMPORT "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/SetIJWProperties.props")
45+
endfunction()
46+
3447
# 4365 - signed/unsigned mismatch
3548
# 4679 - Could not import member. This is an issue with IJW and static abstract methods in interfaces.
3649
add_compile_options(/wd4365 /wd4679)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- The C++/CLI targets don't let us set this in the project file where CMake lets us set project properties, so we set it in an imported project file where it will work. -->
4+
<UseIJWHost>false</UseIJWHost>
5+
</PropertyGroup>
6+
</Project>

src/native/corehost/test/ijw/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ add_library(ijw SHARED ${SOURCES})
1212
target_link_libraries(ijw PRIVATE ${LINK_LIBRARIES_ADDITIONAL})
1313

1414
remove_ijw_incompatible_target_options(ijw)
15+
add_ijw_msbuild_project_properties(ijw ijwhost)
1516

1617
install_with_stripped_symbols(ijw TARGETS corehost_test)

src/tests/Interop/IJW/CopyConstructorMarshaler/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(SOURCES IjwCopyConstructorMarshaler.cpp)
77
# add the shared library
88
add_library (IjwCopyConstructorMarshaler SHARED ${SOURCES})
99
target_link_libraries(IjwCopyConstructorMarshaler PRIVATE ${LINK_LIBRARIES_ADDITIONAL})
10+
add_ijw_msbuild_project_properties(IjwCopyConstructorMarshaler ijwhost)
1011

1112
# add the install targets
1213
install (TARGETS IjwCopyConstructorMarshaler DESTINATION bin)

src/tests/Interop/IJW/IjwNativeDll/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(SOURCES IjwNativeDll.cpp)
77
# add the shared library
88
add_library (IjwNativeDll SHARED ${SOURCES})
99
target_link_libraries(IjwNativeDll PRIVATE ${LINK_LIBRARIES_ADDITIONAL})
10+
add_ijw_msbuild_project_properties(IjwNativeDll ijwhost)
1011

1112
# add the install targets
1213
install (TARGETS IjwNativeDll DESTINATION bin)

src/tests/Interop/IJW/NativeVarargs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(SOURCES IjwNativeVarargs.cpp)
77
# add the shared library
88
add_library (IjwNativeVarargs SHARED ${SOURCES})
99
target_link_libraries(IjwNativeVarargs PRIVATE ${LINK_LIBRARIES_ADDITIONAL})
10+
add_ijw_msbuild_project_properties(IjwNativeVarargs ijwhost)
1011

1112
# add the install targets
1213
install (TARGETS IjwNativeVarargs DESTINATION bin)

0 commit comments

Comments
 (0)