Files
fn_registry/cpp/CMakeLists.txt
T
egutierrez 099be06409 feat(primitives_gallery): demo de gl_texture_load + asset PNG
Añade demos_gl_texture.cpp (carga assets/sample.png con la nueva
funcion gl_texture_load_cpp_gfx, muestra w/h/channels y sliders de
tint RGB + zoom UV via ImGui::ImageWithBg) y un PNG damero 256x256
generado para la demo.

Tambien registra apps/primitives_gallery como subdirectorio en
cpp/CMakeLists.txt (la app vive como WIP en master; aqui solo se
añade el hook de build).

Para integrarse, demos.h, main.cpp y CMakeLists.txt de la gallery
deben anadir respectivamente la declaracion gallery::demo_gl_texture(),
la entrada {"gl_texture", "gl_texture_load", "Gfx", &gallery::demo_gl_texture}
en k_demos[], y demos_gl_texture.cpp + cpp/functions/gfx/gl_texture_load.cpp +
cpp/vendor/stb/stb_image_impl.cpp + include de cpp/vendor/stb a sus sources.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 20:58:50 +02:00

128 lines
4.2 KiB
CMake

cmake_minimum_required(VERSION 3.16)
project(fn_registry_cpp LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# --- Options ---
option(TRACY_ENABLE "Enable Tracy profiling" OFF)
# --- Vendor: Dear ImGui ---
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/imgui)
add_library(imgui STATIC
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/imgui_demo.cpp
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
)
target_include_directories(imgui PUBLIC
${IMGUI_DIR}
${IMGUI_DIR}/backends
)
# --- Vendor: ImPlot ---
set(IMPLOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/implot)
add_library(implot STATIC
${IMPLOT_DIR}/implot.cpp
${IMPLOT_DIR}/implot_items.cpp
)
target_include_directories(implot PUBLIC ${IMPLOT_DIR})
target_link_libraries(implot PUBLIC imgui)
# --- Vendor: Tracy (optional) ---
if(TRACY_ENABLE)
set(TRACY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/tracy)
add_library(tracy STATIC
${TRACY_DIR}/public/TracyClient.cpp
)
target_include_directories(tracy PUBLIC ${TRACY_DIR}/public)
target_compile_definitions(tracy PUBLIC TRACY_ENABLE)
endif()
# --- Vendor: imgui-node-editor ---
set(NODE_EDITOR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/imgui-node-editor)
add_library(imgui_node_editor STATIC
${NODE_EDITOR_DIR}/imgui_node_editor.cpp
${NODE_EDITOR_DIR}/imgui_node_editor_api.cpp
${NODE_EDITOR_DIR}/imgui_canvas.cpp
${NODE_EDITOR_DIR}/crude_json.cpp
)
target_include_directories(imgui_node_editor PUBLIC ${NODE_EDITOR_DIR})
target_link_libraries(imgui_node_editor PUBLIC imgui)
# --- Platform dependencies ---
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Cross-compile: use vendored or system GLFW, link opengl32/gdi32
find_package(glfw3 QUIET)
if(NOT glfw3_FOUND)
# Build GLFW from source if available
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw/CMakeLists.txt)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(vendor/glfw)
else()
message(FATAL_ERROR "GLFW not found. For Windows cross-compile, add GLFW source to cpp/vendor/glfw/")
endif()
endif()
set(PLATFORM_LIBS glfw opengl32 gdi32 imm32)
else()
# Linux native
find_package(glfw3 REQUIRED)
find_package(OpenGL REQUIRED)
set(PLATFORM_LIBS glfw OpenGL::GL ${CMAKE_DL_LIBS})
endif()
target_link_libraries(imgui PUBLIC ${PLATFORM_LIBS})
# --- Framework ---
add_library(fn_framework STATIC
framework/app_base.cpp
)
target_include_directories(fn_framework PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/framework
${CMAKE_CURRENT_SOURCE_DIR}/functions
)
target_link_libraries(fn_framework PUBLIC imgui implot)
if(TRACY_ENABLE)
target_link_libraries(fn_framework PUBLIC tracy)
endif()
# --- Macro for creating ImGui apps ---
function(add_imgui_app target)
add_executable(${target} ${ARGN})
target_link_libraries(${target} PRIVATE fn_framework)
target_include_directories(${target} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/functions
)
endfunction()
# --- Function libraries (headers for composition) ---
# Functions are compiled as part of apps that use them via add_imgui_app.
# Each function is a .h/.cpp pair included by the app's CMakeLists.txt.
# --- Demo app ---
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/apps/chart_demo/CMakeLists.txt)
add_subdirectory(apps/chart_demo)
endif()
# --- Shaders Lab ---
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/apps/shaders_lab/CMakeLists.txt)
add_subdirectory(apps/shaders_lab)
endif()
# --- Primitives Gallery ---
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/apps/primitives_gallery/CMakeLists.txt)
add_subdirectory(apps/primitives_gallery)
endif()
# --- Registry Dashboard (lives in projects/fn_monitoring/apps/) ---
set(_DASH_DIR ${CMAKE_SOURCE_DIR}/../projects/fn_monitoring/apps/registry_dashboard)
if(EXISTS ${_DASH_DIR}/CMakeLists.txt)
add_subdirectory(${_DASH_DIR} ${CMAKE_BINARY_DIR}/apps/registry_dashboard)
endif()