1/1/2024 0 Comments Unix cmake tutorialWith ofxCMake, including an addon in your project is as simple as adding the name of the addon to your CMakeLists.txt, so if you are building from CMake, all your custom rules stay. If you had special build rules or custom compilation targets, those go poof. One of the biggest annoyances in working with OF is that if you want to include a new addon in your project, the PG needs to be called and your project files get overwritten. It can completely eliminate the need for the Project Generator, which IMO is a pain point and a maintenance challenge.This also means that OF can settle on just a single editor for learning purposes (say, VSCode), which makes tutorial writing a lot simpler. If users want a full IDE, they can either generate the appropriate project with CMake, or work with an IDE that is compatible with CMake projects (CLion, and now Visual Studio). VSCode has nice CMake integrations, but plain text editors will work just fine too. Since we are not tied to IDE’s to build, users can choose their own tool to write OF apps with.It lessens the learning curve for new users because they won’t necessarily have to deal with the intricacies of IDE’s in various platforms, and that has an additional advantage in that OF does not have to produce examples and documentation as to how to address these various intricacies.It potentially reduces maintenance, since build rules are just in CMake instead of in 3 different formats (Xcode, MSVC, Make).Given that cross-platform compatibility is one of OF’s most important features, this is a huge boon. If you are building from CMake directly, then your build command is unified across platforms.IMO there are several advantages to using CMake vs the current build approaches in OF. Passed 0.I haven’t tried this approach to CMake, but I have been using a fork of ofxCMake for quite some time and it works well. my_project/buildġ/1 Test #1: HelloTest.BasicAssertions. The CXX compiler identification is GNU 10.2.1 The C compiler identification is GNU 10.2.1 Now you can build and run your test: my_project$ cmake -S. Last two lines enable CMake’s test runner to discover the tests included in the You want to build ( hello_test), and links it to GoogleTest ( gtest_main). The above configuration enables testing in CMake, declares the C++ test binary ) include (GoogleTest ) gtest_discover_tests (hello_test ) With GoogleTest declared as a dependency, you can use GoogleTest code withinĪs an example, create a file named hello_ in your my_project Hash often to point to the latest version.įor more information about how to create CMakeLists.txt files, see the The Git commit hash of the GoogleTest version to use we recommend updating the The above configuration declares a dependency on GoogleTest which is downloadedįrom GitHub. ) # For Windows: Prevent overriding the parent project's compiler/linker settings set (gtest_force_shared_crt ON CACHE BOOL "" FORCE ) FetchContent_MakeAvailable (googletest ) You’ll use this file to set up your project and declare a dependency onįirst, create a directory for your project:Ĭmake_minimum_required (VERSION 3.14 ) project (my_project ) # GoogleTest requires at least C++14 set (CMAKE_CXX_STANDARD 14 ) set (CMAKE_CXX_STANDARD_REQUIRED ON ) include (FetchContent ) FetchContent_Declare ( Set up a projectĬMake uses a file named CMakeLists.txt to configure the build system for a Note: The terminal commands in this tutorial show a Unix shell prompt, but theĬommands work on the Windows command line as well. If you don’t already have CMake installed, see the See Supported Platforms for more information about platforms CMake and a compatible build tool for building the.A compatible C++ compiler that supports at least C++14.You’re using GoogleTest for the first time or need a refresher, we recommend This tutorial aims to get you up and running with GoogleTest using CMake.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |