Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static Lib Building #95

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Static Lib Building #95

wants to merge 4 commits into from

Conversation

AlvaroBarua
Copy link

Hi,

Just added a way of building the library as a static lib, in my specific use case, I was using NOGDI under Windows, which causes the library to not compile. The reason I didn't just removed the define is that it causes some of my apps enums to be invalid (eg: OPAQUE, TRANSPARENT - which are defined in wingdi.h) and also I prefer to keep the OS bloat to the absolute minimum in the main project and this change achieved both of my goals.

Might defeat the purpose of the library and not taken into consideration, but it still keeps the ability of using it as a single header lib, its just an added bonus way of using it.

Cheers,
Alvaro

Adds the ability to build the library as a static library, this decreases the amount of OS bloat your main project needs to compile against and also reorganizes the dependencies to do the same to certain extent in the single header version.
@AlvaroBarua
Copy link
Author

Just noticed that I obliterated the files, might have been line endings, if this gains any traction I'll fix it for a proper merge.

@samangh
Copy link

samangh commented Mar 10, 2024

@AlvaroBarua note that your CMake recipe does not build a static library, unless BUILD_SHARED_LIBS is turned off elsewhere in your CMake project.

Also, this has been discussed in #33

@AlvaroBarua
Copy link
Author

From CMake docs:
Calls to add_library() without any explicit library type check the current BUILD_SHARED_LIBS variable value. If it is true, then the default library type is SHARED. Otherwise, the default is STATIC.

Since the cmake file doesn't specify any value for BUILD_SHARED_LIBS, it will build a static library.

It is only in the case that the parent project has set the value as cached that it would fail.

@samangh
Copy link

samangh commented Mar 11, 2024

From CMake docs:
Calls to add_library() without any explicit library type check the current BUILD_SHARED_LIBS variable value. If it is true, then the default library type is SHARED. Otherwise, the default is STATIC.

Since the cmake file doesn't specify any value for BUILD_SHARED_LIBS, it will build a static library.

It is only in the case that the parent project has set the value as cached that it would fail.

Yes, thanks for the correction. For some reason I had that the other way around in my head!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants