MENU

Fun & Interesting

How I Structure Cross-Platform C++ Projects with CMake

NL Tech 1,048 1 month ago
Video Not Working? Fix It Now

Managing C++ projects across different platforms can be a challenge, especially when dealing with multiple compilers like MSVC (Windows), GCC (Linux), and Apple Clang (macOS). In this video, I break down how to structure cross-platform C++ projects using CMake, making your builds consistent and portable across all major operating systems. We start with a simple "Hello, World!" executable and progressively expand the project by adding a static library and integrating an external dependency—GLFW—via a Git submodule. You'll learn how to configure CMake to handle compilation, linking, and dependency management seamlessly. By the end of this video, you'll have a well-structured C++ project that builds effortlessly on Windows, macOS, and Linux with native compilers. 🔥 Topics Covered: ✅ Why cross-platform C++ development is challenging ✅ Setting up a CMake project for portability ✅ Building a simple "Hello, World!" executable ✅ Adding and linking a static library ✅ Integrating an external dependency (GLFW) as a Git submodule ✅ Configuring CMake to build with MSVC, GCC, and Apple Clang ✅ Demonstrating builds on Windows, Linux, and macOS 📚 Contents: 0:00 Introduction 0:26 The Problem: Building for Different Platforms 0:57 The Solution: Pre-Building with CMake 1:32 What We'll Cover in this Video 2:13 "Hello World" Executable Project with 1 File 5:17 Adding a Static Library 12:00 Adding an External Dependency/Library - GLFW 16:30 Building on macOS 16:58 Building on Windows 17:18 Conclusion ✉️ Social Media: 📧 Email: [email protected] 🐦 Twitter: https://twitter.com/nikelaz 🔗 LinkedIn: https://www.linkedin.com/in/nikola-lazarov #CMake #CPlusPlus #CrossPlatform

Comment