105 lines
4.6 KiB
CMake
105 lines
4.6 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
project(coffee_crisis_arcade_edition VERSION 0.01)
|
|
|
|
# Configuración de compilador para MinGW en Windows, si es necesario
|
|
if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
set(CMAKE_CXX_COMPILER "g++")
|
|
set(CMAKE_C_COMPILER "gcc")
|
|
endif()
|
|
|
|
# Establecer estándar de C++
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
# Define el directorio de los archivos fuente
|
|
set(DIR_SOURCES "${CMAKE_SOURCE_DIR}/source")
|
|
|
|
# Cargar todos los archivos fuente en DIR_SOURCES
|
|
file(GLOB SOURCES "${DIR_SOURCES}/*.cpp")
|
|
|
|
# Verificar si se encontraron archivos fuente
|
|
if(NOT SOURCES)
|
|
message(FATAL_ERROR "No se encontraron archivos fuente en ${DIR_SOURCES}. Verifica que el directorio existe y contiene archivos .cpp.")
|
|
endif()
|
|
|
|
# Configuración de SDL2
|
|
find_package(SDL2 REQUIRED)
|
|
include_directories(${SDL2_INCLUDE_DIRS})
|
|
link_directories(${SDL2_LIBDIR})
|
|
|
|
# Definir las bibliotecas comunes
|
|
set(LIBS SDL2main SDL2)
|
|
|
|
# Objetivos específicos por plataforma
|
|
if(WIN32)
|
|
set(LIBS ${LIBS} mingw32 opengl32 gdi32 winmm imm32 ole32 version)
|
|
|
|
# Windows estándar
|
|
add_executable(${PROJECT_NAME}_windows ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_windows PRIVATE WINDOWS_BUILD)
|
|
set_target_properties(${PROJECT_NAME}_windows PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
|
|
target_link_libraries(${PROJECT_NAME}_windows ${LIBS})
|
|
|
|
# Windows Debug
|
|
add_executable(${PROJECT_NAME}_windows_debug ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_windows_debug PRIVATE WINDOWS_BUILD DEBUG VERBOSE)
|
|
set_target_properties(${PROJECT_NAME}_windows_debug PROPERTIES OUTPUT_NAME "${PROJECT_NAME}_debug")
|
|
target_link_libraries(${PROJECT_NAME}_windows_debug ${LIBS})
|
|
|
|
# Windows Release
|
|
add_executable(${PROJECT_NAME}_windows_release ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_windows_release PRIVATE WINDOWS_BUILD)
|
|
set_target_properties(${PROJECT_NAME}_windows_release PROPERTIES OUTPUT_NAME "${PROJECT_NAME}_release")
|
|
target_link_libraries(${PROJECT_NAME}_windows_release ${LIBS})
|
|
|
|
elseif(APPLE)
|
|
set(LIBS ${LIBS} "-framework OpenGL")
|
|
|
|
# macOS estándar
|
|
add_executable(${PROJECT_NAME}_macos ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_macos PRIVATE MACOS_BUILD)
|
|
set_target_properties(${PROJECT_NAME}_macos PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
|
|
target_link_libraries(${PROJECT_NAME}_macos ${LIBS})
|
|
|
|
# macOS Debug
|
|
add_executable(${PROJECT_NAME}_macos_debug ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_macos_debug PRIVATE MACOS_BUILD DEBUG VERBOSE)
|
|
set_target_properties(${PROJECT_NAME}_macos_debug PROPERTIES OUTPUT_NAME "${PROJECT_NAME}_debug")
|
|
target_link_libraries(${PROJECT_NAME}_macos_debug ${LIBS})
|
|
|
|
# macOS Release
|
|
add_executable(${PROJECT_NAME}_macos_release ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_macos_release PRIVATE MACOS_BUILD)
|
|
set_target_properties(${PROJECT_NAME}_macos_release PROPERTIES OUTPUT_NAME "${PROJECT_NAME}_release")
|
|
target_link_libraries(${PROJECT_NAME}_macos_release ${LIBS})
|
|
|
|
elseif(UNIX AND NOT APPLE)
|
|
set(LIBS ${LIBS} GL)
|
|
|
|
# Linux estándar
|
|
add_executable(${PROJECT_NAME}_linux ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_linux PRIVATE LINUX_BUILD)
|
|
set_target_properties(${PROJECT_NAME}_linux PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
|
|
target_link_libraries(${PROJECT_NAME}_linux ${LIBS})
|
|
|
|
# Linux Debug
|
|
add_executable(${PROJECT_NAME}_linux_debug ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_linux_debug PRIVATE LINUX_BUILD DEBUG VERBOSE)
|
|
set_target_properties(${PROJECT_NAME}_linux_debug PROPERTIES OUTPUT_NAME "${PROJECT_NAME}_debug")
|
|
target_link_libraries(${PROJECT_NAME}_linux_debug ${LIBS})
|
|
|
|
# Linux Release
|
|
add_executable(${PROJECT_NAME}_linux_release ${SOURCES})
|
|
target_compile_definitions(${PROJECT_NAME}_linux_release PRIVATE LINUX_BUILD)
|
|
set_target_properties(${PROJECT_NAME}_linux_release PROPERTIES OUTPUT_NAME "${PROJECT_NAME}_release")
|
|
target_link_libraries(${PROJECT_NAME}_linux_release ${LIBS})
|
|
endif()
|
|
|
|
# Agregar un custom target para cada tipo de build
|
|
add_custom_target(build_windows_debug DEPENDS ${PROJECT_NAME}_windows_debug)
|
|
add_custom_target(build_windows_release DEPENDS ${PROJECT_NAME}_windows_release)
|
|
add_custom_target(build_macos_debug DEPENDS ${PROJECT_NAME}_macos_debug)
|
|
add_custom_target(build_macos_release DEPENDS ${PROJECT_NAME}_macos_release)
|
|
add_custom_target(build_linux_debug DEPENDS ${PROJECT_NAME}_linux_debug)
|
|
add_custom_target(build_linux_release DEPENDS ${PROJECT_NAME}_linux_release)
|