Initial Commit
This commit is contained in:
commit
df452860b1
16 changed files with 442 additions and 0 deletions
177
.gitignore
vendored
Normal file
177
.gitignore
vendored
Normal file
|
@ -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
|
81
CMakeLists.txt
Normal file
81
CMakeLists.txt
Normal file
|
@ -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 <Package>_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)
|
4
COPYING.md
Normal file
4
COPYING.md
Normal file
|
@ -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
|
42
FILESTRUCTURE.md
Normal file
42
FILESTRUCTURE.md
Normal file
|
@ -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(<dir>)` is executed,
|
||||
the `CMakeLists.txt` file from the directory `<dir>` 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.
|
7
LICENSE.md
Normal file
7
LICENSE.md
Normal file
|
@ -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.
|
50
README.md
Normal file
50
README.md
Normal file
|
@ -0,0 +1,50 @@
|
|||
# Welcome to glsl-basic
|
||||
|
||||
[](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<var>={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.
|
18
TODO.md
Normal file
18
TODO.md
Normal file
|
@ -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`
|
2
app/CMakeLists.txt
Normal file
2
app/CMakeLists.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
add_executable(glsl-basic_app glsl-basic_app.cpp)
|
||||
target_link_libraries(glsl-basic_app PRIVATE glsl-basic)
|
7
app/glsl-basic_app.cpp
Normal file
7
app/glsl-basic_app.cpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "glsl-basic/glsl-basic.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main(){
|
||||
int result = glslbasic::add_one(1);
|
||||
std::cout << "1 + 1 = " << result << std::endl;
|
||||
}
|
15
glsl-basicConfig.cmake.in
Normal file
15
glsl-basicConfig.cmake.in
Normal file
|
@ -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()
|
8
include/glsl-basic/glsl-basic.hpp
Normal file
8
include/glsl-basic/glsl-basic.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
namespace glslbasic {
|
||||
|
||||
|
||||
int add_one(int x);
|
||||
|
||||
} // namespace glslbasic
|
5
src/CMakeLists.txt
Normal file
5
src/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
add_library(glsl-basic glsl-basic.cpp)
|
||||
target_include_directories(glsl-basic PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
9
src/glsl-basic.cpp
Normal file
9
src/glsl-basic.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "glsl-basic/glsl-basic.hpp"
|
||||
|
||||
namespace glslbasic {
|
||||
|
||||
int add_one(int x){
|
||||
return x + 1;
|
||||
}
|
||||
|
||||
} // namespace glslbasic
|
5
tests/CMakeLists.txt
Normal file
5
tests/CMakeLists.txt
Normal file
|
@ -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)
|
10
tests/glsl-basic_t.cpp
Normal file
10
tests/glsl-basic_t.cpp
Normal file
|
@ -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);
|
||||
}
|
2
tests/tests.cpp
Normal file
2
tests/tests.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch2/catch.hpp"
|
Loading…
Add table
Reference in a new issue