Last active
March 24, 2025 10:25
-
-
Save nezvers/d1e1012efcb2ef0106a414b3b21fba75 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| cmake_minimum_required(VERSION 3.12) | |
| include(FetchContent) | |
| set(PROJECT_NAME SfmlTemplate) | |
| project(${PROJECT_NAME} VERSION 1.0.0 LANGUAGES CXX) | |
| set(CMAKE_CXX_STANDARD 17) | |
| find_package(OpenGL) | |
| # Detect and add SFML | |
| find_package(sfml 2.5.1 QUIET) | |
| if (NOT sfml_FOUND) | |
| FetchContent_Declare( | |
| sfml | |
| GIT_REPOSITORY "https://github.com/SFML/SFML.git" | |
| GIT_TAG "2.5.1" | |
| ) | |
| # Build static SFML | |
| set(BUILD_SHARED_LIBS OFF) | |
| FetchContent_GetProperties(sfml) | |
| if (NOT sfml_POPULATED) | |
| set(FETCHCONTENT_QUIET NO) | |
| FetchContent_MakeAvailable(sfml) | |
| endif() | |
| endif() | |
| include_directories(${CMAKE_SOURCE_DIR}/include) | |
| file(GLOB SRC_FILES "src/*.cpp" ) | |
| add_executable(${PROJECT_NAME} ${SRC_FILES}) | |
| target_include_directories(${PROJECT_NAME} PRIVATE "include" "lib") | |
| target_link_libraries(${PROJECT_NAME} PRIVATE sfml-system sfml-window sfml-graphics) | |
| set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) | |
| if (UNIX) | |
| target_link_libraries(${PROJECT_NAME} pthread) | |
| endif (UNIX) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment