| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 1 |
+--- |
|
| 2 |
+Checks: > |
|
| 3 |
+ *, |
|
| 4 |
+ -fuchsia-*, |
|
| 5 |
+ # Reduced verbosity, |
|
| 6 |
+ -*-braces-around-statements, |
|
| 7 |
+ -*-implicit-bool-conversion, |
|
| 8 |
+ -*-static-accessed-through-instance, |
|
| 9 |
+ # Interaction with C, |
|
| 10 |
+ -*-cast*, |
|
| 11 |
+ -*-vararg, |
|
| 12 |
+ # Static storage duration throwing constructors, |
|
| 13 |
+ -cert-err58-cpp, |
|
| 14 |
+ # Style, |
|
| 15 |
+ -*-use-trailing-return-type, |
|
| 16 |
+ # Backwards compatibility, |
|
| 17 |
+ -*-union-access, |
|
| 18 |
+ # -Weffc++, |
|
| 19 |
+ -*-redundant-member-init, |
|
| 20 |
+WarningsAsErrors: > |
|
| 21 |
+ *, |
| 0 | 2 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,176 @@ |
| 1 |
+## CMake |
|
| 2 |
+cmake_minimum_required(VERSION 3.14) |
|
| 3 |
+ |
|
| 4 |
+ |
|
| 5 |
+## Project |
|
| 6 |
+set(PROJECT_NAME glfbo3d) |
|
| 7 |
+if ("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
|
|
| 8 |
+ return() |
|
| 9 |
+endif() |
|
| 10 |
+project(${PROJECT_NAME}
|
|
| 11 |
+ VERSION 1.0.0 |
|
| 12 |
+ LANGUAGES CXX |
|
| 13 |
+) |
|
| 14 |
+set(CXX_STANDARD 11) |
|
| 15 |
+set(CXX_STANDARD_REQUIRED ON) |
|
| 16 |
+set(CXX_EXTENSIONS OFF) |
|
| 17 |
+ |
|
| 18 |
+ |
|
| 19 |
+## Packages |
|
| 20 |
+find_package(OpenGL REQUIRED) |
|
| 21 |
+find_package(GLEW REQUIRED) |
|
| 22 |
+find_package(glm REQUIRED) |
|
| 23 |
+ |
|
| 24 |
+ |
|
| 25 |
+## External projects |
|
| 26 |
+include(FetchContent) |
|
| 27 |
+FetchContent_Declare(glshader |
|
| 28 |
+ GIT_REPOSITORY https://git.rcrnstn.net/rcrnstn/glshader |
|
| 29 |
+) |
|
| 30 |
+FetchContent_Declare(gltest |
|
| 31 |
+ GIT_REPOSITORY https://git.rcrnstn.net/rcrnstn/gltest |
|
| 32 |
+) |
|
| 33 |
+FetchContent_MakeAvailable( |
|
| 34 |
+ glshader |
|
| 35 |
+ gltest |
|
| 36 |
+) |
|
| 37 |
+ |
|
| 38 |
+ |
|
| 39 |
+## Main target |
|
| 40 |
+add_library(${PROJECT_NAME}
|
|
| 41 |
+ src/${PROJECT_NAME}.cpp
|
|
| 42 |
+ include/${PROJECT_NAME}.hpp
|
|
| 43 |
+) |
|
| 44 |
+set_property(TARGET ${PROJECT_NAME} PROPERTY PUBLIC_HEADER
|
|
| 45 |
+ include/${PROJECT_NAME}.hpp
|
|
| 46 |
+) |
|
| 47 |
+target_include_directories(${PROJECT_NAME}
|
|
| 48 |
+ PUBLIC |
|
| 49 |
+ $<INSTALL_INTERFACE:include> |
|
| 50 |
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
| 51 |
+ PRIVATE |
|
| 52 |
+ src |
|
| 53 |
+) |
|
| 54 |
+target_link_libraries(${PROJECT_NAME}
|
|
| 55 |
+ PUBLIC |
|
| 56 |
+ OpenGL::GL |
|
| 57 |
+ GLEW::GLEW |
|
| 58 |
+) |
|
| 59 |
+ |
|
| 60 |
+ |
|
| 61 |
+if ("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
|
|
| 62 |
+ |
|
| 63 |
+ |
|
| 64 |
+ ## Test target |
|
| 65 |
+ add_executable(${PROJECT_NAME}-test
|
|
| 66 |
+ tests/${PROJECT_NAME}.cpp
|
|
| 67 |
+ ) |
|
| 68 |
+ target_include_directories(${PROJECT_NAME}-test
|
|
| 69 |
+ PRIVATE |
|
| 70 |
+ tests |
|
| 71 |
+ ) |
|
| 72 |
+ target_link_libraries(${PROJECT_NAME}-test
|
|
| 73 |
+ PRIVATE |
|
| 74 |
+ ${PROJECT_NAME}
|
|
| 75 |
+ OpenGL::GL |
|
| 76 |
+ GLEW::GLEW |
|
| 77 |
+ glm |
|
| 78 |
+ glshader |
|
| 79 |
+ gltest |
|
| 80 |
+ ) |
|
| 81 |
+ add_test( |
|
| 82 |
+ NAME ${PROJECT_NAME}-test
|
|
| 83 |
+ COMMAND ${PROJECT_NAME}-test
|
|
| 84 |
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
| 85 |
+ ) |
|
| 86 |
+ |
|
| 87 |
+ |
|
| 88 |
+ ## Default build type for single-configuration generators |
|
| 89 |
+ if (NOT CMAKE_BUILD_TYPE) |
|
| 90 |
+ set(CMAKE_BUILD_TYPE Debug) |
|
| 91 |
+ endif() |
|
| 92 |
+ |
|
| 93 |
+ |
|
| 94 |
+ ## Language tools and options |
|
| 95 |
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
|
| 96 |
+ find_program(CPPCHECK cppcheck) |
|
| 97 |
+ find_program(CLANG_TIDY clang-tidy) |
|
| 98 |
+ find_program(INCLUDE_WHAT_YOU_USE include-what-you-use) |
|
| 99 |
+ if(CPPCHECK) |
|
| 100 |
+ set(CXX_CPPCHECK ${CPPCHECK} --enable=warning,style --error-exitcode=1)
|
|
| 101 |
+ endif() |
|
| 102 |
+ if(CLANG_TIDY) |
|
| 103 |
+ set(CXX_CLANG_TIDY ${CLANG_TIDY})
|
|
| 104 |
+ endif() |
|
| 105 |
+ if(INCLUDE_WHAT_YOU_USE) |
|
| 106 |
+ set(CXX_INCLUDE_WHAT_YOU_USE ${INCLUDE_WHAT_YOU_USE})
|
|
| 107 |
+ endif() |
|
| 108 |
+ if (MSVC) |
|
| 109 |
+ set(COMPILE_OPTIONS |
|
| 110 |
+ /permissive- |
|
| 111 |
+ /WX |
|
| 112 |
+ /W4 |
|
| 113 |
+ ) |
|
| 114 |
+ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|.*Clang")
|
|
| 115 |
+ set(COMPILE_OPTIONS |
|
| 116 |
+ -pedantic |
|
| 117 |
+ -Werror -Wfatal-errors |
|
| 118 |
+ -Wall -Wextra |
|
| 119 |
+ -Wconversion -Wsign-conversion |
|
| 120 |
+ -Wdouble-promotion |
|
| 121 |
+ -Wimplicit-fallthrough |
|
| 122 |
+ -Wvla |
|
| 123 |
+ -Wzero-as-null-pointer-constant |
|
| 124 |
+ -Weffc++ |
|
| 125 |
+ ) |
|
| 126 |
+ set(SANITIZE_OPTIONS |
|
| 127 |
+ $<$<CONFIG:Debug>:-fsanitize=address,leak,undefined> |
|
| 128 |
+ ) |
|
| 129 |
+ list(APPEND COMPILE_OPTIONS ${SANITIZE_OPTIONS})
|
|
| 130 |
+ list(APPEND LINK_OPTIONS ${SANITIZE_OPTIONS})
|
|
| 131 |
+ endif() |
|
| 132 |
+ include(CheckIPOSupported) |
|
| 133 |
+ check_ipo_supported(RESULT INTERPROCEDURAL_OPTIMIZATION) |
|
| 134 |
+ get_directory_property(BUILDSYSTEM_TARGETS BUILDSYSTEM_TARGETS) |
|
| 135 |
+ set_target_properties( |
|
| 136 |
+ ${BUILDSYSTEM_TARGETS}
|
|
| 137 |
+ PROPERTIES |
|
| 138 |
+ CXX_STANDARD "${CXX_STANDARD}"
|
|
| 139 |
+ CXX_STANDARD_REQUIRED "${CXX_STANDARD_REQUIRED}"
|
|
| 140 |
+ CXX_EXTENSIONS "${CXX_EXTENSIONS}"
|
|
| 141 |
+ CXX_CPPCHECK "${CXX_CPPCHECK}"
|
|
| 142 |
+ CXX_CLANG_TIDY "${CXX_CLANG_TIDY}"
|
|
| 143 |
+ CXX_INCLUDE_WHAT_YOU_USE "${CXX_INCLUDE_WHAT_YOU_USE}"
|
|
| 144 |
+ COMPILE_OPTIONS "${COMPILE_OPTIONS}"
|
|
| 145 |
+ LINK_OPTIONS "${LINK_OPTIONS}"
|
|
| 146 |
+ INTERPROCEDURAL_OPTIMIZATION |
|
| 147 |
+ "${INTERPROCEDURAL_OPTIMIZATION}"
|
|
| 148 |
+ ) |
|
| 149 |
+ |
|
| 150 |
+ |
|
| 151 |
+ ## Testing |
|
| 152 |
+ include(CTest) |
|
| 153 |
+ |
|
| 154 |
+ |
|
| 155 |
+ ## Packaging and installing |
|
| 156 |
+ include(CPack) |
|
| 157 |
+ install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME})
|
|
| 158 |
+ include(GNUInstallDirs) |
|
| 159 |
+ set(CMAKE_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake
|
|
| 160 |
+ CACHE PATH "System CMake package config files" |
|
| 161 |
+ ) |
|
| 162 |
+ install(EXPORT ${PROJECT_NAME}
|
|
| 163 |
+ FILE ${PROJECT_NAME}Config.cmake
|
|
| 164 |
+ DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${PROJECT_NAME}
|
|
| 165 |
+ ) |
|
| 166 |
+ include(CMakePackageConfigHelpers) |
|
| 167 |
+ write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
|
|
| 168 |
+ COMPATIBILITY SameMajorVersion |
|
| 169 |
+ ) |
|
| 170 |
+ install( |
|
| 171 |
+ FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
|
| 172 |
+ DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${PROJECT_NAME}
|
|
| 173 |
+ ) |
|
| 174 |
+ |
|
| 175 |
+ |
|
| 176 |
+endif() |
| ... | ... |
@@ -10,6 +10,112 @@ A [C++11][] test of [OpenGL][] \>=3.2 3D [Framebuffer Objects (FBOs)][]. |
| 10 | 10 |
[OpenGL]: https://www.opengl.org |
| 11 | 11 |
[Framebuffer Objects (FBOs)]: https://www.khronos.org/opengl/wiki/Framebuffer_Object |
| 12 | 12 |
|
| 13 |
+## Dependencies |
|
| 14 |
+ |
|
| 15 |
+Private (tests): |
|
| 16 |
+ |
|
| 17 |
+- [OpenGL][], system (e.g. [`libgl1-mesa-dev`][]). |
|
| 18 |
+- [OpenGL Extension Wrangler (GLEW)][], system (e.g. [`libglew-dev`][]). |
|
| 19 |
+- [OpenGL Mathematics (GLM)][], system (e.g. [`libglm-dev`][]). |
|
| 20 |
+- [`glshader`][], downloaded as part of the CMake configure step. |
|
| 21 |
+- [`gltest`][], downloaded as part of the CMake configure step. |
|
| 22 |
+ |
|
| 23 |
+Private (transitive): |
|
| 24 |
+ |
|
| 25 |
+- [GLFW][], system (e.g. [`libglfw3-dev`][]). |
|
| 26 |
+- [`str`][], downloaded as part of the CMake configure step. |
|
| 27 |
+ |
|
| 28 |
+[OpenGL Extension Wrangler (GLEW)]: http://glew.sourceforge.net |
|
| 29 |
+[OpenGL Mathematics (GLM)]: https://glm.g-truc.net |
|
| 30 |
+[GLFW]: https://www.glfw.org |
|
| 31 |
+[`libgl1-mesa-dev`]: https://packages.debian.org/search?keywords=libgl1-mesa-dev |
|
| 32 |
+[`libglew-dev`]: https://packages.debian.org/search?keywords=libglew-dev |
|
| 33 |
+[`libglm-dev`]: https://packages.debian.org/search?keywords=libglm-dev |
|
| 34 |
+[`libglfw3-dev`]: https://packages.debian.org/search?keywords=libglfw3-dev |
|
| 35 |
+[`glshader`]: https://git.rcrnstn.net/rcrnstn/glshader |
|
| 36 |
+[`gltest`]: https://git.rcrnstn.net/rcrnstn/gltest |
|
| 37 |
+[`str`]: https://git.rcrnstn.net/rcrnstn/str |
|
| 38 |
+ |
|
| 39 |
+## Build system |
|
| 40 |
+ |
|
| 41 |
+There are several ways to use this library in a [CMake][]-based project: |
|
| 42 |
+ |
|
| 43 |
+- Use [`FetchContent`][] to download it and import the targets automatically |
|
| 44 |
+ as part of the configure step: |
|
| 45 |
+ |
|
| 46 |
+ ```cmake |
|
| 47 |
+ include(FetchContent) |
|
| 48 |
+ FetchContent_Declare(glfbo3d |
|
| 49 |
+ GIT_REPOSITORY https://git.rcrnstn.net/rcrnstn/glfbo3d |
|
| 50 |
+ ) |
|
| 51 |
+ FetchContent_MakeAvailable( |
|
| 52 |
+ glfbo3d |
|
| 53 |
+ ) |
|
| 54 |
+ ``` |
|
| 55 |
+ |
|
| 56 |
+- Bundle it and import the targets with [`add_subdirectory`][]. |
|
| 57 |
+ |
|
| 58 |
+- Use [`find_package`][] (requires that the library is [packaged](#packaging) |
|
| 59 |
+ or [installed](#installing)). |
|
| 60 |
+ |
|
| 61 |
+As usual, use [`target_link_libraries`][] to declare the dependency. |
|
| 62 |
+ |
|
| 63 |
+[CMake]: https://cmake.org |
|
| 64 |
+[`FetchContent`]: https://cmake.org/cmake/help/latest/module/FetchContent.html |
|
| 65 |
+[`add_subdirectory`]: https://cmake.org/cmake/help/latest/command/add_subdirectory.html |
|
| 66 |
+[`find_package`]: https://cmake.org/cmake/help/latest/command/find_package.html |
|
| 67 |
+[`target_link_libraries`]: https://cmake.org/cmake/help/latest/command/target_link_libraries.html |
|
| 68 |
+ |
|
| 69 |
+### Configure and generate |
|
| 70 |
+ |
|
| 71 |
+To configure and generate a build tree, use `cmake`: |
|
| 72 |
+ |
|
| 73 |
+```sh |
|
| 74 |
+cmake -B build |
|
| 75 |
+``` |
|
| 76 |
+ |
|
| 77 |
+[`cmake`]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#generate-a-project-buildsystem |
|
| 78 |
+ |
|
| 79 |
+### Build |
|
| 80 |
+ |
|
| 81 |
+To build, use [`cmake --build`][]: |
|
| 82 |
+ |
|
| 83 |
+```sh |
|
| 84 |
+cmake --build build |
|
| 85 |
+``` |
|
| 86 |
+ |
|
| 87 |
+[`cmake --build`]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#build-a-project |
|
| 88 |
+ |
|
| 89 |
+### Test |
|
| 90 |
+ |
|
| 91 |
+To run tests, use [`ctest`][]: |
|
| 92 |
+ |
|
| 93 |
+```sh |
|
| 94 |
+(cd build && ctest --verbose) |
|
| 95 |
+``` |
|
| 96 |
+ |
|
| 97 |
+[`ctest`]: https://cmake.org/cmake/help/latest/manual/ctest.1.html |
|
| 98 |
+ |
|
| 99 |
+### Package |
|
| 100 |
+ |
|
| 101 |
+To package, use [`cpack`][]: |
|
| 102 |
+ |
|
| 103 |
+```sh |
|
| 104 |
+(cd build && cpack) |
|
| 105 |
+``` |
|
| 106 |
+ |
|
| 107 |
+[`cpack`]: https://cmake.org/cmake/help/latest/manual/cpack.1.html |
|
| 108 |
+ |
|
| 109 |
+### Install |
|
| 110 |
+ |
|
| 111 |
+To install onto the current system, use [`cmake --install`][]: |
|
| 112 |
+ |
|
| 113 |
+```sh |
|
| 114 |
+cmake --install build |
|
| 115 |
+``` |
|
| 116 |
+ |
|
| 117 |
+[`cmake --install`]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project |
|
| 118 |
+ |
|
| 13 | 119 |
## License |
| 14 | 120 |
|
| 15 | 121 |
Licensed under the [ISC license][] unless otherwise noted, see the |