@@ -123,25 +123,53 @@ def _msvc_sln_folder(self):
123
123
def _build_msvc (self ):
124
124
msvc_builds_folder = os .path .join (self .source_folder , "builds" , "msvc" )
125
125
msvc_sln_folder = os .path .join (msvc_builds_folder , self ._msvc_sln_folder )
126
+ vcxproj_path = os .path .join (msvc_sln_folder , "libsodium" , "libsodium.vcxproj" )
126
127
127
128
# 1.0.18 only supported up to vs2019. Add support for newer toolsets.
128
129
if self .version == "1.0.18" and self ._msvc_sln_folder == "vs2019" :
129
130
toolset = MSBuildToolchain (self ).toolset
130
131
replace_in_file (
131
- self , os . path . join ( msvc_sln_folder , "libsodium" , "libsodium.vcxproj" ) ,
132
- f "<PlatformToolset>v142</PlatformToolset>" ,
132
+ self , vcxproj_path ,
133
+ "<PlatformToolset>v142</PlatformToolset>" ,
133
134
f"<PlatformToolset>{ toolset } </PlatformToolset>" ,
134
135
)
135
136
136
- # There is no automagic interaction between MSBuildToolchain & MSBuild helper,
137
- # props file generated by MSBuildToolchain must be manually injected by any means.
137
+ # FIXME: There is currently no guarantee from new MSBuild helper that props files
138
+ # generated by MSBuildToolchain and MSBuildDeps have precedence over custom values of project.
139
+ # Therefore conantoolchain.props is injected manually before Microsoft.Cpp.Default.props like it was done
140
+ # with /p:ForceImportBeforeCppTargets in legacy MSBuild helper.
141
+ # see:
142
+ # - https://learn.microsoft.com/en-us/cpp/build/modify-project-properties-without-changing-project-file
143
+ # - https://github.com/conan-io/conan/issues/12155
138
144
conantoolchain_props = os .path .join (self .generators_folder , "conantoolchain.props" )
139
145
replace_in_file (
140
- self , os . path . join ( msvc_builds_folder , "properties" , "Common.props" ) ,
141
- "<ImportGroup Label =\" PropertySheets \" >" ,
142
- f"<ImportGroup Label =\" PropertySheets \" > <Import Project=\" { conantoolchain_props } \" />" ,
146
+ self , vcxproj_path ,
147
+ "<Import Project =\" $(VCTargetsPath) \\ Microsoft.Cpp.Default.props \" / >" ,
148
+ f"<Import Project =\" { conantoolchain_props } \" /> \n <Import Project=\" $(VCTargetsPath) \\ Microsoft.Cpp.Default.props \" />" ,
143
149
)
144
150
151
+ # Honor runtime library from profile
152
+ runtime_library = MSBuildToolchain (self ).runtime_library
153
+ for prop_file , runtime_library_old in [
154
+ ("DebugDEXE.props" , "MultiThreadedDebugDLL" ),
155
+ ("DebugDLL.props" , "MultiThreadedDebugDLL" ),
156
+ ("DebugLEXE.props" , "MultiThreadedDebug" ),
157
+ ("DebugLIB.props" , "MultiThreadedDebug" ),
158
+ ("DebugLTCG.props" , "MultiThreadedDebug" ),
159
+ ("DebugSEXE.props" , "MultiThreadedDebug" ),
160
+ ("ReleaseDEXE.props" , "MultiThreadedDLL" ),
161
+ ("ReleaseDLL.props" , "MultiThreadedDLL" ),
162
+ ("ReleaseLEXE.props" , "MultiThreaded" ),
163
+ ("ReleaseLIB.props" , "MultiThreaded" ),
164
+ ("ReleaseLTCG.props" , "MultiThreaded" ),
165
+ ("ReleaseSEXE.props" , "MultiThreaded" ),
166
+ ]:
167
+ replace_in_file (
168
+ self , os .path .join (msvc_builds_folder , "properties" , prop_file ),
169
+ f"<RuntimeLibrary>{ runtime_library_old } </RuntimeLibrary>" ,
170
+ f"<RuntimeLibrary>{ runtime_library } </RuntimeLibrary>" ,
171
+ )
172
+
145
173
msbuild = MSBuild (self )
146
174
build_type = "{}{}" .format (
147
175
"Dyn" if self .options .shared else "Static" ,
0 commit comments