### Build a Specific Example Project with MSBuild Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/Examples/Openframeworks/ofSpoutExamples/msbuild.md This command builds a single example project, 'SenderGraphics', using MSBuild. Modify the .vcxproj file path for other examples. The command assumes it's run from the project's root directory. ```bash msbuild.exe Sender\SenderGraphics\SenderGraphics.vcxproj -vm /p:Configuration=Release /p:Platform=x64 ``` -------------------------------- ### Configure and Install Package Files Source: https://github.com/leadedge/spout2/blob/master/CMakeLists.txt Generates and installs package configuration files (`spout2-config.cmake` and `spout2-config-version.cmake`) and target export files (`spout2-targets.cmake`). This is done only if installation is not skipped. ```cmake if (NOT SKIP_INSTALL_ALL AND NOT SKIP_INSTALL_LIBRARIES) include(CMakePackageConfigHelpers) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/spout2-config-version.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/spout2-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/spout2-config.cmake" INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/spout2 ) install(EXPORT SpoutTargets FILE spout2-targets.cmake NAMESPACE Spout2:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/spout2 ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/spout2-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/spout2-config-version.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/spout2 ) endif (NOT SKIP_INSTALL_ALL AND NOT SKIP_INSTALL_LIBRARIES) ``` -------------------------------- ### Install SpoutLibrary Components Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutLibrary/CMakeLists.txt Handles the installation of SpoutLibrary targets, headers, and associated files. It conditionally installs libraries and runtime binaries based on SKIP_INSTALL_ALL and SKIP_INSTALL_LIBRARIES flags, and installs headers to the specified include directory. ```cmake if (NOT SKIP_INSTALL_ALL) if(NOT SKIP_INSTALL_LIBRARIES) install( TARGETS SpoutLibrary SpoutLibrary_static EXPORT SpoutTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) endif(NOT SKIP_INSTALL_LIBRARIES) if(NOT SKIP_INSTALL_HEADERS) install( FILES ${SpoutLibrary_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SpoutLibrary ) endif(NOT SKIP_INSTALL_HEADERS) endif (NOT SKIP_INSTALL_ALL) ``` -------------------------------- ### Project Setup and Source Definitions Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial07/CMakeLists.txt Defines the project name, source file directories, and lists all source files for SpoutDX, SpoutSDK, and Tutorial07. ```cmake cmake_minimum_required(VERSION 3.15) project(Tutorial07) # Source file folders set(SPOUTSDK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../SpoutGL) set(SPOUTDX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) # Define source files set(SPOUTDX_SOURCES ${SPOUTDX_DIR}/SpoutDX.cpp ${SPOUTDX_DIR}/SpoutDX.h ) set(SPOUTSDK_SOURCES ${SPOUTSDK_DIR}/SpoutCopy.cpp ${SPOUTSDK_DIR}/SpoutDirectX.cpp ${SPOUTSDK_DIR}/SpoutFrameCount.cpp ${SPOUTSDK_DIR}/SpoutSenderNames.cpp ${SPOUTSDK_DIR}/SpoutSharedMemory.cpp ${SPOUTSDK_DIR}/SpoutUtils.cpp ${SPOUTSDK_DIR}/SpoutCopy.h ${SPOUTSDK_DIR}/SpoutDirectX.h ${SPOUTSDK_DIR}/SpoutFrameCount.h ${SPOUTSDK_DIR}/SpoutSenderNames.h ${SPOUTSDK_DIR}/SpoutSharedMemory.h ${SPOUTSDK_DIR}/SpoutUtils.h ) # Tutorial07 source files set(Tutorial07_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial07.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial07.rc ${CMAKE_CURRENT_SOURCE_DIR}/DDSTextureLoader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/DDSTextureLoader.h ${SPOUTDX_SOURCES} ${SPOUTSDK_SOURCES} ) # Shader files set(Tutorial07_SHADERS ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial07.fx ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial07_VS.hlsl ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial07_PS.hlsl ) ``` ```cmake # Add executable add_executable(${PROJECT_NAME} ${Tutorial07_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/directx.ico ) ``` -------------------------------- ### Install SpoutDX12 Libraries and Headers Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/SpoutDX12/CMakeLists.txt Installs the SpoutDX12 shared and static libraries to the appropriate runtime, library, and archive destinations. It also installs the SpoutDX12 headers and other Spout public headers to the include directory. ```cmake if (NOT SKIP_INSTALL_ALL) if(NOT SKIP_INSTALL_LIBRARIES) install( TARGETS SpoutDX12 SpoutDX12_static EXPORT SpoutTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) endif() if(NOT SKIP_INSTALL_HEADERS) get_target_property(spoutdx_headers SpoutDX SPOUT_PUBLIC_HEADER) install( FILES ${SpoutDX12_HEADERS} ${spoutdx_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SpoutDX12 ) endif() endif() ``` -------------------------------- ### Build OpenFrameworks Library with MSBuild Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/Examples/Openframeworks/ofSpoutExamples/msbuild.md Use this command in the specified directory to build the OpenFrameworks library with a Release configuration for x64 platform. This is a one-time setup step. ```bash MSBuild openframeworksLib.vcxproj -p:Configuration=RELEASE -p:Platform=x64 ``` -------------------------------- ### Install Spout Libraries and Binaries Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutGL/CMakeLists.txt Installs the Spout and Spout_static targets, including archives, libraries, and runtime binaries. This rule is applied if SKIP_INSTALL_ALL and SKIP_INSTALL_LIBRARIES are not set. ```cmake install( TARGETS Spout Spout_static EXPORT SpoutTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) ``` -------------------------------- ### Install Spout Headers Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutGL/CMakeLists.txt Installs the Spout header files to the SpoutGL subdirectory within the installation's include directory. This rule is applied if SKIP_INSTALL_ALL and SKIP_INSTALL_HEADERS are not set. ```cmake install( FILES ${Spout_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SpoutGL ) ``` -------------------------------- ### Include and Initialize SpoutLibrary Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutLibrary/readme.md Include the SpoutLibrary header, link the library, and get a pointer to the SpoutLibrary functions. Use this pointer to call library functions like OpenSpoutConsole for debugging. ```cpp #include "SpoutLibrary.h" // Specify SpoutLibrary.lib for the linker #pragma comment(lib, "libs/SpoutLibrary.lib") // Get a pointer to SpoutLibrary sender = GetSpout(); // Use functions with the library pointer sender->OpenSpoutConsole(); // Empty console for debugging ``` -------------------------------- ### Define Installation Options Source: https://github.com/leadedge/spout2/blob/master/CMakeLists.txt Defines boolean options for controlling the installation of Spout2 components. These options can be set to ON or OFF during the CMake configuration process. ```cmake OPTION(SKIP_INSTALL_ALL "Install headers and libraries" OFF) OPTION(SKIP_INSTALL_HEADERS "Install headers" OFF) OPTION(SKIP_INSTALL_LIBRARIES "Install libraries" OFF) ``` -------------------------------- ### Define SpoutDX12 Static Library Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/SpoutDX12/CMakeLists.txt Configures the static library for SpoutDX12. It sets the compile definition for static builds and links against the SpoutDX static library. Include directories are set for both build and install interfaces. ```cmake add_library(SpoutDX12_static STATIC ${SpoutDX12_SOURCES} ${SpoutDX12_HEADERS}) target_compile_definitions(SpoutDX12_static PRIVATE SPOUT_BUILD_STATIC) target_link_libraries(SpoutDX12_static PUBLIC SpoutDX_static) target_include_directories(SpoutDX12_static PUBLIC $ $ ) ``` -------------------------------- ### Define SpoutDX12 Shared Library (DLL) Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/SpoutDX12/CMakeLists.txt Configures the shared (DLL) library for SpoutDX12. It sets the compile definition for DLL builds and links against the SpoutDX static library and d3d12. Include directories are set for both build and install interfaces. ```cmake add_library(SpoutDX12 SHARED ${SpoutDX12_SOURCES} ${SpoutDX12_HEADERS}) target_compile_definitions(SpoutDX12 PRIVATE SPOUT_BUILD_DLL) target_link_libraries(SpoutDX12 PRIVATE SpoutDX_static d3d12) target_include_directories(SpoutDX12 PUBLIC $ $ ) ``` -------------------------------- ### Set Startup Project in Visual Studio Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial04/CMakeLists.txt Sets the Tutorial04 executable as the startup project within Visual Studio for the current directory. ```cmake # Set startup project in Visual Studio set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) ``` -------------------------------- ### Copy FX File Post-Build Command Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial04/CMakeLists.txt Adds a custom post-build command to copy the Tutorial04.fx shader file to the target directory if it has changed. ```cmake # Copy FX file for runtime add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial04.fx $ ) ``` -------------------------------- ### Visual Studio Specific Settings Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial07/CMakeLists.txt Sets the startup project in Visual Studio and defines source group filters for better organization within the IDE. ```cmake # Set startup project in Visual Studio set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) ``` ```cmake # Visual Studio source groups (IDE filters) source_group("Resource Files" FILES resource.h Tutorial07.rc directx.ico) source_group("SpoutDX" FILES ${SPOUTDX_SOURCES}) source_group("SpoutSDK" FILES ${SPOUTSDK_SOURCES}) ``` -------------------------------- ### Include Directories Configuration Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial04/CMakeLists.txt Configures the include directories for the project, specifying the current source directory and the DirectXMath include directory. ```cmake # Include directories target_include_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${DIRECTXMATH_INCLUDE_DIR} ) ``` -------------------------------- ### Project and Source File Definitions Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial04/CMakeLists.txt Defines the minimum CMake version, project name, and sets variables for Spout SDK and DirectX source file directories. It then lists the source files for SpoutDX, SpoutSDK, and Tutorial04, including resource and shader files. ```cmake cmake_minimum_required(VERSION 3.15) project(Tutorial04) # Source file folders set(SPOUTSDK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../SpoutGL) set(SPOUTDX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) # Define source files set(SPOUTDX_SOURCES ${SPOUTDX_DIR}/SpoutDX.cpp ${SPOUTDX_DIR}/SpoutDX.h ) set(SPOUTSDK_SOURCES ${SPOUTSDK_DIR}/SpoutCopy.cpp ${SPOUTSDK_DIR}/SpoutDirectX.cpp ${SPOUTSDK_DIR}/SpoutFrameCount.cpp ${SPOUTSDK_DIR}/SpoutSenderNames.cpp ${SPOUTSDK_DIR}/SpoutSharedMemory.cpp ${SPOUTSDK_DIR}/SpoutUtils.cpp ${SPOUTSDK_DIR}/SpoutCopy.h ${SPOUTSDK_DIR}/SpoutDirectX.h ${SPOUTSDK_DIR}/SpoutFrameCount.h ${SPOUTSDK_DIR}/SpoutSenderNames.h ${SPOUTSDK_DIR}/SpoutSharedMemory.h ${SPOUTSDK_DIR}/SpoutUtils.h ) # Tutorial04 source files set(Tutorial04_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial04.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial04.rc ${SPOUTDX_SOURCES} ${SPOUTSDK_SOURCES} ) # Shader files set(Tutorial04_SHADERS ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial04.fx ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial04_VS.hlsl ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial04_PS.hlsl ) ``` -------------------------------- ### Build Spout Static Library Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutGL/CMakeLists.txt Configures and builds the static version of the Spout library. It defines compile-time options, links necessary libraries, and sets output directories. ```cmake add_library(Spout_static STATIC ${Spout_SOURCES} ${Spout_HEADERS}) target_compile_definitions(Spout_static PRIVATE SPOUT_BUILD_STATIC) target_link_libraries(Spout_static PUBLIC ${SpoutLink}) target_include_directories(Spout_static PUBLIC $ $ ) set_target_properties(Spout_static PROPERTIES VS_FOLDER "Spout_static" SPOUT_PUBLIC_HEADER "${Spout_HEADERS}" RUNTIME_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/bin LIBRARY_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ARCHIVE_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ) ``` -------------------------------- ### Post-Build Copy Command Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial07/CMakeLists.txt Configures a custom command to copy shader and texture files to the runtime directory after the build. ```cmake # Copy FX and image files for runtime add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/Tutorial07.fx ${CMAKE_CURRENT_SOURCE_DIR}/seafloor.dds $ ) ``` -------------------------------- ### Target Properties Configuration Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial07/CMakeLists.txt Sets properties for the executable, such as making it a Windows executable, enabling DPI awareness, and defining the runtime output directory. ```cmake set_target_properties( ${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE VS_DPI_AWARE "PerMonitor" VS_DEBUGGER_WORKING_DIRECTORY "$" RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries/Examples ) ``` -------------------------------- ### Include Directories and Library Linking Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial07/CMakeLists.txt Specifies include directories for DirectXMath and links necessary DirectX and Windows libraries. ```cmake # Include directories target_include_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${DIRECTXMATH_INCLUDE_DIR} ) ``` ```cmake # Link libraries target_link_libraries( ${PROJECT_NAME} d3d11 d3dcompiler dxgi dxguid psapi version winmm ) ``` -------------------------------- ### ARM Build Configuration with SSE2NEON Source: https://github.com/leadedge/spout2/blob/master/CMakeLists.txt Enables SSE2NEON for ARM builds to allow SIMD code without rewriting. It downloads the sse2neon.h header, adds it to include directories, and sets a preprocessor definition for MSVC. ```cmake if (SPOUT_BUILD_ARM) if (NOT SPOUT_NO_GLOBAL_WARNING) message(WARNING "sse2neon will be added globally") endif (NOT SPOUT_NO_GLOBAL_WARNING) # Use SS2NEON so SIMD code doesn't have to be rewritten for ARM # Download sse2neon.h File(DOWNLOAD https://github.com/DLTcollab/sse2neon/raw/master/sse2neon.h ${PROJECT_SOURCE_DIR}/SPOUTSDK/sse2neon/sse2neon.h) # Add compiler include_directory and /Zc:preprocessor define include_directories(SPOUTSDK/sse2neon) if (MSVC) add_compile_options(/Zc:preprocessor) endif (MSVC) endif (SPOUT_BUILD_ARM) ``` -------------------------------- ### Build Spout Shared Library (DLL) Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutGL/CMakeLists.txt Configures and builds the shared (DLL) version of the Spout library. It sets compile-time definitions, links libraries, and specifies output locations for build artifacts. ```cmake add_library(Spout SHARED ${Spout_SOURCES} ${Spout_HEADERS}) target_compile_definitions(Spout PRIVATE SPOUT_BUILD_DLL) target_link_libraries(Spout PRIVATE ${SpoutLink}) target_include_directories(Spout PUBLIC $ $ ) set_target_properties(Spout PROPERTIES # VS_FOLDER "Spout_dll" VS_FOLDER "Spout" SPOUT_PUBLIC_HEADER "${Spout_HEADERS}" RUNTIME_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/bin LIBRARY_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ARCHIVE_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ) ``` -------------------------------- ### Add Executable and Compile Features Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial04/CMakeLists.txt Adds the main executable for the project using the defined source files and an icon. It also enables C++17 standard support for the project. ```cmake add_executable(${PROJECT_NAME} ${Tutorial04_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/directx.ico ) # Enable C++17 support target_compile_features( ${PROJECT_NAME} PRIVATE cxx_std_17 ) ``` -------------------------------- ### Define SpoutLibrary Static Target Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutLibrary/CMakeLists.txt Configures the static library target for SpoutLibrary. It specifies source and header files, sets a compile definition for static builds, and links against the Spout_static library. Properties like VS_FOLDER and output directories are also set. ```cmake add_library(SpoutLibrary_static STATIC ${SpoutLibrary_SOURCES} ${SpoutLibrary_HEADERS} ) target_compile_definitions(SpoutLibrary_static PRIVATE SPOUT_BUILD_STATIC ) target_link_libraries(SpoutLibrary_static PUBLIC Spout_static) set_target_properties(SpoutLibrary_static PROPERTIES VS_FOLDER "SpoutLibrary_static" SPOUT_PUBLIC_HEADER "${SpoutLibrary_HEADERS}" RUNTIME_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/bin LIBRARY_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ARCHIVE_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ) ``` -------------------------------- ### Configure SpoutDX12 Static Library Properties Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/SpoutDX12/CMakeLists.txt Sets target properties for the SpoutDX12 static library, including the VS_FOLDER, SPOUT_PUBLIC_HEADER, and output directories for runtime, library, and archive files. ```cmake set_target_properties(SpoutDX12_static PROPERTIES VS_FOLDER "SpoutDX12_static" SPOUT_PUBLIC_HEADER "${SpoutDX12_HEADERS}" RUNTIME_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/bin LIBRARY_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ARCHIVE_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ) ``` -------------------------------- ### Define SpoutLibrary Shared Target Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutLibrary/CMakeLists.txt Configures the shared (DLL) library target for SpoutLibrary. It includes source and header files, defines SPOUT_BUILD_DLL for dynamic builds, and links against Spout_static. Properties for Visual Studio folder and output directories are also defined. ```cmake add_library(SpoutLibrary SHARED ${SpoutLibrary_SOURCES} ${SpoutLibrary_HEADERS} ) target_compile_definitions(SpoutLibrary PRIVATE SPOUT_BUILD_DLL ) target_link_libraries(SpoutLibrary PUBLIC Spout_static) set_target_properties(SpoutLibrary PROPERTIES VS_FOLDER "SpoutLibrary" SPOUT_PUBLIC_HEADER "${SpoutLibrary_HEADERS}" RUNTIME_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/bin LIBRARY_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ARCHIVE_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ) ``` -------------------------------- ### Link Libraries Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial04/CMakeLists.txt Links the necessary Windows libraries for DirectX and other system functionalities required by the project. ```cmake # Link libraries target_link_libraries( ${PROJECT_NAME} d3d11 d3dcompiler dxgi dxguid psapi version winmm ) ``` -------------------------------- ### Add SpoutGL Subdirectory Source: https://github.com/leadedge/spout2/blob/master/CMakeLists.txt Includes the SpoutGL subdirectory, which is essential for OpenGL-related Spout functionalities. ```cmake add_subdirectory(SPOUTSDK/SpoutGL) ``` -------------------------------- ### MinGW/MSYS2 Specific Build Options Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial07/CMakeLists.txt Configures compile options, including SSE4 for non-ARM builds, and sets Unicode linking and include directories for MinGW/MSYS2. ```cmake # Optional: for MinGW or MSYS2 builds if (MINGW) if (NOT SPOUT_BUILD_ARM) target_compile_options( ${PROJECT_NAME} PRIVATE -msse4) endif (NOT SPOUT_BUILD_ARM) target_compile_options( ${PROJECT_NAME} PRIVATE -Wall ) target_link_options( ${PROJECT_NAME} PRIVATE -municode ) target_include_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/external/DirectXMath ) endif (MINGW) ``` -------------------------------- ### Compiler Feature and Definition Settings Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial07/CMakeLists.txt Enables C++17 support and defines Unicode preprocessor macros for the project. ```cmake # Enable C++17 support target_compile_features( ${PROJECT_NAME} PRIVATE cxx_std_17 ) ``` ```cmake # Use ANSI build by removing Unicode flags instead of redefining them target_compile_definitions( ${PROJECT_NAME} PRIVATE _UNICODE UNICODE ) ``` -------------------------------- ### Windows Platform Check Source: https://github.com/leadedge/spout2/blob/master/CMakeLists.txt Ensures that the project is being built on a Windows platform. If not, it halts the build with a fatal error, as Spout is Windows-specific. ```cmake if (NOT WIN32) message(FATAL_ERROR "Spout is not supported outside of MS Windows") endif (NOT WIN32) ``` -------------------------------- ### Define SpoutLink Libraries Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutGL/CMakeLists.txt Lists the libraries that Spout depends on for linking. This includes core Windows libraries, DirectX, and others necessary for Spout functionality. ```cmake set(SpoutLink opengl32 kernel32 user32 gdi32 winspool comdlg32 comctl32 advapi32 shell32 ole32 oleaut32 uuid odbc32 odbccp32 d3d9 d3d11 dxgi version winmm ) ``` -------------------------------- ### Configure SpoutDX12 Shared Library Properties Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/SpoutDX12/CMakeLists.txt Sets target properties for the SpoutDX12 shared library, including the VS_FOLDER, SPOUT_PUBLIC_HEADER, and output directories for runtime, library, and archive files. ```cmake set_target_properties(SpoutDX12 PROPERTIES VS_FOLDER "SpoutDX12_dll" SPOUT_PUBLIC_HEADER "${SpoutDX12_HEADERS}" RUNTIME_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/bin LIBRARY_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ARCHIVE_OUTPUT_DIRECTORY ${SPOUT_BINARY_DIR}/lib ) ``` -------------------------------- ### Define Spout Sources and Headers Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutGL/CMakeLists.txt Defines the source and header files for the Spout library. These lists are used to compile both static and shared Spout libraries. ```cmake set(Spout_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Spout.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutCopy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutDirectX.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutFrameCount.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutGL.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutGLextensions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutReceiver.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutSender.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutSenderNames.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutSharedMemory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpoutUtils.cpp ) set(Spout_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Spout.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutCommon.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutCopy.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutDirectX.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutFrameCount.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutGL.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutGLextensions.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutReceiver.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutSender.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutSenderNames.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutSharedMemory.h ${CMAKE_CURRENT_SOURCE_DIR}/SpoutUtils.h ) ``` -------------------------------- ### MinGW SSE4 Optimization Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutGL/CMakeLists.txt Applies SSE4 optimization flags for MinGW builds, provided the target is not an ARM architecture. This is applied to both static and shared Spout libraries. ```cmake if (MINGW AND NOT SPOUT_BUILD_ARM) target_compile_options(Spout_static PRIVATE -msse4) target_compile_options(Spout PRIVATE -msse4) endif() ``` -------------------------------- ### Add SpoutLibrary Subdirectory Source: https://github.com/leadedge/spout2/blob/master/CMakeLists.txt Conditionally adds the SpoutLibrary subdirectory if the SPOUT_BUILD_LIBRARY option is enabled. This allows for building Spout as a static or dynamic library. ```cmake if (SPOUT_BUILD_LIBRARY) add_subdirectory(SPOUTSDK/SpoutLibrary) endif (SPOUT_BUILD_LIBRARY) ``` -------------------------------- ### MSVC Static Runtime Linking Source: https://github.com/leadedge/spout2/blob/master/CMakeLists.txt Configures the MSVC compiler to statically link the C++ runtime libraries for all configurations. This is applied globally if SPOUT_BUILD_CMT is enabled and the platform is MSVC. ```cmake if (SPOUT_BUILD_CMT AND MSVC) if (NOT SPOUT_NO_GLOBAL_WARNING) message(WARNING "MSVC runtime will be set to static globally") endif (NOT SPOUT_NO_GLOBAL_WARNING) # https://gitlab.kitware.com/cmake/cmake/-/issues/18390 add_compile_options( $<$:/MT> $<$:/MTd> $<$:/MT> ) endif (SPOUT_BUILD_CMT AND MSVC) ``` -------------------------------- ### Compile Definitions for ANSI Build Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial04/CMakeLists.txt Sets compile definitions to use an ANSI build by removing Unicode flags, ensuring compatibility. ```cmake # Use ANSI build by removing Unicode flags instead of redefining them target_compile_definitions( ${PROJECT_NAME} PRIVATE _UNICODE UNICODE ) ``` -------------------------------- ### Add SpoutDX Subdirectories Source: https://github.com/leadedge/spout2/blob/master/CMakeLists.txt Conditionally adds the SpoutDirectX subdirectories if the SPOUT_BUILD_SPOUTDX option is enabled. This includes support for DirectX 9 and DirectX 12. ```cmake if (SPOUT_BUILD_SPOUTDX) add_subdirectory(SPOUTSDK/SpoutDirectX/SpoutDX) add_subdirectory(SPOUTSDK/SpoutDirectX/SpoutDX/SpoutDX9) add_subdirectory(SPOUTSDK/SpoutDirectX/SpoutDX/SpoutDX12) endif (SPOUT_BUILD_SPOUTDX) ``` -------------------------------- ### MSVC Specific Compile Options Source: https://github.com/leadedge/spout2/blob/master/SPOUTSDK/SpoutDirectX/SpoutDX/Tutorial04/CMakeLists.txt Sets the /W4 warning level for MSVC compiler to enforce stricter code checking. ```cmake if (MSVC) target_compile_options( ${PROJECT_NAME} PRIVATE /W4 ) endif (MSVC) ```