Created
April 10, 2023 09:36
-
-
Save jpcofr/1b12c605b01ae94e8fc42faa3c921e11 to your computer and use it in GitHub Desktop.
Build config for SFML in macOS 13.3
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
# Description: Build configuration for the "SFML example - Basic window and event handling" | |
# using SFML from its repository. | |
# Compatibility: macOS 13.3 | |
# Dependencies: SFML (master branch) | |
cmake_minimum_required(VERSION 3.25) | |
project(a_window) | |
set(CMAKE_BUILD_TYPE Debug) | |
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build) | |
set(LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) | |
set(EXECUTABLE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) | |
# Find ccache | |
find_program(CCACHE_PROGRAM ccache) | |
if(CCACHE_PROGRAM) | |
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") | |
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}") | |
endif() | |
# Set up external dependencies | |
set(FETCHCONTENT_QUIET FALSE) | |
include(FetchContent) | |
FetchContent_Declare( | |
sfml | |
GIT_REPOSITORY https://github.com/SFML/SFML.git | |
GIT_TAG master | |
) | |
FetchContent_MakeAvailable(sfml) | |
include_directories(${smfl_SOURCE_DIR}/SFML) | |
set(SOURCES src/main.cpp) | |
add_executable(${PROJECT_NAME} ${SOURCES}) | |
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20) | |
target_link_libraries(${PROJECT_NAME} sfml-graphics) |
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(sf::Vector2u(800, 600)), "My window"); | |
while (window.isOpen()) { | |
sf::Event event; | |
while (window.pollEvent(event)) { | |
if (event.type == sf::Event::Closed) { | |
window.close(); | |
} | |
} | |
window.clear(); | |
// Add your drawing code here | |
window.display(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment