diff --git a/CMakeLists.txt b/CMakeLists.txt index 01124945..3e6f3dda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,9 @@ if(WEBFRONT_IS_TOP_LEVEL) endif() add_library(WebFront_options INTERFACE) target_compile_features(WebFront_options INTERFACE cxx_std_23) +# The header-only library instantiates enough templates for the examples to exceed MSVC's default +# object-file section limit (error C1128). +target_compile_options(WebFront_options INTERFACE "$<$:/bigobj>") # Do not force-define __cpp_lib_format on the command line: unlike a header setting it after # actually providing , a command-line -D applies from the start of every translation # unit, so other standard headers (e.g. ) that gate their own integration on diff --git a/cmake/StandardProjectSettings.cmake b/cmake/StandardProjectSettings.cmake index 72439bc4..6b8cbd8d 100644 --- a/cmake/StandardProjectSettings.cmake +++ b/cmake/StandardProjectSettings.cmake @@ -12,6 +12,18 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) "Release" "MinSizeRel" "RelWithDebInfo") +elseif(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND NOT CMAKE_DEFAULT_BUILD_TYPE AND NOT CMAKE_DEFAULT_CONFIGS) + # Only Ninja Multi-Config accepts this variable. Visual Studio and Xcode build Debug unless --config is given. + # The default must belong to CMAKE_CONFIGURATION_TYPES, or generation fails. + foreach(_webfront_candidate RelWithDebInfo Release Debug) + if(_webfront_candidate IN_LIST CMAKE_CONFIGURATION_TYPES) + set(CMAKE_DEFAULT_BUILD_TYPE ${_webfront_candidate}) + break() + endif() + endforeach() + if(NOT CMAKE_DEFAULT_BUILD_TYPE AND CMAKE_CONFIGURATION_TYPES) + list(GET CMAKE_CONFIGURATION_TYPES 0 CMAKE_DEFAULT_BUILD_TYPE) + endif() endif() # Generate compile_commands.json to make it easier to work with clang based tools diff --git a/docs/REACT.md b/docs/REACT.md index 9c2f3628..9f663720 100644 --- a/docs/REACT.md +++ b/docs/REACT.md @@ -130,8 +130,18 @@ The C++ event computes a generation, updates the island and sets a tuple snapsho containing the packed grid, generation and population. Each browser owns a separate simulation, released on disconnect. The original Life starter remains available. -Build the `WebFrontLifeReact` CMake target and run it with a writable copy of -`main.tsx` and `webfront.project.json` from that directory as its project argument. +Build the `WebFrontLifeReact` CMake target. The application only creates an +empty project directory when it is missing (without argument `./life-project`); +it does not copy the example's sources. Use a new directory, so that no existing project is touched: `mkdir` fails if it exists and `cp -n` never overwrites a file. Copy `main.tsx` and +`webfront.project.json` from `examples/life/react/` into that directory first, +then start the application: + +```sh +mkdir life-react-project +cp -n examples/life/react/main.tsx examples/life/react/webfront.project.json life-react-project/ +./build/examples/WebFrontLifeReact life-react-project +``` + In its terminal, run `wf install`, then `wf preview`. The configured registry must carry `@webfront/react@0.1.0`; this change prepares the archive but does not publish to npm. The repository's test registry already carries the package. For a local diff --git a/examples/life/react/LifeReact.cpp b/examples/life/react/LifeReact.cpp index cfc143bb..30435f6e 100644 --- a/examples/life/react/LifeReact.cpp +++ b/examples/life/react/LifeReact.cpp @@ -1,17 +1,23 @@ #include "LifeReact.hpp" +#include "../LifeDeveloperOptions.hpp" #include "../LifeFrontend.hpp" #include +#include #include int main(int argc, char** argv) { - if (argc != 2) { - std::cerr << "Usage: WebFrontLifeReact \n"; + if (argc > 2 || (argc == 2 && *argv[1] == '\0')) { + std::cerr << "Usage: WebFrontLifeReact []\n" + "Without argument the project is ./" + << webfront::demo::LifeDeveloperOptions::defaultProject << ", created empty when missing: copy main.tsx and webfront.project.json from examples/life/react/ into it first.\n"; return 2; } try { - webfront::demo::LifeApp app{argv[1]}; + const std::filesystem::path project = argc == 2 ? argv[1] : webfront::demo::LifeDeveloperOptions::defaultProject; + webfront::demo::prepareLifeProject(project); + webfront::demo::LifeApp app{project}; auto subscription = webfront::demo::installLifeReact(app); app.bootstrap("developer"); app.show();