@@ -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,30 @@ 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
+ #==============================
131
+ # TODO: to remove once https://github.com/conan-io/conan/pull/12817 available in conan client
129
132
if self .version == "1.0.18" and self ._msvc_sln_folder == "vs2019" :
130
133
toolset = MSBuildToolchain (self ).toolset
131
134
replace_in_file (
132
- self , vcxproj_path ,
135
+ self , os . path . join ( msvc_sln_folder , "libsodium" , "libsodium.vcxproj" ) ,
133
136
"<PlatformToolset>v142</PlatformToolset>" ,
134
137
f"<PlatformToolset>{ toolset } </PlatformToolset>" ,
135
138
)
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" )
139
+ conantoolchain_props = os .path .join (self .generators_folder , MSBuildToolchain .filename )
145
140
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 \" />" ,
141
+ self , os . path . join ( msvc_sln_folder , "libsodium" , "libsodium.vcxproj" ) ,
142
+ "<Import Project=\" $(VCTargetsPath)\\ Microsoft.Cpp.targets \" />" ,
143
+ f"<Import Project=\" { conantoolchain_props } \" /><Import Project=\" $(VCTargetsPath)\\ Microsoft.Cpp.targets \" />" ,
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
- )
145
+ #==============================
172
146
173
147
msbuild = MSBuild (self )
174
- build_type = "{}{}" .format (
148
+ msbuild . build_type = "{}{}" .format (
175
149
"Dyn" if self .options .shared else "Static" ,
176
150
"Debug" if self .settings .build_type == "Debug" else "Release" ,
177
151
)
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
152
msbuild .build (os .path .join (msvc_sln_folder , "libsodium.sln" ))
187
153
188
154
def build (self ):
0 commit comments