Last active
October 29, 2023 05:30
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": [ | |
"sfml" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment