Skip to content

Commit

Permalink
Cmake: add him_log_configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Jan 3, 2024
1 parent ed4ce30 commit 3717559
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,7 @@ if (PROJECT_IS_TOP_LEVEL AND NOT IOS AND NOT ANDROID)
install(FILES README.md DESTINATION .)
endif()

message(STATUS "HELLOIMGUI_USE_FREETYPE=${HELLOIMGUI_USE_FREETYPE}")
#------------------------------------------------------------------------------
# Log info
#------------------------------------------------------------------------------
him_log_configuration()
76 changes: 75 additions & 1 deletion hello_imgui_cmake/hello_imgui_build_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ function(_him_add_freetype_to_imgui)

target_link_libraries(imgui PUBLIC ${freetype_linked_library})

if(download_freetype)
set(HELLOIMGUI_FREETYPE_SELECTED_INFO "Downloaded VER-2-13-2" CACHE INTERNAL "" FORCE)
else()
set(HELLOIMGUI_FREETYPE_SELECTED_INFO "Use system Library" CACHE INTERNAL "" FORCE)
endif()

#
# 2. Build lunasvg (static)
#
Expand Down Expand Up @@ -253,7 +259,8 @@ endfunction()

function(him_get_active_backends out_selected_backends)
set(selected_backends "")
foreach(backend ${HELLOIMGUI_AVAILABLE_BACKENDS})
him_get_available_backends(available_backends)
foreach(backend ${available_backends})
if (${backend})
set(selected_backends "${selected_backends} ${backend}")
endif()
Expand Down Expand Up @@ -545,6 +552,8 @@ function (him_use_sdl2_backend target)
${HELLOIMGUI_IMGUI_SOURCE_DIR}/backends/imgui_impl_sdl2.h
${HELLOIMGUI_IMGUI_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp
)
set(HELLOIMGUI_USE_SDL2 ON CACHE INTERNAL "" FORCE)
set(HELLOIMGUI_USE_SDL ON CACHE INTERNAL "" FORCE)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_USE_SDL)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_USE_SDL2)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC _THREAD_SAFE) # flag outputted by sdl2-config --cflags
Expand Down Expand Up @@ -577,6 +586,8 @@ function(_him_fetch_sdl_if_needed)
else()
FetchContent_MakeAvailable(sdl)
endif()
else()
set(HELLOIMGUI_SDL_SELECTED_INFO "Use system Library" CACHE INTERNAL "" FORCE)
endif()
endfunction()

Expand All @@ -597,6 +608,7 @@ function(_him_fetch_declare_sdl)
GIT_TAG release-${sdl_version}
GIT_PROGRESS TRUE
)
set(HELLOIMGUI_SDL_SELECTED_INFO "Downloaded ${sdl_version}" CACHE INTERNAL "" FORCE)
endfunction()

function(_him_prepare_android_sdl_symlink)
Expand Down Expand Up @@ -647,6 +659,8 @@ function(him_use_glfw_backend target)
${HELLOIMGUI_IMGUI_SOURCE_DIR}/backends/imgui_impl_glfw.h
${HELLOIMGUI_IMGUI_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
)
set(HELLOIMGUI_USE_GLFW ON CACHE INTERNAL "" FORCE)
set(HELLOIMGUI_USE_GLFW3 ON CACHE INTERNAL "" FORCE)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_USE_GLFW)
target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_USE_GLFW3)
endfunction()
Expand Down Expand Up @@ -675,6 +689,9 @@ function(_him_fetch_glfw_if_needed)
set(GLFW_BUILD_DOCS OFF)
set(GLFW_INSTALL OFF)
FetchContent_MakeAvailable(glfw)
set(HELLOIMGUI_GLFW_SELECTED_INFO "Downloaded 3.3.8" CACHE INTERNAL "" FORCE)
else()
set(HELLOIMGUI_GLFW_SELECTED_INFO "Use system Library" CACHE INTERNAL "" FORCE)
endif()

endfunction()
Expand Down Expand Up @@ -707,6 +724,63 @@ function(him_install)
endfunction()


###################################################################################################
# Log Configuration at the end of the configuration: API = him_log_configuration
###################################################################################################
function(him_log_configuration)
him_get_active_backends(selected_backends)
set(msg "
hello_imgui build options:
===========================================================================
Backends: ${selected_backends}
---------------------------------------------------------------------------
Options:
HELLOIMGUI_USE_FREETYPE: ${HELLOIMGUI_USE_FREETYPE} (${HELLOIMGUI_FREETYPE_SELECTED_INFO})
HELLOIMGUI_WITH_TEST_ENGINE: ${HELLOIMGUI_WITH_TEST_ENGINE}
BUILD_DEMOS - TESTS - DOCS: ${HELLOIMGUI_BUILD_DEMOS} - ${HELLOIMGUI_BUILD_TESTS} - ${HELLOIMGUI_BUILD_DOCS}
---------------------------------------------------------------------------
Config:
HELLOIMGUI_USE_GLAD: ${HELLOIMGUI_USE_GLAD}
Build ImGui - ImGui source dir: ${HELLOIMGUI_BUILD_IMGUI} - ${HELLOIMGUI_IMGUI_SOURCE_DIR}")

if(EMSCRIPTEN)
set(msg "${msg}
---------------------------------------------------------------------------
Emscripten options
HELLOIMGUI_EMSCRIPTEN_PTHREAD: ${HELLOIMGUI_EMSCRIPTEN_PTHREAD}
HELLOIMGUI_EMSCRIPTEN_PTHREAD_ALLOW_MEMORY_GROWTH: ${HELLOIMGUI_EMSCRIPTEN_PTHREAD_ALLOW_MEMORY_GROWTH}")
endif ()

if(HELLOIMGUI_USE_SDL)
set(msg "${msg}
---------------------------------------------------------------------------
SDL: ${HELLOIMGUI_SDL_SELECTED_INFO}")
endif()

if(HELLOIMGUI_USE_GLFW)
set(msg "${msg}
---------------------------------------------------------------------------
Glfw: ${HELLOIMGUI_GLFW_SELECTED_INFO}")
endif()

if(WIN32)
set(msg "${msg}
---------------------------------------------------------------------------
Windows info
HELLOIMGUI_WIN32_NO_CONSOLE: ${HELLOIMGUI_WIN32_NO_CONSOLE}
HELLOIMGUI_WIN32_AUTO_WINMAIN: ${HELLOIMGUI_WIN32_AUTO_WINMAIN}")
endif()

if(MACOSX)
set(msg "${msg}
---------------------------------------------------------------------------
macOS info
HELLOIMGUI_MACOS_NO_BUNDLE: ${HELLOIMGUI_MACOS_NO_BUNDLE}")
endif()

message(STATUS "${msg}")
endfunction()

###################################################################################################
# Main: API = him_main_add_hello_imgui_library
###################################################################################################
Expand Down

0 comments on commit 3717559

Please sign in to comment.