aaara si, makes, cmakes i gitignores com toca
This commit is contained in:
71
.gitignore
vendored
71
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
demo2_pixels_noise
|
||||
build/
|
||||
|
||||
# ---> C++
|
||||
@@ -34,3 +35,73 @@ build/
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# ---> macOS
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# ---> Windows
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# ---> Linux
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
|
||||
@@ -5,33 +5,45 @@ project(demo2_pixels_noise)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Definir las fuentes y el ejecutable
|
||||
set(SOURCE demo2_pixels_noise.cpp)
|
||||
set(EXECUTABLE demo2_pixels_noise)
|
||||
# Opciones comunes de compilación
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Os -ffunction-sections -fdata-sections")
|
||||
|
||||
# Buscar SDL3 automáticamente
|
||||
find_package(SDL3 REQUIRED)
|
||||
|
||||
# Detectar la plataforma y ajustar configuraciones específicas
|
||||
if(WIN32)
|
||||
set(PLATFORM windows)
|
||||
set(EXE_EXT ".exe")
|
||||
set(EXTRA_LIBS mingw32 ws2_32)
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
set(PLATFORM linux)
|
||||
set(EXE_EXT ".out")
|
||||
set(EXTRA_LIBS "")
|
||||
elseif(APPLE)
|
||||
set(PLATFORM macos)
|
||||
set(EXE_EXT ".out")
|
||||
set(EXTRA_LIBS "")
|
||||
# Si no se encuentra SDL3, generar un error
|
||||
if (NOT SDL3_FOUND)
|
||||
message(FATAL_ERROR "SDL3 no encontrado. Por favor, verifica su instalación.")
|
||||
endif()
|
||||
|
||||
# Añadir el ejecutable
|
||||
add_executable(${EXECUTABLE}${EXE_EXT} ${SOURCE})
|
||||
# Archivos fuente
|
||||
file(GLOB SOURCE_FILES source/*.cpp)
|
||||
|
||||
# Enlazar las bibliotecas específicas y SDL3
|
||||
target_link_libraries(${EXECUTABLE}${EXE_EXT} ${EXTRA_LIBS} SDL3::SDL3)
|
||||
# Comprobar si se encontraron archivos fuente
|
||||
if(NOT SOURCE_FILES)
|
||||
message(FATAL_ERROR "No se encontraron archivos fuente en el directorio 'source/'. Verifica la ruta.")
|
||||
endif()
|
||||
|
||||
# Colocar el ejecutable en la raíz del proyecto
|
||||
set_target_properties(${EXECUTABLE}${EXE_EXT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
# Detectar la plataforma y configuraciones específicas
|
||||
if(WIN32)
|
||||
set(PLATFORM windows)
|
||||
set(LINK_LIBS ${SDL3_LIBRARIES} mingw32 ws2_32)
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
set(PLATFORM linux)
|
||||
set(LINK_LIBS ${SDL3_LIBRARIES})
|
||||
elseif(APPLE)
|
||||
set(PLATFORM macos)
|
||||
set(LINK_LIBS ${SDL3_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# Incluir directorios de SDL3
|
||||
include_directories(${SDL3_INCLUDE_DIRS})
|
||||
|
||||
# Añadir el ejecutable reutilizando el nombre del proyecto
|
||||
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
|
||||
|
||||
# Especificar la ubicación del ejecutable (en la raíz del proyecto)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
# Enlazar las bibliotecas necesarias
|
||||
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
|
||||
|
||||
42
Makefile
42
Makefile
@@ -1,34 +1,22 @@
|
||||
# Makefile sin espacios adicionales y con sintaxis minimalista
|
||||
CXXFLAGS:=-std=c++20 -Wall -Os -ffunction-sections -fdata-sections
|
||||
LDFLAGS:=-lSDL3
|
||||
SOURCE:=demo2_pixels_noise.cpp
|
||||
EXECUTABLE:=demo2_pixels_noise
|
||||
RM:=rm -f
|
||||
# Variables comunes
|
||||
SOURCE := source/*.cpp
|
||||
EXECUTABLE_NAME := demo2_pixels_noise
|
||||
CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections # Opciones comunes de compilación
|
||||
LDFLAGS := -lSDL3 # Flags de enlace comunes
|
||||
OUTPUT_EXT :=
|
||||
|
||||
# Detectar plataforma
|
||||
# Detectar plataforma y configurar
|
||||
ifeq ($(OS),Windows_NT)
|
||||
PLATFORM:=windows
|
||||
LDFLAGS+=-lmingw32 -lws2_32
|
||||
EXE_EXT:=.exe
|
||||
LDFLAGS += -lmingw32 -lws2_32
|
||||
OUTPUT_EXT := .exe
|
||||
else
|
||||
UNAME_S:=$(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
PLATFORM:=linux
|
||||
EXE_EXT:=.out
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
PLATFORM:=macos
|
||||
EXE_EXT:=.out
|
||||
endif
|
||||
OUTPUT_EXT := .out
|
||||
endif
|
||||
|
||||
# Regla principal
|
||||
all: $(EXECUTABLE)
|
||||
# Regla principal: compilar el ejecutable
|
||||
all:
|
||||
$(CXX) $(SOURCE) $(CXXFLAGS) $(LDFLAGS) -o $(EXECUTABLE_NAME)$(OUTPUT_EXT)
|
||||
|
||||
# Compilar
|
||||
$(EXECUTABLE):
|
||||
$(CXX) $(SOURCE) $(CXXFLAGS) $(LDFLAGS) -o $(EXECUTABLE)$(EXE_EXT)
|
||||
|
||||
# Limpiar
|
||||
# Regla para limpiar archivos generados
|
||||
clean:
|
||||
$(RM) $(EXECUTABLE)*
|
||||
rm -f $(EXECUTABLE_NAME)$(OUTPUT_EXT)
|
||||
Reference in New Issue
Block a user