aboutsummaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/example
diff options
context:
space:
mode:
Diffstat (limited to 'dev/MinGfx/example')
-rw-r--r--dev/MinGfx/example/CMakeLists.txt166
-rw-r--r--dev/MinGfx/example/CircleViewer.cpp122
-rw-r--r--dev/MinGfx/example/CircleViewer.h77
-rw-r--r--dev/MinGfx/example/cmake/AutoBuild.cmake541
-rw-r--r--dev/MinGfx/example/cmake/AutoBuildOpenGL.cmake47
-rw-r--r--dev/MinGfx/example/cmake/MessageMacros.cmake17
-rw-r--r--dev/MinGfx/example/main-circleviewer.cpp12
7 files changed, 982 insertions, 0 deletions
diff --git a/dev/MinGfx/example/CMakeLists.txt b/dev/MinGfx/example/CMakeLists.txt
new file mode 100644
index 0000000..a9b27b7
--- /dev/null
+++ b/dev/MinGfx/example/CMakeLists.txt
@@ -0,0 +1,166 @@
+# Original Author(s) of this File:
+# Daniel Keefe, 2017, University of Minnesota
+#
+# Author(s) of Significant Updates/Modifications to the File:
+# ...
+
+
+
+# You are encouraged to copy this example, move it outside of the MinGfx directory, and use
+# it as a starting point for your project. When you do this, you'll have to edit the
+# following line as needed to point to the MinGfx install prefix used on your system.
+
+# !!!!!!!!!!!!! EDIT THE FOLLOWING LINE AS NEEDED !!!!!!!!!!!!!
+list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../build/install ../../..)
+
+# For example, you might have installed to a build tree that now looks like this:
+# /Users/keefe/courses/cs4611/sw/include/MinGfx-1.0/
+# /Users/keefe/courses/cs4611/sw/include/Eigen
+# /Users/keefe/courses/cs4611/sw/include/nanogui
+# /Users/keefe/courses/cs4611/sw/include/ etc..
+
+# /Users/keefe/courses/cs4611/sw/lib/MinGfx-1.0/libMinGfx.a
+# /Users/keefe/courses/cs4611/sw/lib/libnanogui.so
+# /Users/keefe/courses/cs4611/sw/lib/ etc..
+
+# If so, you would set the prefix path as follows:
+#list(APPEND CMAKE_PREFIX_PATH /Users/keefe/courses/cs4611/sw)
+
+
+
+
+
+#### BASIC PROJECT SETUP ####
+
+project(mingfx-example)
+
+# Using 3.9 to get a modern version of FindOpenGL.cmake
+cmake_minimum_required (VERSION 3.9)
+
+# Dependencies that are auto-downloaded, built, and installed for you will go in the
+# directory pointed to by the CMAKE_INSTALL_PREFIX. It defaults to a location inside
+# the build directory.
+if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
+ set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE )
+endif()
+
+# Add to paths cmake uses to search for scripts, modules, and config packages
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_INSTALL_PREFIX})
+list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_INSTALL_PREFIX})
+
+include(MessageMacros)
+h1("Building ${PROJECT_NAME}")
+h2("Configuring paths")
+
+message(STATUS "Module path: ${CMAKE_MODULE_PATH}")
+message(STATUS "Prefix path: ${CMAKE_PREFIX_PATH}")
+message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
+
+
+
+#### SOURCE FOR THIS PROJECT ####
+h2("Configuring source files")
+
+set(SOURCEFILES
+ main-circleviewer.cpp
+ CircleViewer.cpp
+)
+
+set(HEADERFILES
+ CircleViewer.h
+)
+
+set(EXTRAFILES
+# README.md
+)
+
+set_source_files_properties(${EXTRAFILES} PROPERTIES HEADER_FILE_ONLY TRUE)
+
+
+
+#### COMPILE OPTIONS ####
+
+h2("Configuring Compiler Options")
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+
+
+message(STATUS "Building for " ${CMAKE_SYSTEM_NAME} ".")
+
+# Linux specific
+if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ add_definitions(-DLINUX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
+endif()
+
+
+# Apple specific
+if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ add_definitions(-DOSX)
+
+ # RPATH settings, see https://cmake.org/Wiki/CMake_RPATH_handling
+ set(CMAKE_MACOSX_RPATH ON)
+
+ # use, i.e. don't skip the full RPATH for the build tree
+ SET(CMAKE_SKIP_BUILD_RPATH FALSE)
+
+ # when building, don't use the install RPATH already
+ # (but later on when installing)
+ SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+
+ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+
+ # add the automatically determined parts of the RPATH
+ # which point to directories outside the build tree to the install RPATH
+ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+ # the RPATH to be used when installing, but only if it's not a system directory
+ LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
+ IF("${isSystemDir}" STREQUAL "-1")
+ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+ ENDIF("${isSystemDir}" STREQUAL "-1")
+
+endif()
+
+
+# Windows specific
+if (WIN32)
+ add_definitions(-DWIN32)
+endif()
+
+
+
+
+#### DEFINE TARGET(S) ####
+
+h2("Defining Target(s)")
+
+add_executable(${PROJECT_NAME} ${SOURCEFILES} ${HEADERFILES} ${EXTRAFILES})
+
+
+
+#### FIND AND ADD DEPENDENCIES ####
+
+h2("Adding Dependencies")
+set(EXTERNAL_DIR external)
+
+
+# MinGfx (linked with an imported cmake target so no need to specify include dirs)
+# This will try to find MinGfxConfig.cmake, which should have been installed under
+# CMAKE_INSTALL_PREFIX/lib/cmake/MinGfx when you installed the MinGfx Toolkit.
+find_package(MinGfx REQUIRED)
+target_link_libraries(${PROJECT_NAME} PUBLIC MinGfx::MinGfx)
+
+# Add external dependency on OpenGL
+include(AutoBuildOpenGL)
+AutoBuild_use_package_OpenGL(${PROJECT_NAME} PUBLIC)
+
+
+
+#### INSTALL TARGET(S) ####
+
+h2("Configuring Install Target")
+
+# The install locations are relative to the CMAKE_INSTALL_PREFIX variable
+install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
+
diff --git a/dev/MinGfx/example/CircleViewer.cpp b/dev/MinGfx/example/CircleViewer.cpp
new file mode 100644
index 0000000..9bf50b9
--- /dev/null
+++ b/dev/MinGfx/example/CircleViewer.cpp
@@ -0,0 +1,122 @@
+
+#include "CircleViewer.h"
+
+#include <nanogui/nanogui.h>
+#include <iostream>
+
+
+CircleViewer::CircleViewer() : GraphicsApp(1024,768, "Circle Simulation") {
+ simTime_ = 0.0;
+ paused_ = false;
+
+ //InitGraphicsContext();
+}
+
+
+CircleViewer::~CircleViewer() {
+
+}
+
+void CircleViewer::InitNanoGUI() {
+ nanogui::FormHelper *gui = new nanogui::FormHelper(screen());
+ nanogui::ref<nanogui::Window> window = gui->addWindow(Eigen::Vector2i(10, 10), "Simulation Controls");
+ pauseBtn_ = gui->addButton("Pause", std::bind(&CircleViewer::OnPauseBtnPressed, this));
+ gui->addButton("Restart", std::bind(&CircleViewer::OnRestartBtnPressed, this));
+
+ screen()->performLayout();
+}
+
+void CircleViewer::UpdateSimulation(double dt) {
+ if (!paused_) {
+ simTime_ += dt;
+ std::cout << "Update Simulation " << simTime_ << std::endl;
+ }
+}
+
+
+void CircleViewer::OnRestartBtnPressed() {
+ simTime_ = 0.0;
+}
+
+void CircleViewer::OnPauseBtnPressed() {
+ paused_ = !paused_;
+ if (paused_) {
+ pauseBtn_->setCaption("Play");
+ }
+ else {
+ pauseBtn_->setCaption("Pause");
+ }
+}
+
+
+void CircleViewer::OnMouseMove(const Point2 &pos, const Vector2 &delta) {
+ std::cout << "Mouse moved by " << delta << " to reach " << pos << std::endl;
+}
+
+
+void CircleViewer::OnLeftMouseDown(const Point2 &pos) {
+ std::cout << "Left mouse button DOWN at " << pos << std::endl;
+}
+
+void CircleViewer::OnLeftMouseDrag(const Point2 &pos, const Vector2 &delta) {
+ std::cout << "Mouse dragged (left button) by " << delta << " to reach " << pos << std::endl;
+}
+
+void CircleViewer::OnLeftMouseUp(const Point2 &pos) {
+ std::cout << "Left mouse button UP at " << pos << std::endl;
+}
+
+
+void CircleViewer::OnRightMouseDown(const Point2 &pos) {
+ std::cout << "Right mouse button DOWN at " << pos << std::endl;
+}
+
+void CircleViewer::OnRightMouseDrag(const Point2 &pos, const Vector2 &delta) {
+ std::cout << "Mouse dragged (right button) by " << delta << " to reach " << pos << std::endl;
+}
+
+void CircleViewer::OnRightMouseUp(const Point2 &pos) {
+ std::cout << "Right mouse button UP at " << pos << std::endl;
+}
+
+
+void CircleViewer::OnKeyDown(const char *c, int modifiers) {
+ std::cout << "Key DOWN (" << c << ") modifiers=" << modifiers << std::endl;
+}
+
+void CircleViewer::OnKeyUp(const char *c, int modifiers) {
+ std::cout << "Key UP (" << c << ") modifiers=" << modifiers << std::endl;
+}
+
+
+void CircleViewer::OnSpecialKeyDown(int key, int scancode, int modifiers) {
+ std::cout << "Special Key DOWN key=" << key << " scancode=" << scancode << " modifiers=" << modifiers << std::endl;
+}
+
+void CircleViewer::OnSpecialKeyUp(int key, int scancode, int modifiers) {
+ std::cout << "Special Key UP key=" << key << " scancode=" << scancode << " modifiers=" << modifiers << std::endl;
+}
+
+
+void CircleViewer::DrawUsingNanoVG(NVGcontext *ctx) {
+ // example of drawing some circles
+
+ nvgBeginPath(ctx);
+ nvgCircle(ctx, 512+50.0*cos(simTime_), 350+200.0*sin(simTime_), 50);
+ nvgFillColor(ctx, nvgRGBA(100,100,255,200));
+ nvgFill(ctx);
+ nvgStrokeColor(ctx, nvgRGBA(0,0,0,255));
+ nvgStroke(ctx);
+
+ nvgBeginPath(ctx);
+ nvgCircle(ctx, 512+200.0*cos(simTime_), 350+50.0*sin(simTime_), 50);
+ nvgFillColor(ctx, nvgRGBA(255,100,100,200));
+ nvgFill(ctx);
+ nvgStrokeColor(ctx, nvgRGBA(0,0,0,255));
+ nvgStroke(ctx);
+}
+
+void CircleViewer::DrawUsingOpenGL() {
+
+}
+
diff --git a/dev/MinGfx/example/CircleViewer.h b/dev/MinGfx/example/CircleViewer.h
new file mode 100644
index 0000000..4aefbc8
--- /dev/null
+++ b/dev/MinGfx/example/CircleViewer.h
@@ -0,0 +1,77 @@
+
+#include <mingfx.h>
+
+
+/** An application that opens up a window that includes a few buttons
+ for controlling the simulation and can be used to draw circles and
+ other computer graphics.
+
+ After constructing a new CircleViewer, call Run() to start and
+ run the application. Run() will not return until the application
+ window is closed. Make sure that you call cs3081::InitGraphics()
+ before creating the RobotViewer app. Example:
+
+ ```
+ int main(int argc, char **argv) {
+ cs3081::InitGraphics();
+ cs3081::CircleViewer *app = new cs3081::CircleViewer();
+ app->Run();
+ cs3081::ShutdownGraphics();
+ return 0;
+ }
+ ```
+
+ While the window is open UpdateSimulation() will be called
+ repeatedly, once per frame. Fill this in to update your simulation
+ or perform any other processing that should happen over time as the
+ simulation progresses.
+
+ Fill in the On*() methods as desired to respond to user input events.
+
+ Fill in the Draw*() methods to draw graphics to the screen using
+ either the nanovg library or raw OpenGL.
+*/
+class CircleViewer : public GraphicsApp {
+public:
+ CircleViewer();
+ ~CircleViewer();
+
+ void InitNanoGUI();
+
+ void UpdateSimulation(double dt);
+
+
+ void OnRestartBtnPressed();
+
+ void OnPauseBtnPressed();
+
+
+ void OnMouseMove(const Point2 &pos, const Vector2 &delta);
+
+ void OnLeftMouseDown(const Point2 &pos);
+ void OnLeftMouseDrag(const Point2 &pos, const Vector2 &delta);
+ void OnLeftMouseUp(const Point2 &pos);
+
+ void OnRightMouseDown(const Point2 &pos);
+ void OnRightMouseDrag(const Point2 &pos, const Vector2 &delta);
+ void OnRightMouseUp(const Point2 &pos);
+
+
+ void OnKeyDown(const char *c, int modifiers);
+
+ void OnKeyUp(const char *c, int modifiers);
+
+ void OnSpecialKeyDown(int key, int scancode, int modifiers);
+
+ void OnSpecialKeyUp(int key, int scancode, int modifiers);
+
+
+ void DrawUsingNanoVG(NVGcontext *ctx);
+
+ void DrawUsingOpenGL();
+
+private:
+ double simTime_;
+ bool paused_;
+ nanogui::Button *pauseBtn_;
+};
diff --git a/dev/MinGfx/example/cmake/AutoBuild.cmake b/dev/MinGfx/example/cmake/AutoBuild.cmake
new file mode 100644
index 0000000..2e349b9
--- /dev/null
+++ b/dev/MinGfx/example/cmake/AutoBuild.cmake
@@ -0,0 +1,541 @@
+# Author: Daniel F. Keefe
+# Copyright 2017,2018, Daniel F. Keefe and Regents of the University of Minnesota
+# All Rights Reserved.
+
+
+# OVERVIEW / INTENT: AutoBuild is a series of CMake macros and functions for working with sub-projects that are dependencies of a main project. We assume that both the main project and dependencies each build with CMake already. AutoBuild manages the process of checking to see if the dependencies are already available, installed on the system. If not, AutoBuild will automatically download, build, and install the dependencies for you as part of the CMake Configure process.
+
+# WHY IS THIS NEEDED / USEFUL?: AutoBuild is similar in spirit to CMake's ExternalProject_add() command. In fact, AutoBuild uses that command internally. However, there is a key difference between AutoBuild and ExternalProject_add(). With ExternalProject_add() there is a chicken-and-the-egg problem. ExternalProject_add() doesn't download and build the external project until after CMake has finished running and you are building your actual code using Unix Makefiles, Visual Studio, or Xcode. This means the dependency does not exist on disk until CMake has finished running, and, thus, there is no way to use CMake's find_package() routines to find the dependency. You can still make your project link with the dependency, but you have to hardcode paths to tell CMake where it will exist after it is built rather than find it already installed on the system. If you want to only build the dependency if it is not already found on the system, then this means you need to maintain two ways of linking with the dependency in your CMakeLists.txt, using one approach when the dependency is found already installed and using another approach (hardcoded paths with ExternalProject_add()) when it is not found. The hardcoded paths can get a bit complex when working with cross-platform code, and this is precisely what CMake's find_package() is supposed to handle, so it is a bit annoying that it cannot be used in this case.
+
+# HOW IT WORKS: AutoBuild takes a different approach where the goal is for our project's CMakeLists.txt file to always use the same approach to link with a dependency. If the dependency is found on the system, then we go ahead and link with it right away. If it is not found, then rather than scheduling it to be built as part of the build process for our own project, we "pause" our build for a moment to download, build, and install the dependency. Then, once the dependency has been installed, we try again to find it using find_package(), which should always succeed since we just did the install, and continue on building our program.
+
+# LIMITATIONS: Handling dependencies is a hard problem, and this "AutoBuild" strategy is not without its own limitations. For example, a complication arises when using the CMake GUI. When using the CMake GUI, users expect to be able to set the CMAKE_INSTALL_PREFIX interactively after pressing Configure once to bring up all the available options. So, there is a problem if we build and install dependency projects during this first run of CMake Configure -- the user will not yet have had a chance to set CMAKE_INSTALL_PREFIX before the dependency projects are installed, and they may be installed to an undesirable location. AutoBuild addresses this by running a status check at the end of the CMake Configure step. The first time the status check detects that a dependency project should be "auto-built", it prints an informative error message, reminding the user to set CMAKE_INSTALL_PREFIX and then re-run CMake Configure to actually do the download, build, and install steps for each dependency. This seems to be a good match for CMake's GUI mode because it also allows the user to check other related settings (e.g., turning off autobuild for specific projects, forcing autobuild even if the dependency is found on the system, setting the directory to use for downloading projects).
+
+# RUNNING FROM A SCRIPT: When running from the command line or a script, the error-the-first-time-an-autobuild-is-scheduled behavior described above is typically not desired. In this case, users should already be setting CMAKE_INSTALL_PREFIX and any other desired CMake flags on the command line so it is fine to run the autobuilds immediately. To do this, simply run cmake with the following command line argument: -DAUTOBUILD_EXECUTE_NOW=ON
+
+
+# USAGE: WHAT TO ADD TO YOUR CMAKELISTS.TXT FILE TO USE AUTOBUILD:
+
+# Edit 1: Add two calls to your main CMakeLists.txt:
+
+# 1a. Near the top of the file include AutoBuild and call init, like so:
+# include(AutoBuild)
+# AutoBuild_init()
+
+# 1b. At the end of the file call:
+# AutoBuild_check_status()
+
+
+# Edit 2: For each target you wish to link with an external dependency, add a use_package() call right after you
+# define the target with add_library() or add_executable. If the dependency you wish to link with uses
+# modern CMake Config Packages, then the generic AutoBuild_use_package() call is all that is needed.
+# For example, to link my-program with the MinVR library, add the following to the CMakeLists.txt file
+# where you define the my-program target with add_executable:
+
+# add_execuatable(my-program ${SOURCEFILES})
+# AutoBuild_use_package(MinVR . my-program PUBLIC MinVR::MinVR
+# DOWNLOAD_ARGS GIT_REPOSITORY https://github.com/MinVR/MinVR.git GIT_TAG beta
+# )
+
+# Since CMake Config Packages are relatively new and very complex, so not every package provides one
+# (or a correct one). In these cases, the generic AutoBuild_use_package() will not work, and we have
+# to write a version of that is specific to the project we wish to add as a dependency. For example,
+# in order to link with GLFW, which does not provide a ConfigGLFW.cmake file, we must write a
+# GLFW-specific version of AutoBuild_use_package() and then use it like so:
+
+# include(AutoBuildGLFW)
+# AutoBuild_use_package_GLFW(my-program PUBLIC)
+
+# GLFW is one of the first examples in this style, so it is included in the AutoBuild repo. If the
+# repo does not already include an AutoBuild<package-name>.cmake script, then copy an existing
+# example, modify it to work for the package of interest, and once it is working, push it back to
+# the AutoBuild repo so others can benefit as well.
+
+
+
+
+
+
+
+# Usage:
+# AutoBuild_init()
+# Call this one time in your main CMakeLists.txt script somewhere near the beginning of the file.
+macro(AutoBuild_init)
+ message(STATUS "AutoBuild: Initializing.")
+
+ option(AUTOBUILD_DEPENDENCIES "This is a global option that turns on/off the AutoBuild functionality. It is also possible to turn on/off autobuilding for specific packages via variables of the form AUTOBUILD_PACKAGE_<NAME>." ON)
+
+ set(AUTOBUILD_DOWNLOAD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external" CACHE STRING "Location for external project sources downloaded by AutoBuild." )
+endmacro()
+
+
+
+
+
+
+# Usage:
+# AutoBuild_check_status()
+# Call this one time in your main CMakeLists.txt script somewhere near the end of the file.
+macro(AutoBuild_check_status)
+ message(STATUS "AutoBuild: Checking status...")
+
+ # Report status to the user, and if we detected dependencies to autobuild, stop with a
+ # cmake error to give the user a chance to adjust config options, such as the
+ # CMAKE_INSTALL_PREFIX and overriding AUTOBUILD_<PROJNAME> on a case-by-case basis if
+ # needed. Assuming all looks good, we will then download, build, and install each
+ # dependency that we need the next time CMake Configure is run.
+
+ set(PREFIX "AUTOBUILD_PACKAGE_")
+ get_cmake_property(ALLVARS VARIABLES)
+ string(REGEX MATCHALL "(^|;)${PREFIX}[A-Za-z0-9_]*" MATCHED_VARS "${ALLVARS}")
+
+ if (NOT "${MATCHED_VARS}" STREQUAL "")
+ message(STATUS "AutoBuild: Status check for each dependency linked using AutoBuild:")
+
+ set(RERUN_CONFIGURE "FALSE")
+
+ foreach (VARIABLE ${MATCHED_VARS})
+ #message(STATUS "${VARIABLE}=${${VARIABLE}}")
+
+ string(REPLACE ${PREFIX} "" PACKAGE_NAME ${VARIABLE})
+ string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER)
+
+ if ("${${PACKAGE_NAME}_AUTOBUILT}")
+ set(STATUS_STR "Now installed to CMAKE_INSTALL_PREFIX (${CMAKE_INSTALL_PREFIX}).")
+ elseif("${${VARIABLE}}")
+ set(STATUS_STR "Set to auto-build next time you run CMake Configure.")
+ set(RERUN_CONFIGURE "TRUE")
+ else()
+ set(STATUS_STR "Autobuild off (either found on the system or manually turned off).")
+ endif()
+
+ message(STATUS "AutoBuild: Dependency = ${PACKAGE_NAME}; Status = ${STATUS_STR}")
+
+ endforeach()
+
+ # Error out if any packages are set to autobuild but have not yet been built
+ if ("${RERUN_CONFIGURE}")
+
+ # This flag confirms that the user has had a chance to see any new AutoBuild config
+ # options and we can now proceed on the next run of CMake Configure to do the auto
+ # download, build, and install steps.
+ set(AUTOBUILD_EXECUTE_NOW "ON" CACHE BOOL "If on, the AutoBuild download, build, install steps will run the next time CMake Configure is run.")
+ mark_as_advanced(AUTOBUILD_EXECUTE_NOW)
+
+ message(SEND_ERROR "AutoBuild: One or more packages are setup to be downloaded, built, and installed with AutoBuild the next time you run CMake Configure. Check now to make sure that your CMAKE_INSTALL_PREFIX points to the place where you want these dependencies installed. Also, check variables of the form AUTOBUILD_PACKAGE_* to make sure the packages you want to build are ON and the ones you do not are OFF. When all looks good, run Configure again to perform the download, build, and install steps. This message will be shown only once -- the first time your project schedules a dependency to be autobuilt.")
+
+ endif()
+ endif()
+
+ message(STATUS "AutoBuild: Completed status check.")
+endmacro()
+
+
+
+
+
+
+
+# Usage:
+# AutoBuild_use_package(
+# # This 1st argument is required, it is the name of the project/package you wish to use. The project should
+# # provide a <package-name>Config.cmake file for CMake to find.
+# MinVR
+#
+# # The 2nd argument is required and it is the relative path from the root of the external project's source
+# # tree to a CMakeLists.txt file that can be used to build the project.
+# .
+#
+# # The 3rd argument is required. It is the name of the target you wish to link this dependency to.
+# my-program
+#
+# # The 4th argument is required. It impacts how dependencies are propogated through CMake. You can treat
+# # this dependency as an INTERFACE, PUBLIC, or PRIVATE. See the following URL for details:
+# # https://cmake.org/cmake/help/latest/command/target_include_directories.html
+# PUBLIC
+#
+# # The 5th argument is required. It is the name of the imported target(s) provided in the projects CMake
+# # Config Package. By convention, these typically start with the project name and then ::, like a namespace.
+# MinVR::MinVR
+#
+# # The remaining arguments are optional and are used to provide more specific instructions on the find_package,
+# # download, build, and install steps. List additional flags for these steps after the keywords:
+# # FIND_PACKAGE_ARGS, DOWNLOAD_ARGS, and/or BUILD_AND_INSTALL_ARGS. For example:
+#
+# DOWNLOAD_ARGS GIT_REPOSITORY https://github.com/MinVR/MinVR.git GIT_TAG beta
+# )
+#
+macro(AutoBuild_use_package PACKAGE_NAME RELPATH_TO_CMAKELISTS YOUR_TARGET INTERFACE_PUBLIC_OR_PRIVATE IMPORTED_TARGETS)
+
+ set(OPTIONS)
+ set(ONE_VALUE_ARGS)
+ set(MULTI_VALUE_ARGS FIND_PACKAGE_ARGS DOWNLOAD_ARGS BUILD_AND_INSTALL_ARGS)
+ cmake_parse_arguments(EXTRA "${OPTIONS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
+
+ string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER)
+
+ AutoBuild_find_package_config_mode(${PACKAGE_NAME} ${EXTRA_FIND_PACKAGE_ARGS})
+
+ if ("${AUTOBUILD_PACKAGE_${PACKAGE_NAME_UPPER}}")
+ if ("${AUTOBUILD_EXECUTE_NOW}")
+ message(STATUS "AutoBuild: Starting download, build, install sequence for ${PACKAGE_NAME}.")
+
+ AutoBuild_download_project(${PACKAGE_NAME} ${EXTRA_DOWNLOAD_ARGS})
+
+ AutoBuild_build_and_install_project(${PACKAGE_NAME} ${RELPATH_TO_CMAKELISTS} ${EXTRA_BUILD_AND_INSTALL_ARGS})
+
+ AutoBuild_find_built_package_config_mode(${PACKAGE_NAME} CONFIG ${EXTRA_FIND_PACKAGE_ARGS})
+
+ set(${PACKAGE_NAME_UPPER}_AUTOBUILT "TRUE" CACHE BOOL "Confirms that package ${PACKAGE_NAME} was successfully built by the AutoBuild system.")
+ mark_as_advanced(${PACKAGE_NAME}_AUTOBUILT)
+
+ else()
+ message(STATUS "AutoBuild: Scheduled to build ${PACKAGE_NAME} the next time CMake Configure is run.")
+ endif()
+ endif()
+
+
+ # If we've found the package, either directly on the system or after autobuilding, then link with it
+ if ("${${PACKAGE_NAME}_FOUND}" OR "${${PACKAGE_NAME_UPPER}_FOUND}")
+ message(STATUS "Linking target ${YOUR_TARGET} with ${INTERFACE_PUBLIC_OR_PRIVATE} dependency ${PACKAGE_NAME}.")
+
+ target_link_libraries(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} ${IMPORTED_TARGETS})
+
+ target_compile_definitions(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} -DUSE_${PACKAGE_NAME_UPPER})
+ endif()
+
+endmacro()
+
+
+
+
+
+
+
+
+
+
+
+# ------ Implementation Details Below this Line -- External Users Should Not Need To Call Anything Below -------
+
+
+macro(AutoBuild_find_package_config_mode PACKAGE_NAME)
+ # Users can pass in extra arguments to the find_package command if needed.
+ set(EXTRA_MACRO_ARGS ${ARGN})
+
+ string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER)
+
+
+ # Force CMake to find the package again -- need for the case where the package exists on the system
+ # but we want to force building and installing it. after the install, we need to clear these flags
+ # so that find_package will find the newlyl installed version.
+ unset(${PACKAGE_NAME}_DIR CACHE)
+ unset(${PACKAGE_NAME_UPPER}_DIR CACHE)
+ unset(${PACKAGE_NAME}_FOUND CACHE)
+ unset(${PACKAGE_NAME_UPPER}_FOUND CACHE)
+
+ message(STATUS "AutoBuild: Searching for package ${PACKAGE_NAME} using cmake's find_package() config mode...")
+
+ if (NOT AUTOBUILD_DEPENDENCIES)
+
+ message(STATUS "AutoBuild: AUTOBUILD_DEPENDENCIES is OFF, using default CMake find_package() behavior.")
+ find_package(${PACKAGE_NAME} CONFIG ${EXTRA_MACRO_ARGS})
+
+ else()
+
+ # Try first to find the package within the current CMAKE_INSTALL_PREFIX. In the case when multiple
+ # versions of a library are installed on the same system, this makes sure that we will find a version
+ # that was previously built using AutoBuild first.
+ find_package(${PACKAGE_NAME} CONFIG PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH ${EXTRA_MACRO_ARGS})
+
+ # Try again with the normal version of find_package(), which will search a variety of places on
+ # the system, see details here: https://cmake.org/cmake/help/latest/command/find_package.html
+ if (NOT ("${${PACKAGE_NAME}_FOUND}" OR "${${PACKAGE_NAME_UPPER}_FOUND}"))
+ find_package(${PACKAGE_NAME} CONFIG ${EXTRA_MACRO_ARGS})
+ endif()
+
+
+ if ("${${PACKAGE_NAME}_FOUND}" OR "${${PACKAGE_NAME_UPPER}_FOUND}")
+ set(FOUND_AT_DIR "${${PACKAGE_NAME}_DIR}")
+ if ("${FOUND_AT_DIR}" STREQUAL "")
+ set(FOUND_AT_DIR "${${PACKAGE_NAME_UPPER}_DIR}")
+ endif()
+ message(STATUS "AutoBuild: OK - Found ${PACKAGE_NAME} at ${FOUND_AT_DIR}.")
+ # Found the package on the system, so there is no need to autobuild it, but we still add
+ # an option (defaulting to OFF) so that users can "force" building their own version of
+ # the dependency if they wish.
+ option(AUTOBUILD_PACKAGE_${PACKAGE_NAME_UPPER} "If on, the AutoBuild CMake plugin will download, build, and install ${PACKAGE_NAME} to CMAKE_INSTALL_PREFIX the next time that CMake Configure is run." OFF)
+ else()
+ message(STATUS "AutoBuild: Could not find ${PACKAGE_NAME}, setting AUTOBUILD_PACKAGE_${PACKAGE_NAME_UPPER}=ON.")
+ # If the package is still not found, then we will need to autobuild it, add the option with a default of ON
+ option(AUTOBUILD_PACKAGE_${PACKAGE_NAME_UPPER} "If on, the AutoBuild CMake plugin will download, build, and install ${PACKAGE_NAME} to CMAKE_INSTALL_PREFIX the next time that CMake Configure is run." ON)
+ endif()
+
+ endif()
+endmacro()
+
+
+
+macro(AutoBuild_find_built_package_config_mode PACKAGE_NAME)
+ # Users can pass in extra arguments to the find_package command if needed.
+ set(EXTRA_MACRO_ARGS ${ARGN})
+
+ string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER)
+
+ # Force CMake to find the package again -- need for the case where the package exists on the system
+ # but we want to force building and installing it. after the install, we need to clear these flags
+ # so that find_package will find the newlyl installed version.
+ unset(${PACKAGE_NAME}_DIR CACHE)
+ unset(${PACKAGE_NAME_UPPER}_DIR CACHE)
+ unset(${PACKAGE_NAME}_FOUND CACHE)
+ unset(${PACKAGE_NAME_UPPER}_FOUND CACHE)
+
+ message(STATUS "AutoBuild: Searching again (after autobuilding) for package ${PACKAGE_NAME} using config mode...")
+
+ # Try first to find the package within the current CMAKE_INSTALL_PREFIX. In the case when multiple
+ # versions of a library are installed on the same system, this makes sure that we will find a version
+ # that was previously built using AutoBuild first.
+ find_package(${PACKAGE_NAME} PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH ${EXTRA_MACRO_ARGS} QUIET)
+
+ # Try again with the normal version of find_package(), which will search a variety of places on
+ # the system, see details here: https://cmake.org/cmake/help/latest/command/find_package.html
+ if (NOT ("${${PACKAGE_NAME}_FOUND}" OR "${${PACKAGE_NAME_UPPER}_FOUND}"))
+ find_package(${PACKAGE_NAME} ${EXTRA_MACRO_ARGS})
+ endif()
+
+
+ if ("${${PACKAGE_NAME}_FOUND}" OR "${${PACKAGE_NAME_UPPER}_FOUND}")
+ set(FOUND_AT_DIR "${${PACKAGE_NAME}_DIR}")
+ if ("${FOUND_AT_DIR}" STREQUAL "")
+ set(FOUND_AT_DIR "${${PACKAGE_NAME_UPPER}_DIR}")
+ endif()
+ message(STATUS "AutoBuild: OK - Found ${PACKAGE_NAME} at ${FOUND_AT_DIR}.")
+ else()
+ message(FATAL_ERROR "AutoBuild: Just completed a download, build, and install sequence for package ${PACKAGE_NAME}, and it should now be installed at the prefix ${CMAKE_INSTALL_PREFIX}, but cmake is still unable to find it with find_package().")
+ endif()
+endmacro()
+
+
+
+macro(AutoBuild_find_package_module_mode PACKAGE_NAME)
+ # Users can pass in extra arguments to the find_package command if needed.
+ set(EXTRA_MACRO_ARGS ${ARGN})
+
+ string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER)
+
+
+ # Force CMake to find the package again -- need for the case where the package exists on the system
+ # but we want to force building and installing it. after the install, we need to clear these flags
+ # so that find_package will find the newlyl installed version.
+ unset(${PACKAGE_NAME}_DIR CACHE)
+ unset(${PACKAGE_NAME_UPPER}_DIR CACHE)
+ unset(${PACKAGE_NAME}_FOUND CACHE)
+ unset(${PACKAGE_NAME_UPPER}_FOUND CACHE)
+
+ message(STATUS "AutoBuild: Searching for package ${PACKAGE_NAME} using cmake's find_package() module mode...")
+
+ if (NOT AUTOBUILD_DEPENDENCIES)
+
+ message(STATUS "AutoBuild: AUTOBUILD_DEPENDENCIES is OFF, using default CMake find_package() behavior.")
+ find_package(${PACKAGE_NAME} MODULE ${EXTRA_MACRO_ARGS})
+
+ else()
+
+ # AutoBuild allows users to force building a dependency even if it is already found installed on the
+ # system. To make this work, any Find*.cmake scripts that are used with AutoBuild must look first
+ # for the library under ${CMAKE_INSTALL_PREFIX}. This makes it so that preference is given to
+ # libraries just built and installed there with AutoBuild.
+ find_package(${PACKAGE_NAME} MODULE ${EXTRA_MACRO_ARGS})
+
+ if ("${${PACKAGE_NAME}_FOUND}" OR "${${PACKAGE_NAME_UPPER}_FOUND}")
+ set(FOUND_AT_DIR "${${PACKAGE_NAME}_DIR}")
+ if ("${FOUND_AT_DIR}" STREQUAL "")
+ set(FOUND_AT_DIR "${${PACKAGE_NAME_UPPER}_DIR}")
+ endif()
+ message(STATUS "AutoBuild: OK - Found ${PACKAGE_NAME} at ${FOUND_AT_DIR}.")
+ # Found the package on the system, so there is no need to autobuild it, but we still add
+ # an option (defaulting to OFF) so that users can "force" building their own version of
+ # the dependency if they wish.
+ option(AUTOBUILD_PACKAGE_${PACKAGE_NAME_UPPER} "If on, the AutoBuild CMake plugin will download, build, and install ${PACKAGE_NAME} to CMAKE_INSTALL_PREFIX the next time that CMake Configure is run." OFF)
+ else()
+ message(STATUS "AutoBuild: Could not find ${PACKAGE_NAME}, setting AUTOBUILD_PACKAGE_${PACKAGE_NAME_UPPER}=ON.")
+ # If the package is still not found, then we will need to autobuild it, add the option with a default of ON
+ option(AUTOBUILD_PACKAGE_${PACKAGE_NAME_UPPER} "If on, the AutoBuild CMake plugin will download, build, and install ${PACKAGE_NAME} to CMAKE_INSTALL_PREFIX the next time that CMake Configure is run." ON)
+ endif()
+
+ endif()
+endmacro()
+
+
+
+macro(AutoBuild_find_built_package_module_mode PACKAGE_NAME)
+ # Users can pass in extra arguments to the find_package command if needed.
+ set(EXTRA_MACRO_ARGS ${ARGN})
+
+ string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER)
+
+ # Force CMake to find the package again -- need for the case where the package exists on the system
+ # but we want to force building and installing it. after the install, we need to clear these flags
+ # so that find_package will find the newlyl installed version.
+ unset(${PACKAGE_NAME}_DIR CACHE)
+ unset(${PACKAGE_NAME_UPPER}_DIR CACHE)
+ unset(${PACKAGE_NAME}_FOUND CACHE)
+ unset(${PACKAGE_NAME_UPPER}_FOUND CACHE)
+
+ message(STATUS "AutoBuild: Searching again (after autobuilding) for package ${PACKAGE_NAME} using module mode...")
+
+ # AutoBuild allows users to force building a dependency even if it is already found installed on the
+ # system. To make this work, any Find*.cmake scripts that are used with AutoBuild must look first
+ # for the library under ${CMAKE_INSTALL_PREFIX}. This makes it so that preference is given to
+ # libraries just built and installed there with AutoBuild.
+ find_package(${PACKAGE_NAME} MODULE ${EXTRA_MACRO_ARGS})
+
+ if ("${${PACKAGE_NAME}_FOUND}" OR "${${PACKAGE_NAME_UPPER}_FOUND}")
+ set(FOUND_AT_DIR "${${PACKAGE_NAME}_DIR}")
+ if ("${FOUND_AT_DIR}" STREQUAL "")
+ set(FOUND_AT_DIR "${${PACKAGE_NAME_UPPER}_DIR}")
+ endif()
+ message(STATUS "AutoBuild: OK - Found ${PACKAGE_NAME} at ${FOUND_AT_DIR}.")
+ else()
+ message(FATAL_ERROR "AutoBuild: Just completed a download, build, and install sequence for package ${PACKAGE_NAME}, and it should now be installed at the prefix ${CMAKE_INSTALL_PREFIX}, but cmake is still unable to find it with find_package().")
+ endif()
+endmacro()
+
+
+
+# Usage:
+# AutoBuild_download_project(
+# # This first argument is the name of the project to download. It is required:
+# glm
+#
+# # Additional arguments specify how to download the project using GIT, SVN, CVS, or URL.
+# # These can be any of the arguments used for the downloading step of the cmake builtin
+# # ExternalProject_Add command.
+# GIT_REPOSITORY "https://github.com/g-truc/glm.git"
+# GIT_TAG master
+# etc..
+# )
+function(AutoBuild_download_project EXT_PROJECT_NAME)
+
+ big_message("AUTOBUILD: BEGIN EXTERNAL PROJECT DOWNLOAD (${EXT_PROJECT_NAME}).")
+
+ message(STATUS "AutoBuild: Creating a download helper project for ${EXT_PROJECT_NAME}.")
+
+ set(DOWNLOAD_OPTIONS ${ARGN})
+ string (REGEX REPLACE "(^|[^\\\\]);" "\\1 " DOWNLOAD_OPTIONS "${DOWNLOAD_OPTIONS}")
+
+ file(MAKE_DIRECTORY ${AUTOBUILD_DOWNLOAD_DIR}/${EXT_PROJECT_NAME})
+
+ # Write the CMakeLists.txt.in file to disk
+ set(DLHELPER_FILE_TEXT "\n \
+ # This is a helper cmake project -- the only thing this project does is download \n \
+ # the external project. So, the configure, build, install, and test commands for \n \
+ # ExternalProject_Add() are intentionally set as NOPs. \n \
+ \n \
+ cmake_minimum_required (VERSION 3.9) \n \
+ \n \
+ project(@EXT_PROJECT_NAME@-download) \n \
+ \n \
+ include(ExternalProject) \n \
+ ExternalProject_Add( \n \
+ @EXT_PROJECT_NAME@ \n \
+ SOURCE_DIR \"@AUTOBUILD_DOWNLOAD_DIR@/@EXT_PROJECT_NAME@/src\" \n \
+ BINARY_DIR \"@AUTOBUILD_DOWNLOAD_DIR@/@EXT_PROJECT_NAME@/download-helper\" \n \
+ @DOWNLOAD_OPTIONS@ \n \
+ CONFIGURE_COMMAND \"\" \n \
+ BUILD_COMMAND \"\" \n \
+ INSTALL_COMMAND \"\" \n \
+ TEST_COMMAND \"\" \n \
+ LOG_DOWNLOAD ON \n \
+ GIT_PROGRESS 1 \n \
+ ) \n \
+ ")
+
+ file(WRITE ${AUTOBUILD_DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper/CMakeLists.txt.in ${DLHELPER_FILE_TEXT})
+
+ configure_file(
+ ${AUTOBUILD_DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper/CMakeLists.txt.in
+ ${AUTOBUILD_DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper/CMakeLists.txt
+ )
+
+ message(STATUS "AutoBuild: Generating build files for the ${EXT_PROJECT_NAME} download helper project.")
+ message(STATUS " Using working dir: ${AUTOBUILD_DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper")
+
+ execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY "${AUTOBUILD_DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper" OUTPUT_VARIABLE stdout ERROR_VARIABLE stderr RESULT_VARIABLE exitcode)
+ if(NOT "${exitcode}" STREQUAL "0")
+ message(FATAL_ERROR "AutoBuild: Error while creating download helper project: ${stdout} ${stderr}")
+ endif()
+
+ message(STATUS "AutoBuild: Building the ${EXT_PROJECT_NAME} download helper project. (This actually performs the download and may take some time...)")
+ execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${AUTOBUILD_DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper" OUTPUT_VARIABLE stdout ERROR_VARIABLE stderr RESULT_VARIABLE exitcode)
+ if(NOT "${exitcode}" STREQUAL "0")
+ message(FATAL_ERROR "AutoBuild: Error running download helper project: ${stdout} ${stderr}")
+ endif()
+
+ message(STATUS "AutoBuild: Completed download of external project ${EXT_PROJECT_NAME}.")
+
+endfunction()
+
+
+# Usage:
+# AutoBuild_build_and_install_project(
+# # This first argument is the name of the external project to download. It is required:
+# VRPN
+# # This second argument is the relative path from ${EXTERNAL_DIR_NAME}/projectname/ to the project's
+# # main CMakeLists.txt file:
+# src
+#
+# # Additional arguments are passed on as options to the cmake build file generator
+# -DVRPN_BUILD_DIRECTSHOW_VIDEO_SERVER=OFF
+# -DVRPN_BUILD_HID_GUI=OFF
+# etc..
+# )
+function(AutoBuild_build_and_install_project EXT_PROJECT_NAME RELPATH_TO_CMAKELISTS)
+
+ big_message("AUTOBUILD: BEGIN EXTERNAL PROJECT BUILD AND INSTALL (${EXT_PROJECT_NAME}).")
+
+ # any extra args to the function are interpreted as arguments for the cmake config process
+ set(CMAKE_CONFIG_OPTIONS ${ARGN})
+
+ # always set the install prefix to be the same as for the main project
+ list(APPEND CMAKE_CONFIG_OPTIONS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX})
+
+ set(SRC_DIR "${AUTOBUILD_DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/src/${RELPATH_TO_CMAKELISTS}")
+ set(BUILD_DIR "${CMAKE_BINARY_DIR}/external/${EXT_PROJECT_NAME}")
+
+ file(MAKE_DIRECTORY ${BUILD_DIR})
+
+ message(STATUS "AutoBuild: Generating build files for external project ${EXT_PROJECT_NAME}.")
+ message(STATUS " Using source dir: ${SRC_DIR}")
+ message(STATUS " Using build dir: ${BUILD_DIR}")
+ message(STATUS " Config options: ${CMAKE_CONFIG_OPTIONS}")
+
+ execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" ${SRC_DIR} ${CMAKE_CONFIG_OPTIONS} WORKING_DIRECTORY ${BUILD_DIR} OUTPUT_VARIABLE stdout ERROR_VARIABLE stderr RESULT_VARIABLE exitcode)
+ if(NOT "${exitcode}" STREQUAL "0")
+ message(FATAL_ERROR "AutoBuild: Error generating build files for external project: ${stdout} ${stderr}")
+ endif()
+
+ message(STATUS "AutoBuild: Building external project ${EXT_PROJECT_NAME} (Configuration = Debug). (This may take some time...)")
+ execute_process(COMMAND "${CMAKE_COMMAND}" --build ${BUILD_DIR} --config Debug --target install OUTPUT_VARIABLE stdout ERROR_VARIABLE stderr RESULT_VARIABLE exitcode)
+ if(NOT "${exitcode}" STREQUAL "0")
+ message(FATAL_ERROR "AutoBuild: Error building Debug configuration for external project: ${stdout} ${stderr}")
+ endif()
+
+ message(STATUS "AutoBuild: Building external project ${EXT_PROJECT_NAME} (Configuration = Release). (This may take some time...)")
+ execute_process(COMMAND "${CMAKE_COMMAND}" --build ${BUILD_DIR} --config Release --target install OUTPUT_VARIABLE stdout ERROR_VARIABLE stderr RESULT_VARIABLE exitcode)
+ if(NOT "${exitcode}" STREQUAL "0")
+ message(FATAL_ERROR "AutoBuild: Error building Release configuration for external project: ${stdout} ${stderr}")
+ endif()
+
+ message(STATUS "AutoBuild: Completed external build of ${EXT_PROJECT_NAME}.\n\n")
+
+endfunction()
+
+
+macro(big_message TITLE)
+ string(TOUPPER ${TITLE} TITLE)
+ message(STATUS "\n\n==== ${TITLE} ====")
+endmacro()
+
+
+
diff --git a/dev/MinGfx/example/cmake/AutoBuildOpenGL.cmake b/dev/MinGfx/example/cmake/AutoBuildOpenGL.cmake
new file mode 100644
index 0000000..c74b2b8
--- /dev/null
+++ b/dev/MinGfx/example/cmake/AutoBuildOpenGL.cmake
@@ -0,0 +1,47 @@
+# Author: Daniel F. Keefe
+# Copyright 2017,2018, Daniel F. Keefe and Regents of the University of Minnesota
+# All Rights Reserved.
+
+
+# Usage:
+# AutoBuild_use_package_OpenGL(
+# # The 1st argument is required. It is the name of the target you wish to link this dependency to.
+# my-program
+#
+# # The 2nd argument is required. It impacts how dependencies are propogated through CMake. You can treat
+# # this dependency as an INTERFACE, PUBLIC, or PRIVATE. See the following URL for details:
+# # https://cmake.org/cmake/help/latest/command/target_include_directories.html
+# PUBLIC
+# )
+#
+macro(AutoBuild_use_package_OpenGL YOUR_TARGET INTERFACE_PUBLIC_OR_PRIVATE)
+
+ message(STATUS "AutoBuild: Searching for package OpenGL...")
+
+ # Check to see if the library is already installed on the system
+ # CMake ships with FindOpenGL.cmake and in CMake 3.9+ it defines
+ # the imported targets OpenGL::GL and OpenGL::GLU. Using these is
+ # now the preferred way to link with OpenGL and all of its dependencies.
+ # See https://cmake.org/cmake/help/v3.9/module/FindOpenGL.html
+ find_package(OpenGL)
+
+ if (NOT ${OPENGL_FOUND})
+ message(FATAL_ERROR "AutoBuild: OpenGL was not found on the system. AutoBuild can auto-download
+ and build many dependencies for you, but not OpenGL. It should come pre-installed on your system.")
+ endif()
+
+ message(STATUS "AutoBuild: Ok. Found OpenGL.")
+ message(STATUS " OpenGL headers: ${OPENGL_INCLUDE_DIR}")
+ message(STATUS " OpenGL libs: ${OPENGL_LIBRARIES}")
+
+ message(STATUS "Linking target ${YOUR_TARGET} with ${INTERFACE_PUBLIC_OR_PRIVATE} dependency OpenGL::GL.")
+ target_link_libraries(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} OpenGL::GL)
+
+ if (${OPENGL_GLU_FOUND})
+ message(STATUS "Linking target ${YOUR_TARGET} with ${INTERFACE_PUBLIC_OR_PRIVATE} dependency OpenGL::GLU.")
+ target_link_libraries(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} OpenGL::GLU)
+ endif()
+
+ target_compile_definitions(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} -DUSE_OPENGL)
+
+endmacro()
diff --git a/dev/MinGfx/example/cmake/MessageMacros.cmake b/dev/MinGfx/example/cmake/MessageMacros.cmake
new file mode 100644
index 0000000..4628e5c
--- /dev/null
+++ b/dev/MinGfx/example/cmake/MessageMacros.cmake
@@ -0,0 +1,17 @@
+# This file is part of the MinVR cmake build system.
+# See the main MinVR/CMakeLists.txt file for authors, copyright, and license info.
+
+
+macro(h1 TITLE)
+ string(TOUPPER ${TITLE} TITLE)
+ message(STATUS "\n\n==== ${TITLE} ====")
+endmacro()
+
+macro(h2 TITLE)
+ message(STATUS "\n* ${TITLE}")
+endmacro()
+
+macro(h3 TITLE)
+ message(STATUS "- ${TITLE}")
+endmacro()
+
diff --git a/dev/MinGfx/example/main-circleviewer.cpp b/dev/MinGfx/example/main-circleviewer.cpp
new file mode 100644
index 0000000..50e0d33
--- /dev/null
+++ b/dev/MinGfx/example/main-circleviewer.cpp
@@ -0,0 +1,12 @@
+
+#include "CircleViewer.h"
+
+
+int main(int argc, char **argv) {
+
+ CircleViewer app;
+ app.Run();
+
+ return 0;
+}
+