@@ -76,6 +76,10 @@ def source(self):
76
76
def generate (self ):
77
77
if is_msvc (self ):
78
78
tc = MSBuildToolchain (self )
79
+ tc .configuration = "{}{}" .format (
80
+ "Debug" if self .settings .build_type == "Debug" else "Release" ,
81
+ "DLL" if self .options .shared else "LIB" ,
82
+ )
79
83
tc .generate ()
80
84
else :
81
85
env = VirtualBuildEnv (self )
@@ -121,68 +125,28 @@ def _msvc_sln_folder(self):
121
125
return sln_folders .get (str (self .settings .compiler ), {}).get (str (self .settings .compiler .version ), default_folder )
122
126
123
127
def _build_msvc (self ):
124
- msvc_builds_folder = os .path .join (self .source_folder , "builds" , "msvc" )
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" )
128
+ msvc_sln_folder = os .path .join (self .source_folder , "builds" , "msvc" , self ._msvc_sln_folder )
127
129
128
- # 1.0.18 only supported up to vs2019. Add support for newer toolsets.
130
+ # TODO: to remove once https://github.com/conan-io/conan/pull/12817 available in conan client
129
131
if self .version == "1.0.18" and self ._msvc_sln_folder == "vs2019" :
130
132
toolset = MSBuildToolchain (self ).toolset
131
133
replace_in_file (
132
- self , vcxproj_path ,
134
+ self , os . path . join ( msvc_sln_folder , "libsodium" , "libsodium.vcxproj" ) ,
133
135
"<PlatformToolset>v142</PlatformToolset>" ,
134
136
f"<PlatformToolset>{ toolset } </PlatformToolset>" ,
135
137
)
136
-
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
144
- conantoolchain_props = os .path .join (self .generators_folder , "conantoolchain.props" )
138
+ conantoolchain_props = os .path .join (self .generators_folder , MSBuildToolchain .filename )
145
139
replace_in_file (
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 \" />" ,
140
+ self , os . path . join ( msvc_sln_folder , "libsodium" , "libsodium.vcxproj" ) ,
141
+ "<Import Project=\" $(VCTargetsPath)\\ Microsoft.Cpp.targets \" />" ,
142
+ f"<Import Project=\" { conantoolchain_props } \" /><Import Project=\" $(VCTargetsPath)\\ Microsoft.Cpp.targets \" />" ,
149
143
)
150
144
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
-
173
145
msbuild = MSBuild (self )
174
- build_type = "{}{}" .format (
146
+ msbuild . build_type = "{}{}" .format (
175
147
"Dyn" if self .options .shared else "Static" ,
176
148
"Debug" if self .settings .build_type == "Debug" else "Release" ,
177
149
)
178
-
179
- platform = {
180
- "x86" : "Win32" ,
181
- "x86_64" : "x64" ,
182
- }[str (self .settings .arch )]
183
-
184
- msbuild .build_type = build_type
185
- msbuild .platform = platform
186
150
msbuild .build (os .path .join (msvc_sln_folder , "libsodium.sln" ))
187
151
188
152
def build (self ):
0 commit comments