### Build Examples Source: https://github.com/emweb/wt/blob/master/INSTALL.html Builds the project examples using the make command. This is the first step in deploying the example applications. ```shell make -C examples ``` -------------------------------- ### CMake Example Installation Configuration Source: https://github.com/emweb/wt/blob/master/examples/CMakeLists.txt Handles the installation logic for WT examples, determining subdirectories for binaries, documentation roots, and application roots based on source file locations and existence of specific directories like 'docroot' or 'approot'. ```cmake IF(INSTALL_EXAMPLES) SET( ${name}_SOURCEFILES ${ARGV} ) LIST( REMOVE_AT ${name}_SOURCEFILES 0 ) LIST(GET ${name}_SOURCEFILES 0 ${name}_FIRST_SOURCEFILE ) GET_SOURCE_FILE_PROPERTY(${name}_FIRST_SOURCEFILE_FULLPATH ${${name}_FIRST_SOURCEFILE} LOCATION) STRING(REPLACE ${WT_SOURCE_DIR}/examples/ "" ${name}_SUBDIRANDSOURCE ${${name}_FIRST_SOURCEFILE_FULLPATH}) STRING(REPLACE /${${name}_FIRST_SOURCEFILE} "" ${name}_SUBDIR ${${name}_SUBDIRANDSOURCE}) SET( EXAMPLESUBDIR ${${name}_SUBDIR} ) SET( EXAMPLESUBDIRFROMPREFIX ${EXAMPLES_DESTINATION}/${EXAMPLESUBDIR} ) STRING( REPLACE .wt "" EXAMPLENAME ${name} ) SET(DOCROOTSUBFOLDER) SET(_${EXAMPLENAME}_POTENTIAL_DOCROOTSUBFOLDER ${WT_SOURCE_DIR}/examples/${EXAMPLESUBDIR}/docroot) IF(EXISTS ${_${EXAMPLENAME}_POTENTIAL_DOCROOTSUBFOLDER}) SET(DOCROOTSUBFOLDER docroot) ENDIF(EXISTS ${_${EXAMPLENAME}_POTENTIAL_DOCROOTSUBFOLDER}) SET(APPROOTSUBFOLDER) SET(_${EXAMPLENAME}_POTENTIAL_APPROOTSUBFOLDER ${WT_SOURCE_DIR}/examples/${EXAMPLESUBDIR}/approot) IF(EXISTS ${_${EXAMPLENAME}_POTENTIAL_APPROOTSUBFOLDER}) SET(APPROOTSUBFOLDER approot) ENDIF(EXISTS ${_${EXAMPLENAME}_POTENTIAL_APPROOTSUBFOLDER}) ENDIF(INSTALL_EXAMPLES) ``` -------------------------------- ### Running a Wt Example Source: https://github.com/emweb/wt/blob/master/INSTALL.html Demonstrates how to navigate to an example's source directory, create a symbolic link for resources, and execute the example using command-line arguments. It also specifies the server address and port. ```shell $ cd ../examples/_foobar_ # source directory for example _foobar_ $ ln -s ../../resources . # include standard Wt resource files $ ../../build/examples/_foobar_/_foobar_.wt --docroot . --http-listen 0.0.0.0:8080 ``` -------------------------------- ### Build Wt Examples Source: https://github.com/emweb/wt/blob/master/INSTALL.html Command to compile the example applications that come with the Wt library. The '-C examples' flag changes the directory to 'examples' before executing 'make'. ```shell make -C examples ``` -------------------------------- ### Deploy Example Application Source: https://github.com/emweb/wt/blob/master/INSTALL.html Copies the built example binary, source directory, and resources to a destination directory for web serving. It also highlights the use of 'approot' for cleaner deployment. ```shell export DESTINATION=/var/www/localhost/htdocs/wt-examples mkdir -p $DESTINATION/_foobar_ cp -r examples/_foobar_/* resources/* build/examples/_foobar_/*.wt $DESTINATION/_foobar_/ ``` -------------------------------- ### Setup Resources Link Source: https://github.com/emweb/wt/blob/master/examples/qrlogin/README.txt Creates a symbolic link to the resources directory, typically required for the example to access necessary files. ```bash ln -s ../../resources . ``` -------------------------------- ### CMake WT_ADD_EXAMPLE Macro for Example Installation Source: https://github.com/emweb/wt/blob/master/examples/CMakeLists.txt Defines a CMake macro `WT_ADD_EXAMPLE` to handle the installation of project examples. It conditionally sets variables for Windows-specific script paths and configures installation targets based on the operating system, generating batch files for Windows and executable scripts for other platforms. ```cmake MACRO(WT_ADD_EXAMPLE EXAMPLENAME EXAMPLESUBDIR) IF(INSTALL_EXAMPLES) IF(EXISTS ${_${EXAMPLENAME}_POTENTIAL_APPROOTSUBFOLDER}) SET(APPROOTSUBFOLDER approot) ENDIF(EXISTS ${_${EXAMPLENAME}_POTENTIAL_APPROOTSUBFOLDER}) INSTALL( TARGETS ${name} DESTINATION ${EXAMPLES_DESTINATION}/${${name}_SUBDIR} ) IF(WIN32) SET(SCRIPT_DOCROOT "--docroot .") IF(DOCROOTSUBFOLDER) SET(SCRIPT_DOCROOT "--docroot ${DOCROOTSUBFOLDER}") ENDIF(DOCROOTSUBFOLDER) SET(SCRIPT_APPROOT "") IF(APPROOTSUBFOLDER) SET(SCRIPT_APPROOT "--approot ${APPROOTSUBFOLDER}") ENDIF(APPROOTSUBFOLDER) CONFIGURE_FILE(${WT_SOURCE_DIR}/examples/run-example.bat.cmake ${WT_BINARY_DIR}/examples/${EXAMPLESUBDIR}/${EXAMPLENAME}.bat @ONLY) INSTALL(PROGRAMS ${WT_BINARY_DIR}/examples/${EXAMPLESUBDIR}/${EXAMPLENAME}.bat DESTINATION bin ) ELSE(WIN32) CONFIGURE_FILE(${WT_SOURCE_DIR}/examples/run-example.cmake ${WT_BINARY_DIR}/examples/${EXAMPLESUBDIR}/${EXAMPLENAME} @ONLY) INSTALL(PROGRAMS ${WT_BINARY_DIR}/examples/${EXAMPLESUBDIR}/${EXAMPLENAME} DESTINATION ${EXAMPLES_DESTINATION}/${EXAMPLESUBDIR}) ENDIF(WIN32) ENDIF(INSTALL_EXAMPLES) ENDMACRO(WT_ADD_EXAMPLE) ``` -------------------------------- ### WT Example Setup with CMake Source: https://github.com/emweb/wt/blob/master/examples/authentication/mfa/pin/CMakeLists.txt This snippet demonstrates CMake commands for setting up a WT (Wt C++ framework) example. It includes adding an example with its source files, linking necessary libraries, configuring files, and setting include directories. ```cmake WT_ADD_EXAMPLE(pin-login.wt myauthwidget.h myauthwidget.cpp mysession.h mysession.cpp myuser.h myuser.cpp pinwidget.h pinwidget.cpp pin-login.cpp ) target_link_libraries(pin-login.wt ${EXAMPLES_DBO_LIBS}) configure_file(approot/template.xml template.xml COPYONLY) include_directories(${WT_SOURCE_DIR}/src) ``` -------------------------------- ### Wt Application Server Setup Source: https://github.com/emweb/wt/blob/master/doc/tutorial/auth.adoc Sets up the Wt web server, defines the application entry point, configures authentication services, and starts the server. Handles potential exceptions during server execution. ```cpp std::unique_ptr createApplication(const Wt::WEnvironment &env) { return std::make_unique(env); } int main(int argc, char **argv) { try { Wt::WServer server{argc, argv, WTHTTP_CONFIGURATION}; server.addEntryPoint(Wt::EntryPointType::Application, createApplication); Session::configureAuth(); server.run(); } catch (Wt::WServer::Exception& e) { std::cerr << e.what() << '\n'; } catch (Wt::Dbo::Exception &e) { std::cerr << "Dbo exception: " << e.what() << '\n'; } catch (std::exception &e) { std::cerr << "exception: " << e.what() << '\n'; } } ``` -------------------------------- ### Wt Example Build Configuration Source: https://github.com/emweb/wt/blob/master/examples/webgl/CMakeLists.txt This CMake script configures the build for a Wt web application example, specifically the 'webgl.wt' example. It conditionally links against Boost headers and uses the WT_ADD_EXAMPLE macro for proper setup, handling potential ISAPI connector builds. ```cmake IF(BOOST_WT_FOUND) # # The ADD_EXAMPLE macro (defined in examples/CMakeLists.txt) ensures that # the example is correctly built for the requested connector. It is equivalent # to the following two lines: # ADD_EXECUTABLE(hello.wt hello.C) # TARGET_LINK_LIBRARIES(hello.wt ${EXAMPLES_CONNECTOR}) # except when the ISAPI (for Microsoft IIS) connector is used, where it will # build a DLL with the proper symbols exported. # WT_ADD_EXAMPLE(webgl.wt teapot.C readObj.C PaintWidget.C) IF(TARGET Boost::headers) TARGET_LINK_LIBRARIES(webgl.wt Boost::headers) ENDIF() # # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/include) # instead of the following: # INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) ELSE(BOOST_WT_FOUND) MESSAGE(STATUS "** Not building webgl example: requires boost headers.") ENDIF(BOOST_WT_FOUND) ``` -------------------------------- ### Execute WT Example Command Source: https://github.com/emweb/wt/blob/master/examples/README.md This command navigates to an example's source directory and executes the example program. It specifies the document root, HTTP address, port, and resource directory for the example's operation. ```shell cd foobar # source directory for example foobar ../../build/examples/foobar/foobar.wt --docroot . --http-address 0.0.0.0 --http-port 8080 --resources-dir=../../resources ``` -------------------------------- ### Run QRLogin Example Source: https://github.com/emweb/wt/blob/master/examples/qrlogin/README.txt Command to execute the QRLogin example application, specifying its configuration file. ```bash ../../build/examples/qrlogin/qrlogin.wt -c wt_config.xml ``` -------------------------------- ### CMake Android Build Setup for WT Examples Source: https://github.com/emweb/wt/blob/master/examples/CMakeLists.txt Configures the build process for WT examples targeting Android. This includes creating directories, setting library output paths, generating Java files via `configure_file`, running `ant` for project updates, and stripping binaries. ```cmake if(ANDROID) set(WT_ANDROID plaforms/android/wt-android) make_directory(${CMAKE_CURRENT_BINARY_DIR}/wt-android) make_directory(${CMAKE_CURRENT_BINARY_DIR}/wt-android/libs/armeabi) SET(MYLIST ${ARGV}) LIST(INSERT MYLIST 1 SHARED) ADD_LIBRARY(${MYLIST}) set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/wt-android/libs/armeabi" OUTPUT_NAME wt-jni) string(REPLACE ".wt" "" APP_NAME ${name}) string(LENGTH ${APP_NAME} APP_NAME_LENGTH) math(EXPR APP_NAME_LENGTH_MINUS_ONE "${APP_NAME_LENGTH} - 1") string(SUBSTRING ${APP_NAME} 0 1 APP_NAME_BEGIN) string(TOUPPER ${APP_NAME_BEGIN} APP_NAME_BEGIN_UPPER) string(SUBSTRING ${APP_NAME} 1 ${APP_NAME_LENGTH_MINUS_ONE} APP_NAME_END) set(APP_NAME "Wt${APP_NAME_BEGIN_UPPER}${APP_NAME_END}") make_directory(${CMAKE_CURRENT_BINARY_DIR}/wt-android/assets) set(WT_ANDROID target/android/wt-android) configure_file(${WT_SOURCE_DIR}/${WT_ANDROID}/src/eu/webtoolkit/android/WtAndroid.java ${CMAKE_CURRENT_BINARY_DIR}/wt-android/src/eu/webtoolkit/android/WtAndroid.java) make_directory(${CMAKE_CURRENT_BINARY_DIR}/wt-android/src/eu/webtoolkit/android/${APP_NAME}/) configure_file("${WT_SOURCE_DIR}/${WT_ANDROID}/src/eu/webtoolkit/android/WtExample.java.template" ${CMAKE_CURRENT_BINARY_DIR}/wt-android/src/eu/webtoolkit/android/${APP_NAME}/${APP_NAME}.java) make_directory(${CMAKE_CURRENT_BINARY_DIR}/wt-android/res) FILE(COPY ${WT_SOURCE_DIR}/${WT_ANDROID}/utils.xml DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wt-android) configure_file("${WT_SOURCE_DIR}/${WT_ANDROID}/AndroidManifest.xml.template" ${CMAKE_CURRENT_BINARY_DIR}/wt-android/AndroidManifest.xml) add_custom_command(TARGET ${name} POST_BUILD COMMAND ant -f ${CMAKE_CURRENT_BINARY_DIR}/wt-android/utils.xml -Dwt.dir=${WT_SOURCE_DIR} -Dexample.dir=${CMAKE_CURRENT_SOURCE_DIR} -Dwt-android.dir=${CMAKE_CURRENT_BINARY_DIR}/wt-android/) IF(NOT DEFINED ANDROID_STRIP) MESSAGE(" Warning!!! ANDROID_STRIP is not defined!") MESSAGE(" Warning!!! The so file will not be stripped and your android") MESSAGE(" package might be too large to fit on the target") MESSAGE(" device!") ELSE(NOT DEFINED ANDROID_STRIP) add_custom_command(TARGET ${name} POST_BUILD COMMAND ${ANDROID_STRIP} "${CMAKE_CURRENT_BINARY_DIR}/wt-android/libs/armeabi/*") ENDIF(NOT DEFINED ANDROID_STRIP) add_custom_command(TARGET ${name} POST_BUILD COMMAND ${ANDROID_SDK_DIR}/tools/android update project --name wt-android --target ${ANDROID_SDK_TARGET_ID} --path ${CMAKE_CURRENT_BINARY_DIR}/wt-android/) add_custom_command(TARGET ${name} POST_BUILD COMMAND ant -f ${CMAKE_CURRENT_BINARY_DIR}/wt-android/build.xml debug) ENDIF(ANDROID) ``` -------------------------------- ### CMake Build Configuration for dbo-tutorial9 Source: https://github.com/emweb/wt/blob/master/examples/feature/dbo/tutorial9/CMakeLists.txt This CMake script sets up the build environment for the 'dbo-tutorial9' executable. It defines the source files, links necessary libraries (conditionally including Boost.Thread), sets include directories, and configures installation properties based on build flags. ```cmake SET(tutorial_libs ${EXAMPLES_DBO_LIBS}) #IF (MULTI_THREADED) # SET(tutorial_libs ${tutorial_libs} ${BOOST_THREAD_LIB}) #ENDIF (MULTI_THREADED) ADD_EXECUTABLE(dbo-tutorial9 main.C Membership.C Organisation.C Person.C) TARGET_LINK_LIBRARIES(dbo-tutorial9 ${tutorial_libs}) INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) IF(MSVC) SET_TARGET_PROPERTIES(dbo-tutorial9 PROPERTIES FOLDER "dbo/examples") ENDIF(MSVC) IF(INSTALL_EXAMPLES) INSTALL(TARGETS dbo-tutorial9 DESTINATION ${CMAKE_INSTALL_PREFIX}/${EXAMPLES_DESTINATION}/feature/dbo/) ENDIF(INSTALL_EXAMPLES) ``` -------------------------------- ### Wt Composer Example Build Configuration Source: https://github.com/emweb/wt/blob/master/examples/composer/CMakeLists.txt Configures the build process for the Wt composer example. It checks for Boost.Wt, adds example sources, and links necessary libraries. It also sets include directories for Wt headers. ```cmake IF(BOOST_WT_FOUND) WT_ADD_EXAMPLE(composer.wt AddresseeEdit.C AttachmentEdit.C ComposeExample.C Composer.C ContactSuggestions.C Label.C Option.C OptionList.C ) IF(TARGET Boost::headers) TARGET_LINK_LIBRARIES(composer.wt Boost::headers) ENDIF() # If you have Wt installed somewhere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/include) # instead of the following: # INCLUDE_DIRECTORIES( ${WT_SOURCE_DIR}/src ${WT_SOURCE_DIR}/examples/treelist ) ELSE(BOOST_WT_FOUND) MESSAGE(STATUS "** Not building composer example: requires boost headers.") ENDIF(BOOST_WT_FOUND) ``` -------------------------------- ### Build Qt6 Wt Example Source: https://github.com/emweb/wt/blob/master/examples/wtwithqt/CMakeLists.txt Configures and builds the 'helloqt6' Wt example using Qt6. This section is active when Qt6 is detected and enabled. It handles MOC file generation, example target creation, and library linking. ```cmake IF (NOT BUILD_WTWITHQT6) MESSAGE(STATUS "** Not building wtwithqt6 example.") MESSAGE(STATUS " wtwithqt6 example requires a Qt6 installation.") ELSE (NOT BUILD_WTWITHQT6) QT6_GENERATE_MOC(${CMAKE_CURRENT_SOURCE_DIR}/QtObject.h ${CMAKE_CURRENT_BINARY_DIR}/moccedQtObject6.C) WT_ADD_EXAMPLE(helloqt6.wt hello.C QtObject.C ${CMAKE_CURRENT_BINARY_DIR}/moccedQtObject6.C ) TARGET_LINK_LIBRARIES(helloqt6.wt wtwithqt6 ) # # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/wt/include) # instead of the following: # TARGET_INCLUDE_DIRECTORIES( helloqt6.wt PRIVATE ${WT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/lib ) ENDIF (NOT BUILD_WTWITHQT6) ``` -------------------------------- ### Build Qt5 Wt Example Source: https://github.com/emweb/wt/blob/master/examples/wtwithqt/CMakeLists.txt Configures and builds the 'helloqt5' Wt example using Qt5. This block is executed if Qt5 is found and enabled. It involves generating MOC files, defining the example target, and linking required libraries. ```cmake IF (NOT BUILD_WTWITHQT5) MESSAGE(STATUS "** Not building wtwithqt5 example.") MESSAGE(STATUS " wtwithqt5 example requires a Qt5 installation.") ELSE (NOT BUILD_WTWITHQT5) QT5_GENERATE_MOC(${CMAKE_CURRENT_SOURCE_DIR}/QtObject.h ${CMAKE_CURRENT_BINARY_DIR}/moccedQtObject5.C) WT_ADD_EXAMPLE(helloqt5.wt hello.C QtObject.C ${CMAKE_CURRENT_BINARY_DIR}/moccedQtObject5.C ) TARGET_LINK_LIBRARIES(helloqt5.wt wtwithqt5 ) # # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/wt/include) # instead of the following: # TARGET_INCLUDE_DIRECTORIES( helloqt5.wt PRIVATE ${WT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/lib ) ENDIF (NOT BUILD_WTWITHQT5) ``` -------------------------------- ### Build Wt Examples for Android Source: https://github.com/emweb/wt/blob/master/target/android/README.txt Executes the make command to build the Wt examples. This process generates an .apk file for each example, which can be installed on an Android device or emulator. ```shell make -C examples ``` -------------------------------- ### Running Wt Examples in MSVC IDE Source: https://github.com/emweb/wt/blob/master/INSTALL.win32.html Instructions for configuring command arguments within the MSVC IDE to run Wt examples. This includes setting the http address, port, deploy path, and document root for the server. ```APIDOC MSVC IDE Configuration: 1. Right-click on the example project you want to run and select 'Properties'. 2. Navigate to 'Configuration Properties' -> 'Debugging'. 3. Set the 'Command Arguments' to: --http-address=0.0.0.0 --http-port=8080 --deploy-path=/hello --docroot=. This configuration starts an httpd server listening on all local interfaces on port 8080. The example can then be browsed at http://127.0.0.1:8080/hello. ``` -------------------------------- ### CMake Configuration for Wt Examples Source: https://github.com/emweb/wt/blob/master/examples/feature/widgetset/CMakeLists.txt This CMake script configures build settings for Wt examples. It conditionally includes directories based on the EXAMPLES_CONNECTOR variable and provides guidance on setting up include paths for Wt installations. ```cmake IF (EXAMPLES_CONNECTOR MATCHES "wthttp|Wt::HTTP") WT_ADD_EXAMPLE(hellowidgetset.wt hello.C) # # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/include) # instead of the following: # INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) ELSE (EXAMPLES_CONNECTOR MATCHES "wthttp") MESSAGE(STATUS "** hello-widget set example requires the built-in http... Skipping.") ENDIF (EXAMPLES_CONNECTOR MATCHES "wthttp|Wt::HTTP") ``` -------------------------------- ### Wt Server Application Startup Source: https://github.com/emweb/wt/blob/master/doc/tutorial/wt.adoc Demonstrates the basic structure for starting a Wt web application server. It shows the use of `WRun()` as a convenience function which internally manages a `WServer` instance. ```cpp int main(int argc, char **argv) { // Start the Wt application server return WRun(argc, argv, [](WEnvironment& env) { // Create and return a new WApplication instance for each session return std::make_unique(env); }); } ``` -------------------------------- ### Wt Examples CMakeLists.txt for Windows Source: https://github.com/emweb/wt/blob/master/examples/CMakeLists.txt Configuration for building Wt examples as a standalone project on Windows. It sets up CMake, finds Boost and Wt, configures imported targets for Wt::Wt and Wt::HTTP, and handles HPDF library linking. ```cmake CMAKE_MINIMUM_REQUIRED(VERSION 3.13...3.22) Project(WtExamples) find_package(Boost COMPONENTS filesystem) find_package(Wt REQUIRED Wt HTTP) set_target_properties(Wt::Wt PROPERTIES MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo ) set_target_properties(Wt::HTTP PROPERTIES MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo ) get_filename_component(WT_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) set(HAVE_HARU TRUE) add_library(HPDF::HPDF SHARED IMPORTED) set_target_properties(HPDF::HPDF PROPERTIES IMPORTED_IMPLIB "${WT_INSTALL_DIR}/lib/hpdf.lib" IMPORTED_IMPLIB_DEBUG "${WT_INSTALL_DIR}/lib/hpdfd.lib" IMPORTED_LOCATION "${WT_INSTALL_DIR}/bin/hpdf.dll" IMPORTED_LOCATION_DEBUG "${WT_INSTALL_DIR}/bin/hpdfd.dll" INTERFACE_INCLUDE_DIRECTORIES "${WT_INSTALL_DIR}/include" IMPORTED_LINK_INTERFACE_LANGUAGES "C" INTERFACE_COMPILE_DEFINITIONS HPDF_DLL ) SET(EXAMPLES_CONNECTOR Wt::HTTP) SET(EXAMPLES_WT_LIB Wt::Wt) SET(EXAMPLES_WTDBO_LIB Wt::Dbo) SET(EXAMPLES_WTDBOSQLITE3_LIB Wt::DboSqlite3) SET(EXAMPLES_WTDBOPOSTGRES_LIB Wt::DboPostgres) SET(EXAMPLES_WTDBOMYSQL_LIB Wt::DboMySQL) IF(${Boost_FOUND}) SET(BOOST_FS_LIB ${Boost_FILESYSTEM_LIBRARY}) set(BOOST_SYSTEM_LIB "") SET(BOOST_WT_FOUND true) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) ENDIF() # Windows SDK is always multithreaded SET(BOOST_WT_MT_FOUND true) SET(MULTI_THREADED true) SET(MULTI_THREADED_BUILD true) SET(WT_HAS_WRASTERIMAGE true) ``` -------------------------------- ### Build Widget Gallery Theme with PNPM Source: https://github.com/emweb/wt/blob/master/doc/development/themes.md Builds the widget gallery theme by installing dependencies and running the build script. This involves navigating to the example's style directory and executing PNPM commands to install dependencies and build the theme. ```shell cd examples/widgetgallery/style pnpm install # Install node_modules pnpm run build ``` -------------------------------- ### Set Include Directories Source: https://github.com/emweb/wt/blob/master/examples/widgetgallery/CMakeLists.txt Configures the include directories for the 'widgetgallery.wt' target. It prioritizes using installed Wt header files but falls back to the Wt source directory's 'src' folder if Wt is not installed or found. ```cmake target_include_directories(widgetgallery.wt PRIVATE ${WT_SOURCE_DIR}/src) ``` -------------------------------- ### Installing Wt::Dbo from Source (UNIX-like) Source: https://github.com/emweb/wt/blob/master/doc/tutorial/dbo.adoc Provides step-by-step instructions for building and installing the Wt::Dbo library separately from the Wt framework on a UNIX-like system. It uses CMake for the build process. ```sh cd wt-xxx mkdir build cd build cmake ../ # extra options may be needed, see instructions cd src/Wt/Dbo make sudo make install ``` -------------------------------- ### Wt Hello World Application Example Source: https://github.com/emweb/wt/blob/master/doc/tutorial/wt.adoc Demonstrates a basic Wt application that prompts the user for their name and displays a greeting. It includes the application class definition and the main function to run the Wt application. ```cpp #include #include #include #include #include #include class HelloApplication : public Wt::WApplication { public: HelloApplication(const Wt::WEnvironment& env); private: Wt::WLineEdit *nameEdit_; Wt::WText *greeting_; }; HelloApplication::HelloApplication(const Wt::WEnvironment& env) : Wt::WApplication(env) { setTitle("Hello world"); root()->addNew("Your name, please? "); nameEdit_ = root()->addNew(); Wt::WPushButton *button = root()->addNew("Greet me."); root()->addNew(); greeting_ = root()->addNew(); auto greet = [this]{ greeting_->setText("Hello there, " + nameEdit_->text()); }; button->clicked().connect(greet); } int main(int argc, char **argv) { return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) { return std::make_unique(env); }); } ``` -------------------------------- ### Configure Wt Include Directories Source: https://github.com/emweb/wt/blob/master/examples/dragdrop/CMakeLists.txt Specifies directories where the build system should search for header files. This is crucial for compiling Wt applications, especially when Wt is installed in a non-standard location. ```Build System # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/include) # instead of the following: INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) ``` -------------------------------- ### Build Custom Bootstrap Theme Source: https://github.com/emweb/wt/blob/master/examples/custom-bs-theme/README.md Commands to install dependencies and build a custom Bootstrap 5 theme using NPM. This process includes Sass compilation, auto-prefixing, minification, and source maps. ```shell npm install npm run build ``` -------------------------------- ### Define Wt Example Executable with WT_ADD_EXAMPLE Source: https://github.com/emweb/wt/blob/master/examples/hello/CMakeLists.txt The WT_ADD_EXAMPLE macro simplifies building Wt examples. It's equivalent to ADD_EXECUTABLE and TARGET_LINK_LIBRARIES, with special handling for ISAPI connectors to build DLLs. ```cmake WT_ADD_EXAMPLE(hello.wt hello.C) ``` -------------------------------- ### Update Curl Dependencies in Versions.props Source: https://github.com/emweb/wt/blob/master/doc/saml/windows_setup.md Configures MSBuild properties for the Curl library, including versioning and GUIDs for different architectures (32-bit, 64-bit, debug, release). It handles conditional logic based on LIBCURL_FILE_VERSION. ```xml BAD_LIBCURL_FILE_VERSION $(LIBCURL_VERSION) 7.75.0 $(LIBCURL_DIR) curl-$(CurlVersion) $(LIBCURL_FILE_VERSION) {C5DA388E-C39C-4164-98EF-CB5660F9ABB4} {38B92986-C5BA-4CB1-BFFD-E031FF22BE4C} {42951E00-7863-41B6-A770-BB3711588BDD} {8C610CA1-DDA8-45AA-A9C4-914420824D84} ``` -------------------------------- ### Define WT Blog Example Target Source: https://github.com/emweb/wt/blob/master/examples/blog/CMakeLists.txt Configures the 'blog.wt' target using WT_ADD_EXAMPLE, listing source files. It also sets compile definitions based on ASCIIDOCTOR_EXECUTABLE and links against Boost headers and example-specific libraries. ```cmake IF(BOOST_WT_FOUND) INCLUDE(CheckFunctionExists) INCLUDE(CheckLibraryExists) WT_ADD_EXAMPLE(blog.wt model/BlogSession.C model/BlogUserDatabase.C model/Post.C model/Comment.C model/User.C model/Tag.C model/Token.C view/PostView.C view/CommentView.C view/BlogLoginWidget.C view/BlogView.C view/EditUsers.C asciidoc/asciidoc.C BlogRSSFeed.C blog.C ) if(ASCIIDOCTOR_EXECUTABLE) target_compile_definitions(blog.wt PRIVATE ASCIIDOCTOR_EXECUTABLE="${ASCIIDOCTOR_EXECUTABLE}") endif() IF(TARGET Boost::headers) TARGET_LINK_LIBRARIES(blog.wt Boost::headers) ENDIF() TARGET_LINK_LIBRARIES(blog.wt ${EXAMPLES_DBO_LIBS}) ``` -------------------------------- ### Windows Time Zone Data Setup Source: https://github.com/emweb/wt/blob/master/examples/feature/locale/README.md Instructions for setting up IANA time zone data on Windows for the locale feature. This involves creating a 'tzdata' directory, downloading the IANA time zone database, and including the 'windowsZones.xml' file. ```APIDOC Windows Time Zone Data Setup: 1. Create a directory named `tzdata` in the directory where the example will be run. 2. Download the Data Only Distribution from the IANA time zone database (https://www.iana.org/time-zones). 3. Extract the downloaded contents into the `tzdata` directory. 4. Download `windowsZones.xml` from http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml. 5. Add `windowsZones.xml` to the `tzdata` directory. This setup allows the application to correctly interpret time zone information on Windows systems. ``` -------------------------------- ### Update log4shib Path in Versions.props Source: https://github.com/emweb/wt/blob/master/doc/saml/windows_setup.md Configures MSBuild properties for the log4shib library, including versioning and GUIDs for 32-bit and 64-bit components (debug and release). It sets default versions and handles conditional logic for version checking. ```xml 2_0 2.0.0 $(LOG4SHIB_MM_VERSION) BAD_LOG4SHIB_FILE_VERSION $(LOG4SHIB_FILE_VERSION) {4A96D4F3-51DD-4FBD-9478-8EC2197FAF70} {08A406FB-D426-40A6-B5C1-9FFBC9A085B2} {AED2A19A-D47E-41B4-A4FB-5F23601F989D} {A30DBD49-6717-44CB-9A38-349D4F8DF149} cpp-log4shib ``` -------------------------------- ### Run WidgetGallery Application Source: https://github.com/emweb/wt/blob/master/examples/widgetgallery/README.md This command illustrates how to run the WidgetGallery application using its built-in httpd, specifying the document root, application root, and HTTP address/port. It requires navigating to the docroot directory and creating a symbolic link to Wt resources. ```shell cd widgetgallery/docroot ln -s ../../../resources . # include standard Wt resource files in docroot cd .. ../../build/examples/widgetgallery/widgetgallery.wt \ --docroot docroot --approot approot \ --http-address 0.0.0.0 --http-port 8080 ``` -------------------------------- ### Configure Wt Include Directories Source: https://github.com/emweb/wt/blob/master/examples/feature/scrollvisibility/CMakeLists.txt Demonstrates how to configure include directories for Wt projects using CMake. It highlights the recommended practice of using installed Wt header files and provides an example of setting the include path relative to the Wt source directory. ```cmake # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/include) # instead of the following: INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) ``` -------------------------------- ### Wt Example Build Configuration (CMake) Source: https://github.com/emweb/wt/blob/master/examples/te-benchmark/CMakeLists.txt This CMake script configures the build process for Wt examples, specifically the 'te-benchmark' application. It includes conditional logic for multi-threaded builds, checking for Boost.Wt, and enabling support for MySQL or PostgreSQL databases, linking necessary libraries and definitions. ```cmake if(NOT MULTI_THREADED_BUILD) message(STATUS "** Not building te-benchmark example: requires a multi-threaded build.") else() IF(BOOST_WT_FOUND) # # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/include) # instead of the following: # INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) IF(ENABLE_MYSQL AND MYSQL_FOUND) WT_ADD_EXAMPLE(te-benchmark.wt benchmark.cpp) TARGET_LINK_LIBRARIES(te-benchmark.wt ${EXAMPLES_WTDBO_LIB} ${EXAMPLES_WTDBOMYSQL_LIB}) IF(TARGET Boost::headers) TARGET_LINK_LIBRARIES(te-benchmark.wt Boost::headers) ENDIF() ENDIF(ENABLE_MYSQL AND MYSQL_FOUND) IF(ENABLE_POSTGRES AND POSTGRES_FOUND) WT_ADD_EXAMPLE(te-benchmark-pg.wt benchmark.cpp) TARGET_COMPILE_DEFINITIONS(te-benchmark-pg.wt PRIVATE BENCHMARK_USE_POSTGRES) TARGET_LINK_LIBRARIES(te-benchmark-pg.wt ${EXAMPLES_WTDBO_LIB} ${EXAMPLES_WTDBOPOSTGRES_LIB}) IF(TARGET Boost::headers) TARGET_LINK_LIBRARIES(te-benchmark-pg.wt Boost::headers) ENDIF() ENDIF(ENABLE_POSTGRES AND POSTGRES_FOUND) ELSE(BOOST_WT_FOUND) MESSAGE(STATUS "** Not building te-benchmark example: requires boost headers.") ENDIF(BOOST_WT_FOUND) endif() ``` -------------------------------- ### Wt Example Build Configuration Source: https://github.com/emweb/wt/blob/master/examples/feature/template-fun/CMakeLists.txt Configures the build process for a Wt example, conditionally linking Boost headers and setting include directories based on the availability of Boost.Wt. ```cmake IF(BOOST_WT_FOUND) WT_ADD_EXAMPLE(widgetfunction.wt Example.C WidgetFunction.C) IF(TARGET Boost::headers) TARGET_LINK_LIBRARIES(widgetfunction.wt Boost::headers) ENDIF() # # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/include) # instead of the following: # INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) ELSE(BOOST_WT_FOUND) MESSAGE(STATUS "** Not building template-fun example: requires boost headers.") ENDIF(BOOST_WT_FOUND) ``` -------------------------------- ### Update OpenSSL Dependencies in Versions.props Source: https://github.com/emweb/wt/blob/master/doc/saml/windows_setup.md Configures MSBuild properties for the OpenSSL library, specifying versioning and GUIDs for different components (libeay32, ssleay32) across 32-bit and 64-bit architectures, including debug variants. It includes conditional logic for version checking. ```xml 1_1_1_10 openssl-1.1.1j $(OPENSSL_DIR) BAD_OPENSSL_FILE_VERSION $(OPENSSL_FILE_VERSION) {E5CDA78B-1024-4DF7-9F11-8532B6F55E21} {6AD1215B-E983-4823-A363-6127420408E4} {E3B837AE-B103-45F7-AC98-72BE66B76746} {C7454E2E-DAEA-487B-AB1C-9339E5E390C0} {6E57A83F-E67E-4E8D-B24B-ACDDFC7FDA5E} {73702736-2A6F-43DC-BB08-663641C1798C} {DBA7EF27-C817-43EC-B2E6-A4E945355F0A} {96350A7E-15DA-4CF4-B90D-F3E670AF9D36} ``` -------------------------------- ### Add Example Build Target Source: https://github.com/emweb/wt/blob/master/examples/filedrop/CMakeLists.txt Defines an executable target for an example application, linking it with the specified connector library. Handles ISAPI DLL creation for IIS. ```cmake WT_ADD_EXAMPLE(filedrop.wt filedrop.C FileDropApplication.C custom_transfer/MyFileDropWidget.C custom_transfer/MyUploadResource.C) ``` -------------------------------- ### Add Example to WT Build Source: https://github.com/emweb/wt/blob/master/examples/treelist/CMakeLists.txt The WT_ADD_EXAMPLE macro is used to register a new example within the WT framework. It typically takes the example's source file and associated components as arguments. ```build-script WT_ADD_EXAMPLE(demotreelist.wt DemoTreeList.C IconPair.C TreeNode.C) ``` -------------------------------- ### SocketNotifier Example Build Source: https://github.com/emweb/wt/blob/master/examples/feature/socketnotifier/CMakeLists.txt Configures the build for the Wt socketnotifier example. It checks if a multi-threaded build is enabled and skips the example if it's not. It also skips the example on MinGW environments due to potential issues with `getaddrinfo` and `freeaddrinfo`. If conditions are met, it adds the example, sets include directories to the Wt source, and links the Wt socket library. ```cmake IF(NOT MULTI_THREADED_BUILD) MESSAGE(STATUS "** Not building socketnotifier feature example: requires a multi-threaded build.") ELSE(NOT MULTI_THREADED_BUILD) IF (MINGW) MESSAGE(STATUS "** Not building socketnotifier example for lack of getaddrinfo freeaddrinfo.") ELSE (MINGW) WT_ADD_EXAMPLE(socketnotifier.wt SocketNotifier.C) # # If you have Wt installed somehwere, you should use the # installed Wt header files for your own Wt projects. # e.g. INCLUDE_DIRECTORIES(/usr/local/include) # instead of the following: # INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) TARGET_LINK_LIBRARIES(socketnotifier.wt ${WT_SOCKET_LIBRARY}) ENDIF (MINGW) ENDIF(NOT MULTI_THREADED_BUILD) ```