-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
34 lines (26 loc) · 1.01 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
cmake_minimum_required(VERSION 3.16)
project(game)
set(CMAKE_CXX_STANDARD 17)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
file(GLOB_RECURSE SOURCES src/*.cpp)
add_executable(${PROJECT_NAME} ${SOURCES})
include_directories(headers /usr/include)
find_package(SFML 2.5 COMPONENTS graphics QUIET)
if(NOT SFML_FOUND)
message(">>> Installing SFML because it wasn't found")
# Install SFML
include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.x)
FetchContent_MakeAvailable(SFML)
endif()
target_link_libraries(${PROJECT_NAME} sfml-graphics sfml-window sfml-system)
# Create a custom target to copy the assets
add_custom_target(copy_assets ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets
COMMENT "Copying assets to the build directory"
)
# Make sure the 'copy_assets' target is run before building the main executable
add_dependencies(${PROJECT_NAME} copy_assets)