Last active
October 27, 2024 23:58
-
-
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 542fa54..2f1f509 100644 | |
--- a/.gitignore | |
+++ b/.gitignore | |
@@ -2,6 +2,9 @@ | |
.DS_Store | |
Thumbs.db | |
+# vcpkg | |
+/vcpkg_installed/ | |
+ | |
# Build output | |
/build/ | |
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 ae5c329..71b0336 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -29,7 +29,7 @@ INCLUDES = $(addprefix -I,$(SRC_DIR) $(INCLUDE_DIR)) | |
TEST_INCLUDES = -I$(TEST_DIR) | |
# C preprocessor settings | |
-CPPFLAGS = $(INCLUDES) -MMD -MP | |
+CPPFLAGS = $(INCLUDES) -MMD -MP -DSFML_STATIC | |
# C++ compiler settings | |
CXX = g++ | |
@@ -64,19 +64,19 @@ ifeq ($(OS),windows) | |
LDFLAGS += -static-libgcc -static-libstdc++ | |
# Windows-specific settings | |
- INCLUDES += | |
- LDFLAGS += | |
+ INCLUDES += -isystem vcpkg_installed/x64-mingw-static/include | |
+ LDFLAGS += -Lvcpkg_installed/x64-mingw-static/lib | |
LDLIBS += | |
else ifeq ($(OS),macos) | |
# macOS-specific settings | |
- INCLUDES += | |
- LDFLAGS += | |
+ INCLUDES += -isystem vcpkg_installed/x64-osx/include | |
+ LDFLAGS += -Lvcpkg_installed/x64-osx/lib | |
LDLIBS += | |
else ifeq ($(OS),linux) | |
# Linux-specific settings | |
- INCLUDES += | |
- LDFLAGS += | |
- LDLIBS += | |
+ INCLUDES += -isystem vcpkg_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