Skip to content

Instantly share code, notes, and snippets.

@KRMisha
Last active October 29, 2023 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KRMisha/7c19c73b2833f54f2d84bc7bb3ae788c to your computer and use it in GitHub Desktop.
Save KRMisha/7c19c73b2833f54f2d84bc7bb3ae788c to your computer and use it in GitHub Desktop.
How to integrate vcpkg into a Makefile (https://github.com/KRMisha/Makefile) for SFML
diff --git a/.gitignore b/.gitignore
index 89fe674..d8cc90e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,6 @@ Thumbs.db
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
+
+# vcpkg
+/vcpkg_installed/
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.0f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
window.clear();
window.draw(shape);
window.display();
}
}
diff --git a/Makefile b/Makefile
index 3e0c8b1..22b8fb5 100644
--- a/Makefile
+++ b/Makefile
@@ -22,5 +22,5 @@ INCLUDES := -I$(INCLUDE_DIR)
# C preprocessor settings
-CPPFLAGS = $(INCLUDES) -MMD -MP
+CPPFLAGS = $(INCLUDES) -MMD -MP -DSFML_STATIC
# C++ compiler settings
@@ -61,23 +61,23 @@ ifeq ($(OS),windows)
ifeq ($(win32),1)
# Windows 32-bit settings
- INCLUDES +=
- LDFLAGS +=
+ INCLUDES += -Ivcpkg_installed/x86-windows/include
+ LDFLAGS += -Lvcpkg_installed/x86-windows/lib
LDLIBS +=
else
# Windows 64-bit settings
- INCLUDES +=
- LDFLAGS +=
+ INCLUDES += -Ivcpkg_installed/x86-windows/include
+ LDFLAGS += -Lvcpkg_installed/x86-windows/lib
LDLIBS +=
endif
else ifeq ($(OS),macos)
# macOS-specific settings
- INCLUDES +=
- LDFLAGS +=
+ INCLUDES += -Ivcpkg_installed/x64-osx/include
+ LDFLAGS += -Lvcpkg_installed/x64-osx/lib
LDLIBS +=
else ifeq ($(OS),linux)
# Linux-specific settings
- INCLUDES +=
- LDFLAGS +=
- LDLIBS +=
+ INCLUDES += -Ivcpkg_installed/x64-linux/include
+ LDFLAGS += -Lvcpkg_installed/x64-linux/lib
+ LDLIBS += -lsfml-graphics-s -lfreetype -lsfml-window-s -lX11 -lXrandr -lXcursor -ludev -lsfml-system-s
endif
{
"dependencies": [
"sfml"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment