commit df452860b162eb42f575fffeec0dfb15889225b1 Author: PlexSheep Date: Thu Oct 12 21:24:34 2023 +0200 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac8daea --- /dev/null +++ b/.gitignore @@ -0,0 +1,177 @@ +# The scikit-build build directory +_skbuild + +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ +CMakeFiles +CMakeCache.txt +DartConfiguration.tcl diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c7244e4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,81 @@ +cmake_minimum_required(VERSION 3.9) + +# Set a name and a version number for your project: +project(glsl-basic VERSION 0.0.1 LANGUAGES CXX) + +# Set CMake policies for this project + +# We allow _ROOT (env) variables for locating dependencies +cmake_policy(SET CMP0074 NEW) + +# Initialize some default paths +include(GNUInstallDirs) + +# Define the minimum C++ standard that is required +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + + + +# Compilation options + +# Find external dependencies +find_package(GLFW) + +# compile the library +add_subdirectory(src) + + +# compile the application +add_subdirectory(app) + +# compile the tests +include(CTest) +if(BUILD_TESTING) + find_package(Catch2 REQUIRED) + include(Catch) + add_subdirectory(tests) +endif() + + + +# Add an alias target for use if this project is included as a subproject in another project +add_library(glsl-basic::glsl-basic ALIAS glsl-basic) + +# Install targets and configuration +install( + TARGETS glsl-basic + EXPORT glsl-basic-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + EXPORT glsl-basic-targets + FILE glsl-basicTargets.cmake + NAMESPACE glsl-basic:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glsl-basic) + +include(CMakePackageConfigHelpers) +configure_package_config_file( + ${CMAKE_CURRENT_LIST_DIR}/glsl-basicConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/glsl-basicConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glsl-basic) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/glsl-basicConfig.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glsl-basic) + +export( + EXPORT glsl-basic-targets + FILE ${CMAKE_CURRENT_BINARY_DIR}/glsl-basicTargets.cmake + NAMESPACE glsl-basic::) + +install( + DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +# This prints a summary of found dependencies +include(FeatureSummary) +feature_summary(WHAT ALL) diff --git a/COPYING.md b/COPYING.md new file mode 100644 index 0000000..52c94fe --- /dev/null +++ b/COPYING.md @@ -0,0 +1,4 @@ +This is the list of copyright holders of glsl-basic. +For information on the license, see LICENSE.md. + +* Christoph J. Scherr, 2023 diff --git a/FILESTRUCTURE.md b/FILESTRUCTURE.md new file mode 100644 index 0000000..68628f1 --- /dev/null +++ b/FILESTRUCTURE.md @@ -0,0 +1,42 @@ +This is an explanation of the file structure that the cookiecutter +generated for you: + +* C++ source files: + * `include/glsl-basic/glsl-basic.hpp` is the main + C++ header that declares the interface of your library. + * `src/glsl-basic.cpp` is the main file that implements this library. + * `app/glsl-basic_app.cpp` is an executable that uses the library. + This can e.g. be used to provide a command line interface for your project. + * `tests/glsl-basic_t.cpp` contains the unit tests for the library. + The unit tests are written using Catch2. For further reading on what can be achieved + with Catch2, we recommend [their tutorial](https://github.com/catchorg/Catch2/blob/devel/docs/tutorial.md). + * `tests/tests.cpp` is the Catch2 testing driver. You do not need to change + this. Placing this in a separate compilation unit than the unit test + implementation decreases the compilation time of the test suite. +* CMake build system files + * `CMakeLists.txt` describes the CMake configuration script. You can find such files + in many directories. When CMake runs, the `CMakeLists.txt` from the top-level directory + executes top to bottom. Whenever a command `add_subdirectory()` is executed, + the `CMakeLists.txt` file from the directory `` is immediately executed. A comprehensive + reference of CMake's capabilities can be found in the [official CMake docs](https://cmake.org/documentation/). + A well-written, opinionated book for beginners and experts is [Modern CMake](https://cliutils.gitlab.io/modern-cmake/). + * `glsl-basicConfig.cmake.in` provides a template for the configuration + installed alongside your project. This is required to implement the transitivity of your dependency + on `GLFW`: If downstream projects use your library, they should + automatically search for `GLFW`. The config file template implements + exactly this logic. +* Documentation configuration files +* Configuration for CI/Code analysis/Documentation services +* Markdown files with meta information on the project. [Markdown](https://www.markdownguide.org/basic-syntax/) is + a good language for these files, as it is easy to write and rendered into something beautiful by your git repository + hosting provider. + * `README.md` is the file that users will typically see first when discovering your project. + * `COPYING.md` provides a list of copyright holders. + * `LICENSE.md` contains the license you selected. + * `TODO.md` contains a list of TODOs after running the cookiecutter. Following the + instructions in that file will give you a fully functional repository with a lot + of integration into useful web services activated and running. + * `FILESTRUCTURE.md` describes the generated files. Feel free to remove this from the + repository if you do not need it. +* Other files + * `.gitignore` contains a default selection of files to omit from version control. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9eb8898 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2023, The copyright holders according to COPYING.md + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ea739e4 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Welcome to glsl-basic + +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) + + + +# Prerequisites + +Building glsl-basic requires the following software installed: + +* A C++11-compliant compiler +* CMake `>= 3.9` +* GLFW +* The testing framework [Catch2](https://github.com/catchorg/Catch2) for building the test suite + +# Building glsl-basic + +The following sequence of commands builds glsl-basic. +It assumes that your current working directory is the top-level directory +of the freshly cloned repository: + +``` +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +cmake --build . +``` + +The build process can be customized with the following CMake variables, +which can be set by adding `-D={ON, OFF}` to the `cmake` call: + +* `BUILD_TESTING`: Enable building of the test suite (default: `ON`) + + + +# Testing glsl-basic + +When built according to the above explanation (with `-DBUILD_TESTING=ON`), +the C++ test suite of `glsl-basic` can be run using +`ctest` from the build directory: + +``` +cd build +ctest +``` + + +# Documentation + +glsl-basic *should* provide a documentation. diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..605dd8a --- /dev/null +++ b/TODO.md @@ -0,0 +1,18 @@ +This TODO list is automatically generated from the cookiecutter-cpp-project template. +The following tasks need to be done to get a fully working project: + + +* Push to your remote repository for the first time by doing `git push origin main`. +* Make sure that the following software is installed on your computer: + * A C++-11-compliant C++ compiler + * CMake `>= 3.9` + * The testing framework [Catch2](https://github.com/catchorg/Catch2) + * Adapt your list of external dependencies in `CMakeLists.txt` and `glsl-basicConfig.cmake.in`. + You can e.g. + * Link your library or applications to your dependency. For this to work, you need + to see if your dependency exports targets and what their name is. As this is highly + individual, this cookiecutter could not do this for you. + * Add more dependencies in analogy to `GLFW` + * Make dependencies requirements by adding `REQUIRED` to `find_package()` + * Add version constraints to dependencies by adding `VERSION` to `find_package()` + * Make a dependency a pure build time dependency by removing it from `glsl-basicConfig.cmake.in` \ No newline at end of file diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt new file mode 100644 index 0000000..5299e0b --- /dev/null +++ b/app/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(glsl-basic_app glsl-basic_app.cpp) +target_link_libraries(glsl-basic_app PRIVATE glsl-basic) diff --git a/app/glsl-basic_app.cpp b/app/glsl-basic_app.cpp new file mode 100644 index 0000000..5389942 --- /dev/null +++ b/app/glsl-basic_app.cpp @@ -0,0 +1,7 @@ +#include "glsl-basic/glsl-basic.hpp" +#include + +int main(){ + int result = glslbasic::add_one(1); + std::cout << "1 + 1 = " << result << std::endl; +} \ No newline at end of file diff --git a/glsl-basicConfig.cmake.in b/glsl-basicConfig.cmake.in new file mode 100644 index 0000000..46fb3c6 --- /dev/null +++ b/glsl-basicConfig.cmake.in @@ -0,0 +1,15 @@ +get_filename_component( + GLSL-BASIC_CMAKE_DIR + ${CMAKE_CURRENT_LIST_FILE} + PATH +) +set(CMAKE_MODULE_PATH ${GLSL-BASIC_CMAKE_DIR} ${CMAKE_MODULE_PATH}) + +include(CMakeFindDependencyMacro) +if(@GLFW_FOUND@) +find_dependency(GLFW) +endif() + +if(NOT TARGET glsl-basic::glsl-basic) + include("${GLSL-BASIC_CMAKE_DIR}/glsl-basicTargets.cmake") +endif() diff --git a/include/glsl-basic/glsl-basic.hpp b/include/glsl-basic/glsl-basic.hpp new file mode 100644 index 0000000..cc21413 --- /dev/null +++ b/include/glsl-basic/glsl-basic.hpp @@ -0,0 +1,8 @@ +#pragma once + +namespace glslbasic { + + +int add_one(int x); + +} // namespace glslbasic diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..fbecb2f --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(glsl-basic glsl-basic.cpp) +target_include_directories(glsl-basic PUBLIC + $ + $ +) diff --git a/src/glsl-basic.cpp b/src/glsl-basic.cpp new file mode 100644 index 0000000..ace3b2f --- /dev/null +++ b/src/glsl-basic.cpp @@ -0,0 +1,9 @@ +#include "glsl-basic/glsl-basic.hpp" + +namespace glslbasic { + +int add_one(int x){ + return x + 1; +} + +} // namespace glslbasic \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..7e94a84 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(tests tests.cpp glsl-basic_t.cpp) +target_link_libraries(tests PUBLIC glsl-basic Catch2::Catch2) + +# allow user to run tests with `make test` or `ctest` +catch_discover_tests(tests) diff --git a/tests/glsl-basic_t.cpp b/tests/glsl-basic_t.cpp new file mode 100644 index 0000000..f09dc97 --- /dev/null +++ b/tests/glsl-basic_t.cpp @@ -0,0 +1,10 @@ +#include "glsl-basic/glsl-basic.hpp" +#include "catch2/catch.hpp" + +using namespace glslbasic; + +TEST_CASE( "add_one", "[adder]" ){ + REQUIRE(add_one(0) == 1); + REQUIRE(add_one(123) == 124); + REQUIRE(add_one(-1) == 0); +} \ No newline at end of file diff --git a/tests/tests.cpp b/tests/tests.cpp new file mode 100644 index 0000000..62bf747 --- /dev/null +++ b/tests/tests.cpp @@ -0,0 +1,2 @@ +#define CATCH_CONFIG_MAIN +#include "catch2/catch.hpp"