-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate imgui_bundle_add_demo.cmake
- Loading branch information
Showing
9 changed files
with
91 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
bindings/imgui_bundle/demos_cpp/demos_imguizmo/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Add one demo application per file | ||
add_this_folder_auto_demos() | ||
ibd_add_this_folder_auto_demos() | ||
|
||
# Also add these demos as a library (where IMGUI_BUNDLE_BUILD_DEMO_AS_LIBRARY will disable existing main() functions) | ||
add_this_folder_as_demos_library() | ||
ibd_add_this_folder_as_demos_library() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
bindings/imgui_bundle/demos_cpp/demos_immvision/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Add one demo application per file | ||
add_this_folder_auto_demos() | ||
ibd_add_this_folder_auto_demos() | ||
|
||
# Also add these demos as a library (where IMGUI_BUNDLE_BUILD_DEMO_AS_LIBRARY will disable existing main() functions) | ||
add_this_folder_as_demos_library() | ||
ibd_add_this_folder_as_demos_library() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Add one demo application per file | ||
add_this_folder_auto_demos() | ||
ibd_add_this_folder_auto_demos() | ||
|
||
# Also add these demos as a library (where IMGUI_BUNDLE_BUILD_DEMO_AS_LIBRARY will disable existing main() functions) | ||
add_this_folder_as_demos_library() | ||
ibd_add_this_folder_as_demos_library() | ||
|
||
target_sources(demo_nanovg_full PRIVATE demo_nanovg_full/demo_nanovg_full_impl.cpp demo_nanovg_full/demo_nanovg_full_impl.h) |
4 changes: 2 additions & 2 deletions
4
bindings/imgui_bundle/demos_cpp/demos_node_editor/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Add one demo application per file | ||
add_this_folder_auto_demos() | ||
ibd_add_this_folder_auto_demos() | ||
|
||
# Also add these demos as a library (where IMGUI_BUNDLE_BUILD_DEMO_AS_LIBRARY will disable existing main() functions) | ||
add_this_folder_as_demos_library() | ||
ibd_add_this_folder_as_demos_library() |
4 changes: 2 additions & 2 deletions
4
bindings/imgui_bundle/demos_cpp/demos_tex_inspect/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Add one demo application per file | ||
add_this_folder_auto_demos() | ||
ibd_add_this_folder_auto_demos() | ||
|
||
# Also add these demos as a library (where IMGUI_BUNDLE_BUILD_DEMO_AS_LIBRARY will disable existing main() functions) | ||
add_this_folder_as_demos_library() | ||
ibd_add_this_folder_as_demos_library() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
add_this_folder_auto_demos() | ||
ibd_add_this_folder_auto_demos() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# CMake functions to simplify the creation of demo apps using imgui_bundle | ||
# Those are convenience functions, mostly used in the C++ and in the tutorials. | ||
|
||
function(ibd_add_demo_cpp) | ||
# Creates an app using imgui_bundle_add_app, and link it with demo_utils | ||
# Usage: | ||
# ibd_add_demo_cpp(demo_name demo_file_1.cpp demo_file_2.cpp) | ||
set(args ${ARGN}) | ||
list(GET args 0 demo_name) | ||
set(demos_asset_folder ${IMGUI_BUNDLE_PATH}/bindings/imgui_bundle/demos_assets) | ||
imgui_bundle_add_app(${args} ASSETS_LOCATION ${demos_asset_folder}) | ||
if(MSVC) | ||
hello_imgui_msvc_target_set_folder(${demo_name} demos_cpp) | ||
endif() | ||
target_link_libraries(${demo_name} PUBLIC demo_utils) | ||
if (EMSCRIPTEN) | ||
# Bundle demos_assets | ||
hello_imgui_bundle_assets_from_folder(${demo_name} ${demos_cpp_folder}/../demos_assets) | ||
endif() | ||
endfunction() | ||
|
||
function(ibd_add_single_file_demo_cpp demo_cpp_file) | ||
# Creates a demo app | ||
# Usage: | ||
# ibd_add_single_file_demo_cpp(demo_file.cpp) | ||
get_filename_component(demo_name "${demo_cpp_file}" NAME_WE) | ||
ibd_add_demo_cpp(${demo_name} ${demo_cpp_file}) | ||
endfunction() | ||
|
||
function(ibd_add_auto_demo demo_cpp_file) | ||
# Creates a demo app, and provides main() automatically | ||
# Usage: | ||
# ibd_add_auto_demo(demo_file.cpp) | ||
# (demo_file.cpp should provide a function named according to the containing file, e.g. `void demo_file()`) | ||
get_filename_component(demo_cpp_file "${demo_cpp_file}" NAME) | ||
get_filename_component(demo_name "${demo_cpp_file}" NAME_WE) | ||
ibd_add_demo_cpp(${demo_name} ${demo_cpp_file}) | ||
|
||
# Read the contents of the cpp file | ||
file(READ "${demo_cpp_file}" demo_cpp_file_content) | ||
|
||
# If the cpp file does not contain a main function, provide it | ||
if (NOT "${demo_cpp_file_content}" MATCHES "int main") | ||
message(STATUS "${demo_cpp_file} does not contain a main function, adding it!") | ||
set(main_file ${CMAKE_CURRENT_BINARY_DIR}/${demo_cpp_file}.autogenerated.cpp) | ||
configure_file(${demos_cpp_folder}/_auto_main/_auto_main.cpp.in ${main_file}) | ||
target_sources(${demo_name} PRIVATE ${main_file}) | ||
endif() | ||
|
||
endfunction() | ||
|
||
function(ibd_add_this_folder_demos) | ||
# Creates demo apps for all cpp files in the current folder | ||
FILE(GLOB demo_cpp_files *.cpp) | ||
FOREACH(demo_cpp_file ${demo_cpp_files}) | ||
ibd_add_single_file_demo_cpp(${demo_cpp_file}) | ||
ENDFOREACH() | ||
endfunction() | ||
|
||
function(ibd_add_this_folder_auto_demos) | ||
# Creates demo apps for all cpp files in the current folder, and provide a main for them | ||
FILE(GLOB demo_cpp_files *.cpp) | ||
FOREACH(demo_cpp_file ${demo_cpp_files}) | ||
ibd_add_auto_demo(${demo_cpp_file}) | ||
ENDFOREACH() | ||
endfunction() | ||
|
||
|
||
function(ibd_add_this_folder_as_demos_library) | ||
file(GLOB sources *.cpp) | ||
get_filename_component(folder_name "${CMAKE_CURRENT_LIST_DIR}" NAME_WE) | ||
set(demos_library_name ${folder_name}) | ||
add_library(${demos_library_name} ${sources}) | ||
target_link_libraries(${demos_library_name} PRIVATE imgui_bundle) | ||
target_compile_definitions(${demos_library_name} PRIVATE IMGUI_BUNDLE_BUILD_DEMO_AS_LIBRARY) | ||
endfunction() |