44 lines
1.0 KiB
CMake
44 lines
1.0 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
project(Minesweeper)
|
|
|
|
# Set C++ standard
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Find SFML package
|
|
find_package(SFML 2.5 COMPONENTS graphics window system REQUIRED)
|
|
|
|
# Create assets directory if it doesn't exist
|
|
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/assets)
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets)
|
|
endif()
|
|
|
|
# Add executable
|
|
add_executable(Minesweeper
|
|
src/main.cpp
|
|
)
|
|
|
|
# Link SFML libraries
|
|
target_link_libraries(Minesweeper
|
|
sfml-graphics
|
|
sfml-window
|
|
sfml-system
|
|
)
|
|
|
|
# Copy assets to build directory (for out-of-source builds)
|
|
add_custom_command(TARGET Minesweeper POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
${CMAKE_CURRENT_SOURCE_DIR}/assets
|
|
$<TARGET_FILE_DIR:Minesweeper>/assets
|
|
COMMENT "Copying assets to build directory"
|
|
)
|
|
|
|
# Install target (optional)
|
|
install(TARGETS Minesweeper
|
|
RUNTIME DESTINATION bin
|
|
)
|
|
|
|
# Install assets (optional)
|
|
install(DIRECTORY assets/
|
|
DESTINATION share/Minesweeper
|
|
) |