diff --git a/README.md b/README.md index d8c6e50..042ee0b 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ A simple C++ library for terminal based user interface. - [Starter example project](https://github.com/ArthurSonzogni/ftxui-starter) - [Documentation](https://arthursonzogni.github.io/FTXUI/) -- [Examples (WebAssembly)](https://arthursonzogni.github.io/FTXUI/examples/) +- [Examples (WebAssembly)](https://arthursonzogni.com/FTXUI/examples/) - [Build using CMake](https://arthursonzogni.com/FTXUI/doc/#build-using-cmake) - [Build using nxxm](https://arthursonzogni.com/FTXUI/doc/#build-using-cmake) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index b47de23..3062e2a 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -3,10 +3,9 @@ if (DOXYGEN_FOUND) # Generate example list for documentation set(EXAMPLE_LIST "${CMAKE_CURRENT_BINARY_DIR}/example_list.md") file(WRITE ${EXAMPLE_LIST} "# Examples") - file(GLOB_RECURSE EXAMPLES RELATIVE ${PROJECT_SOURCE_DIR} - "${PROJECT_SOURCE_DIR}/examples/*.cpp") + get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES) foreach(EXAMPLE IN LISTS EXAMPLES) - file(APPEND ${EXAMPLE_LIST} "\n@example ${EXAMPLE}") + file(APPEND ${EXAMPLE_LIST} "\n@example examples/${EXAMPLE}.cpp") endforeach(EXAMPLE IN LISTS EXAMPLES) configure_file(Doxyfile.in Doxyfile @ONLY) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 41e3207..c30eb67 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,14 +1,19 @@ +set(EXAMPLES_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +function(example name) + add_executable(${name} ${name}.cpp) + target_link_libraries(${name} PUBLIC ${DIRECTORY_LIB}) + file(RELATIVE_PATH dir ${EXAMPLES_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + set_property(GLOBAL APPEND PROPERTY FTXUI::EXAMPLES ${dir}/${name}) +endfunction(example) + add_subdirectory(component) add_subdirectory(dom) -add_subdirectory(util) if (EMSCRIPTEN) + get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES) foreach(file "index.html" - "run_webassembly.sh") - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/${file} - ${CMAKE_CURRENT_BINARY_DIR}/${file} - ) + "run_webassembly.py") + configure_file(${file} ${file}) endforeach(file) endif() diff --git a/examples/component/CMakeLists.txt b/examples/component/CMakeLists.txt index 30702f5..29f61ab 100644 --- a/examples/component/CMakeLists.txt +++ b/examples/component/CMakeLists.txt @@ -1,7 +1,4 @@ -function(example name) - add_executable(${name} ${name}.cpp) - target_link_libraries(${name} PUBLIC component) -endfunction(example) +set(DIRECTORY_LIB component) example(button) example(checkbox) @@ -23,3 +20,4 @@ example(tab_horizontal) example(tab_vertical) example(toggle) example(resizable_split) +example(print_key_press) diff --git a/examples/util/print_key_press.cpp b/examples/component/print_key_press.cpp similarity index 100% rename from examples/util/print_key_press.cpp rename to examples/component/print_key_press.cpp diff --git a/examples/dom/CMakeLists.txt b/examples/dom/CMakeLists.txt index e750925..c1297ea 100644 --- a/examples/dom/CMakeLists.txt +++ b/examples/dom/CMakeLists.txt @@ -1,7 +1,4 @@ -function(example name) - add_executable(${name} ${name}.cpp) - target_link_libraries(${name} PUBLIC dom) -endfunction(example) +set(DIRECTORY_LIB dom) example(border) example(color_gallery) diff --git a/examples/index.html b/examples/index.html index a4a427d..fe903b6 100644 --- a/examples/index.html +++ b/examples/index.html @@ -23,52 +23,10 @@