### Setup ios-cmake Script Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Metal/README.md Demonstrates how to set up the ios-cmake toolchain for the sample project. The version can be customized by modifying IOS_CMAKE_VERSION. ```shell # Download ios-cmake by running `setup_ios_cmake` in the `script` directory. You can change the version to download by changing `IOS_CMAKE_VERSION` in the script. [ios-cmake]: https://github.com/leetal/ios-cmake [stb_image.h]: https://github.com/nothings/stb/blob/master/stb_image.h ``` -------------------------------- ### Sample Project Deliverables Generation Example Source: https://github.com/live2d/cubismnativesamples/blob/develop/README.md Shows where the deliverables for CMake projects (excluding Android) are generated, typically in the 'bin' directory. This example uses the macOS OpenGL sample build script. ```bash Demo └─ proj.mac.cmake └─ build └─ make_gcc └─ bin └─ Demo ├─ Resources # Same as Samples/Resources └─ Demo # Executable applications ``` -------------------------------- ### Executable Application Setup Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.win.cmake/CMakeLists.txt Defines the main executable, adds common source files and subdirectories, and links all necessary libraries including Framework, GLFW, and OpenGL. ```cmake # Make executable app. add_executable(${APP_NAME}) # Add common source files. add_subdirectory(${COMMON_SRC_PATH} ${CMAKE_CURRENT_BINARY_DIR}/src/Common) # Add source files. add_subdirectory(src) # Link libraries to app. target_link_libraries(${APP_NAME} Framework glfw ${OPENGL_LIBRARIES} # Solve the MSVCRT confliction. debug -NODEFAULTLIB:libcmtd.lib optimized -NODEFAULTLIB:libcmt.lib ) # Specify include directories. target_include_directories(${APP_NAME} PRIVATE ${STB_PATH}) # Build in multi-process. target_compile_options(${APP_NAME} PRIVATE /MP) ``` -------------------------------- ### LAppModel Usage Example: Loading a Model Source: https://context7.com/live2d/cubismnativesamples/llms.txt Demonstrates how to instantiate and load a Live2D model using the LAppModel class. ```cpp // Usage Example - Loading a Model void LoadModel() { LAppModel* model = new LAppModel(); // Load from Resources directory // Model directory should contain: ModelName.model3.json model->LoadAssets("Resources/Haru/", "Haru.model3.json"); } ``` -------------------------------- ### CMake Project Setup and Path Definitions Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.win.cmake/CMakeLists.txt Initializes the CMake project, defines the application name, and sets up essential directory paths for the SDK, Core, Framework, and third-party libraries. ```cmake cmake_minimum_required(VERSION 3.16) option( CORE_CRL_MD "Use Cubism Core that is multithread-specific and DLL-specific version" OFF ) # Set app name. set(APP_NAME Demo) # Set directory paths. set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty) set(STB_PATH ${THIRD_PARTY_PATH}/stb) set(GLEW_PATH ${THIRD_PARTY_PATH}/glew) set(GLFW_PATH ${THIRD_PARTY_PATH}/glfw) set(RES_PATH ${SDK_ROOT_PATH}/Samples/Resources) set(SAMPLE_SHADER_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/Shaders/Standard) set(FRAMEWORK_SHADER_PATH ${FRAMEWORK_PATH}/src/Rendering/OpenGL/Shaders/Standard) set(COMMON_SRC_PATH ${SDK_ROOT_PATH}/Samples/Common) # Set project. project(${APP_NAME}) # Set Visual Studio startup project. set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${APP_NAME}) # Define output directory. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${APP_NAME}) # Set configuration (Release and Debug only). set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "Configurations" FORCE ) # Suppress generation of ZERO_CHECK project. set(CMAKE_SUPPRESS_REGENERATION ON) ``` -------------------------------- ### CMake Project Setup and Path Definitions Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.android.cmake/Full/app/CMakeLists.txt Sets the minimum CMake version, application name, and defines paths to the Cubism SDK components and common source files. Ensure SDK_ROOT_PATH is correctly set to your Live2D Cubism SDK installation. ```cmake cmake_minimum_required(VERSION 3.10) # Set app name. set(APP_NAME Demo) # Set directory paths. set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../..) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(COMMON_SRC_PATH ${SDK_ROOT_PATH}/Samples/Common) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty) set(STB_PATH ${THIRD_PARTY_PATH}/stb) ``` -------------------------------- ### LAppModel Usage Example: Playing Motions Source: https://context7.com/live2d/cubismnativesamples/llms.txt Shows how to play predefined or random motions on a Live2D model instance, including optional callback functions for motion events. ```cpp // Usage Example - Playing Motions void PlayMotion(LAppModel* model) { // Motion callback functions auto onBegan = [](ACubismMotion* self) { printf("Motion began: %p\n", self); }; auto onFinished = [](ACubismMotion* self) { printf("Motion finished: %p\n", self); }; // Start specific motion (group "TapBody", index 0, normal priority) model->StartMotion("TapBody", 0, PriorityNormal, onFinished, onBegan); // Or start random motion from a group model->StartRandomMotion("Idle", PriorityIdle, onFinished, onBegan); } ``` -------------------------------- ### LAppModel Usage Example: Setting Expressions Source: https://context7.com/live2d/cubismnativesamples/llms.txt Illustrates how to set specific expressions by ID or choose a random expression for a Live2D model. ```cpp // Usage Example - Setting Expressions void SetExpression(LAppModel* model) { // Set specific expression by ID model->SetExpression("F01"); // Or set random expression model->SetRandomExpression(); } ``` -------------------------------- ### CMake Minimum Version and Project Setup Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.harmonyos.cmake/Full/entry/src/main/cpp/CMakeLists.txt Sets the minimum required CMake version and defines the application name. This is standard practice for CMake projects. ```cmake cmake_minimum_required(VERSION 3.4.1) # Set app name. set(APP_NAME Demo) ``` -------------------------------- ### Setup Model Textures Source: https://context7.com/live2d/cubismnativesamples/llms.txt Iterates through model settings to load and bind textures. It constructs the full texture path and uses the texture manager to load the PNG. Alpha pre-multiplication is configured after binding. ```cpp // Usage Example - Loading Model Textures void LAppModel::SetupTextures() { for (csmInt32 modelTextureNumber = 0; modelTextureNumber < _modelSetting->GetTextureCount(); modelTextureNumber++) { // Skip empty texture names if (strcmp(_modelSetting->GetTextureFileName(modelTextureNumber), "") == 0) { continue; } // Build texture path csmString texturePath = _modelSetting->GetTextureFileName(modelTextureNumber); texturePath = _modelHomeDir + texturePath; // Load texture LAppTextureManager::TextureInfo* texture = LAppDelegate::GetInstance()->GetTextureManager()->CreateTextureFromPngFile( texturePath.GetRawString() ); // Bind texture to model renderer const csmInt32 glTextureNumber = texture->id; GetRenderer()->BindTexture( modelTextureNumber, glTextureNumber ); } // Configure alpha blending GetRenderer()->IsPremultipliedAlpha(false); } ``` -------------------------------- ### CMake Project Setup and Paths Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.android.cmake/Minimum/app/CMakeLists.txt Configures the minimum CMake version, application name, and defines key directory paths for the SDK, Core, Framework, and common source files. Ensure SDK_ROOT_PATH is correctly set relative to the CMakeLists.txt. ```cmake cmake_minimum_required(VERSION 3.10) # Set app name. set(APP_NAME Demo) # Set directory paths. set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../..) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty) set(COMMON_SRC_PATH ${SDK_ROOT_PATH}/Samples/Common) set(STB_PATH ${THIRD_PARTY_PATH}/stb) ``` -------------------------------- ### CMake Build Configuration for OpenGL Sample (CMakeLists.txt) Source: https://context7.com/live2d/cubismnativesamples/llms.txt Example CMakeLists.txt for building an OpenGL sample on Linux. It sets up project details, links necessary libraries like Live2DCubismCore, GLEW, GLFW, and OpenGL, and configures resource copying. ```cmake cmake_minimum_required(VERSION 3.16) set(APP_NAME Demo) set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty) set(RES_PATH ${SDK_ROOT_PATH}/Samples/Resources) project(${APP_NAME}) # C++14 required set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Add Cubism Core as static library add_library(Live2DCubismCore STATIC IMPORTED) set_target_properties(Live2DCubismCore PROPERTIES IMPORTED_LOCATION ${CORE_PATH}/lib/linux/x86_64/libLive2DCubismCore.a INTERFACE_INCLUDE_DIRECTORIES ${CORE_PATH}/include ) # Add GLEW and GLFW add_subdirectory(${GLEW_PATH}/build/cmake ${CMAKE_CURRENT_BINARY_DIR}/glew) add_subdirectory(${GLFW_PATH} ${CMAKE_CURRENT_BINARY_DIR}/glfw) # Add Cubism Framework with OpenGL renderer set(FRAMEWORK_SOURCE OpenGL) add_subdirectory(${FRAMEWORK_PATH} ${CMAKE_CURRENT_BINARY_DIR}/Framework) target_compile_definitions(Framework PUBLIC CSM_TARGET_LINUX_GL) target_link_libraries(Framework Live2DCubismCore glew_s) # Find OpenGL find_package(OpenGL REQUIRED) # Build executable add_executable(${APP_NAME}) add_subdirectory(src) target_link_libraries(${APP_NAME} Framework glfw ${OPENGL_LIBRARIES} ) # Copy resources to build directory add_custom_command( TARGET ${APP_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${RES_PATH} $/Resources ) # Optional: Enable offscreen rendering modes # target_compile_definitions(${APP_NAME} PRIVATE USE_RENDER_TARGET) # target_compile_definitions(${APP_NAME} PRIVATE USE_MODEL_RENDER_TARGET) ``` -------------------------------- ### Configure GLFW Build Options Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.linux.cmake/CMakeLists.txt Disables documentation, tests, and examples for GLFW, and prevents its installation. This optimizes the build by excluding unnecessary components of the GLFW library. ```cmake # Surpress GLEW and GLFW process. set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(GLFW_INSTALL OFF CACHE BOOL "" FORCE) set(BUILD_UTILS OFF CACHE BOOL "" FORCE) ``` -------------------------------- ### LAppDelegate Class Definition Source: https://context7.com/live2d/cubismnativesamples/llms.txt Manages the application lifecycle, including window creation, OpenGL context, Cubism Framework setup, and input handling. Use GetInstance() and ReleaseInstance() for singleton access. ```cpp // LAppDelegate.hpp class LAppDelegate { public: // Get singleton instance (creates if not exists) static LAppDelegate* GetInstance(); // Release singleton instance static void ReleaseInstance(); // Initialize application (GLFW, OpenGL, Cubism Framework) bool Initialize(); // Release all resources void Release(); // Main render loop void Run(); // Mouse button callback for OpenGL/GLFW void OnMouseCallBack(GLFWwindow* window, int button, int action, int modify); // Mouse position callback for OpenGL/GLFW void OnMouseCallBack(GLFWwindow* window, double x, double y); // Get window dimensions static void GetClientSize(int& rWidth, int& rHeight); // Get GLFW window handle GLFWwindow* GetWindow() { return _window; } // Get view instance LAppView* GetView() { return _view; } // Get texture manager instance LAppTextureManager* GetTextureManager() { return _textureManager; } // Check if application should end bool GetIsEnd() { return _isEnd; } // Signal application to end void AppEnd() { _isEnd = true; } }; // Usage Example - Application Initialization bool LAppDelegate::Initialize() { // Initialize GLFW if (glfwInit() == GL_FALSE) { return GL_FALSE; } // Create window _window = glfwCreateWindow(RenderTargetWidth, RenderTargetHeight, "SAMPLE", NULL, NULL); if (_window == NULL) { glfwTerminate(); return GL_FALSE; } // Set OpenGL context glfwMakeContextCurrent(_window); glfwSwapInterval(1); // Initialize GLEW if (glewInit() != GLEW_OK) { glfwTerminate(); return GL_FALSE; } // Setup OpenGL state glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // Register input callbacks glfwSetMouseButtonCallback(_window, EventHandler::OnMouseCallBack); glfwSetCursorPosCallback(_window, EventHandler::OnMouseCallBack); // Initialize Cubism Framework InitializeCubism(); // Load models LAppLive2DManager::GetInstance(); // Initialize view _view->Initialize(width, height); _view->InitializeSprite(); return GL_TRUE; } ``` -------------------------------- ### LAppWavFileHandler - Audio/Lip-Sync Support Source: https://context7.com/live2d/cubismnativesamples/llms.txt Handles the loading and processing of WAV files for audio playback, synchronized with lip-sync animation. It provides functionalities to start playback, update the handler, and retrieve audio data and parameters. ```APIDOC ## LAppWavFileHandler - Audio/Lip-Sync Support Handles loading and processing WAV files for audio playback synchronized with lip-sync animation. ### Structures - **WavFileInfo**: Contains information about a loaded WAV file, including file name, number of channels, bits per sample, sampling rate, and samples per channel. ### Methods - **Update(Csm::csmFloat32 deltaTimeSeconds)**: Updates the handler state. Returns true if audio is currently playing. - **GetParameter()**: Retrieves the current lip-sync parameter value. - **Start(const Csm::csmString& filePath)**: Starts playing a WAV file from the specified path. - **GetRms() const**: Gets the current RMS (Root Mean Square) volume level for lip-sync. - **GetWavFileInfo() const**: Retrieves the information of the currently loaded WAV file. - **GetRawData() const**: Gets the raw PCM data of the audio. - **GetRawDataSize() const**: Gets the size of the raw PCM data. - **GetPcmData() const**: Gets the normalized PCM data (ranging from -1.0 to 1.0). - **NormalizePcmSample(Csm::csmUint32 bitsPerSample, Csm::csmByte* data, Csm::csmUint32 dataSize)**: A static method to normalize a PCM sample to the -1.0 to 1.0 range. ### Usage Example - Playing Motion with Sound ```cpp Csm::CubismMotionQueueEntryHandle LAppModel::StartMotion( const csmChar* group, csmInt32 no, csmInt32 priority, ACubismMotion::FinishedMotionCallback onFinishedMotionHandler, ACubismMotion::BeganMotionCallback onBeganMotionHandler) { // ... motion loading code ... // Check for associated sound file csmString voice = _modelSetting->GetMotionSoundFileName(group, no); if (strcmp(voice.GetRawString(), "") != 0) { csmString path = _modelHomeDir + voice; // Start WAV playback for lip-sync _wavFileHandler.Start(path); } // Start the motion return _motionManager->StartMotionPriority(motion, autoDelete, priority); } ``` ``` -------------------------------- ### Play Motion with Associated Sound Source: https://context7.com/live2d/cubismnativesamples/llms.txt Initiates motion playback and checks for an associated WAV file. If found, it constructs the file path and starts the WAV file handler for audio synchronization and lip-sync. ```cpp // Usage Example - Playing Motion with Sound Csm::CubismMotionQueueEntryHandle LAppModel::StartMotion( const csmChar* group, csmInt32 no, csmInt32 priority, ACubismMotion::FinishedMotionCallback onFinishedMotionHandler, ACubismMotion::BeganMotionCallback onBeganMotionHandler) { // ... motion loading code ... // Check for associated sound file csmString voice = _modelSetting->GetMotionSoundFileName(group, no); if (strcmp(voice.GetRawString(), "") != 0) { csmString path = _modelHomeDir + voice; // Start WAV playback for lip-sync _wavFileHandler.Start(path); } // Start the motion return _motionManager->StartMotionPriority(motion, autoDelete, priority); } ``` -------------------------------- ### Handling Tap Interactions with Live2D Models Source: https://context7.com/live2d/cubismnativesamples/llms.txt Example of handling tap events to interact with Live2D models. It checks if a tap hits specific areas (head or body) and triggers corresponding actions like expression changes or motions. Requires `HitTest` and motion functions to be implemented. ```cpp // Usage Example - Handling Tap Interactions void LAppLive2DManager::OnTap(csmFloat32 x, csmFloat32 y) { for (csmUint32 i = 0; i < _models.GetSize(); i++) { // Check if tap hit the head area if (_models[i]->HitTest(HitAreaNameHead, x, y)) { // Trigger random expression change _models[i]->SetRandomExpression(); } // Check if tap hit the body area else if (_models[i]->HitTest(HitAreaNameBody, x, y)) { // Trigger body tap motion with callbacks _models[i]->StartRandomMotion( MotionGroupTapBody, PriorityNormal, FinishedMotion, BeganMotion ); } } } ``` -------------------------------- ### Application Entry Point Source: https://context7.com/live2d/cubismnativesamples/llms.txt The main function initializes the application delegate and enters the render loop. Ensure LAppDelegate::Initialize() returns GL_TRUE before proceeding. ```cpp #include "LAppDelegate.hpp" int main(int argc, char* argv[]) { // Create the application instance and initialize if (LAppDelegate::GetInstance()->Initialize() == GL_FALSE) { return 1; } // Enter the main render loop LAppDelegate::GetInstance()->Run(); return 0; } ``` -------------------------------- ### Suppressing GLEW and GLFW Build Options Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.win.cmake/CMakeLists.txt Configures build options for GLEW and GLFW to disable documentation, tests, examples, and installation, ensuring only necessary components are built. ```cmake # Surpress GLEW and GLFW process. set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_INSTALL OFF CACHE BOOL "" FORCE) set(BUILD_UTILS OFF CACHE BOOL "" FORCE) ``` -------------------------------- ### Set up Project and Directories Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.mac.cmake/CMakeLists.txt Configures the minimum CMake version, application name, and various directory paths for SDK components, frameworks, common sources, third-party libraries, and resources. ```cmake cmake_minimum_required(VERSION 3.16) # Set app name. set(APP_NAME Demo) # Set directory paths. set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(COMMON_SRC_PATH ${SDK_ROOT_PATH}/Samples/Common) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty) set(STB_PATH ${THIRD_PARTY_PATH}/stb) set(GLEW_PATH ${THIRD_PARTY_PATH}/glew) set(GLFW_PATH ${THIRD_PARTY_PATH}/glfw) set(RES_PATH ${SDK_ROOT_PATH}/Samples/Resources) set(SAMPLE_SHADER_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/Shaders/Standard) set(FRAMEWORK_SHADER_PATH ${FRAMEWORK_PATH}/src/Rendering/OpenGL/Shaders/Standard) # Set project. project(${APP_NAME}) ``` -------------------------------- ### Create Executable and Link Libraries Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.ios.cmake/CMakeLists.txt Creates the main executable for the application, adds source files from the 'src' subdirectory, and links all required frameworks and libraries. ```cmake # Make executable app. add_executable(${APP_NAME}) # Add source files. add_subdirectory(src) # Link libraries to app. target_link_libraries(${APP_NAME} Framework ${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY} ${GLKIT_LIBRARY} ${OPENGLES_LIBRARY} ${QUARTZCORE_LIBRARY} ${UIKIT_LIBRARY} ) # Specify include directories. target_include_directories(${APP_NAME} PRIVATE ${STB_PATH}) ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Vulkan/Demo/proj.win.cmake/CMakeLists.txt Ensures compatibility with CMake 3.17 or higher and sets the application name. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.17) # Set app name. set(APP_NAME Demo) # Set project. project(${APP_NAME}) ``` -------------------------------- ### Set CMake Minimum Version and Project Name Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.linux.cmake/CMakeLists.txt Specifies the minimum required CMake version and sets the application name. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required(VERSION 3.16) # Set app name. set(APP_NAME Demo) ``` -------------------------------- ### Optional Render Target Definitions Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.mac.cmake/CMakeLists.txt Provides commented-out examples for defining compile-time options to control where the renderer draws, such as to a specific view target, model target, or the default framebuffer. ```cmake # You can change target that renderer draws by enabling following definition. # # * USE_RENDER_TARGET # Renderer draws to target of LAppView. # * USE_MODEL_RENDER_TARGET # Renderer draws to target of each LAppModel. # * default # Renderer draws to default main framebuffer. # # INFO: USE_RENDER_TARGET has higher priority than USE_MODEL_RENDER_TARGET. # # target_compile_definitions(${APP_NAME} # PRIVATE # USE_RENDER_TARGET # USE_MODEL_RENDER_TARGET # ) ``` -------------------------------- ### Create Executable and Link Libraries Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Metal/Demo/proj.ios.cmake/CMakeLists.txt Defines the main executable target, adds source files from subdirectories, and links all necessary framework and system libraries to the application. ```cmake # Make executable app. add_executable(${APP_NAME}) # Add source files. add_subdirectory(src) # Link libraries to app. target_link_libraries(${APP_NAME} Framework ${COREGRAPHICS_LIBRARY} ${FOUNDATION_LIBRARY} ${METALKIT_LIBRARY} ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} ${UIKIT_LIBRARY} ) # Specify include directories. target_include_directories(${APP_NAME} PRIVATE ${STB_PATH}) ``` -------------------------------- ### Set Project and Paths Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Metal/Demo/proj.ios.cmake/CMakeLists.txt Configures the minimum CMake version, application name, and various directory paths for SDK components, frameworks, and resources. ```cmake cmake_minimum_required(VERSION 3.16) # Set app name. set(APP_NAME Demo) # Set directory paths. set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/Metal/thirdParty) set(STB_PATH ${THIRD_PARTY_PATH}/stb) set(RES_PATH ${SDK_ROOT_PATH}/Samples/Resources) set(SAMPLE_SHADER_PATH ${SDK_ROOT_PATH}/Samples/Metal/Shaders) set(FRAMEWORK_SHADER_PATH ${FRAMEWORK_PATH}/src/Rendering/Metal/Shaders) # Set project. project(${APP_NAME}) ``` -------------------------------- ### Main Render Loop Implementation Source: https://context7.com/live2d/cubismnativesamples/llms.txt The main application render loop using GLFW. Handles window resizing, updates time, clears the screen, renders the view (including models and UI), and swaps buffers. Ensure `glfwWindowShouldClose` and `_isEnd` flags are managed correctly. ```cpp // Usage Example - Main Render Loop void LAppDelegate::Run() { while (glfwWindowShouldClose(_window) == GL_FALSE && !_isEnd) { int width, height; glfwGetWindowSize(_window, &width, &height); // Handle window resize if ((_windowWidth != width || _windowHeight != height) && width > 0 && height > 0) { _view->Initialize(width, height); _view->ResizeSprite(); _view->DestroySpriteRenderTarget(); LAppLive2DManager::GetInstance()->SetRenderTargetSize(width, height); _windowWidth = width; _windowHeight = height; } glViewport(0, 0, _windowWidth, _windowHeight); // Update time LAppPal::UpdateTime(); // Clear screen glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearDepth(1.0); // Render view (includes models and UI) _view->Render(); // Swap buffers glfwSwapBuffers(_window); // Process events glfwPollEvents(); } Release(); LAppDelegate::ReleaseInstance(); } ``` -------------------------------- ### Directory Structure Overview Source: https://github.com/live2d/cubismnativesamples/blob/develop/README.md Illustrates the organization of the Cubism Native Samples project, including directories for Core, Framework, and various platform-specific samples. ```text . ├─ Core # Directory containing Live2D Cubism Core ├─ Framework # Directory containing source code for rendering and animation functions └─ Samples ├─ D3D9 # Directory containing the DirectX 9.0c sample project ├─ D3D11 # Directory containing the DirectX 11 sample project ├─ Metal # Directory containing the Metal sample project ├─ OpenGL # Directory containing the OpenGL sample project ├─ Vulkan # Directory containing the Vulkan sample project └─ Resources # Directory containing resources such as model files and images ``` -------------------------------- ### Define Executable and Add Sources Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.mac.cmake/CMakeLists.txt Creates the main executable target, adds common source files from the Common directory, and includes sources from the local 'src' subdirectory. ```cmake # Make executable app. add_executable(${APP_NAME}) # Add common source files. add_subdirectory(${COMMON_SRC_PATH} ${CMAKE_CURRENT_BINARY_DIR}/src/Common) # Add source files. add_subdirectory(src) ``` -------------------------------- ### Initialize Cubism Framework Source: https://context7.com/live2d/cubismnativesamples/llms.txt Configures and initializes the Cubism Framework, setting up logging, file loading, and memory allocation. This must be called before loading any models. ```cpp void LAppDelegate::InitializeCubism() { // Configure Cubism options _cubismOption.LogFunction = LAppPal::PrintMessage; _cubismOption.LoggingLevel = LAppDefine::CubismLoggingLevel; _cubismOption.LoadFileFunction = LAppPal::LoadFileAsBytes; _cubismOption.ReleaseBytesFunction = LAppPal::ReleaseBytes; // Start up Cubism Framework with allocator and options Csm::CubismFramework::StartUp(&_cubismAllocator, &_cubismOption); // Initialize the framework CubismFramework::Initialize(); // Create default projection matrix CubismMatrix44 projection; // Initialize time tracking LAppPal::UpdateTime(); } ``` -------------------------------- ### Define Project Paths Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Vulkan/Demo/proj.win.cmake/CMakeLists.txt Sets up essential directory paths for the SDK, core libraries, framework, third-party components, resources, and shaders. These paths are crucial for locating project files during the build. ```cmake # Set directory paths. set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/Vulkan/thirdParty) set(STB_PATH ${THIRD_PARTY_PATH}/stb) set(GLFW_PATH ${THIRD_PARTY_PATH}/glfw) set(RES_PATH ${SDK_ROOT_PATH}/Samples/Resources) set(SAMPLE_SHADER_PATH ${SDK_ROOT_PATH}/Samples/Vulkan/Shaders) set(FRAMEWORK_SHADER_PATH ${FRAMEWORK_PATH}/src/Rendering/Vulkan/Shaders) set(COMMON_SRC_PATH ${SDK_ROOT_PATH}/Samples/Common) ``` -------------------------------- ### Import Live2D Cubism Core Library Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.mac.cmake/CMakeLists.txt Imports the Live2D Cubism Core as a static library, determines the system architecture, and sets the library path and include directories. ```cmake # Add Cubism Core. # Import as static library. add_library(Live2DCubismCore STATIC IMPORTED) # Get architecture. EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE ) # Set library path and inlude path. set_target_properties(Live2DCubismCore PROPERTIES IMPORTED_LOCATION ${CORE_PATH}/lib/macos/${ARCHITECTURE}/libLive2DCubismCore.a INTERFACE_INCLUDE_DIRECTORIES ${CORE_PATH}/include ) ``` -------------------------------- ### Create Executable and Add Source Directories Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Vulkan/Demo/proj.win.cmake/CMakeLists.txt Defines the main executable target and adds common source files, application-specific sources, and shader directories. This organizes the project structure for compilation. ```cmake # Make executable app. add_executable(${APP_NAME}) # Add common source files. add_subdirectory(${COMMON_SRC_PATH} ${CMAKE_CURRENT_BINARY_DIR}/src/Common) # Add source files. add_subdirectory(src) # Add shader files. add_subdirectory(${SAMPLE_SHADER_PATH} ${CMAKE_CURRENT_BINARY_DIR}/SampleShaders) add_subdirectory(${FRAMEWORK_SHADER_PATH} ${CMAKE_CURRENT_BINARY_DIR}/FrameworkShaders) add_dependencies(Framework SampleShaders) add_dependencies(Framework FrameworkShaders) ``` -------------------------------- ### Set Project and Paths in CMake Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.ios.cmake/CMakeLists.txt Configures the application name, and defines various directory paths for SDK, Core, Framework, third-party libraries, resources, and shaders. ```cmake cmake_minimum_required(VERSION 3.16) # Set app name. set(APP_NAME Demo) # Set directory paths. set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) set(CORE_PATH ${SDK_ROOT_PATH}/Core) set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework) set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty) set(STB_PATH ${THIRD_PARTY_PATH}/stb) set(RES_PATH ${SDK_ROOT_PATH}/Samples/Resources) set(FRAMEWORK_SHADER_PATH ${FRAMEWORK_PATH}/src/Rendering/OpenGL/Shaders/StandardES) # Set project. project(${APP_NAME}) ``` -------------------------------- ### Configure Cubism Native Framework Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.ios.cmake/CMakeLists.txt Adds the Cubism Native Framework as a subdirectory, defines rendering targets, includes GLEW headers, and links the Live2DCubismCore library to it. ```cmake # Specify Cubism Framework rendering. set(FRAMEWORK_SOURCE OpenGL) # Add Cubism Native Framework. add_subdirectory(${FRAMEWORK_PATH} ${CMAKE_CURRENT_BINARY_DIR}/Framework) # Add rendering definition to framework. target_compile_definitions(Framework PUBLIC CSM_TARGET_IPHONE_ES2) # Add include path of GLEW to framework. target_include_directories(Framework PUBLIC ${GLEW_PATH}/include) # Link libraries to framework. target_link_libraries(Framework Live2DCubismCore) ``` -------------------------------- ### Post-Build Copy Commands Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Vulkan/Demo/proj.win.cmake/CMakeLists.txt Defines custom commands to execute after the application is built. These commands copy resource directories, sample shaders, and framework shaders to the build output directory. ```cmake # Copy resource directory to build directory. add_custom_command( TARGET ${APP_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${RES_PATH} $/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/SampleShaders/compiledShaders $/SampleShaders COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkShaders/compiledShaders $/FrameworkShaders ) ``` -------------------------------- ### Configure Live2D Cubism Framework Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.mac.cmake/CMakeLists.txt Sets the rendering framework to OpenGL, adds the Cubism Native Framework as a subdirectory, defines the rendering target for macOS, and links necessary libraries. ```cmake # Specify Cubism Framework rendering. set(FRAMEWORK_SOURCE OpenGL) # Add Cubism Native Framework. add_subdirectory(${FRAMEWORK_PATH} ${CMAKE_CURRENT_BINARY_DIR}/Framework) # Add rendering definition to framework. target_compile_definitions(Framework PUBLIC CSM_TARGET_MAC_GL) # Add include path of GLEW to framework. target_include_directories(Framework PUBLIC ${GLEW_PATH}/include) # Link libraries to framework. target_link_libraries(Framework Live2DCubismCore glew_s) ``` -------------------------------- ### Configure Build Output and Settings Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.mac.cmake/CMakeLists.txt Defines the runtime output directory, supported build configurations (Debug, Release), suppresses regeneration checks, and configures build options for GLFW. ```cmake # Define output directory. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${APP_NAME}) # Set configuration (Release and Debug only). set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "Configurations" FORCE ) # Suppress generation of ZERO_CHECK project. set(CMAKE_SUPPRESS_REGENERATION ON) # Surpress GLEW and GLFW process. set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(GLFW_INSTALL OFF CACHE BOOL "" FORCE) set(BUILD_UTILS OFF CACHE BOOL "" FORCE) ``` -------------------------------- ### Configure Target Sources for Live2D Cubism (Minimum Demo) Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/D3D9/Demo/proj.d3d9.cmake/src/CMakeLists.txt Includes source files for the minimum demo build of the Live2D Cubism project. This configuration is used when CSM_MINIMUM_DEMO is defined. ```cmake if (CSM_MINIMUM_DEMO) target_sources(${APP_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.hpp ${CMAKE_CURRENT_SOURCE_DIR}/mainMinimum.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismSprite.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismSprite.hpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismSpriteShader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismSpriteShader.hpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismTextureManager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismTextureManager.hpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismUserModelExtend.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismUserModelExtend.hpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismDirectXView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismDirectXView.hpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismDirectXRenderer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CubismDirectXRenderer.hpp ) else () target_sources(${APP_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppDefine.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppDelegate.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppLive2DManager.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppModel.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppPal.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppSprite.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppSpriteShader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppSpriteShader.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppTextureManager.hpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/LAppView.hpp ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) endif () ``` -------------------------------- ### Cubism Framework Initialization Source: https://context7.com/live2d/cubismnativesamples/llms.txt Initializes the Cubism Framework, setting up essential components like memory allocation, logging, and file loading functions before any models can be loaded. ```APIDOC ## Cubism Framework Initialization ### Description Initializes the Cubism Framework, setting up essential components like memory allocation, logging, and file loading functions before any models can be loaded. ### Method `void` ### Endpoint N/A (Function Call) ### Parameters None ### Request Example ```cpp void LAppDelegate::InitializeCubism() { // Configure Cubism options _cubismOption.LogFunction = LAppPal::PrintMessage; _cubismOption.LoggingLevel = LAppDefine::CubismLoggingLevel; _cubismOption.LoadFileFunction = LAppPal::LoadFileAsBytes; _cubismOption.ReleaseBytesFunction = LAppPal::ReleaseBytes; // Start up Cubism Framework with allocator and options Csm::CubismFramework::StartUp(&_cubismAllocator, &_cubismOption); // Initialize the framework CubismFramework::Initialize(); // Create default projection matrix CubismMatrix44 projection; // Initialize time tracking LAppPal::UpdateTime(); } ``` ### Response N/A (Function Call) ### Response Example N/A ``` -------------------------------- ### Link Libraries and Specify Include Directories for Executable Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.mac.cmake/CMakeLists.txt Links the Framework, GLFW, and OpenGL libraries to the main application executable and specifies private include directories for STB. ```cmake # Link libraries to app. target_link_libraries(${APP_NAME} Framework glfw ${OPENGL_LIBRARIES} ) # Specify include directories. target_include_directories(${APP_NAME} PRIVATE ${STB_PATH}) ``` -------------------------------- ### Copy Resources and Shaders Post-Build Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.mac.cmake/CMakeLists.txt Configures custom build commands to copy resource directories, sample shaders, and framework shaders to the build output directory after the target is built. ```cmake # Copy resource directory to build directory. add_custom_command( TARGET ${APP_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${RES_PATH} $/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${SAMPLE_SHADER_PATH} $/SampleShaders COMMAND ${CMAKE_COMMAND} -E copy_directory ${FRAMEWORK_SHADER_PATH} $/FrameworkShaders ) ``` -------------------------------- ### Configuring Live2D Cubism Native Framework Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.win.cmake/CMakeLists.txt Adds the Live2D Cubism Native Framework as a subdirectory, sets the rendering source to OpenGL, defines compilation flags, and links necessary libraries. ```cmake # Specify Cubism Framework rendering. set(FRAMEWORK_SOURCE OpenGL) # Add Cubism Native Framework. add_subdirectory(${FRAMEWORK_PATH} ${CMAKE_CURRENT_BINARY_DIR}/Framework) # Add rendering definition to framework. target_compile_definitions(Framework PUBLIC CSM_TARGET_WIN_GL) # Add include path of GLEW to framework. target_include_directories(Framework PUBLIC ${GLEW_PATH}/include) # Link libraries to framework. target_link_libraries(Framework Live2DCubismCore glew_s) ``` -------------------------------- ### Configure Live2D Cubism Native Framework Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.linux.cmake/CMakeLists.txt Adds the Live2D Cubism Native Framework as a subdirectory. It specifies OpenGL as the rendering framework, defines necessary compile-time flags for Linux GL, includes GLEW headers, and links the Cubism Core and GLEW libraries to the framework. ```cmake # Specify Cubism Framework rendering. set(FRAMEWORK_SOURCE OpenGL) # Add Cubism Native Framework. add_subdirectory(${FRAMEWORK_PATH} ${CMAKE_CURRENT_BINARY_DIR}/Framework) # Add rendering definition to framework. target_compile_definitions(Framework PUBLIC CSM_TARGET_LINUX_GL) # Add include path of GLEW to framework. target_include_directories(Framework PUBLIC ${GLEW_PATH}/include) # Link libraries to framework. target_link_libraries(Framework Live2DCubismCore glew_s) ``` -------------------------------- ### Configure Build Output and Configurations Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Vulkan/Demo/proj.win.cmake/CMakeLists.txt Specifies the runtime output directory for executables and defines the build configurations (Debug, Release). It also suppresses the generation of the ZERO_CHECK project for cleaner builds. ```cmake # Define output directory. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${APP_NAME}) # Set configuration (Release and Debug only). set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "Configurations" FORCE ) # Suppress generation of ZERO_CHECK project. set(CMAKE_SUPPRESS_REGENERATION ON) ``` -------------------------------- ### Set Project and Build Configuration Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.linux.cmake/CMakeLists.txt Configures the project name and defines the output directory for runtime files. It also sets the available build configurations (Debug, Release) and suppresses the generation of the ZERO_CHECK project for cleaner builds. ```cmake # Set project. project(${APP_NAME}) # Define output directory. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${APP_NAME}) # Set configuration (Release and Debug only). set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "Configurations" FORCE ) # Suppress generation of ZERO_CHECK project. set(CMAKE_SUPPRESS_REGENERATION ON) ``` -------------------------------- ### Specify Include Directories and Link Libraries for Framework Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Vulkan/Demo/proj.win.cmake/CMakeLists.txt Configures include directories for Vulkan headers and links the Live2D Cubism Core and Vulkan libraries to the Framework target. This ensures the framework has access to required components. ```cmake # Link libraries to framework. target_include_directories(Framework PUBLIC ${Vulkan_INCLUDE_DIRS}) # Link libraries to framework. target_link_libraries(Framework Live2DCubismCore ${Vulkan_LIBRARIES}) ``` -------------------------------- ### Implement stb_image Library Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Metal/thirdParty/stb/README.md To use the stb_image library, define STB_IMAGE_IMPLEMENTATION in exactly one C/C++ source file before including the header. This enables the function definitions. ```c #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" ``` -------------------------------- ### Configure Build Output and C++ Standard Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.ios.cmake/CMakeLists.txt Sets the output directory for runtime files, defines available build configurations (Debug, Release), suppresses regeneration, and specifies the C++ standard to C++14. ```cmake # Define output directory. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${APP_NAME}) # Set configuration (Release and Debug only). set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "Configurations" FORCE ) # Suppress generation of ZERO_CHECK project. set(CMAKE_SUPPRESS_REGENERATION ON) # Specify version of compiler. set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) ``` -------------------------------- ### Optional Render Target Definitions Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.ios.cmake/CMakeLists.txt Commented-out section showing how to define compile-time options for controlling where the renderer draws its output (e.g., to LAppView, individual LAppModels, or the main framebuffer). ```cmake # You can change target that renderer draws by enabling following definition. # # * USE_RENDER_TARGET # Renderer draws to target of LAppView. # * USE_MODEL_RENDER_TARGET # Renderer draws to target of each LAppModel. # * default # Renderer draws to default main framebuffer. # # INFO: USE_RENDER_TARGET has higher priority than USE_MODEL_RENDER_TARGET. # # target_compile_definitions(${APP_NAME} # PRIVATE # USE_RENDER_TARGET # USE_MODEL_RENDER_TARGET # ) ``` -------------------------------- ### Specify Include Directories for Application Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Vulkan/Demo/proj.win.cmake/CMakeLists.txt Adds include directories for the STB library and Vulkan headers to the application target. This allows the application to find necessary header files. ```cmake # Specify include directories. target_include_directories(${APP_NAME} PRIVATE ${STB_PATH}) target_include_directories(${APP_NAME} PRIVATE ${Vulkan_INCLUDE_DIRS}) ``` -------------------------------- ### Build Configuration and Compiler Settings Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/Metal/Demo/proj.ios.cmake/CMakeLists.txt Defines output directories, configuration types (Debug/Release), suppresses regeneration, and sets C++ standard to C++14 with extensions disabled. ```cmake # Define output directory. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${APP_NAME}) # Set configuration (Release and Debug only). set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "Configurations" FORCE ) # Suppress generation of ZERO_CHECK project. set(CMAKE_SUPPRESS_REGENERATION ON) # Specify version of compiler. set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") ``` -------------------------------- ### Find System Libraries for iOS Source: https://github.com/live2d/cubismnativesamples/blob/develop/Samples/OpenGL/Demo/proj.ios.cmake/CMakeLists.txt Finds necessary system libraries for iOS development, including CoreGraphics, Foundation, GLKit, OpenGLES, QuartzCore, and UIKit. ```cmake # Find libraries. find_library(COREGRAPHICS_LIBRARY CoreGraphics) find_library(FOUNDATION_LIBRARY Foundation) find_library(GLKIT_LIBRARY GLKit) find_library(OPENGLES_LIBRARY OpenGLES) find_library(QUARTZCORE_LIBRARY QuartzCore) find_library(UIKIT_LIBRARY UIKit) ```