premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

Add support for CopyToOutputDirectory for VS C++ projects

Open MaximeLussier opened this issue 1 year ago • 4 comments

What problem will this solve? Projects using DLL not present in the system will not load them if not copied alongside the executable

What might be a solution? Add a flag to enable "CopyToOutputDirectory" or add it always

What other alternatives have you already considered? Currently, we SED the vcxproj after generation

Anything else we should know? This:

  <ItemGroup>
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264com_AVX.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264com_SSE2.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264com_SSE4_2.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264com_SSSE3.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264dec_AVX.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264dec_SSE2.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264dec_SSE4_2.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264dec_SSSE3.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264enc_AVX.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264enc_SSE2.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264enc_SSE4_2.dll" />
    <None Include="..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264enc_SSSE3.dll" />
  </ItemGroup>

vs

<ItemGroup>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264com_AVX.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264com_SSE2.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264com_SSE4_2.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264com_SSSE3.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264dec_AVX.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264dec_SSE2.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264dec_SSE4_2.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264dec_SSSE3.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264enc_AVX.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264enc_SSE2.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264enc_SSE4_2.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Include=".\..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win\h264enc_SSSE3.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

MaximeLussier avatar Mar 29 '23 16:03 MaximeLussier

Does buildaction "Copy" do what you're after? It was added in this PR #1978 it's not CopyToOutputDirectory, but it might work, otherwise it's a UWP-specific element and we'll need to add CopyToOutputDirectory for Windows.

samsinsane avatar Apr 12 '23 14:04 samsinsane

Not really. The buildaction "copy" would require us to manually specify the source files and destination directory! The CopyToOutputDirectory automatically does it for the required libraries.

MaximeLussier avatar Apr 12 '23 14:04 MaximeLussier

I think you're thinking of something else, the PR I linked shows an example through a unit test. https://github.com/premake/premake-core/blob/d150691d1eabfcc6e523a2649e367d11b129dfbf/modules/vstudio/tests/vc2010/test_files.lua#L110 https://github.com/premake/premake-core/blob/d150691d1eabfcc6e523a2649e367d11b129dfbf/modules/vstudio/tests/vc2010/test_files.lua#L115-L116 https://github.com/premake/premake-core/blob/d150691d1eabfcc6e523a2649e367d11b129dfbf/modules/vstudio/tests/vc2010/test_files.lua#L128-L133

samsinsane avatar Apr 12 '23 14:04 samsinsane

Ah, we will need to take a look at that. But I believe we only specify the directory path of the libraries in the lua file (e.g ..\SourcesMeiWebRtc\ExternalCodecs\h264_lib\lib_win) and all the .dll are added to the vcxproj... The CopyToOutputDirectory was generated by GYP which we stopped using.

MaximeLussier avatar Apr 12 '23 15:04 MaximeLussier