Files
Tahgibu/cmake/BuildTargets.cmake
2026-10-24 12:01:52 -03:00

79 lines
3.8 KiB
CMake

# Destinos: biblioteca del núcleo, aplicación, pruebas y ejemplos.
set(TAHGIBU_CORE_SOURCES
src/core/error.c src/core/context.c
src/document/document.c src/document/doc_ops.c
src/history/history.c
src/editor/edit.c src/editor/tools/tool_raster.c src/editor/tools/tool_fill.c src/editor/tools/tool_region.c
src/animation/render.c src/animation/player.c
src/rendering/canvas.c
src/io/io_util.c src/io/json.c src/io/png.c src/io/tgb_format.c src/io/image_io.c
src/recovery/recovery_points.c src/recovery/autosave.c
src/extensions/plugin_manager.c src/extensions/lua_bridge.c
${TAHGIBU_PLATFORM_SOURCES})
add_library(tahgibu_core STATIC ${TAHGIBU_CORE_SOURCES})
target_include_directories(tahgibu_core PUBLIC include)
target_link_libraries(tahgibu_core PUBLIC ZLIB::ZLIB ${TAHGIBU_PLATFORM_LIBS})
if(UNIX)
target_compile_definitions(tahgibu_core PUBLIC _GNU_SOURCE)
endif()
tahgibu_apply_warnings(tahgibu_core)
if(TAHGIBU_WITH_LUA)
target_compile_definitions(tahgibu_core PRIVATE TAHGIBU_WITH_LUA)
target_include_directories(tahgibu_core PRIVATE ${LUA_INCLUDE_DIR})
target_link_libraries(tahgibu_core PUBLIC ${LUA_LIBRARIES})
endif()
if(TAHGIBU_BUILD_APP)
add_executable(tahgibu src/main.c src/ui/ui_main.c src/ui/ui_canvas.c src/ui/ui_panel.c src/ui/ui_timeline.c src/ui/ui_widgets.c)
target_include_directories(tahgibu PRIVATE src)
target_link_libraries(tahgibu PRIVATE tahgibu_core raylib)
tahgibu_apply_warnings(tahgibu)
if(WIN32)
set_target_properties(tahgibu PROPERTIES WIN32_EXECUTABLE ON)
endif()
install(TARGETS tahgibu RUNTIME DESTINATION bin)
install(DIRECTORY resources/palettes DESTINATION share/tahgibu)
install(FILES README.md LICENSE CHANGELOG.md DESTINATION share/doc/tahgibu)
install(DIRECTORY docs/ DESTINATION share/doc/tahgibu/docs)
endif()
install(DIRECTORY include/tahgibu DESTINATION include)
install(TARGETS tahgibu_core ARCHIVE DESTINATION lib)
if(TAHGIBU_BUILD_EXAMPLES)
add_library(ejemplo_cruz MODULE extensions/native/ejemplo_cruz.c)
target_include_directories(ejemplo_cruz PRIVATE include)
set_target_properties(ejemplo_cruz PROPERTIES PREFIX "")
tahgibu_apply_warnings(ejemplo_cruz)
endif()
if(TAHGIBU_BUILD_TESTS)
enable_testing()
if(UNIX) # las pruebas usan POSIX (fork, mkdtemp, rlimit): aún no son portables a Windows
set(TAHGIBU_PLUGIN_TEST_DIR ${CMAKE_BINARY_DIR}/tests/plugins)
set(TAHGIBU_TEST_PLUGINS plug_good plug_readonly plug_needs_edit plug_init_fails plug_no_entry plug_old_api plug_no_version plug_no_name plug_events)
foreach(p ${TAHGIBU_TEST_PLUGINS})
add_library(${p} MODULE tests/plugins/${p}.c)
target_include_directories(${p} PRIVATE include)
set_target_properties(${p} PROPERTIES PREFIX "" LIBRARY_OUTPUT_DIRECTORY ${TAHGIBU_PLUGIN_TEST_DIR})
tahgibu_apply_warnings(${p})
endforeach()
foreach(t test_canvas_draw test_document_history test_animation test_recovery_points test_io_formats test_io_files test_recovery test_plugins)
add_executable(${t} tests/${t}.c)
target_include_directories(${t} PRIVATE tests)
target_link_libraries(${t} PRIVATE tahgibu_core)
tahgibu_apply_warnings(${t})
add_test(NAME ${t} COMMAND ${t})
endforeach()
target_compile_definitions(test_plugins PRIVATE TGB_TEST_PLUGIN_DIR="${TAHGIBU_PLUGIN_TEST_DIR}")
add_dependencies(test_plugins ${TAHGIBU_TEST_PLUGINS})
if(TAHGIBU_UI_SMOKE) # prueba de la interfaz con un raylib FALSO (desarrollo)
add_executable(ui_smoke tests/ui_smoke/ui_smoke.c tests/ui_smoke/mock_raylib.c
src/ui/ui_main.c src/ui/ui_canvas.c src/ui/ui_panel.c src/ui/ui_timeline.c src/ui/ui_widgets.c)
target_include_directories(ui_smoke PRIVATE tests tools/dev/raylib_stub src)
target_link_libraries(ui_smoke PRIVATE tahgibu_core)
add_test(NAME ui_smoke COMMAND ui_smoke)
endif()
endif()
endif()