minesweeper/CMakeLists.txt
theredbluecube2@gmail.com 92a3b6e20a bbbb
2025-12-06 18:44:08 +03:00

72 lines
2.1 KiB
CMake

# SPDX-FileCopyrightText: 2025 thorium1256
#
# SPDX-License-Identifier: GPL-3.0-or-later
cmake_minimum_required(VERSION 3.11)
project(tuimine LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Compiler flags
add_compile_options(-Wall -Wextra)
# Find ncursesw (wide character version)
# Use the CURSES module but specifically look for ncursesw
set(CURSES_NEED_NCURSES TRUE)
set(CURSES_NEED_WIDE TRUE) # This is key for wide character support
find_package(Curses REQUIRED)
message(STATUS "Found Curses include path: ${CURSES_INCLUDE_PATH}")
message(STATUS "Found Curses libraries: ${CURSES_LIBRARIES}")
message(STATUS "Curses include dir: ${CURSES_INCLUDE_DIRS}")
# Optional SDL2
option(WITH_SDL2 "Enable SDL2 controller support" ON)
if(WITH_SDL2)
find_package(SDL2 QUIET)
if(SDL2_FOUND)
message(STATUS "SDL2 found - controller support enabled")
add_definitions(-DWITH_SDL2)
else()
message(STATUS "SDL2 not found - controller support disabled")
endif()
endif()
# Build type specific settings
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-g)
else()
add_compile_options(-O2)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")
endif()
# Create executable
file(GLOB SOURCES "src/*.cpp")
add_executable(tuimine ${SOURCES})
target_include_directories(tuimine PRIVATE include)
# Link ncursesw - use the variables found by find_package(Curses)
if(CURSES_LIBRARIES)
target_link_libraries(tuimine PRIVATE ${CURSES_LIBRARIES})
else()
# Fallback to linking ncursesw directly
target_link_libraries(tuimine PRIVATE ncursesw)
endif()
if(WITH_SDL2 AND SDL2_FOUND)
target_link_libraries(tuimine PRIVATE SDL2::SDL2)
endif()
# Output configuration
set_target_properties(tuimine PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin/debug"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin/release"
OUTPUT_NAME_DEBUG "debug"
OUTPUT_NAME_RELEASE "tuimine"
)
# Install
install(TARGETS tuimine RUNTIME DESTINATION bin)