Canvis en CMakeLists.txt
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# CMakeLists.txt completo (incluyendo configuraciones anteriores)
|
||||
# CMakeLists.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(coffee_crisis_arcade_edition VERSION 0.01)
|
||||
@@ -14,7 +14,13 @@ set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Configuración global de flags de compilación
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Os -ffunction-sections -fdata-sections")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
|
||||
# Flags específicas para Debug
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
|
||||
|
||||
# Flags específicas para Release
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -ffunction-sections -fdata-sections")
|
||||
|
||||
# Define el directorio de los archivos fuente
|
||||
set(DIR_SOURCES "${CMAKE_SOURCE_DIR}/source")
|
||||
@@ -47,78 +53,24 @@ set(LIBS SDL2)
|
||||
# Configuración común de salida de ejecutables en el directorio raíz
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
# Objetivos específicos por plataforma
|
||||
# Añadir ejecutable principal
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
# Añadir definiciones de compilación dependiendo del tipo de build
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:DEBUG>:DEBUG VERBOSE>)
|
||||
|
||||
# Enlazar bibliotecas
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBS})
|
||||
|
||||
# Configuración específica para cada plataforma
|
||||
if(WIN32)
|
||||
set(LIBS ${LIBS} SDL2main 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}_windows")
|
||||
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}_windows_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}_windows_release")
|
||||
target_link_libraries(${PROJECT_NAME}_windows_release ${LIBS})
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE WINDOWS_BUILD)
|
||||
target_link_libraries(${PROJECT_NAME} mingw32 opengl32 gdi32 winmm imm32 ole32 version)
|
||||
elseif(APPLE)
|
||||
set(LIBS ${LIBS} "-framework OpenGL")
|
||||
|
||||
# Añadir la flag de compilación para desactivar advertencias de obsolescencia
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUILD)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
|
||||
|
||||
# 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}_macos")
|
||||
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}_macos_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}_macos_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}_linux")
|
||||
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}_linux_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}_linux_release")
|
||||
target_link_libraries(${PROJECT_NAME}_linux_release ${LIBS})
|
||||
endif()
|
||||
|
||||
# Agregar custom targets para invocar objetivos de build específicos
|
||||
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)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD)
|
||||
endif()
|
||||
Reference in New Issue
Block a user