vslavik / bakefile

Bakefile makefiles generator
http://bakefile.org
MIT License
142 stars 20 forks source link

Fix include in static library #110

Closed ricnish closed 5 years ago

ricnish commented 5 years ago

Additional library was not working with static library in Visual Studio projects.

vslavik commented 5 years ago

Sorry, while I appreciate the PR, I understand neither what the problem is nor how the patch is meant to fix. The incomplete example code with some apparently unrelated snippets doesn't really help, please describe the issue exactly and in detail with full example and reproduction steps allowing to run it, including explaining what happens and what you expect to happen.

ricnish commented 5 years ago

Hi vslavik, The problem: I have a static C++ library and I need to link another library ("myLib.lib" for instance) in the project.

In Visual Studio project I can do it by setting the project property page in "Librarian" and add the library to "Additional Dependencies" and the library´s path in "Additional Library Directories".

If you check the Visual Studio project file ".vcxproj" there will be a new xml section:

    <Lib>
      <AdditionalLibraryDirectories>myLibDir;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
      <AdditionalDependencies>myLib.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Lib>

In the bakefile project, if I set as following the documentation:

// Static library MyLibrary { libdirs = myLibDir; libs = myLib; }

No new section configuration is created in the .vcxproj when I generate the Visual Studio project from bakefile.

Fix: In the file vs201x.py line 245, there is an "if" preventing to process a library, and inside this code, in line 258, there is another "if" checking if it is a library and it will never be executed.

What I have done was to move out the library processing to get it generated.

Best regards.

vslavik commented 5 years ago

Bakefile doesn't include static libraries in other static libraries by design.

That's a freak feature of VS that nobody else does, and even with VS it does more harm than good. It's either that or ability to record dependencies with static libraries for inclusion when building actual executable targets. The latter is actually useful.

This is by design.