├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .ignore ├── .travis.yml ├── ADAPT.md ├── AUTHORS ├── CMakeLists.txt ├── Dockerfile ├── LICENSE ├── README.md ├── appveyor.yml ├── cmake-init-logo.png ├── cmake-init-logo.svg ├── cmake ├── CheckTemplate.cmake ├── ClangTidy.cmake ├── CompileOptions.cmake ├── ComponentInstall.cmake ├── Coverage.cmake ├── Cppcheck.cmake ├── Custom.cmake ├── FindASSIMP.cmake ├── FindEGL.cmake ├── FindFFMPEG.cmake ├── FindGLESv2.cmake ├── FindGLEW.cmake ├── FindGTK3.cmake ├── FindGTK4.cmake ├── FindHIDAPI.cmake ├── FindSDL2.cmake ├── Findclang_tidy.cmake ├── Findcppcheck.cmake ├── Findgcov.cmake ├── Findgoogletest.cmake ├── Findlcov.cmake ├── Findnodejs.cmake ├── Gcov.cmake ├── GenerateTemplateExportHeader.cmake ├── GetGitRevisionDescription.cmake ├── GetGitRevisionDescription.cmake.in ├── HealthCheck.cmake ├── README.md └── RuntimeDependencies.cmake ├── configure ├── data └── README.md ├── deploy ├── CMakeLists.txt ├── README.md ├── packages │ └── pack-template.cmake └── ubuntu-ppa │ ├── debian │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ ├── rules │ └── source │ │ └── format │ └── recipe.txt ├── docs ├── CMakeLists.txt ├── README.md ├── api-docs │ └── CMakeLists.txt └── manual │ ├── CMakeLists.txt │ └── cmake-init.tex ├── source ├── CMakeLists.txt ├── README.md ├── baselib │ ├── CMakeLists.txt │ ├── include │ │ └── baselib │ │ │ └── baselib.h │ └── source │ │ └── baselib.cpp ├── codegeneration │ ├── template_api.h.in │ └── template_msvc_api.h.in ├── examples │ ├── CMakeLists.txt │ ├── fibcmd │ │ ├── CMakeLists.txt │ │ └── main.cpp │ └── fibgui │ │ ├── CMakeLists.txt │ │ ├── MainWindow.cpp │ │ ├── MainWindow.h │ │ ├── MainWindow.ui │ │ └── main.cpp ├── fiblib │ ├── CMakeLists.txt │ ├── include │ │ └── fiblib │ │ │ ├── CTFibonacci.h │ │ │ ├── CTFibonacci.inl │ │ │ └── Fibonacci.h │ └── source │ │ └── Fibonacci.cpp ├── tests │ ├── CMakeLists.txt │ ├── README.md │ └── fiblib-test │ │ ├── CMakeLists.txt │ │ ├── fibonacci_test.cpp │ │ └── main.cpp └── version.h.in └── template-config.cmake /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: install cmake 15 | run: sudo apt install -y cmake 16 | - name: configure 17 | run: ./configure && ./configure 18 | - name: make 19 | run: make 20 | working-directory: build 21 | test: 22 | needs: build 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | - name: install cmake and googletest 27 | run: sudo apt install -y cmake libgmock-dev lcov 28 | - name: configure 29 | run: ./configure && CMAKE_OPTIONS="-DOPTION_ENABLE_COVERAGE=On" ./configure 30 | - name: tests 31 | run: make test 32 | working-directory: build 33 | check: 34 | needs: build 35 | runs-on: ubuntu-latest 36 | steps: 37 | - uses: actions/checkout@v2 38 | - name: install cmake 39 | run: sudo apt install -y cmake cppcheck clang-tidy 40 | - name: configure 41 | run: ./configure && ./configure 42 | - name: check 43 | run: make check-all 44 | working-directory: build 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # Build dir 16 | *-build* 17 | build* 18 | debug_build 19 | release_build 20 | /bin 21 | /lib 22 | /install 23 | 24 | # Qt cache 25 | CMakeLists.txt.user 26 | CMakeLists.txt.user.* 27 | 28 | # IDE project files 29 | *.sublime-project 30 | *.sublime-workspace 31 | 32 | # Local config windows 33 | _configure.bat 34 | _open-project.bat 35 | _start-cmake-gui.bat 36 | _start-cmd.bat 37 | 38 | # Local config unix 39 | .localconfig 40 | 41 | # Wiki 42 | wiki 43 | -------------------------------------------------------------------------------- /.ignore: -------------------------------------------------------------------------------- 1 | source/tests/googletest/* 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: sh 2 | 3 | env: 4 | global: 5 | - CMAKE_OPTIONS="-DOPTION_BUILD_EXAMPLES=On" 6 | 7 | matrix: 8 | include: 9 | 10 | - os: osx 11 | osx_image: xcode9.1 12 | env: CMAKE_CONFIGURATION=release BUILD_DIR=build 13 | 14 | - os: osx 15 | osx_image: xcode9.1 16 | env: CMAKE_CONFIGURATION=debug BUILD_DIR=build-debug 17 | 18 | - os: linux 19 | compiler: clang 20 | env: CMAKE_CONFIGURATION=release BUILD_DIR=build 21 | 22 | - os: linux 23 | compiler: clang 24 | env: CMAKE_CONFIGURATION=debug BUILD_DIR=build-debug 25 | 26 | - os: linux 27 | compiler: gcc 28 | env: 29 | - CMAKE_CONFIGURATION=release BUILD_DIR=build 30 | - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" 31 | addons: 32 | apt: 33 | sources: 34 | - ubuntu-toolchain-r-test 35 | packages: 36 | - cmake 37 | - g++-5 38 | 39 | - os: linux 40 | compiler: gcc 41 | env: 42 | - CMAKE_CONFIGURATION=debug BUILD_DIR=build-debug 43 | - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" 44 | addons: 45 | apt: 46 | sources: 47 | - ubuntu-toolchain-r-test 48 | packages: 49 | - cmake 50 | - g++-5 51 | 52 | - os: windows 53 | env: 54 | - CMAKE_GENERATOR_OVERRIDE="Visual Studio 15 2017 Win64" 55 | - BUILD_DIR=build-debug 56 | - CMAKE_CONFIGURATION=debug 57 | 58 | - os: windows 59 | env: 60 | - CMAKE_GENERATOR_OVERRIDE="Visual Studio 15 2017 Win64" 61 | - BUILD_DIR=build 62 | - CMAKE_CONFIGURATION=release 63 | 64 | before_script: 65 | - eval "${MATRIX_EVAL}" 66 | - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then export PATH="$PATH:/c/Program Files/CMake/bin"; fi 67 | - chmod +x ./configure 68 | - ./configure 69 | - ./configure $CMAKE_CONFIGURATION 70 | 71 | script: 72 | - cmake --build $BUILD_DIR 73 | - cmake --build $BUILD_DIR --target test 74 | - cmake --build $BUILD_DIR --target coverage 75 | -------------------------------------------------------------------------------- /ADAPT.md: -------------------------------------------------------------------------------- 1 | 2 | To adapt this template to your own project, follow these steps: 3 | 4 | 5 | In the root directory adapt/change/do the following: 6 | -------------------------------------------------------------------- 7 | 8 | * [ ] Edit AUTHORS 9 | * [ ] Edit LICENSE 10 | * [ ] Edit README.md 11 | * [ ] Rename ./template-config.cmake -> ./\-config.cmake 12 | 13 | CMakeLists.txt: 14 | * [ ] Set META_PROJECT_* 15 | * [ ] Set META_VERSION_* 16 | * [ ] Set META_AUTHOR_* 17 | * [ ] Set META_CMAKE_INIT_SHA (to the commit hash of the applied cmake-init template, e.g., to 83d7cbc29a6fcb74a98498e5b0fcebd953d9d5cc) 18 | * [ ] Adjust INSTALL_* to the desired install locations for all systems (defaults should be fine for a start) 19 | 20 | 21 | In subdirectory "./deploy/" do: 22 | -------------------------------------------------------------------- 23 | 24 | deploy/CMakeLists.txt: 25 | * [ ] Rename deploy/packages/pack-template.cmake -> pack-\.cmake 26 | 27 | deploy/packages/pack-\.cmake: 28 | * [ ] Adjust OPTION_PACK_GENERATOR to your liking for all systems 29 | * [ ] Adjust package options, e.g., CPACK_DEBIAN_PACKAGE_DEPENDS, CPACK_DEBIAN_PACKAGE_SECTION, CPACK_DEBIAN_PACKAGE_PRIORITY, CPACK_RPM_PACKAGE_LICENSE, CPACK_RPM_PACKAGE_GROUP, ... 30 | 31 | 32 | In subdirectory "./source/" do: 33 | -------------------------------------------------------------------- 34 | 35 | * [ ] Rename template-version.h -> \-version.h 36 | 37 | 38 | In subdirectory "./source/baselib/source" do: 39 | -------------------------------------------------------------------- 40 | 41 | source/baselib/source/baselib.cpp: 42 | * [ ] Substitute template/template-version.h -> \/\-version.h 43 | * [ ] Substitute TEMPLATE_VERSION -> \_VERSION 44 | 45 | * [ ] Rename template-version.h -> \-version.h 46 | 47 | 48 | In subdirectory "./source/examples/fibcmd" do: 49 | -------------------------------------------------------------------- 50 | 51 | source/fibcmd/main.cpp: 52 | * [ ] Substitute template-version.h -> \-version.h 53 | * [ ] Substitute TEMPLATE_VERSION -> \_VERSION 54 | 55 | 56 | In subdirectory "./source/codegeneration/" do: 57 | -------------------------------------------------------------------- 58 | 59 | * [ ] Remove/replace *_features.h for project-specific compiler feature detection headers (generate with current CMake and place here old cmake compatibility) 60 | 61 | 62 | In subdirectory "./docs/api-docs/" do: 63 | -------------------------------------------------------------------- 64 | 65 | docs/api-docs/doxyfile.in: 66 | * [ ] Adjust INPUT tag (list of doxygen annotated sources) 67 | 68 | docs/api-docs/CMakeLists.txt 69 | * [ ] Adjust DEPENDS parameter to include all targets of project 70 | 71 | 72 | In subdirectory "./docs/manual/" do: 73 | -------------------------------------------------------------------- 74 | 75 | docs/manual/cmake-init.tex: 76 | * [ ] Rename to match own project name 77 | 78 | docs/manual/CMakeLists.txt 79 | * [ ] Adjust source and pdf file name 80 | 81 | 82 | In subdirectory "./source/tests/" do: 83 | -------------------------------------------------------------------- 84 | 85 | source/tests/CMakeLists.txt: 86 | * [ ] Set META_PROJECT_NAME 87 | 88 | 89 | General stuff left to do: 90 | -------------------------------------------------------------------- 91 | 92 | * [ ] Rename and adjust targets in source/ 93 | * [ ] Add new targets to source/CMakeLists.txt 94 | * [ ] Add new targets to ./{project}-config.cmake 95 | * [ ] Add new targets to the INPUT tag in docs/api-docs/doxyfile.in 96 | * [ ] Remove data/DATA_FOLDER.txt 97 | * [ ] Populate data/ 98 | * [ ] Remove ADAPT.md 99 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | Stefan Buschmann 3 | Daniel Limberger 4 | Willy Scheibel 5 | 6 | Thanks to all Contributors 7 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # CMake options 4 | # 5 | 6 | # CMake version 7 | cmake_minimum_required(VERSION 3.20 FATAL_ERROR) 8 | 9 | 10 | # 11 | # Detect type of CMake setup 12 | # 13 | 14 | # Use PROJECT_IS_TOP_LEVEL once we bump the required CMake version up to 3.21 15 | get_directory_property(META_HAS_PARENT PARENT_DIRECTORY) 16 | if(META_HAS_PARENT) 17 | set(META_BUILD_AS_ROOT Off) 18 | else() 19 | set(META_BUILD_AS_ROOT On) 20 | endif() 21 | 22 | 23 | # 24 | # Configure CMake environment 25 | # 26 | 27 | # Register general cmake commands 28 | include(cmake/Custom.cmake) 29 | 30 | # Set policies 31 | set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted. 32 | set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default. 33 | set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types. 34 | set_policy(CMP0069 NEW) # ENABLE CMP0069: INTERPROCEDURAL_OPTIMIZATION is enforced when enabled. 35 | set_policy(CMP0077 NEW) # ENABLE CMP0077: option() honors normal variables. 36 | set_policy(CMP0120 OLD) # DISABLE CMP0120: The WriteCompilerDetectionHeader module is removed. 37 | 38 | # Include cmake modules 39 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 40 | 41 | include(GenerateExportHeader) 42 | include(WriteCompilerDetectionHeader) 43 | 44 | # Include custom cmake modules 45 | include(cmake/Coverage.cmake) 46 | include(cmake/GenerateTemplateExportHeader.cmake) 47 | include(cmake/GetGitRevisionDescription.cmake) 48 | include(cmake/HealthCheck.cmake) 49 | 50 | 51 | # 52 | # Project configuration options 53 | # 54 | 55 | # Project options 56 | option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON) 57 | option(OPTION_SELF_CONTAINED "Create a self-contained install with all dependencies." OFF) 58 | option(OPTION_BUILD_TESTS "Build tests." ON) 59 | option(OPTION_BUILD_DOCS "Build documentation." OFF) 60 | option(OPTION_BUILD_EXAMPLES "Build examples." OFF) 61 | option(OPTION_ENABLE_COVERAGE "Add coverage information." OFF) 62 | 63 | # Get git revision 64 | if (OPTION_USE_GIT_INFORMATION AND META_BUILD_AS_ROOT) 65 | get_git_head_revision(GIT_REFSPEC GIT_SHA1) 66 | string(SUBSTRING "${GIT_SHA1}" 0 12 GIT_REV) 67 | if(NOT GIT_SHA1) 68 | set(GIT_REV "0") 69 | endif() 70 | else() 71 | set(GIT_SHA1 "") 72 | set(GIT_REV "0") 73 | endif() 74 | 75 | 76 | # 77 | # Project description and (meta) information 78 | # 79 | 80 | # Meta information about the project 81 | set(META_PROJECT_NAME "template") 82 | set(META_PROJECT_DESCRIPTION "CMake Project Template") 83 | set(META_AUTHOR_ORGANIZATION "CG Internals GmbH") 84 | set(META_AUTHOR_DOMAIN "https://github.com/cginternals/cmake-init/") 85 | set(META_AUTHOR_MAINTAINER "opensource@cginternals.com") 86 | set(META_VERSION_MAJOR "2") 87 | set(META_VERSION_MINOR "1") 88 | set(META_VERSION_PATCH "0") 89 | set(META_VERSION_REVISION "${GIT_REV}") 90 | set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}") 91 | set(META_NAME_VERSION "${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})") 92 | set(META_CMAKE_INIT_SHA "${GIT_REV}") 93 | set(META_CMAKE_INIT_BRANCH "cmake-3.20") 94 | 95 | string(MAKE_C_IDENTIFIER ${META_PROJECT_NAME} META_PROJECT_ID) 96 | string(TOUPPER ${META_PROJECT_ID} META_PROJECT_ID) 97 | 98 | 99 | # 100 | # Declare project 101 | # 102 | 103 | # Generate folders for IDE targets (e.g., VisualStudio solutions) 104 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 105 | set(IDE_FOLDER "") 106 | 107 | # Declare project 108 | project(${META_PROJECT_NAME} 109 | VERSION ${META_VERSION} 110 | DESCRIPTION ${META_PROJECT_DESCRIPTION} 111 | ) 112 | 113 | enable_language(C) 114 | enable_language(CXX) 115 | 116 | # Set output directories 117 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) 118 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) 119 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) 120 | 121 | # Create version file 122 | file(WRITE "${PROJECT_BINARY_DIR}/VERSION" "${META_NAME_VERSION}") 123 | 124 | 125 | # 126 | # Project Health Check Setup 127 | # 128 | 129 | # Add cmake-init template check cmake targets 130 | add_check_template_target(${META_CMAKE_INIT_SHA} ${META_CMAKE_INIT_BRANCH}) 131 | 132 | # Configure health check tools 133 | enable_cppcheck(ON) 134 | enable_clang_tidy(ON) 135 | enable_coverage(${OPTION_ENABLE_COVERAGE}) 136 | 137 | 138 | # 139 | # Compiler settings and options 140 | # 141 | 142 | include(cmake/CompileOptions.cmake) 143 | 144 | 145 | # 146 | # Deployment/installation setup 147 | # 148 | 149 | # Get project name 150 | set(project ${META_PROJECT_NAME}) 151 | 152 | # Check for system dir install 153 | set(SYSTEM_DIR_INSTALL FALSE) 154 | if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local") 155 | set(SYSTEM_DIR_INSTALL TRUE) 156 | endif() 157 | 158 | # Installation paths 159 | if(UNIX AND SYSTEM_DIR_INSTALL) 160 | # Install into the system (/usr/bin or /usr/local/bin) 161 | set(INSTALL_ROOT "share/${project}") # /usr/[local]/share/ 162 | set(INSTALL_CMAKE "share/${project}/cmake") # /usr/[local]/share//cmake 163 | set(INSTALL_EXAMPLES "share/${project}") # /usr/[local]/share/ 164 | set(INSTALL_DATA "share/${project}") # /usr/[local]/share/ 165 | set(INSTALL_BIN "bin") # /usr/[local]/bin 166 | set(INSTALL_SHARED "lib") # /usr/[local]/lib 167 | set(INSTALL_LIB "lib") # /usr/[local]/lib 168 | set(INSTALL_INCLUDE "include") # /usr/[local]/include 169 | set(INSTALL_DOC "share/doc/${project}") # /usr/[local]/share/doc/ 170 | set(INSTALL_SHORTCUTS "share/applications") # /usr/[local]/share/applications 171 | set(INSTALL_ICONS "share/pixmaps") # /usr/[local]/share/pixmaps 172 | set(INSTALL_INIT "/etc/init") # /etc/init (upstart init scripts) 173 | else() 174 | # Install into local directory 175 | set(INSTALL_ROOT ".") # ./ 176 | set(INSTALL_CMAKE "cmake") # ./cmake 177 | set(INSTALL_EXAMPLES ".") # ./ 178 | set(INSTALL_DATA ".") # ./ 179 | set(INSTALL_BIN ".") # ./ 180 | set(INSTALL_SHARED "lib") # ./lib 181 | set(INSTALL_LIB "lib") # ./lib 182 | set(INSTALL_INCLUDE "include") # ./include 183 | set(INSTALL_DOC "doc") # ./doc 184 | set(INSTALL_SHORTCUTS "misc") # ./misc 185 | set(INSTALL_ICONS "misc") # ./misc 186 | set(INSTALL_INIT "misc") # ./misc 187 | endif() 188 | 189 | # Set runtime path 190 | set(CMAKE_SKIP_BUILD_RPATH FALSE) # Add absolute path to all dependencies for BUILD 191 | set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use CMAKE_INSTALL_RPATH for INSTALL 192 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # Do NOT add path to dependencies for INSTALL 193 | 194 | if(NOT SYSTEM_DIR_INSTALL) 195 | # Find libraries relative to binary 196 | if(APPLE) 197 | set(EXECUTABLE_INSTALL_RPATH "@loader_path/../../../${INSTALL_LIB}") 198 | set(LIBRARY_INSTALL_RPATH "@loader_path/../../../${INSTALL_LIB}") 199 | else() 200 | set(EXECUTABLE_INSTALL_RPATH "$ORIGIN/${INSTALL_LIB}") 201 | set(LIBRARY_INSTALL_RPATH "$ORIGIN") 202 | endif() 203 | endif() 204 | 205 | 206 | # 207 | # Project modules 208 | # 209 | 210 | add_subdirectory(source) 211 | add_subdirectory(docs) 212 | add_subdirectory(deploy) 213 | 214 | 215 | # 216 | # Deployment (global project files) 217 | # 218 | 219 | # Install version file 220 | install(FILES "${PROJECT_BINARY_DIR}/VERSION" DESTINATION ${INSTALL_ROOT} COMPONENT runtime) 221 | 222 | # Install cmake find script for the project 223 | install(FILES ${META_PROJECT_NAME}-config.cmake DESTINATION ${INSTALL_ROOT} COMPONENT dev) 224 | 225 | # Install the project meta files 226 | install(FILES AUTHORS DESTINATION ${INSTALL_ROOT} COMPONENT runtime) 227 | install(FILES LICENSE DESTINATION ${INSTALL_ROOT} COMPONENT runtime) 228 | install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime) 229 | 230 | # Install runtime data 231 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA} COMPONENT runtime) 232 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG BASE=ubuntu:20.04 2 | ARG PROJECT_NAME=cmake-init 3 | ARG WORKSPACE=/workspace 4 | 5 | # BUILD 6 | 7 | FROM $BASE AS cmake-init-build 8 | 9 | ARG PROJECT_NAME 10 | ARG WORKSPACE 11 | ARG COMPILER_FLAGS="-j 4" 12 | 13 | ENV DEBIAN_FRONTEND=noninteractive 14 | 15 | RUN apt update 16 | RUN apt install -y --no-install-recommends sudo \ 17 | && echo 'user ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/user 18 | RUN apt install -y --no-install-recommends cmake git build-essential 19 | 20 | ENV PROJECT_DIR="$WORKSPACE/$PROJECT_NAME" 21 | 22 | WORKDIR $WORKSPACE 23 | 24 | ADD cmake $PROJECT_NAME/cmake 25 | ADD docs $PROJECT_NAME/docs 26 | ADD data $PROJECT_NAME/data 27 | ADD deploy $PROJECT_NAME/deploy 28 | ADD source $PROJECT_NAME/source 29 | ADD CMakeLists.txt $PROJECT_NAME/CMakeLists.txt 30 | ADD configure $PROJECT_NAME/configure 31 | ADD template-config.cmake $PROJECT_NAME/template-config.cmake 32 | ADD $PROJECT_NAME-logo.png $PROJECT_NAME/$PROJECT_NAME-logo.png 33 | ADD $PROJECT_NAME-logo.svg $PROJECT_NAME/$PROJECT_NAME-logo.svg 34 | ADD LICENSE $PROJECT_NAME/LICENSE 35 | ADD README.md $PROJECT_NAME/README.md 36 | ADD AUTHORS $PROJECT_NAME/AUTHORS 37 | 38 | WORKDIR $PROJECT_DIR 39 | RUN ./configure 40 | RUN CMAKE_OPTIONS="-DOPTION_BUILD_TESTS=Off -DCMAKE_INSTALL_PREFIX=$WORKSPACE/$PROJECT_NAME-install" ./configure 41 | RUN cmake --build build -- $COMPILER_FLAGS 42 | RUN cmake --build build --target install 43 | 44 | # DEPLOY 45 | 46 | FROM $BASE AS cmake-init 47 | 48 | ARG PROJECT_NAME 49 | ARG WORKSPACE 50 | 51 | ENV DEBIAN_FRONTEND=noninteractive 52 | 53 | RUN apt update 54 | RUN apt install -y --no-install-recommends cmake 55 | 56 | COPY --from=cmake-init-build $WORKSPACE/$PROJECT_NAME-install $WORKSPACE/$PROJECT_NAME 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2012-2015 Computer Graphics Systems Group at the Hasso-Plattner-Institute, Germany. 3 | 4 | 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: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | 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. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | The C++ CMake Project Template 5 | 6 | [![Travis](https://img.shields.io/travis/cginternals/cmake-init/master.svg?style=flat&logo=travis)](https://travis-ci.org/cginternals/cmake-init) 7 | [![Appveyor](https://img.shields.io/appveyor/ci/scheibel/cmake-init/master.svg?style=flat&logo=appveyor)](https://ci.appveyor.com/project/scheibel/cmake-init/branch/master) 8 | [![Tokei](https://tokei.rs/b1/github/cginternals/cmake-init)](https://github.com/Aaronepower/tokei) 9 | [![Setup Guide](https://img.shields.io/badge/cmake%20guide-wiki-blue.svg?style=flat)](https://github.com/cginternals/cmake-init/wiki/Setup-Guide) 10 | 11 | 12 | *cmake-init* is a sophisticated copy & paste template for modern C and C++ projects. 13 | The main goals include support of all use cases around software development (programming, testing, Q&A, deployment, documentation) while being modular, flexible, and idiomatic. *cmake-init* is therefore a collection of cmake best-practices. 14 | 15 | The main target platforms are typical desktop, laptop, and server platforms. Currently supported are: 16 | 17 | * Windows 18 | * macOS 19 | * GNU/Linux 20 | 21 | However, other UNIX versions may work as well if they are supported by CMake. 22 | 23 | The cmake-init template assumes you want to setup a project using 24 | * CMake (3.20 or above) 25 | * C/C++ compiler 26 | 27 | 28 | # Contents 29 | 30 | * [Usage](#usage) 31 | * [Adaption Guide](#adaption-guide) 32 | * [Non-Goals](#non-goals) 33 | * [Module Documentation](#module-documentation) 34 | * [Core Modules](#core-modules) 35 | * [CMake Initialization](#cmake-initialization) 36 | * [CMake Backward Compatibility](#cmake-backward-compatability) 37 | * [Project Meta Information](#project-meta-information) 38 | * [Project Meta Information Code Generation](#project-meta-information-code-generation) 39 | * [Project Build Options](#project-build-options) 40 | * [Maintainer Modules](#maintainer-modules) 41 | * [cmake-init Template Check](#cmake-init-template-check) 42 | * [Development Modules](#development-modules) 43 | * [Version Control System Integration](#version-control-system-integration) 44 | * [Build Targets](#build-targets) 45 | * [Documentation](#documentation) 46 | * [Tests](#tests) 47 | * [Linter](#linter) 48 | * [Continuous Integration](#continuous-integration) 49 | * [Deployment](#deployment) 50 | * [Packaging](#packaging) 51 | * [Run-time Assets](#run-time-assets) 52 | 53 | # Usage 54 | 55 | The intended use of the template is a copy of the current version with a subsequent replacement of project names and customization of modules to your needs. This is documented within the [adaption guide](#adaption-guide). 56 | Another approach is the initialization of a new CMake project where the required features are adopted from cmake-init. We propose the former workflow. 57 | 58 | Concluding, a new project should contain the core modules and, as needed, add the maintainer and development modules as required. All modules are designed in a way that they can be excluded. The process of integration or removal of a module/feature is documented with each module. 59 | 60 | ## Adaption Guide 61 | 62 | The file [ADAPT.md](https://github.com/cginternals/cmake-init/blob/master/ADAPT.md) contains a task checklist for new projects. Your start with a copy of cmake-init and process each item from the checklist, adjusting the template to your needs. 63 | 64 | ## Update 65 | 66 | After some time working on a project, cmake-init may be updated and you want to integrate the changes. 67 | For an overview of changes we suggest to use the [cmake-init Template Check](#cmake-init-template-check) module. 68 | Alternatively, you can update the required modules selectively. 69 | 70 | 71 | 72 | # Non-Goals 73 | 74 | In order to be usable in a deterministic, idiomatic fashion, cmake-init avoids the following approaches and features: 75 | 76 | ## Super-Build 77 | 78 | Due to the current semantics of targets and CMake internals, combining multiple 79 | cmake-init projects into one super-build project is not officially supported. 80 | There are limited and restricting workarounds. 81 | Actual solution: treat each project separately and use explicit dependency management. 82 | 83 | ## High Abstraction 84 | 85 | We use low abstractions to not build a language upon CMake a user has to learn. 86 | 87 | ## File Glob 88 | 89 | Explicit source specification prevents erroneous cases when adding and removing 90 | sources from the project tree. 91 | 92 | # Module Documentation 93 | 94 | ## Core Modules 95 | 96 | ### CMake Initialization 97 | 98 | As with most CMake projects, cmake-init initializes the CMake environment. This includes the minimum required CMake version, 99 | 100 | ```cmake 101 | # CMake version 102 | cmake_minimum_required(VERSION 3.20 FATAL_ERROR) 103 | ``` 104 | 105 | required policies, 106 | 107 | ```cmake 108 | # Set policies 109 | set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted. 110 | set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default. 111 | set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types. 112 | ``` 113 | 114 | adaption of the cmake module path, 115 | 116 | ```cmake 117 | # Include cmake modules 118 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 119 | ``` 120 | 121 | and an include of default modules that are typically required for each project. 122 | 123 | ```cpp 124 | include(GenerateExportHeader) 125 | include(WriteCompilerDetectionHeader) 126 | ``` 127 | 128 | ### Project Meta Information 129 | 130 | The declaration of project-wide information--that are used, e.g., within documentation, testing, and deployment--, is combined within the project meta information section in the main `CMakeLists.txt`. 131 | 132 | ```cmake 133 | # 134 | # Project description and (meta) information 135 | # 136 | 137 | # Meta information about the project 138 | set(META_PROJECT_NAME "template") 139 | set(META_PROJECT_DESCRIPTION "CMake Project Template") 140 | set(META_AUTHOR_ORGANIZATION "CG Internals GmbH") 141 | set(META_AUTHOR_DOMAIN "https://github.com/cginternals/cmake-init/") 142 | set(META_AUTHOR_MAINTAINER "opensource@cginternals.com") 143 | set(META_VERSION_MAJOR "2") 144 | set(META_VERSION_MINOR "0") 145 | set(META_VERSION_PATCH "0") 146 | set(META_VERSION_REVISION "") 147 | set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}") 148 | set(META_NAME_VERSION "${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})") 149 | set(META_CMAKE_INIT_SHA "") 150 | 151 | string(MAKE_C_IDENTIFIER ${META_PROJECT_NAME} META_PROJECT_ID) 152 | string(TOUPPER ${META_PROJECT_ID} META_PROJECT_ID) 153 | ``` 154 | 155 | *cmake-init* supports the projects name, description, organization, domain, and maintainer email as well as detailed version information. For the version, we suggest to use [semantic versioning](https://semver.org/). 156 | Depending on your version control system, you may want to integrate the current revision of the software as well: see [Version Control System Integration](#version-control-system-integration). If you use the [cmake-init Template Check](#cmake-init-template-check) module, the cmake-init SHA is declared within this section, too. 157 | 158 | Last, *cmake-init* derives a project ID that complies with the naming schemes of C to be used within auto-generated and derived source code content (e.g., macro identifiers). 159 | 160 | 161 | ### Project Meta Information Code Generation 162 | 163 | The result of this module is the generation of a C header file that propagates the project meta information to your C and C++ projects. 164 | For this, the CMake file configuration feature is used on the `version.h.in` header template. 165 | 166 | ```c 167 | #define @META_PROJECT_ID@_PROJECT_NAME "@META_PROJECT_NAME@" 168 | #define @META_PROJECT_ID@_PROJECT_DESCRIPTION "@META_PROJECT_DESCRIPTION@" 169 | 170 | #define @META_PROJECT_ID@_AUTHOR_ORGANIZATION "@META_AUTHOR_ORGANIZATION@" 171 | #define @META_PROJECT_ID@_AUTHOR_DOMAIN "@META_AUTHOR_DOMAIN@" 172 | #define @META_PROJECT_ID@_AUTHOR_MAINTAINER "@META_AUTHOR_MAINTAINER@" 173 | 174 | #define @META_PROJECT_ID@_VERSION_MAJOR "@META_VERSION_MAJOR@" 175 | #define @META_PROJECT_ID@_VERSION_MINOR "@META_VERSION_MINOR@" 176 | #define @META_PROJECT_ID@_VERSION_PATCH "@META_VERSION_PATCH@" 177 | #define @META_PROJECT_ID@_VERSION_REVISION "@META_VERSION_REVISION@" 178 | 179 | #define @META_PROJECT_ID@_VERSION "@META_VERSION@" 180 | #define @META_PROJECT_ID@_NAME_VERSION "@META_NAME_VERSION@" 181 | ``` 182 | 183 | The template file is configured with the project meta information and the result is stored within the build directory. Beware that this header is stored in a path derived from your project name. You should adopt this as required. 184 | 185 | ```cmake 186 | # Generate version-header 187 | configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_NAME}/${META_PROJECT_NAME}-version.h) 188 | ``` 189 | 190 | We suggest to deploy this header disregarding its internal or even public use. 191 | 192 | ```cmake 193 | # 194 | # Deployment 195 | # 196 | 197 | # Deploy generated headers 198 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_NAME} DESTINATION include COMPONENT dev) 199 | ``` 200 | 201 | 202 | ### Project Build Options 203 | 204 | ## Maintainer Modules 205 | 206 | ### cmake-init Template Check 207 | 208 | This module allows to check the actuality of the used cmake-init template for own projects. 209 | This module is usable when the following is integrated into the `CMakeLists.txt`. 210 | 211 | ```cmake 212 | # Add cmake-init template check cmake targets 213 | add_check_template_target( ) 214 | ``` 215 | 216 | Here, the `` contains the git hash of the used cmake-init template. 217 | Further, the files `cmake/HealthCheck.cmake` and `cmake/CheckTemplate.cmake` are required. 218 | 219 | The hash is usually configured using 220 | 221 | ```cmake 222 | # Meta information about the project 223 | set(META_CMAKE_INIT_SHA "") 224 | set(META_CMAKE_INIT_BRANCH "") 225 | 226 | # Add cmake-init template check cmake targets 227 | add_check_template_target( ) 228 | ``` 229 | 230 | Correctly configures, this module adds a cmake build target named `check-template` that compares the passed `` with the current master commit hash of this repository and provides a link for a diff view. 231 | 232 | ## Development Modules 233 | 234 | ### Version Control System Integration 235 | 236 | ```cmake 237 | # Get git revision 238 | get_git_head_revision(GIT_REFSPEC GIT_SHA1) 239 | string(SUBSTRING "${GIT_SHA1}" 0 12 GIT_REV) 240 | if(NOT GIT_SHA1) 241 | set(GIT_REV "0") 242 | endif() 243 | ``` 244 | 245 | ### Build Targets 246 | 247 | ### Documentation 248 | 249 | ### Tests 250 | 251 | Tests are available using the Google testing frameworks `googletest` and `googlemock`. 252 | cmake-init assumes an external installment of both frameworks. 253 | Typically, package managers of each system provides a sufficient installment. 254 | For example, on Ubuntu you can install the `libgmock-dev` package. 255 | On macOS using Homebrew, this package is named `googletest 256 | 257 | ### Linter 258 | 259 | ### Continuous Integration 260 | 261 | ### Deployment 262 | 263 | ### Packaging 264 | 265 | ### Run-time Assets 266 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | branches: 3 | only: 4 | - master 5 | clone_folder: c:\projects\cmake-init 6 | image: 7 | - Visual Studio 2015 8 | - Visual Studio 2017 9 | - Visual Studio 2019 10 | configuration: 11 | - Release 12 | - Debug 13 | platform: 14 | - x64 15 | environment: 16 | matrix: 17 | - arch: Win64 18 | # - arch: #does not work, Release|x64 not a valid target 19 | matrix: 20 | fast_finish: true 21 | 22 | # skip unsupported combinations 23 | init: 24 | - set arch= 25 | - if "%arch%"=="Win64" ( set arch= x64) 26 | - echo %arch% 27 | - echo %APPVEYOR_BUILD_WORKER_IMAGE% 28 | - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( set generator="Visual Studio 15 2017" ) 29 | - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" ( set generator="Visual Studio 14 2015" ) 30 | - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" ( set generator="Visual Studio 16 2019" ) 31 | - echo %generator% 32 | 33 | before_build: 34 | - cmd: |- 35 | mkdir build 36 | cd build 37 | cmake --version 38 | cmake .. -G %generator% -A %arch% 39 | 40 | build: 41 | project: c:\projects\cmake-init\build\template.sln 42 | verbosity: minimal 43 | parallel: true 44 | only_commits: 45 | files: 46 | - CMakeLists.txt 47 | - appveyor.yml 48 | - source/ 49 | - cmake/ 50 | -------------------------------------------------------------------------------- /cmake-init-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cginternals/cmake-init/44ba67b32f7cc5d9c8fc0ae4186a2cb2a0c2fe0a/cmake-init-logo.png -------------------------------------------------------------------------------- /cmake-init-logo.svg: -------------------------------------------------------------------------------- 1 | cmake-init-logo -------------------------------------------------------------------------------- /cmake/CheckTemplate.cmake: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Get cmake-init latest commit SHA on master 4 | # 5 | 6 | if(NOT APPLIED_CMAKE_INIT_BRANCH) 7 | set(APPLIED_CMAKE_INIT_BRANCH "master") 8 | endif () 9 | 10 | file(DOWNLOAD 11 | "https://api.github.com/repos/cginternals/cmake-init/commits/${APPLIED_CMAKE_INIT_BRANCH}" 12 | "${PROJECT_BINARY_DIR}/cmake-init.github.data" 13 | ) 14 | file(READ 15 | "${PROJECT_BINARY_DIR}/cmake-init.github.data" 16 | CMAKE_INIT_INFO 17 | ) 18 | 19 | string(REGEX MATCH 20 | "\"sha\": \"([0-9a-f]+)\"," 21 | CMAKE_INIT_SHA 22 | ${CMAKE_INIT_INFO}) 23 | 24 | string(SUBSTRING 25 | ${CMAKE_INIT_SHA} 26 | 8 27 | 40 28 | CMAKE_INIT_SHA 29 | ) 30 | 31 | # 32 | # Get latest cmake-init commit on this repository 33 | # 34 | 35 | # APPLIED_CMAKE_INIT_SHA can be set by parent script 36 | if(NOT APPLIED_CMAKE_INIT_SHA) 37 | # [TODO]: Get from git commit list (see cmake_init/source/scripts/check_template.sh) 38 | set(APPLIED_CMAKE_INIT_SHA "") 39 | endif () 40 | 41 | if("${APPLIED_CMAKE_INIT_SHA}" STREQUAL "") 42 | message(WARNING 43 | "No cmake-init version detected, could not verify up-to-dateness. " 44 | "Set the cmake-init version by defining a META_CMAKE_INIT_SHA for your project." 45 | ) 46 | return() 47 | endif() 48 | 49 | if(${APPLIED_CMAKE_INIT_SHA} STREQUAL ${CMAKE_INIT_SHA}) 50 | message(STATUS "cmake-init template is up-to-date (${CMAKE_INIT_SHA})") 51 | else() 52 | message(STATUS "cmake-init template needs an update https://github.com/cginternals/cmake-init/compare/${APPLIED_CMAKE_INIT_SHA}...${APPLIED_CMAKE_INIT_BRANCH}") 53 | endif() 54 | -------------------------------------------------------------------------------- /cmake/ClangTidy.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Function to register a target for clang-tidy 3 | function(perform_clang_tidy check_target target) 4 | set(includes "$") 5 | 6 | add_custom_target( 7 | ${check_target} 8 | COMMAND 9 | ${clang_tidy_EXECUTABLE} 10 | -p\t${PROJECT_BINARY_DIR} 11 | ${ARGN} 12 | -checks=* 13 | "$<$>:--\t$<$:-I$>>" 14 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 15 | ) 16 | 17 | set_target_properties(${check_target} 18 | PROPERTIES 19 | FOLDER "Maintenance" 20 | EXCLUDE_FROM_DEFAULT_BUILD 1 21 | ) 22 | 23 | add_dependencies(${check_target} ${target}) 24 | endfunction() 25 | -------------------------------------------------------------------------------- /cmake/CompileOptions.cmake: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Platform and architecture setup 4 | # 5 | 6 | # Get upper case system name 7 | string(TOUPPER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_UPPER) 8 | 9 | # Determine architecture (32/64 bit) 10 | set(X64 OFF) 11 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 12 | set(X64 ON) 13 | endif() 14 | 15 | 16 | # 17 | # Project options 18 | # 19 | 20 | set(DEFAULT_PROJECT_OPTIONS 21 | DEBUG_POSTFIX "d" 22 | CXX_STANDARD 11 23 | LINKER_LANGUAGE "CXX" 24 | POSITION_INDEPENDENT_CODE ON 25 | CXX_VISIBILITY_PRESET "hidden" 26 | CXX_EXTENSIONS Off 27 | ) 28 | 29 | 30 | # 31 | # Include directories 32 | # 33 | 34 | set(DEFAULT_INCLUDE_DIRECTORIES) 35 | 36 | if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") 37 | LIST(APPEND DEFAULT_INCLUDE_DIRECTORIES "/usr/local/include") 38 | endif () 39 | 40 | 41 | # 42 | # Libraries 43 | # 44 | 45 | set(DEFAULT_LIBRARIES) 46 | 47 | 48 | # 49 | # Compile definitions 50 | # 51 | 52 | set(DEFAULT_COMPILE_DEFINITIONS 53 | SYSTEM_${SYSTEM_NAME_UPPER} 54 | ) 55 | 56 | # MSVC compiler options 57 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" OR 58 | "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" MATCHES "xMSVC") 59 | set(DEFAULT_COMPILE_DEFINITIONS ${DEFAULT_COMPILE_DEFINITIONS} 60 | _SCL_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the Standard C++ Library 61 | _CRT_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the CRT Library 62 | ) 63 | endif () 64 | 65 | 66 | # 67 | # Compile options 68 | # 69 | 70 | set(DEFAULT_COMPILE_OPTIONS_PRIVATE) 71 | set(DEFAULT_COMPILE_OPTIONS_PUBLIC) 72 | 73 | # MSVC compiler options 74 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") 75 | set(DEFAULT_COMPILE_OPTIONS_PRIVATE ${DEFAULT_COMPILE_OPTIONS_PRIVATE} 76 | $<$: 77 | /MP # -> build with multiple processes 78 | > 79 | /W4 # -> warning level 4 80 | # /WX # -> treat warnings as errors 81 | /wd4251 # -> disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2' 82 | /wd4592 # -> disable warning: 'identifier': symbol will be dynamically initialized (implementation limitation) 83 | # /wd4201 # -> disable warning: nonstandard extension used: nameless struct/union (caused by GLM) 84 | /wd4127 # -> disable warning: conditional expression is constant (caused by Qt) 85 | 86 | # /Zm114 # -> Memory size for precompiled headers (insufficient for msvc 2013) 87 | /Zm200 # -> Memory size for precompiled headers 88 | 89 | $<$: 90 | -Wno-microsoft-cast 91 | > 92 | 93 | #$<$: 94 | #/RTCc # -> value is assigned to a smaller data type and results in a data loss 95 | #> 96 | 97 | $<$: 98 | /Gw # -> whole program global optimization 99 | /GS- # -> buffer security check: no 100 | /GL # -> whole program optimization: enable link-time code generation (disables Zi) 101 | /GF # -> enable string pooling 102 | > 103 | 104 | # No manual c++11 enable for MSVC as all supported MSVC versions for cmake-init have C++11 implicitly enabled (MSVC >=2013) 105 | ) 106 | endif () 107 | 108 | # GCC and Clang compiler options 109 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT MSVC) 110 | set(DEFAULT_COMPILE_OPTIONS_PRIVATE ${DEFAULT_COMPILE_OPTIONS_PRIVATE} 111 | #-fno-exceptions # since we use stl and stl is intended to use exceptions, exceptions should not be disabled 112 | 113 | -Wall 114 | -Wextra 115 | -Wunused 116 | 117 | -Wreorder 118 | -Wignored-qualifiers 119 | -Wmissing-braces 120 | -Wreturn-type 121 | -Wswitch 122 | -Wswitch-default 123 | -Wuninitialized 124 | -Wmissing-field-initializers 125 | 126 | $<$: 127 | -Wmaybe-uninitialized 128 | 129 | -Wno-unknown-pragmas 130 | 131 | $<$,4.8>: 132 | -Wpedantic 133 | 134 | -Wreturn-local-addr 135 | > 136 | > 137 | 138 | $<$: 139 | -Wpedantic 140 | 141 | $<$: 142 | -Wno-language-extension-token 143 | -Wno-microsoft-cast 144 | > 145 | 146 | # -Wreturn-stack-address # gives false positives 147 | > 148 | ) 149 | set(DEFAULT_COMPILE_OPTIONS_PUBLIC ${DEFAULT_COMPILE_OPTIONS_PUBLIC} 150 | $<$: 151 | -pthread 152 | > 153 | ) 154 | endif () 155 | 156 | 157 | # 158 | # Linker options 159 | # 160 | 161 | set(DEFAULT_LINKER_OPTIONS) 162 | 163 | # Use pthreads on mingw and linux 164 | if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_SYSTEM_NAME}" MATCHES "Linux") 165 | set(DEFAULT_LINKER_OPTIONS ${DEFAULT_LINKER_OPTIONS} 166 | PUBLIC 167 | -pthread 168 | ) 169 | 170 | if (${OPTION_COVERAGE_ENABLED}) 171 | set(DEFAULT_LINKER_OPTIONS ${DEFAULT_LINKER_OPTIONS} 172 | PUBLIC 173 | -fprofile-arcs 174 | -ftest-coverage 175 | ) 176 | endif () 177 | endif() 178 | -------------------------------------------------------------------------------- /cmake/ComponentInstall.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Execute cmake_install.cmake wrapper that allows to pass both DESTDIR and COMPONENT environment variable 3 | 4 | execute_process( 5 | COMMAND ${CMAKE_COMMAND} -DCOMPONENT=$ENV{COMPONENT} -P cmake_install.cmake 6 | ) 7 | -------------------------------------------------------------------------------- /cmake/Coverage.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(${CMAKE_CURRENT_LIST_DIR}/Gcov.cmake) 3 | 4 | set(OPTION_COVERAGE_ENABLED OFF) 5 | 6 | set(LCOV_EXCLUDE_COVERAGE 7 | ${LCOV_EXCLUDE_COVERAGE} 8 | "\"*/googletest/*\"" 9 | "\"*v1*\"" 10 | "\"/usr/*\"" 11 | ) 12 | 13 | # Function to register a target for enabled coverage report 14 | function(generate_coverage_report target) 15 | if(NOT TARGET coverage) 16 | add_custom_target(coverage) 17 | 18 | set_target_properties(coverage 19 | PROPERTIES 20 | FOLDER "Maintenance" 21 | EXCLUDE_FROM_DEFAULT_BUILD 1 22 | ) 23 | endif() 24 | 25 | if (${OPTION_COVERAGE_ENABLED}) 26 | generate_lcov_report(coverage-${target} ${target} ${ARGN}) 27 | add_dependencies(coverage coverage-${target}) 28 | endif() 29 | endfunction() 30 | 31 | # Enable or disable coverage 32 | function(enable_coverage status) 33 | if(NOT ${status}) 34 | set(OPTION_COVERAGE_ENABLED ${status} PARENT_SCOPE) 35 | message(STATUS "Coverage lcov skipped: Manually disabled") 36 | 37 | return() 38 | endif() 39 | 40 | find_package(lcov) 41 | 42 | if(NOT lcov_FOUND) 43 | set(OPTION_COVERAGE_ENABLED OFF PARENT_SCOPE) 44 | message(STATUS "Coverage lcov skipped: lcov not found") 45 | 46 | return() 47 | endif() 48 | 49 | set(OPTION_COVERAGE_ENABLED ${status} PARENT_SCOPE) 50 | message(STATUS "Coverage report enabled") 51 | endfunction() 52 | -------------------------------------------------------------------------------- /cmake/Cppcheck.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Function to register a target for cppcheck 3 | function(perform_cppcheck check_target target) 4 | set(includes "$") 5 | 6 | add_custom_target( 7 | ${check_target} 8 | COMMAND 9 | ${cppcheck_EXECUTABLE} 10 | "$<$:-I$>" 11 | --enable=all 12 | --std=c++11 13 | --verbose 14 | --suppress=missingIncludeSystem 15 | ${ARGN} 16 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 17 | ) 18 | 19 | set_target_properties(${check_target} 20 | PROPERTIES 21 | FOLDER "Maintenance" 22 | EXCLUDE_FROM_DEFAULT_BUILD 1 23 | ) 24 | 25 | add_dependencies(${check_target} ${target}) 26 | endfunction() 27 | -------------------------------------------------------------------------------- /cmake/Custom.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Set policy if policy is available 3 | function(set_policy POL VAL) 4 | 5 | if(POLICY ${POL}) 6 | cmake_policy(SET ${POL} ${VAL}) 7 | endif() 8 | 9 | endfunction(set_policy) 10 | 11 | 12 | # Define function "source_group_by_path with three mandatory arguments (PARENT_PATH, REGEX, GROUP, ...) 13 | # to group source files in folders (e.g. for MSVC solutions). 14 | # 15 | # Example: 16 | # source_group_by_path("${CMAKE_CURRENT_SOURCE_DIR}/src" "\\\\.h$|\\\\.inl$|\\\\.cpp$|\\\\.c$|\\\\.ui$|\\\\.qrc$" "Source Files" ${sources}) 17 | function(source_group_by_path PARENT_PATH REGEX GROUP) 18 | 19 | foreach (FILENAME ${ARGN}) 20 | 21 | get_filename_component(FILEPATH "${FILENAME}" REALPATH) 22 | file(RELATIVE_PATH FILEPATH ${PARENT_PATH} ${FILEPATH}) 23 | get_filename_component(FILEPATH "${FILEPATH}" DIRECTORY) 24 | 25 | string(REPLACE "/" "\\" FILEPATH "${FILEPATH}") 26 | 27 | source_group("${GROUP}\\${FILEPATH}" REGULAR_EXPRESSION "${REGEX}" FILES ${FILENAME}) 28 | 29 | endforeach() 30 | 31 | endfunction(source_group_by_path) 32 | 33 | 34 | # Function that extract entries matching a given regex from a list. 35 | # ${OUTPUT} will store the list of matching filenames. 36 | function(list_extract OUTPUT REGEX) 37 | 38 | foreach(FILENAME ${ARGN}) 39 | if(${FILENAME} MATCHES "${REGEX}") 40 | list(APPEND ${OUTPUT} ${FILENAME}) 41 | endif() 42 | endforeach() 43 | 44 | set(${OUTPUT} ${${OUTPUT}} PARENT_SCOPE) 45 | 46 | endfunction(list_extract) 47 | -------------------------------------------------------------------------------- /cmake/FindASSIMP.cmake: -------------------------------------------------------------------------------- 1 | 2 | # ASSIMP_FOUND 3 | # ASSIMP_INCLUDE_DIR 4 | # ASSIMP_LIBRARY_RELEASE 5 | # ASSIMP_LIBRARY_DEBUG 6 | # ASSIMP_LIBRARIES 7 | # ASSIMP_BINARY (win32 only) 8 | 9 | include(FindPackageHandleStandardArgs) 10 | 11 | find_path(ASSIMP_INCLUDE_DIR assimp/Importer.hpp 12 | 13 | PATHS 14 | $ENV{ASSIMP_DIR} 15 | $ENV{PROGRAMFILES}/Assimp 16 | /usr 17 | /usr/local 18 | /sw 19 | /opt/local 20 | 21 | PATH_SUFFIXES 22 | /include 23 | 24 | DOC "The directory where assimp/Importer.hpp etc. resides") 25 | 26 | if(MSVC AND X64) 27 | set(ASSIMP_PF "64") 28 | else() 29 | set(ASSIMP_PF "86") 30 | endif() 31 | 32 | find_library(ASSIMP_LIBRARY_RELEASE NAMES assimp 33 | 34 | HINTS 35 | ${ASSIMP_INCLUDE_DIR}/.. 36 | 37 | PATHS 38 | $ENV{ASSIMP_DIR} 39 | /usr 40 | /usr/local 41 | /sw 42 | /opt/local 43 | 44 | PATH_SUFFIXES 45 | /lib 46 | /lib${ASSIMP_PF} 47 | /build/code 48 | /build-debug/code 49 | 50 | DOC "The Assimp library (release)") 51 | 52 | find_library(ASSIMP_LIBRARY_DEBUG NAMES assimpd 53 | 54 | HINTS 55 | ${ASSIMP_INCLUDE_DIR}/.. 56 | 57 | PATHS 58 | $ENV{ASSIMP_DIR} 59 | /usr 60 | /usr/local 61 | /sw 62 | /opt/local 63 | 64 | PATH_SUFFIXES 65 | /lib 66 | /lib${ASSIMP_PF} 67 | /build/code 68 | /build-debug/code 69 | 70 | DOC "The Assimp library (debug)") 71 | 72 | set(ASSIMP_LIBRARIES "") 73 | if(ASSIMP_LIBRARY_RELEASE AND ASSIMP_LIBRARY_DEBUG) 74 | set(ASSIMP_LIBRARIES 75 | optimized ${ASSIMP_LIBRARY_RELEASE} 76 | debug ${ASSIMP_LIBRARY_DEBUG}) 77 | elseif(ASSIMP_LIBRARY_RELEASE) 78 | set(ASSIMP_LIBRARIES ${ASSIMP_LIBRARY_RELEASE}) 79 | elseif(ASSIMP_LIBRARY_DEBUG) 80 | set(ASSIMP_LIBRARIES ${ASSIMP_LIBRARY_DEBUG}) 81 | endif() 82 | 83 | if(WIN32) 84 | 85 | find_file(ASSIMP_BINARY NAMES assimp.dll "assimp${ASSIMP_PF}.dll" 86 | 87 | HINTS 88 | ${ASSIMP_INCLUDE_DIR}/.. 89 | 90 | PATHS 91 | $ENV{ASSIMP_DIR} 92 | 93 | PATH_SUFFIXES 94 | /bin 95 | /bin${ASSIMP_PF} 96 | 97 | DOC "The Assimp binary") 98 | 99 | endif() 100 | 101 | find_package_handle_standard_args(ASSIMP DEFAULT_MSG ASSIMP_LIBRARIES ASSIMP_INCLUDE_DIR) 102 | mark_as_advanced(ASSIMP_FOUND ASSIMP_INCLUDE_DIR ASSIMP_LIBRARIES) 103 | -------------------------------------------------------------------------------- /cmake/FindEGL.cmake: -------------------------------------------------------------------------------- 1 | 2 | # EGL::EGL 3 | # EGL_FOUND 4 | # EGL_INCLUDE_DIR 5 | # EGL_LIBRARY 6 | 7 | include(FindPackageHandleStandardArgs) 8 | 9 | find_path(EGL_INCLUDE_DIR EGL/egl.h 10 | 11 | PATHS 12 | $ENV{EGL_DIR} 13 | /usr 14 | /usr/local 15 | /sw 16 | /opt/local 17 | 18 | PATH_SUFFIXES 19 | /include 20 | 21 | DOC "The directory where EGL/egl.h resides") 22 | 23 | find_library(EGL_LIBRARY NAMES EGL 24 | 25 | PATHS 26 | $ENV{EGL_DIR} 27 | /usr 28 | /usr/local 29 | /sw 30 | /opt/local 31 | 32 | # authors prefered choice for development 33 | 34 | PATH_SUFFIXES 35 | /lib 36 | /lib64 37 | /lib/x86_64-linux-gnu 38 | 39 | DOC "The EGL library") 40 | 41 | add_library(EGL::EGL SHARED IMPORTED) 42 | 43 | set_target_properties(EGL::EGL PROPERTIES 44 | INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}" 45 | INTERFACE_LINK_LIBRARIES "${EGL_LIBRARY}" 46 | ) 47 | 48 | set_property(TARGET EGL::EGL APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 49 | set_target_properties(EGL::EGL PROPERTIES 50 | IMPORTED_LOCATION_RELEASE "${EGL_LIBRARY}" 51 | ) 52 | 53 | find_package_handle_standard_args(EGL REQUIRED_VARS EGL_INCLUDE_DIR EGL_LIBRARY) 54 | mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY) 55 | 56 | -------------------------------------------------------------------------------- /cmake/FindFFMPEG.cmake: -------------------------------------------------------------------------------- 1 | 2 | # - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil) 3 | # Once done this will define 4 | # 5 | # FFMPEG_FOUND - system has ffmpeg or libav 6 | # FFMPEG_INCLUDE_DIR - the ffmpeg include directory 7 | # FFMPEG_LIBRARIES - Link these to use ffmpeg 8 | # FFMPEG_LIBAVCODEC 9 | # FFMPEG_LIBAVFORMAT 10 | # FFMPEG_LIBAVUTIL 11 | # FFMPEG_LIBSWSCALE 12 | # 13 | # Copyright (c) 2008 Andreas Schneider 14 | # Modified for other libraries by Lasse Kärkkäinen 15 | # Modified for Hedgewars by Stepik777 16 | # 17 | # Redistribution and use is allowed according to the terms of the New 18 | # BSD license. 19 | # 20 | 21 | include(FindPackageHandleStandardArgs) 22 | 23 | if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) 24 | # in cache already 25 | set(FFMPEG_FOUND TRUE) 26 | else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) 27 | find_path(FFMPEG_AVCODEC_INCLUDE_DIR 28 | NAMES libavcodec/avcodec.h 29 | PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include 30 | PATH_SUFFIXES ffmpeg libav 31 | ) 32 | 33 | find_library(FFMPEG_LIBAVCODEC 34 | NAMES avcodec 35 | PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib 36 | ) 37 | 38 | find_library(FFMPEG_LIBAVFORMAT 39 | NAMES avformat 40 | PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib 41 | ) 42 | 43 | find_library(FFMPEG_LIBAVUTIL 44 | NAMES avutil 45 | PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib 46 | ) 47 | 48 | find_library(FFMPEG_LIBSWSCALE 49 | NAMES swscale 50 | PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib 51 | ) 52 | 53 | if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT) 54 | set(FFMPEG_FOUND TRUE) 55 | endif() 56 | 57 | if (FFMPEG_FOUND) 58 | set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR}) 59 | 60 | set(FFMPEG_LIBRARIES 61 | ${FFMPEG_LIBAVCODEC} 62 | ${FFMPEG_LIBAVFORMAT} 63 | ${FFMPEG_LIBAVUTIL} 64 | ${FFMPEG_LIBSWSCALE} 65 | ) 66 | 67 | endif (FFMPEG_FOUND) 68 | 69 | if (FFMPEG_FOUND) 70 | if (NOT FFMPEG_FIND_QUIETLY) 71 | message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}") 72 | endif (NOT FFMPEG_FIND_QUIETLY) 73 | else (FFMPEG_FOUND) 74 | if (FFMPEG_FIND_REQUIRED) 75 | message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil") 76 | endif (FFMPEG_FIND_REQUIRED) 77 | endif (FFMPEG_FOUND) 78 | 79 | endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) 80 | -------------------------------------------------------------------------------- /cmake/FindGLESv2.cmake: -------------------------------------------------------------------------------- 1 | 2 | # GLESv2::GLESv2 3 | # GLESv2_FOUND 4 | # GLESv2_INCLUDE_DIR 5 | # GLESv2_LIBRARY 6 | 7 | include(FindPackageHandleStandardArgs) 8 | 9 | find_path(GLESv2_INCLUDE_DIR GLES2/gl2.h 10 | 11 | PATHS 12 | $ENV{GLESv2_DIR} 13 | /usr 14 | /usr/local 15 | /sw 16 | /opt/local 17 | 18 | PATH_SUFFIXES 19 | /include 20 | 21 | DOC "The directory where GLESv2/GLESv2.h resides") 22 | 23 | find_library(GLESv2_LIBRARY NAMES GLESv2 24 | 25 | PATHS 26 | $ENV{GLESv2_DIR} 27 | /usr 28 | /usr/local 29 | /sw 30 | /opt/local 31 | 32 | # authors prefered choice for development 33 | 34 | PATH_SUFFIXES 35 | /lib 36 | /lib64 37 | /lib/x86_64-linux-gnu 38 | 39 | DOC "The GLESv2 library") 40 | 41 | add_library(GLESv2::GLESv2 SHARED IMPORTED) 42 | 43 | set_target_properties(GLESv2::GLESv2 PROPERTIES 44 | INTERFACE_INCLUDE_DIRECTORIES "${GLESv2_INCLUDE_DIR}" 45 | INTERFACE_LINK_LIBRARIES "${GLESv2_LIBRARY}" 46 | ) 47 | 48 | set_property(TARGET GLESv2::GLESv2 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 49 | set_target_properties(GLESv2::GLESv2 PROPERTIES 50 | IMPORTED_LOCATION_RELEASE "${GLESv2_LIBRARY}" 51 | ) 52 | 53 | find_package_handle_standard_args(GLESv2 REQUIRED_VARS GLESv2_INCLUDE_DIR GLESv2_LIBRARY) 54 | mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY) 55 | 56 | -------------------------------------------------------------------------------- /cmake/FindGLEW.cmake: -------------------------------------------------------------------------------- 1 | 2 | # GLEW_FOUND 3 | # GLEW_INCLUDE_DIR 4 | # GLEW_LIBRARY 5 | 6 | # GLEW_BINARY (win32 only) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | 10 | find_path(GLEW_INCLUDE_DIR GL/glew.h 11 | 12 | PATHS 13 | $ENV{GLEW_DIR} 14 | /usr 15 | /usr/local 16 | /sw 17 | /opt/local 18 | 19 | PATH_SUFFIXES 20 | /include 21 | 22 | DOC "The directory where GL/glew.h resides") 23 | 24 | if (X64) 25 | set(GLEW_BUILD_DIR Release/x64) 26 | else() 27 | set(GLEW_BUILD_DIR Release/Win32) 28 | endif() 29 | 30 | find_library(GLEW_LIBRARY NAMES GLEW glew glew32 glew32s 31 | 32 | PATHS 33 | $ENV{GLEW_DIR} 34 | /usr 35 | /usr/local 36 | /sw 37 | /opt/local 38 | 39 | # authors prefered choice for development 40 | /build 41 | /build-release 42 | /build-debug 43 | $ENV{GLEW_DIR}/build 44 | $ENV{GLEW_DIR}/build-release 45 | $ENV{GLEW_DIR}/build-debug 46 | 47 | PATH_SUFFIXES 48 | /lib 49 | /lib64 50 | /lib/${GLEW_BUILD_DIR} 51 | 52 | DOC "The GLEW library") 53 | 54 | if(WIN32) 55 | 56 | find_file(GLEW_BINARY NAMES glew32.dll glew32s.dll 57 | 58 | HINTS 59 | ${GLEW_INCLUDE_DIR}/.. 60 | 61 | PATHS 62 | $ENV{GLEW_DIR} 63 | 64 | PATH_SUFFIXES 65 | /bin 66 | /bin/${GLEW_BUILD_DIR} 67 | 68 | DOC "The GLEW binary") 69 | 70 | endif() 71 | 72 | find_package_handle_standard_args(GLEW REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY) 73 | mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY) 74 | -------------------------------------------------------------------------------- /cmake/FindGTK3.cmake: -------------------------------------------------------------------------------- 1 | 2 | # GTK3::GTK3 3 | # GTK3_FOUND 4 | # GTK3_INCLUDE_DIRS 5 | # GTK3_LIBRARIES 6 | 7 | include(FindPackageHandleStandardArgs) 8 | 9 | find_package(PkgConfig QUIET) 10 | pkg_check_modules(GTK3 QUIET gtk+-3.0) 11 | 12 | if(GTK3_FOUND) 13 | 14 | add_library(GTK3::GTK3 INTERFACE IMPORTED) 15 | 16 | set_target_properties(GTK3::GTK3 PROPERTIES 17 | INTERFACE_INCLUDE_DIRECTORIES "${GTK3_INCLUDE_DIRS}" 18 | ) 19 | 20 | set_target_properties(GTK3::GTK3 PROPERTIES 21 | INTERFACE_LINK_LIBRARIES "${GTK3_LIBRARIES}" 22 | ) 23 | 24 | endif() 25 | 26 | find_package_handle_standard_args(GTK3 27 | DEFAULT_MSG 28 | REQUIRED_VARS 29 | GTK3_FOUND 30 | ) 31 | 32 | mark_as_advanced(GTK3_FOUND GTK3_INCLUDE_DIRS GTK3_LIBRARIES) 33 | -------------------------------------------------------------------------------- /cmake/FindGTK4.cmake: -------------------------------------------------------------------------------- 1 | 2 | # GTK4::GTK4 3 | # GTK4_FOUND 4 | # GTK4_INCLUDE_DIRS 5 | # GTK4_LIBRARIES 6 | 7 | include(FindPackageHandleStandardArgs) 8 | 9 | find_package(PkgConfig QUIET) 10 | pkg_check_modules(GTK4 QUIET IMPORTED_TARGET gtk4) 11 | 12 | set(GTK4_FOUND OFF) 13 | 14 | if(TARGET PkgConfig::GTK4) 15 | set(GTK4_FOUND ON) 16 | 17 | add_library(GTK4::GTK4 INTERFACE IMPORTED) 18 | 19 | set_target_properties(GTK4::GTK4 PROPERTIES 20 | INTERFACE_LINK_LIBRARIES PkgConfig::GTK4 21 | ) 22 | 23 | endif() 24 | 25 | find_package_handle_standard_args(GTK4 26 | DEFAULT_MSG 27 | REQUIRED_VARS 28 | GTK4_FOUND 29 | ) 30 | mark_as_advanced(GTK4_FOUND) 31 | -------------------------------------------------------------------------------- /cmake/FindHIDAPI.cmake: -------------------------------------------------------------------------------- 1 | 2 | # HIDAPI_FOUND 3 | # HIDAPI_INCLUDE_DIRS 4 | # HIDAPI_LIBRARIES 5 | 6 | include(FindPackageHandleStandardArgs) 7 | 8 | find_path(HIDAPI_INCLUDE_DIRS 9 | NAMES hidapi/hidapi.h 10 | /usr/include 11 | /usr/local/include 12 | /sw/include 13 | /opt/local/include 14 | DOC "The directory where hidapi/hidapi.h resides") 15 | 16 | find_library(HIDAPI_LIBRARIES 17 | NAMES hidapi-hidraw hidapi-libusb 18 | PATHS 19 | /usr/lib64 20 | /usr/local/lib64 21 | /sw/lib64 22 | /opt/loca/lib64 23 | /usr/lib 24 | /usr/local/lib 25 | /sw/lib 26 | /opt/local/lib 27 | DOC "The hidapi library") 28 | 29 | 30 | find_package_handle_standard_args(HIDAPI REQUIRED_VARS HIDAPI_LIBRARIES HIDAPI_INCLUDE_DIRS) 31 | 32 | mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY) 33 | 34 | -------------------------------------------------------------------------------- /cmake/FindSDL2.cmake: -------------------------------------------------------------------------------- 1 | 2 | # SDL2::SDL2 3 | # SDL2_FOUND 4 | # SDL2_INCLUDE_DIRS 5 | # SDL2_LIBRARIES 6 | 7 | include(FindPackageHandleStandardArgs) 8 | 9 | find_package(PkgConfig QUIET) 10 | pkg_check_modules(SDL2 QUIET sdl2) 11 | 12 | if(SDL2_FOUND) 13 | 14 | add_library(SDL2::SDL2 INTERFACE IMPORTED) 15 | 16 | set_target_properties(SDL2::SDL2 PROPERTIES 17 | INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" 18 | ) 19 | 20 | set_target_properties(SDL2::SDL2 PROPERTIES 21 | INTERFACE_LINK_LIBRARIES "${SDL2_LIBRARIES}" 22 | ) 23 | 24 | endif() 25 | 26 | find_package_handle_standard_args(SDL2 27 | DEFAULT_MSG 28 | REQUIRED_VARS 29 | SDL2_INCLUDE_DIRS 30 | SDL2_LIBRARIES 31 | ) 32 | 33 | mark_as_advanced(SDL2_FOUND SDL2_INCLUDE_DIRS SDL2_LIBRARIES) 34 | -------------------------------------------------------------------------------- /cmake/Findclang_tidy.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Findclang_tidy results: 3 | # clang_tidy_FOUND 4 | # clang_tidy_EXECUTABLE 5 | 6 | include(FindPackageHandleStandardArgs) 7 | 8 | find_program(clang_tidy_EXECUTABLE 9 | NAMES 10 | clang-tidy-3.5 11 | clang-tidy-3.6 12 | clang-tidy-3.7 13 | clang-tidy-3.8 14 | clang-tidy-3.9 15 | clang-tidy-4.0 16 | clang-tidy 17 | PATHS 18 | "${CLANG_TIDY_DIR}" 19 | ) 20 | 21 | find_package_handle_standard_args(clang_tidy 22 | FOUND_VAR 23 | clang_tidy_FOUND 24 | REQUIRED_VARS 25 | clang_tidy_EXECUTABLE 26 | ) 27 | 28 | mark_as_advanced(clang_tidy_EXECUTABLE) -------------------------------------------------------------------------------- /cmake/Findcppcheck.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Findcppcheck results: 3 | # cppcheck_FOUND 4 | # cppcheck_EXECUTABLE 5 | 6 | include(FindPackageHandleStandardArgs) 7 | 8 | # work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html 9 | set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)") 10 | 11 | find_program(cppcheck_EXECUTABLE 12 | NAMES 13 | cppcheck 14 | PATHS 15 | "${CPPCHECK_DIR}" 16 | "$ENV{CPPCHECK_DIR}" 17 | "$ENV{PROGRAMFILES}/Cppcheck" 18 | "$ENV{${PROGRAMFILES_x86_ENV}}/Cppcheck" 19 | ) 20 | 21 | find_package_handle_standard_args(cppcheck 22 | FOUND_VAR 23 | cppcheck_FOUND 24 | REQUIRED_VARS 25 | cppcheck_EXECUTABLE 26 | ) 27 | 28 | mark_as_advanced(cppcheck_EXECUTABLE) 29 | -------------------------------------------------------------------------------- /cmake/Findgcov.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Findgcov results: 3 | # gcov_FOUND 4 | # gcov_EXECUTABLE 5 | 6 | include(FindPackageHandleStandardArgs) 7 | 8 | # work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html 9 | set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)") 10 | 11 | find_program(gcov_EXECUTABLE 12 | NAMES 13 | gcov 14 | PATHS 15 | "${GCOV_DIR}" 16 | "$ENV{GCOV_DIR}" 17 | "$ENV{PROGRAMFILES}/gcov" 18 | "$ENV{${PROGRAMFILES_x86_ENV}}/gcov" 19 | ) 20 | 21 | find_package_handle_standard_args(gcov 22 | FOUND_VAR 23 | gcov_FOUND 24 | REQUIRED_VARS 25 | gcov_EXECUTABLE 26 | ) 27 | 28 | mark_as_advanced(gcov_EXECUTABLE) 29 | -------------------------------------------------------------------------------- /cmake/Findgoogletest.cmake: -------------------------------------------------------------------------------- 1 | 2 | # googletest_FOUND 3 | # Target googletest::googletest 4 | 5 | include(FindPackageHandleStandardArgs) 6 | 7 | find_package(PkgConfig) 8 | 9 | # enable MSVC syntax if required 10 | if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") 11 | set(PKG_CONFIG_ARGN ${PKG_CONFIG_ARGN} "--msvc-syntax") 12 | endif() 13 | 14 | pkg_search_module(GMOCK QUIET gmock_main) 15 | 16 | find_package_handle_standard_args(googletest REQUIRED_VARS GMOCK_CFLAGS GMOCK_LDFLAGS) 17 | mark_as_advanced(GMOCK_CFLAGS GMOCK_LDFLAGS) 18 | 19 | if (googletest_FOUND) 20 | # the linker flags aren't correct for use with target_link_libraries 21 | # example: /libpath:[path]/lib.lib;gmock_main.lib;gmock.lib;gtest.lib 22 | # note that the path arg falsely includes a .lib suffix 23 | # additionally, cmake expects linker flags to start with - 24 | # thus, the leading / has to be replaced 25 | # example result: -libpath:[path]/lib;gmock_main.lib;gmock.lib;gtest.lib 26 | if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") 27 | string(REGEX REPLACE "(\\/)(libpath[^;]*)(\\.lib)" "-\\2" GMOCK_LDFLAGS "${GMOCK_LDFLAGS}") 28 | endif() 29 | 30 | # Create interface library to link against gmock 31 | add_library(googletest::googletest INTERFACE IMPORTED) 32 | 33 | target_link_libraries(googletest::googletest 34 | INTERFACE 35 | ${GMOCK_LDFLAGS} 36 | ) 37 | 38 | target_compile_options(googletest::googletest 39 | INTERFACE 40 | ${GMOCK_CFLAGS} 41 | ) 42 | endif () 43 | -------------------------------------------------------------------------------- /cmake/Findlcov.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Findlcov results: 3 | # lcov_FOUND 4 | # lcov_EXECUTABLE 5 | 6 | include(FindPackageHandleStandardArgs) 7 | 8 | # work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html 9 | set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)") 10 | 11 | find_program(lcov_EXECUTABLE 12 | NAMES 13 | lcov 14 | PATHS 15 | "${LCOV_DIR}" 16 | "$ENV{LCOV_DIR}" 17 | "$ENV{PROGRAMFILES}/lcov" 18 | "$ENV{${PROGRAMFILES_x86_ENV}}/lcov" 19 | ) 20 | 21 | find_program(genhtml_EXECUTABLE 22 | NAMES 23 | genhtml 24 | PATHS 25 | "${LCOV_DIR}" 26 | "$ENV{LCOV_DIR}" 27 | "$ENV{PROGRAMFILES}/lcov" 28 | "$ENV{${PROGRAMFILES_x86_ENV}}/lcov" 29 | ) 30 | 31 | find_package_handle_standard_args(lcov 32 | FOUND_VAR 33 | lcov_FOUND 34 | REQUIRED_VARS 35 | lcov_EXECUTABLE 36 | genhtml_EXECUTABLE 37 | ) 38 | 39 | mark_as_advanced( 40 | lcov_EXECUTABLE 41 | genhtml_EXECUTABLE 42 | ) 43 | -------------------------------------------------------------------------------- /cmake/Findnodejs.cmake: -------------------------------------------------------------------------------- 1 | 2 | # NODEJS_FOUND 3 | # NODEJS_INCLUDE_DIRS 4 | # NODEJS_INCLUDE_DIR 5 | # NODEJS_LIBUV_INCLUDE_DIR 6 | 7 | include(FindPackageHandleStandardArgs) 8 | 9 | find_path(NODEJS_INCLUDE_DIR node.h 10 | $ENV{NODEJS_HOME} 11 | $ENV{NODEJSDIR} 12 | $ENV{NODEJS_HOME}/src 13 | $ENV{NODEJSDIR}/src 14 | /usr/include/nodejs/src 15 | /usr/local/include/nodejs/src 16 | /usr/include 17 | /usr/local/include 18 | /sw/include 19 | /usr/local/include/node 20 | /opt/local/include 21 | DOC "The directory where node.h resides.") 22 | 23 | find_path(NODEJS_LIBUV_INCLUDE_DIR uv.h 24 | $ENV{NODEJS_HOME} 25 | $ENV{NODEJSDIR} 26 | $ENV{NODEJS_HOME}/src 27 | $ENV{NODEJSDIR}/src 28 | $ENV{NODEJS_HOME}/deps/uv/include 29 | $ENV{NODEJSDIR}/deps/uv/include 30 | /usr/include/nodejs/deps/uv/include 31 | /usr/local/include/nodejs/deps/uv/include 32 | /usr/include 33 | /usr/local/include 34 | /sw/include 35 | /opt/local/include 36 | /usr/local/include/node 37 | DOC "The directory where uv.h resides.") 38 | 39 | find_path(NODEJS_LIBV8_INCLUDE_DIR v8.h 40 | $ENV{NODEJS_HOME} 41 | $ENV{NODEJSDIR} 42 | $ENV{NODEJS_HOME}/src 43 | $ENV{NODEJSDIR}/src 44 | $ENV{NODEJS_HOME}/deps/v8/include 45 | $ENV{NODEJSDIR}/deps/v8/include 46 | /usr/include/nodejs/deps/uv/include 47 | /usr/local/include/nodejs/deps/uv/include 48 | /usr/include 49 | /usr/local/include 50 | /sw/include 51 | /opt/local/include 52 | /usr/local/include/node 53 | DOC "The directory where v8.h resides.") 54 | 55 | set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIR} ${NODEJS_LIBUV_INCLUDE_DIR} ${NODEJS_LIBV8_INCLUDE_DIR}) 56 | 57 | find_package_handle_standard_args(NODEJS REQUIRED_VARS NODEJS_INCLUDE_DIRS) 58 | mark_as_advanced(NODEJS_INCLUDE_DIRS) 59 | -------------------------------------------------------------------------------- /cmake/Gcov.cmake: -------------------------------------------------------------------------------- 1 | 2 | #mkdir build/coverage 3 | #lcov -d build/source/tests/fiblib-test/CMakeFiles/fiblib-test.dir -c -o build/coverage/fiblib-test.info 4 | #genhtml -o build/coverage/html build/coverage/fiblib-test.info 5 | 6 | set(LCOV_EXCLUDE_COVERAGE) 7 | 8 | # Function to register a target for coverage 9 | function(generate_lcov_report coverage_target target) 10 | if(NOT TARGET coverage-init) 11 | add_custom_target( 12 | coverage-zero 13 | COMMAND 14 | ${lcov_EXECUTABLE} 15 | --zerocounters 16 | --base-directory ${CMAKE_BINARY_DIR} 17 | --directory ${CMAKE_SOURCE_DIR} 18 | -q 19 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 20 | ) 21 | 22 | add_custom_target( 23 | coverage-init 24 | COMMAND 25 | ${lcov_EXECUTABLE} 26 | --no-external 27 | --capture 28 | --initial 29 | --base-directory ${CMAKE_BINARY_DIR} 30 | --directory ${CMAKE_SOURCE_DIR} 31 | --output-file ${CMAKE_BINARY_DIR}/coverage-base.info 32 | -q 33 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 34 | BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-base.info 35 | ) 36 | 37 | add_custom_target( 38 | coverage-info 39 | COMMAND 40 | ${lcov_EXECUTABLE} 41 | --capture 42 | --no-external 43 | --base-directory ${CMAKE_BINARY_DIR} 44 | --directory ${CMAKE_SOURCE_DIR} 45 | --output-file ${CMAKE_BINARY_DIR}/coverage-captured.info 46 | -q 47 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 48 | BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-captured.info 49 | ) 50 | 51 | add_custom_target( 52 | coverage-merge 53 | COMMAND 54 | ${lcov_EXECUTABLE} 55 | --add-tracefile ${CMAKE_BINARY_DIR}/coverage-base.info 56 | --add-tracefile ${CMAKE_BINARY_DIR}/coverage-captured.info 57 | --output-file ${CMAKE_BINARY_DIR}/coverage-merged.info 58 | -q 59 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 60 | BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-merged.info 61 | ) 62 | 63 | add_custom_target( 64 | coverage-filter 65 | COMMAND 66 | ${lcov_EXECUTABLE} 67 | --base-directory ${CMAKE_BINARY_DIR} 68 | --directory ${CMAKE_SOURCE_DIR} 69 | --remove ${CMAKE_BINARY_DIR}/coverage-merged.info 70 | ${LCOV_EXCLUDE_COVERAGE} 71 | --output-file ${CMAKE_BINARY_DIR}/coverage-filtered.info 72 | -q 73 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 74 | BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-filtered.info 75 | ) 76 | 77 | add_custom_target( 78 | coverage-report 79 | COMMAND 80 | ${genhtml_EXECUTABLE} 81 | --output-directory ${CMAKE_BINARY_DIR}/coverage 82 | --title "${META_PROJECT_NAME} Test Coverage" 83 | --num-spaces 4 84 | ${CMAKE_BINARY_DIR}/coverage-filtered.info 85 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 86 | DEPENDS ${CMAKE_BINARY_DIR}/coverage-filtered.info 87 | ) 88 | 89 | add_dependencies(coverage-init coverage-zero) 90 | #add_dependencies(coverage-info coverage-init) 91 | add_dependencies(coverage-merge coverage-info) 92 | add_dependencies(coverage-filter coverage-merge) 93 | add_dependencies(coverage-report coverage-filter) 94 | add_dependencies(coverage coverage-report) 95 | endif() 96 | 97 | add_custom_target(${coverage_target} 98 | COMMAND $ 99 | ) 100 | 101 | add_dependencies(coverage-info ${coverage_target}) 102 | add_dependencies(${coverage_target} coverage-init) 103 | 104 | endfunction() 105 | -------------------------------------------------------------------------------- /cmake/GenerateTemplateExportHeader.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Creates an export header similar to generate_export_header, but for templates. 3 | # The main difference is that for MSVC, templates must not get exported. 4 | # When the file ${export_file} is included in source code, the macro ${target_id}_TEMPLATE_API 5 | # may get used to define public visibility for templates on GCC and Clang platforms. 6 | function(generate_template_export_header target target_id export_file) 7 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") 8 | configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_msvc_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file}) 9 | else() 10 | configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file}) 11 | endif() 12 | endfunction() 13 | -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake: -------------------------------------------------------------------------------- 1 | # - Returns a version string from Git 2 | # 3 | # These functions force a re-configure on each git commit so that you can 4 | # trust the values of the variables in your build system. 5 | # 6 | # get_git_head_revision( [ ...]) 7 | # 8 | # Returns the refspec and sha hash of the current head revision 9 | # 10 | # git_describe( [ ...]) 11 | # 12 | # Returns the results of git describe on the source tree, and adjusting 13 | # the output so that it tests false if an error occurs. 14 | # 15 | # git_get_exact_tag( [ ...]) 16 | # 17 | # Returns the results of git describe --exact-match on the source tree, 18 | # and adjusting the output so that it tests false if there was no exact 19 | # matching tag. 20 | # 21 | # Requires CMake 2.6 or newer (uses the 'function' command) 22 | # 23 | # Original Author: 24 | # 2009-2010 Ryan Pavlik 25 | # http://academic.cleardefinition.com 26 | # Iowa State University HCI Graduate Program/VRAC 27 | # 28 | # Copyright Iowa State University 2009-2010. 29 | # Distributed under the Boost Software License, Version 1.0. 30 | # (See accompanying file LICENSE_1_0.txt or copy at 31 | # http://www.boost.org/LICENSE_1_0.txt) 32 | 33 | if(__get_git_revision_description) 34 | return() 35 | endif() 36 | set(__get_git_revision_description YES) 37 | 38 | # We must run the following at "include" time, not at function call time, 39 | # to find the path to this module rather than the path to a calling list file 40 | get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) 41 | 42 | function(get_git_head_revision _refspecvar _hashvar) 43 | set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 44 | set(GIT_DIR "${GIT_PARENT_DIR}/.git") 45 | while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories 46 | set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") 47 | get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) 48 | if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) 49 | # We have reached the root directory, we are not in git 50 | set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) 51 | set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) 52 | return() 53 | endif() 54 | set(GIT_DIR "${GIT_PARENT_DIR}/.git") 55 | endwhile() 56 | # check if this is a submodule 57 | if(NOT IS_DIRECTORY ${GIT_DIR}) 58 | file(READ ${GIT_DIR} submodule) 59 | string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) 60 | get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) 61 | get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) 62 | endif() 63 | set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") 64 | if(NOT EXISTS "${GIT_DATA}") 65 | file(MAKE_DIRECTORY "${GIT_DATA}") 66 | endif() 67 | 68 | if(NOT EXISTS "${GIT_DIR}/HEAD") 69 | return() 70 | endif() 71 | set(HEAD_FILE "${GIT_DATA}/HEAD") 72 | configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) 73 | 74 | configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" 75 | "${GIT_DATA}/grabRef.cmake" 76 | @ONLY) 77 | include("${GIT_DATA}/grabRef.cmake") 78 | 79 | set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) 80 | set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) 81 | endfunction() 82 | 83 | function(git_describe _var) 84 | if(NOT GIT_FOUND) 85 | find_package(Git QUIET) 86 | endif() 87 | get_git_head_revision(refspec hash) 88 | if(NOT GIT_FOUND) 89 | set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) 90 | return() 91 | endif() 92 | if(NOT hash) 93 | set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) 94 | return() 95 | endif() 96 | 97 | # TODO sanitize 98 | #if((${ARGN}" MATCHES "&&") OR 99 | # (ARGN MATCHES "||") OR 100 | # (ARGN MATCHES "\\;")) 101 | # message("Please report the following error to the project!") 102 | # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") 103 | #endif() 104 | 105 | #message(STATUS "Arguments to execute_process: ${ARGN}") 106 | 107 | execute_process(COMMAND 108 | "${GIT_EXECUTABLE}" 109 | describe 110 | ${hash} 111 | ${ARGN} 112 | WORKING_DIRECTORY 113 | "${CMAKE_CURRENT_SOURCE_DIR}" 114 | RESULT_VARIABLE 115 | res 116 | OUTPUT_VARIABLE 117 | out 118 | ERROR_QUIET 119 | OUTPUT_STRIP_TRAILING_WHITESPACE) 120 | if(NOT res EQUAL 0) 121 | set(out "${out}-${res}-NOTFOUND") 122 | endif() 123 | 124 | set(${_var} "${out}" PARENT_SCOPE) 125 | endfunction() 126 | 127 | function(git_get_exact_tag _var) 128 | git_describe(out --exact-match ${ARGN}) 129 | set(${_var} "${out}" PARENT_SCOPE) 130 | endfunction() 131 | -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | set(HEAD_REF) 18 | 19 | if (NOT EXISTS "@HEAD_FILE@") 20 | return() 21 | endif() 22 | 23 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 24 | 25 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 26 | if(HEAD_CONTENTS MATCHES "ref") 27 | # named branch 28 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 29 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 30 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 31 | elseif(EXISTS "@GIT_DIR@/packed-refs") 32 | configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) 33 | file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) 34 | if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") 35 | set(HEAD_HASH "${CMAKE_MATCH_1}") 36 | endif() 37 | endif() 38 | else() 39 | # detached HEAD 40 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 41 | endif() 42 | 43 | if(NOT HEAD_HASH AND EXISTS "@GIT_DATA@/head-ref") 44 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 45 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 46 | endif() 47 | -------------------------------------------------------------------------------- /cmake/HealthCheck.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(${CMAKE_CURRENT_LIST_DIR}/Cppcheck.cmake) 3 | include(${CMAKE_CURRENT_LIST_DIR}/ClangTidy.cmake) 4 | 5 | set(OPTION_CPPCHECK_ENABLED Off) 6 | set(OPTION_CLANG_TIDY_ENABLED Off) 7 | 8 | # Function to register a target for enabled health checks 9 | function(perform_health_checks target) 10 | if(NOT TARGET check-all) 11 | add_custom_target(check-all) 12 | 13 | set_target_properties(check-all 14 | PROPERTIES 15 | FOLDER "Maintenance" 16 | EXCLUDE_FROM_DEFAULT_BUILD 1 17 | ) 18 | endif() 19 | 20 | add_custom_target(check-${target}) 21 | 22 | set_target_properties(check-${target} 23 | PROPERTIES 24 | FOLDER "Maintenance" 25 | EXCLUDE_FROM_DEFAULT_BUILD 1 26 | ) 27 | 28 | if (OPTION_CPPCHECK_ENABLED) 29 | perform_cppcheck(cppcheck-${target} ${target} ${ARGN}) 30 | add_dependencies(check-${target} cppcheck-${target}) 31 | endif() 32 | 33 | if (OPTION_CLANG_TIDY_ENABLED) 34 | perform_clang_tidy(clang-tidy-${target} ${target} ${ARGN}) 35 | add_dependencies(check-${target} clang-tidy-${target}) 36 | endif() 37 | 38 | add_dependencies(check-all check-${target}) 39 | endfunction() 40 | 41 | # Enable or disable cppcheck for health checks 42 | function(enable_cppcheck status) 43 | if(NOT ${status}) 44 | set(OPTION_CPPCHECK_ENABLED ${status} PARENT_SCOPE) 45 | message(STATUS "Check cppcheck skipped: Manually disabled") 46 | 47 | return() 48 | endif() 49 | 50 | find_package(cppcheck) 51 | 52 | if(NOT cppcheck_FOUND) 53 | set(OPTION_CPPCHECK_ENABLED Off PARENT_SCOPE) 54 | message(STATUS "Check cppcheck skipped: cppcheck not found") 55 | 56 | return() 57 | endif() 58 | 59 | set(OPTION_CPPCHECK_ENABLED ${status} PARENT_SCOPE) 60 | message(STATUS "Check cppcheck") 61 | endfunction() 62 | 63 | # Enable or disable clang-tidy for health checks 64 | function(enable_clang_tidy status) 65 | if(NOT ${status}) 66 | set(OPTION_CLANG_TIDY_ENABLED ${status} PARENT_SCOPE) 67 | message(STATUS "Check clang-tidy skipped: Manually disabled") 68 | 69 | return() 70 | endif() 71 | 72 | find_package(clang_tidy) 73 | 74 | if(NOT clang_tidy_FOUND) 75 | set(OPTION_CLANG_TIDY_ENABLED Off PARENT_SCOPE) 76 | message(STATUS "Check clang-tidy skipped: clang-tidy not found") 77 | 78 | return() 79 | endif() 80 | 81 | set(OPTION_CLANG_TIDY_ENABLED ${status} PARENT_SCOPE) 82 | message(STATUS "Check clang-tidy") 83 | 84 | set(CMAKE_EXPORT_COMPILE_COMMANDS On PARENT_SCOPE) 85 | endfunction() 86 | 87 | # Configure cmake target to check for cmake-init template 88 | function(add_check_template_target current_template_sha current_template_branch) 89 | add_custom_target( 90 | check-template 91 | COMMAND ${CMAKE_COMMAND} 92 | -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} 93 | -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} 94 | -DAPPLIED_CMAKE_INIT_SHA=${current_template_sha} 95 | -DAPPLIED_CMAKE_INIT_BRANCH=${current_template_branch} 96 | -P ${PROJECT_SOURCE_DIR}/cmake/CheckTemplate.cmake 97 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 98 | ) 99 | 100 | set_target_properties(check-template 101 | PROPERTIES 102 | FOLDER "Maintenance" 103 | EXCLUDE_FROM_DEFAULT_BUILD 1 104 | ) 105 | endfunction() 106 | -------------------------------------------------------------------------------- /cmake/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cginternals/cmake-init/44ba67b32f7cc5d9c8fc0ae4186a2cb2a0c2fe0a/cmake/README.md -------------------------------------------------------------------------------- /cmake/RuntimeDependencies.cmake: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Default dependencies for the runtime-package 4 | # 5 | 6 | # Install 3rd-party runtime dependencies into runtime-component 7 | # install(FILES ... COMPONENT runtime) 8 | 9 | 10 | # 11 | # Full dependencies for self-contained packages 12 | # 13 | 14 | if(OPTION_SELF_CONTAINED) 15 | 16 | # Install 3rd-party runtime dependencies into runtime-component 17 | # install(FILES ... COMPONENT runtime) 18 | 19 | endif() 20 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Default options 4 | 5 | BUILD_DIR="build" 6 | CMAKE_GENERATOR="Unix Makefiles" 7 | BUILD_TYPE="Release" 8 | CMAKE_OPTIONS="$CMAKE_OPTIONS" 9 | 10 | # Create default configs 11 | if [ ! -d "./.localconfig" ] 12 | then 13 | mkdir ".localconfig" 14 | 15 | touch ".localconfig/default" 16 | echo "#!/bin/bash" >> ".localconfig/default" 17 | echo "" >> ".localconfig/default" 18 | echo "# Default configuration for configure (is always sourced)" >> ".localconfig/default" 19 | echo "" >> ".localconfig/default" 20 | echo "# CMake generator" >> ".localconfig/default" 21 | echo "CMAKE_GENERATOR=\"Unix Makefiles\"" >> ".localconfig/default" 22 | echo "" >> ".localconfig/default" 23 | echo "# Build directory and build type" >> ".localconfig/default" 24 | echo "BUILD_DIR=\"build\"" >> ".localconfig/default" 25 | echo "BUILD_TYPE=\"Release\"" >> ".localconfig/default" 26 | echo "" >> ".localconfig/default" 27 | echo "# Installation directory" >> ".localconfig/default" 28 | echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=../install\"" >> ".localconfig/default" 29 | echo "" >> ".localconfig/default" 30 | echo "# Build static libraries" >> ".localconfig/default" 31 | echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF\"" >> ".localconfig/default" 32 | echo "" >> ".localconfig/default" 33 | echo "# Enable examples" >> ".localconfig/default" 34 | echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_EXAMPLES:BOOL=ON\"" >> ".localconfig/default" 35 | echo "" >> ".localconfig/default" 36 | echo "# Enable documentation" >> ".localconfig/default" 37 | echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_DOCS:BOOL=ON\"" >> ".localconfig/default" 38 | echo "" >> ".localconfig/default" 39 | echo "# Disable tests" >> ".localconfig/default" 40 | echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_TESTS:BOOL=OFF\"" >> ".localconfig/default" 41 | echo "" >> ".localconfig/default" 42 | echo "" >> ".localconfig/default" 43 | echo "# CMake and environment variables (e.g., search paths for external libraries)" >> ".localconfig/default" 44 | echo "" >> ".localconfig/default" 45 | echo "# Qt" >> ".localconfig/default" 46 | echo "#export CMAKE_PREFIX_PATH=\"\${CMAKE_PREFIX_PATH}:/opt/Qt5.2.1/5.2.1/gcc_64/\"" >> ".localconfig/default" 47 | 48 | touch ".localconfig/debug" 49 | echo "#!/bin/bash" >> ".localconfig/debug" 50 | echo "" >> ".localconfig/debug" 51 | echo "# Configuration for debug builds" >> ".localconfig/debug" 52 | echo "" >> ".localconfig/debug" 53 | echo "# Build directory and build type" >> ".localconfig/debug" 54 | echo "BUILD_DIR=\"\${BUILD_DIR}-debug\"" >> ".localconfig/debug" 55 | echo "BUILD_TYPE=\"Debug\"" >> ".localconfig/debug" 56 | 57 | touch ".localconfig/pack" 58 | echo "#!/bin/bash" >> ".localconfig/pack" 59 | echo "" >> ".localconfig/pack" 60 | echo "# Configuration for creating packages" >> ".localconfig/pack" 61 | echo "" >> ".localconfig/pack" 62 | echo "# Installation directory" >> ".localconfig/pack" 63 | echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr\"" >> ".localconfig/pack" 64 | echo "" >> ".localconfig/pack" 65 | echo "# Enable self-contained installation" >> ".localconfig/pack" 66 | echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_SELF_CONTAINED:BOOL=ON\"" >> ".localconfig/pack" 67 | echo "" >> ".localconfig/pack" 68 | echo "# Enable all components for the package" >> ".localconfig/pack" 69 | echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_EXAMPLES:BOOL=ON\"" >> ".localconfig/pack" 70 | echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_DOCS:BOOL=ON\"" >> ".localconfig/pack" 71 | echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_TESTS:BOOL=OFF\"" >> ".localconfig/pack" 72 | 73 | echo "Default configuration has been written to .localconfig" 74 | echo "Please review and adjust the configuration, then run again" 75 | echo "" 76 | echo " ./configure $@" 77 | 78 | exit 79 | fi 80 | 81 | # Read local default options 82 | if [ -f "./.localconfig/default" ] 83 | then 84 | . ./.localconfig/default 85 | fi 86 | 87 | # Parse command line arguments 88 | for ARG in "$@" 89 | do 90 | # Read in configuration for that command-line argument 91 | CONFIGFILE="./.localconfig/$ARG" 92 | if [ -f "./.localconfig/$ARG" ] 93 | then 94 | . "./.localconfig/$ARG" 95 | elif [ -f "$HOME/.localconfig/$ARG" ] 96 | then 97 | . "$HOME/.localconfig/$ARG" 98 | else 99 | echo "Configuration \"$ARG\" not found (searched in ./.localconfig and ~/.localconfig)" 100 | fi 101 | done 102 | 103 | if [ "$CMAKE_GENERATOR_OVERRIDE" != "" ] 104 | then 105 | echo "Override CMAKE_GENERATOR to $CMAKE_GENERATOR_OVERRIDE" 106 | CMAKE_GENERATOR="$CMAKE_GENERATOR_OVERRIDE" 107 | fi 108 | 109 | if [ -n "$BUILD_DIR_PREFIX" ]; then 110 | BUILD_DIR="${BUILD_DIR_PREFIX}-${BUILD_DIR}" 111 | fi 112 | 113 | # Configure build 114 | echo "Configuring in \"$BUILD_DIR\"" 115 | echo "" 116 | 117 | # Create build directory 118 | if [ ! -d "$BUILD_DIR" ] 119 | then 120 | mkdir -p "$BUILD_DIR" 121 | fi 122 | 123 | # Configure project 124 | 125 | PREVIOUS_DIR=$(pwd) 126 | 127 | pushd $BUILD_DIR 128 | echo cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR" 129 | cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR" 130 | if [ $? == 0 ] 131 | then 132 | echo "" 133 | echo "Project configured. To build the project, use"; 134 | echo "" 135 | echo " cmake --build $BUILD_DIR" 136 | else 137 | echo "" 138 | echo "Configuration failed."; 139 | fi 140 | popd 141 | -------------------------------------------------------------------------------- /data/README.md: -------------------------------------------------------------------------------- 1 | This is the runtime data folder for your project. 2 | 3 | Use it only for data that is needed and loaded at runtime by your application. 4 | It is installed and shipped during packaging of your application. 5 | 6 | Other data files such as desktop icons, init scripts, or files needed for packaging, 7 | belong into the deploy directory. 8 | 9 | Have a look at the cmake-init documentation to learn how your application is able 10 | to locate its data folder at runtime. 11 | -------------------------------------------------------------------------------- /deploy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Target 'pack' 4 | # 5 | 6 | add_custom_target(pack) 7 | set_target_properties(pack PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) 8 | 9 | 10 | # Install additional runtime dependencies 11 | include(${PROJECT_SOURCE_DIR}/cmake/RuntimeDependencies.cmake) 12 | 13 | 14 | # 15 | # Packages 16 | # 17 | 18 | include(packages/pack-${META_PROJECT_NAME}.cmake) 19 | 20 | 21 | # 22 | # Target 'component_install' 23 | # 24 | 25 | add_custom_target( 26 | component_install 27 | COMMAND make preinstall 28 | COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/ComponentInstall.cmake 29 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 30 | ) 31 | -------------------------------------------------------------------------------- /deploy/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Deployment Types 3 | 4 | ## System Install 5 | 6 | ## Global Install 7 | 8 | ## Source Build 9 | 10 | ## Relocatable 11 | 12 | # Packages and Installer 13 | 14 | ## Package Manager 15 | 16 | # Components 17 | -------------------------------------------------------------------------------- /deploy/packages/pack-template.cmake: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Check if cpack is available 4 | # 5 | 6 | if(NOT EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") 7 | return() 8 | endif() 9 | 10 | 11 | # 12 | # Output packages 13 | # 14 | 15 | if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") 16 | # Windows installer 17 | set(OPTION_PACK_GENERATOR "NSIS;ZIP" CACHE STRING "Package targets") 18 | set(PACK_COMPONENT_INSTALL ON) 19 | set(PACK_INCLUDE_TOPDIR OFF) 20 | elseif(UNIX AND SYSTEM_DIR_INSTALL) 21 | # System installation packages for unix systems 22 | if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") 23 | set(OPTION_PACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "Package targets") 24 | set(PACK_COMPONENT_INSTALL ON) 25 | set(PACK_INCLUDE_TOPDIR OFF) 26 | else() 27 | set(OPTION_PACK_GENERATOR "TGZ" CACHE STRING "Package targets") 28 | set(PACK_COMPONENT_INSTALL OFF) 29 | set(PACK_INCLUDE_TOPDIR OFF) 30 | endif() 31 | #elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") 32 | # MacOS X disk image 33 | # At the moment, DMG generator and CPACK_INCLUDE_TOPLEVEL_DIRECTORY=ON do not work together. 34 | # Therefore, we disable dmg images for MacOS until we've found a solution 35 | # set(OPTION_PACK_GENERATOR "DragNDrop" CACHE STRING "Package targets") 36 | # set(PACK_COMPONENT_INSTALL OFF) 37 | # set(PACK_INCLUDE_TOPDIR ON) 38 | else() 39 | # Default (portable package for any platform) 40 | set(OPTION_PACK_GENERATOR "ZIP;TGZ" CACHE STRING "Package targets") 41 | set(PACK_COMPONENT_INSTALL OFF) 42 | set(PACK_INCLUDE_TOPDIR ON) 43 | endif() 44 | 45 | 46 | # 47 | # Package components 48 | # 49 | 50 | set(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "${META_PROJECT_NAME} library") 51 | set(CPACK_COMPONENT_RUNTIME_DESCRIPTION "Runtime components for ${META_PROJECT_NAME} library") 52 | 53 | set(CPACK_COMPONENT_DEV_DISPLAY_NAME "C/C++ development files") 54 | set(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for ${META_PROJECT_NAME} library") 55 | set(CPACK_COMPONENT_DEV_DEPENDS runtime) 56 | 57 | set(CPACK_COMPONENTS_ALL runtime dev) 58 | 59 | if (OPTION_BUILD_EXAMPLES) 60 | set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example applications") 61 | set(CPACK_COMPONENT_EXAMPLES_DESCRIPTION "Example applications for ${META_PROJECT_NAME} library") 62 | set(CPACK_COMPONENT_EXAMPLES_DEPENDS runtime) 63 | 64 | set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} examples) 65 | endif() 66 | 67 | if (OPTION_BUILD_DOCS) 68 | set(CPACK_COMPONENT_DOCS_DISPLAY_NAME "Documentation") 69 | set(CPACK_COMPONENT_DOCS_DESCRIPTION "Documentation of ${META_PROJECT_NAME} library") 70 | 71 | set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} docs) 72 | endif() 73 | 74 | 75 | # 76 | # Initialize CPack 77 | # 78 | 79 | # Reset CPack configuration 80 | if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") 81 | set(CPACK_IGNORE_FILES "") 82 | set(CPACK_INSTALLED_DIRECTORIES "") 83 | set(CPACK_SOURCE_IGNORE_FILES "") 84 | set(CPACK_SOURCE_INSTALLED_DIRECTORIES "") 85 | set(CPACK_STRIP_FILES "") 86 | set(CPACK_SOURCE_TOPLEVEL_TAG "") 87 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "") 88 | set(CPACK_PACKAGE_RELOCATABLE OFF) 89 | set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ${PACK_INCLUDE_TOPDIR}) 90 | set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY ${PACK_INCLUDE_TOPDIR}) 91 | endif() 92 | 93 | # Find cpack executable 94 | get_filename_component(CPACK_PATH ${CMAKE_COMMAND} PATH) 95 | set(CPACK_COMMAND "${CPACK_PATH}/cpack") 96 | 97 | # Set install prefix 98 | if(SYSTEM_DIR_INSTALL) 99 | set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 100 | else() 101 | set(CPACK_PACKAGING_INSTALL_PREFIX "") 102 | endif() 103 | 104 | # Package project 105 | set(project_name ${META_PROJECT_NAME}) # Name of package project 106 | set(project_root ${META_PROJECT_NAME}) # Name of root project that is to be installed 107 | 108 | # Package information 109 | string(TOLOWER ${META_PROJECT_NAME} package_name) 110 | set(package_description ${META_PROJECT_DESCRIPTION}) 111 | set(package_vendor ${META_AUTHOR_ORGANIZATION}) 112 | set(package_maintainer ${META_AUTHOR_MAINTAINER}) 113 | 114 | # Package specific options 115 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/deploy/packages/${project_name}) 116 | 117 | 118 | # 119 | # Package information 120 | # 121 | 122 | set(CPACK_PACKAGE_NAME "${package_name}") 123 | set(CPACK_PACKAGE_VENDOR "${package_vendor}") 124 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${package_description}") 125 | set(CPACK_PACKAGE_VERSION "${META_VERSION}") 126 | set(CPACK_PACKAGE_VERSION_MAJOR "${META_VERSION_MAJOR}") 127 | set(CPACK_PACKAGE_VERSION_MINOR "${META_VERSION_MINOR}") 128 | set(CPACK_PACKAGE_VERSION_PATCH "${META_VERSION_PATCH}") 129 | set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") 130 | set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md") 131 | set(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/README.md") 132 | set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md") 133 | set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake-init-logo.png") 134 | set(CPACK_PACKAGE_FILE_NAME "${package_name}-${CPACK_PACKAGE_VERSION}") 135 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "${package_name}") 136 | set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${package_name}") 137 | 138 | 139 | # 140 | # NSIS package 141 | # 142 | 143 | # Fix icon path 144 | if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows" AND CPACK_PACKAGE_ICON) 145 | # NOTE: for using MUI (UN)WELCOME images we suggest to replace nsis defaults, 146 | # since there is currently no way to do so without manipulating the installer template (which we won't). 147 | # http://public.kitware.com/pipermail/cmake-developers/2013-January/006243.html 148 | 149 | # SO the following only works for the installer icon, not for the welcome image. 150 | 151 | # NSIS requires "\\" - escaped backslash to work properly. We probably won't rely on this feature, 152 | # so just replacing / with \\ manually. 153 | 154 | #file(TO_NATIVE_PATH "${CPACK_PACKAGE_ICON}" CPACK_PACKAGE_ICON) 155 | string(REGEX REPLACE "/" "\\\\\\\\" CPACK_PACKAGE_ICON "${CPACK_PACKAGE_ICON}") 156 | endif() 157 | 158 | # Fix installation path for x64 builds 159 | if(X64) 160 | # http://public.kitware.com/Bug/view.php?id=9094 161 | set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") 162 | endif() 163 | 164 | # Package options 165 | #set(CPACK_NSIS_DISPLAY_NAME "${package_name}-${META_VERSION}") 166 | #set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/deploy/images/logo.ico") 167 | #set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/deploy/images/logo.ico") 168 | 169 | # Optional Preliminaries (i.e., silent Visual Studio Redistributable install) 170 | if(NOT INSTALL_MSVC_REDIST_FILEPATH) 171 | set(INSTALL_MSVC_REDIST_FILEPATH "" CACHE FILEPATH "Visual C++ Redistributable Installer (note: manual match the selected generator)" FORCE) 172 | endif() 173 | 174 | if(EXISTS ${INSTALL_MSVC_REDIST_FILEPATH}) 175 | get_filename_component(MSVC_REDIST_NAME ${INSTALL_MSVC_REDIST_FILEPATH} NAME) 176 | string(REGEX REPLACE "/" "\\\\\\\\" INSTALL_MSVC_REDIST_FILEPATH ${INSTALL_MSVC_REDIST_FILEPATH}) 177 | list(APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS " 178 | SetOutPath \\\"$TEMP\\\" 179 | File \\\"${INSTALL_MSVC_REDIST_FILEPATH}\\\" 180 | ExecWait '\\\"$TEMP\\\\${MSVC_REDIST_NAME} /quiet\\\"' 181 | Delete \\\"$TEMP\\\\${MSVC_REDIST_NAME}\\\" 182 | ") 183 | endif() 184 | 185 | 186 | # 187 | # Debian package 188 | # 189 | 190 | set(CPACK_DEBIAN_PACKAGE_NAME "${package_name}") 191 | set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") 192 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all") 193 | #set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12)") 194 | set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${package_maintainer}") 195 | set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") 196 | set(CPACK_DEBIAN_PACKAGE_SECTION "devel") 197 | set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") 198 | #set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "") 199 | #set(CPACK_DEBIAN_PACKAGE_SUGGESTS "") 200 | set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "") 201 | set(CPACK_DEB_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL}) 202 | 203 | 204 | # 205 | # RPM package 206 | # 207 | 208 | set(CPACK_RPM_PACKAGE_NAME "${package_name}") 209 | set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") 210 | set(CPACK_RPM_PACKAGE_RELEASE 1) 211 | set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") 212 | set(CPACK_RPM_PACKAGE_REQUIRES "") 213 | set(CPACK_RPM_PACKAGE_PROVIDES "") 214 | set(CPACK_RPM_PACKAGE_VENDOR "${package_vendor}") 215 | set(CPACK_RPM_PACKAGE_LICENSE "MIT") 216 | set(CPACK_RPM_PACKAGE_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") 217 | set(CPACK_RPM_PACKAGE_DESCRIPTION "") 218 | set(CPACK_RPM_PACKAGE_GROUP "unknown") 219 | #set(CPACK_RPM_SPEC_INSTALL_POST "") 220 | #set(CPACK_RPM_SPEC_MORE_DEFINE "") 221 | #set(CPACK_RPM_USER_BINARY_SPECFILE "") 222 | #set(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE "") 223 | #set(CPACK_RPM__INSTALL_SCRIPT_FILE "") 224 | #set(CPACK_RPM_PACKAGE_DEBUG 1) 225 | set(CPACK_RPM_PACKAGE_RELOCATABLE OFF) 226 | set(CPACK_RPM_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL}) 227 | 228 | 229 | # 230 | # Archives (zip, tgz, ...) 231 | # 232 | 233 | set(CPACK_ARCHIVE_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL}) 234 | 235 | 236 | # 237 | # Execute CPack 238 | # 239 | 240 | set(CPACK_OUTPUT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackConfig-${project_name}.cmake") 241 | set(CPACK_GENERATOR "${OPTION_PACK_GENERATOR}") 242 | set(CPack_CMake_INCLUDED FALSE) 243 | include(CPack) 244 | 245 | 246 | # 247 | # Package target 248 | # 249 | 250 | # Create target 251 | add_custom_target( 252 | pack-${project_name} 253 | COMMAND ${CPACK_COMMAND} --config ${PROJECT_BINARY_DIR}/CPackConfig-${project_name}.cmake -C $ 254 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 255 | ) 256 | set_target_properties(pack-${project_name} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) 257 | 258 | # Set dependencies 259 | add_dependencies(pack pack-${project_name}) 260 | -------------------------------------------------------------------------------- /deploy/ubuntu-ppa/debian/changelog: -------------------------------------------------------------------------------- 1 | 2 | cmake-init (2.0.0-0) UNRELEASED; urgency=low 3 | 4 | * Initial release. 5 | 6 | -- Willy Scheibel Tue, 31 Jan 2017 13:30:00 +0100 7 | -------------------------------------------------------------------------------- /deploy/ubuntu-ppa/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /deploy/ubuntu-ppa/debian/control: -------------------------------------------------------------------------------- 1 | Source: cmake-init 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Willy Scheibel 5 | Build-Depends: build-essential, cmake, qtbase5-dev, doxygen, graphviz 6 | Standards-Version: 3.8.0 7 | 8 | Package: libcmake-init 9 | Architecture: any 10 | Depends: 11 | Homepage: https://github.com/cginternals/cmake-init 12 | Description: Template for reliable, cross-platform C++ project setup using cmake. 13 | 14 | Package: libcmake-init-dev 15 | Architecture: any 16 | Depends: libcmake-init 17 | Homepage: https://github.com/cginternals/cmake-init 18 | Description: Template for reliable, cross-platform C++ project setup using cmake. 19 | 20 | Package: libcmake-init-examples-data 21 | Architecture: any 22 | Homepage: https://github.com/cginternals/cmake-init 23 | Description: Template for reliable, cross-platform C++ project setup using cmake. 24 | 25 | Package: libcmake-init-examples 26 | Architecture: any 27 | Depends: libcmake-init, libcmake-init-examples-data, libqt5core5a 28 | Homepage: https://github.com/cginternals/cmake-init 29 | Description: Template for reliable, cross-platform C++ project setup using cmake. 30 | 31 | Package: libcmake-init-docs 32 | Architecture: any 33 | Homepage: https://github.com/cginternals/cmake-init 34 | Description: Template for reliable, cross-platform C++ project setup using cmake. 35 | 36 | Package: libcmake-init-dbg 37 | Architecture: any 38 | Depends: libcmake-init, libcmake-init-dev 39 | Homepage: https://github.com/cginternals/cmake-init 40 | Description: Template for reliable, cross-platform C++ project setup using cmake. 41 | 42 | Package: libcmake-init-all 43 | Architecture: any 44 | Depends: libcmake-init, libcmake-init-dev, libcmake-init-docs, libcmake-init-examples 45 | Homepage: https://github.com/cginternals/cmake-init 46 | Description: Template for reliable, cross-platform C++ project setup using cmake. -------------------------------------------------------------------------------- /deploy/ubuntu-ppa/debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianised by Willy Scheibel on 2 | Tue, 31 Jan 2017 13:30:00 +0100 3 | 4 | It was downloaded from: 5 | 6 | https://github.com/cginternals/cmake-init 7 | 8 | Upstream Author: 9 | 10 | CG Internals 11 | 12 | Copyright: 13 | 14 | Copyright (c) 2015-2025 CG Internals GmbH and Computer Graphics Systems Group at the Hasso-Plattner-Institute, Germany. 15 | 16 | License: 17 | 18 | This software is available to you under the terms of the MIT license, see "https://github.com/cginternals/cmake-init/blob/master/LICENSE". 19 | -------------------------------------------------------------------------------- /deploy/ubuntu-ppa/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | BUILDDIR = build 4 | BUILDDEBUGDIR = build-debug 5 | 6 | # firstly called by launchpad 7 | clean: 8 | rm -rf $(BUILDDIR) 9 | rm -rf $(BUILDDEBUGDIR) 10 | 11 | # secondly called by launchpad 12 | build: build-arch 13 | 14 | build-arch: 15 | mkdir $(BUILDDIR) 16 | cd $(BUILDDIR);cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DOPTION_BUILD_TESTS=Off -DOPTION_BUILD_EXAMPLES=On -DOPTION_BUILD_DOCS=On .. 17 | make -C $(BUILDDIR) 18 | mkdir $(BUILDDEBUGDIR) 19 | cd $(BUILDDEBUGDIR);cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr -DOPTION_BUILD_TESTS=Off -DOPTION_BUILD_EXAMPLES=Off -DOPTION_BUILD_DOCS=Off .. 20 | make -C $(BUILDDEBUGDIR) 21 | 22 | # thirdly called by launchpad 23 | binary: binary-arch 24 | 25 | binary-arch: libcmake-init libcmake-init-dev libcmake-init-docs libcmake-init-dbg libcmake-init-examples-data libcmake-init-examples libcmake-init-all 26 | 27 | libcmake-init: build 28 | cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=runtime make component_install 29 | mkdir -p debian/tmp/DEBIAN 30 | dpkg-gencontrol -plibcmake-init 31 | dpkg --build debian/tmp .. 32 | rm -rf debian/tmp 33 | 34 | libcmake-init-dev: build 35 | cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=dev make component_install 36 | mkdir -p debian/tmp/DEBIAN 37 | dpkg-gencontrol -plibcmake-init-dev 38 | dpkg --build debian/tmp .. 39 | rm -rf debian/tmp 40 | 41 | libcmake-init-docs: build 42 | cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=docs make component_install 43 | mkdir -p debian/tmp/DEBIAN 44 | dpkg-gencontrol -plibcmake-init-docs 45 | dpkg --build debian/tmp .. 46 | rm -rf debian/tmp 47 | 48 | libcmake-init-dbg: build 49 | cd $(BUILDDEBUGDIR); DESTDIR=../debian/tmp COMPONENT=runtime make component_install 50 | cd $(BUILDDEBUGDIR); DESTDIR=../debian/tmp COMPONENT=dev make component_install 51 | rm -rf debian/tmp/usr/include 52 | rm debian/tmp/usr/share/*/*-config.cmake 53 | rm debian/tmp/usr/share/*/AUTHORS 54 | rm debian/tmp/usr/share/*/LICENSE 55 | rm debian/tmp/usr/share/*/README.md 56 | rm debian/tmp/usr/share/*/VERSION 57 | rm debian/tmp/usr/share/*/cmake/*/*-export.cmake 58 | mkdir -p debian/tmp/DEBIAN 59 | dpkg-gencontrol -plibcmake-init-dbg 60 | dpkg --build debian/tmp .. 61 | rm -rf debian/tmp 62 | 63 | libcmake-init-examples-data: build 64 | cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=examples_data make component_install 65 | mkdir -p debian/tmp/DEBIAN 66 | dpkg-gencontrol -plibcmake-init-examples-data 67 | dpkg --build debian/tmp .. 68 | rm -rf debian/tmp 69 | 70 | libcmake-init-examples: build 71 | cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=examples_qt make component_install 72 | mkdir -p debian/tmp/DEBIAN 73 | dpkg-gencontrol -plibcmake-init-examples 74 | dpkg --build debian/tmp .. 75 | rm -rf debian/tmp 76 | 77 | libcmake-init-all: build 78 | mkdir -p debian/tmp/DEBIAN 79 | dpkg-gencontrol -plibcmake-init-all 80 | dpkg --build debian/tmp .. 81 | rm -rf debian/tmp 82 | 83 | .PHONY: build build-arch binary binary-arch clean libcmake-init libcmake-init-dev libcmake-init-docs libcmake-init-dbg libcmake-init-examples-data libcmake-init-examples libcmake-init-all 84 | -------------------------------------------------------------------------------- /deploy/ubuntu-ppa/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /deploy/ubuntu-ppa/recipe.txt: -------------------------------------------------------------------------------- 1 | # git-build-recipe format 0.4 deb-version {debupstream}+{revno} 2 | lp:cmake-init 3 | nest-part packaging lp:cmake-init deploy/ubuntu-ppa/debian debian master 4 | -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Target 'docs' 4 | # 5 | 6 | if(NOT OPTION_BUILD_DOCS) 7 | return() 8 | endif() 9 | 10 | add_custom_target(docs) 11 | 12 | 13 | # 14 | # Documentation 15 | # 16 | 17 | add_subdirectory(api-docs) 18 | add_subdirectory(manual) 19 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cginternals/cmake-init/44ba67b32f7cc5d9c8fc0ae4186a2cb2a0c2fe0a/docs/README.md -------------------------------------------------------------------------------- /docs/api-docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Find doxygen 4 | # 5 | 6 | find_package(Doxygen) 7 | if(NOT DOXYGEN_FOUND) 8 | message(STATUS "Disabled generation of doxygen documentation (missing doxygen).") 9 | return() 10 | endif() 11 | 12 | 13 | # 14 | # Target name 15 | # 16 | 17 | set(target api-docs) 18 | message(STATUS "Doc ${target}") 19 | 20 | 21 | # 22 | # Configure Doxygen 23 | # 24 | 25 | set(DOXYGEN_QUIET YES) 26 | set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${PROJECT_SOURCE_DIR}/README.md) 27 | set(DOXYGEN_PROJECT_LOGO ${PROJECT_SOURCE_DIR}/cmake-init-logo.png) # TODO replace by ${META_PROJECT_NAME}-logo.png 28 | set(DOXYGEN_USE_MATHJAX YES) 29 | set(DOXYGEN_EXTRACT_ALL YES) 30 | set(DOXYGEN_EXTRACT_LOCAL_CLASSES NO) 31 | 32 | 33 | # 34 | # Create Target 35 | # 36 | 37 | doxygen_add_docs(${target} 38 | ${PROJECT_SOURCE_DIR}/README.md 39 | # library headers 40 | ${PROJECT_SOURCE_DIR}/source/baselib/include 41 | ${PROJECT_SOURCE_DIR}/source/fiblib/include 42 | # generated headers 43 | ${CMAKE_BINARY_DIR}/source/include 44 | ${CMAKE_BINARY_DIR}/source/baselib/include 45 | ${CMAKE_BINARY_DIR}/source/fiblib/include 46 | ALL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 47 | ) 48 | add_dependencies(docs ${target}) 49 | 50 | 51 | # 52 | # Deployment 53 | # 54 | 55 | install( 56 | DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html 57 | DESTINATION ${INSTALL_DOC} 58 | COMPONENT docs 59 | ) 60 | -------------------------------------------------------------------------------- /docs/manual/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Find LaTeX 4 | # 5 | 6 | find_package(LATEX) 7 | if(NOT LATEX_FOUND) 8 | message(STATUS "Disabled generation of documentation (missing LaTeX).") 9 | return() 10 | endif() 11 | 12 | 13 | # 14 | # Target name 15 | # 16 | 17 | set(target docs-manual) 18 | message(STATUS "Doc ${target}") 19 | 20 | 21 | # 22 | # Input and output files 23 | # 24 | 25 | set(source "${CMAKE_CURRENT_SOURCE_DIR}/cmake-init.tex") 26 | set(pdf "${CMAKE_CURRENT_BINARY_DIR}/cmake-init.pdf") 27 | 28 | 29 | # 30 | # Create documentation 31 | # 32 | 33 | # Invoke LaTeX 34 | add_custom_command( 35 | OUTPUT ${pdf} 36 | DEPENDS ${source} 37 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 38 | COMMAND ${PDFLATEX_COMPILER} \"${source}\" 39 | COMMAND ${PDFLATEX_COMPILER} \"${source}\" 40 | COMMAND ${PDFLATEX_COMPILER} \"${source}\" 41 | COMMENT "Creating LaTeX documentation." 42 | ) 43 | 44 | # Declare target 45 | add_custom_target(${target} ALL DEPENDS ${pdf}) 46 | add_dependencies(docs ${target}) 47 | 48 | 49 | # 50 | # Deployment 51 | # 52 | 53 | # PDF file 54 | install(FILES ${pdf} 55 | DESTINATION "${INSTALL_DOC}" 56 | COMPONENT docs 57 | ) 58 | -------------------------------------------------------------------------------- /docs/manual/cmake-init.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass{article} 3 | 4 | \usepackage[pdfborder={0 0 0}]{hyperref} 5 | 6 | \begin{document} 7 | 8 | \title{cmake-init: C++ CMake Project Template} 9 | 10 | \maketitle 11 | 12 | \begin{abstract} 13 | \noindent 14 | cmake-init is a copy and paste template, that provides the following features: 15 | 16 | \begin{itemize} 17 | \item Cross Platform 18 | \begin{itemize} 19 | \item Windows 20 | \item Linux 21 | \item Mac 22 | \end{itemize} 23 | \item Libraries, Applications, Testing template 24 | \item Documentation template 25 | \item Installation, Packaging template 26 | \item CMake find script template for defined libraries 27 | \end{itemize} 28 | 29 | \end{abstract} 30 | 31 | \setcounter{tocdepth}{2} 32 | \tableofcontents 33 | 34 | \newpage 35 | 36 | \end{document} 37 | -------------------------------------------------------------------------------- /source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Configuration for all sub-projects 4 | # 5 | 6 | # Generate version-header 7 | configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_NAME}/${META_PROJECT_NAME}-version.h) 8 | 9 | 10 | # 11 | # Sub-projects 12 | # 13 | 14 | # Libraries 15 | set(IDE_FOLDER "") 16 | add_subdirectory(baselib) 17 | add_subdirectory(fiblib) 18 | 19 | # Examples 20 | set(IDE_FOLDER "Examples") 21 | add_subdirectory(examples) 22 | 23 | # Tests 24 | if(OPTION_BUILD_TESTS) 25 | set(IDE_FOLDER "Tests") 26 | add_subdirectory(tests) 27 | endif() 28 | 29 | 30 | # 31 | # Deployment 32 | # 33 | 34 | # Deploy generated headers 35 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_NAME} DESTINATION include COMPONENT dev) 36 | -------------------------------------------------------------------------------- /source/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Target Types 3 | 4 | ## Command-line Executable 5 | 6 | ## GUI Executable 7 | 8 | ## Flexible Library 9 | 10 | ## Shared Library 11 | 12 | ## Static Library 13 | 14 | ## Plugin 15 | 16 | ## Header-only Library 17 | 18 | ## Virtual Library 19 | 20 | ## CMake-only Library 21 | 22 | # Dependencies 23 | 24 | # Build Options 25 | 26 | # Compiler Features 27 | 28 | # Source Code 29 | 30 | # Tests 31 | 32 | ## Testing Systems 33 | 34 | ## External Testing 35 | 36 | # Continuous Integration 37 | 38 | # Linter 39 | -------------------------------------------------------------------------------- /source/baselib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # External dependencies 4 | # 5 | 6 | # find_package(THIRDPARTY REQUIRED) 7 | 8 | 9 | # 10 | # Library name and options 11 | # 12 | 13 | # Target name 14 | set(target baselib) 15 | 16 | # Exit here if required dependencies are not met 17 | message(STATUS "Lib ${target}") 18 | 19 | # Set API export file and macro 20 | string(MAKE_C_IDENTIFIER ${target} target_id) 21 | string(TOUPPER ${target_id} target_id) 22 | set(feature_file "include/${target}/${target}_features.h") 23 | set(export_file "include/${target}/${target}_export.h") 24 | set(template_export_file "include/${target}/${target}_api.h") 25 | set(export_macro "${target_id}_API") 26 | 27 | 28 | # 29 | # Sources 30 | # 31 | 32 | set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}") 33 | set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source") 34 | 35 | set(headers 36 | ${include_path}/baselib.h 37 | ) 38 | 39 | set(sources 40 | ${source_path}/baselib.cpp 41 | ) 42 | 43 | # Group source files 44 | set(header_group "Header Files (API)") 45 | set(source_group "Source Files") 46 | source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$" 47 | ${header_group} ${headers}) 48 | source_group_by_path(${source_path} "\\\\.cpp$|\\\\.c$|\\\\.h$|\\\\.hpp$" 49 | ${source_group} ${sources}) 50 | 51 | 52 | # 53 | # Create library 54 | # 55 | 56 | # Build library 57 | add_library(${target} 58 | ${sources} 59 | ${headers} 60 | ) 61 | 62 | # Create namespaced alias 63 | add_library(${META_PROJECT_NAME}::${target} ALIAS ${target}) 64 | 65 | # Export library for downstream projects 66 | export(TARGETS ${target} NAMESPACE ${META_PROJECT_NAME}:: FILE ${PROJECT_BINARY_DIR}/cmake/${target}/${target}-export.cmake) 67 | 68 | # Create feature detection header 69 | # Compilers: https://cmake.org/cmake/help/v3.1/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID 70 | # Feature: https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html 71 | write_compiler_detection_header( 72 | FILE ${feature_file} 73 | PREFIX ${target_id} 74 | COMPILERS AppleClang Clang GNU MSVC 75 | FEATURES cxx_alignas cxx_alignof cxx_constexpr cxx_final cxx_noexcept cxx_nullptr cxx_sizeof_member cxx_thread_local 76 | VERSION 3.20 77 | ) 78 | 79 | # Create API export header 80 | generate_export_header(${target} 81 | EXPORT_FILE_NAME ${export_file} 82 | EXPORT_MACRO_NAME ${export_macro} 83 | ) 84 | 85 | generate_template_export_header(${target} 86 | ${target_id} 87 | ${template_export_file} 88 | ) 89 | 90 | 91 | # 92 | # Project options 93 | # 94 | 95 | set_target_properties(${target} 96 | PROPERTIES 97 | ${DEFAULT_PROJECT_OPTIONS} 98 | INSTALL_RPATH "${LIBRARY_INSTALL_RPATH}" 99 | FOLDER "${IDE_FOLDER}" 100 | VERSION "${META_VERSION}" 101 | SOVERSION "${META_VERSION_MAJOR}" 102 | ) 103 | 104 | 105 | # 106 | # Include directories 107 | # 108 | 109 | target_include_directories(${target} 110 | PRIVATE 111 | ${PROJECT_BINARY_DIR}/source/include 112 | ${CMAKE_CURRENT_SOURCE_DIR}/include 113 | ${CMAKE_CURRENT_BINARY_DIR}/include 114 | 115 | PUBLIC 116 | ${DEFAULT_INCLUDE_DIRECTORIES} 117 | 118 | INTERFACE 119 | $ 120 | $ 121 | $ 122 | ) 123 | 124 | 125 | # 126 | # Libraries 127 | # 128 | 129 | target_link_libraries(${target} 130 | PRIVATE 131 | 132 | PUBLIC 133 | ${DEFAULT_LIBRARIES} 134 | 135 | INTERFACE 136 | ) 137 | 138 | 139 | # 140 | # Compile definitions 141 | # 142 | 143 | target_compile_definitions(${target} 144 | PRIVATE 145 | 146 | PUBLIC 147 | $<$>:${target_id}_STATIC_DEFINE> 148 | ${DEFAULT_COMPILE_DEFINITIONS} 149 | 150 | INTERFACE 151 | ) 152 | 153 | 154 | # 155 | # Compile options 156 | # 157 | 158 | target_compile_options(${target} 159 | PRIVATE 160 | ${DEFAULT_COMPILE_OPTIONS_PRIVATE} 161 | PUBLIC 162 | ${DEFAULT_COMPILE_OPTIONS_PUBLIC} 163 | 164 | INTERFACE 165 | ) 166 | 167 | 168 | # 169 | # Linker options 170 | # 171 | 172 | target_link_options(${target} 173 | PRIVATE 174 | 175 | PUBLIC 176 | ${DEFAULT_LINKER_OPTIONS} 177 | 178 | INTERFACE 179 | ) 180 | 181 | 182 | # 183 | # Target Health 184 | # 185 | 186 | perform_health_checks( 187 | ${target} 188 | ${sources} 189 | ${headers} 190 | ) 191 | 192 | 193 | # 194 | # Deployment 195 | # 196 | 197 | # Library 198 | install(TARGETS ${target} 199 | EXPORT "${target}-export" COMPONENT dev 200 | RUNTIME DESTINATION ${INSTALL_BIN} COMPONENT runtime 201 | LIBRARY DESTINATION ${INSTALL_SHARED} COMPONENT runtime 202 | ARCHIVE DESTINATION ${INSTALL_LIB} COMPONENT dev 203 | ) 204 | 205 | # Header files 206 | install(DIRECTORY 207 | ${CMAKE_CURRENT_SOURCE_DIR}/include/${target} DESTINATION ${INSTALL_INCLUDE} 208 | COMPONENT dev 209 | ) 210 | 211 | # Generated header files 212 | install(DIRECTORY 213 | ${CMAKE_CURRENT_BINARY_DIR}/include/${target} DESTINATION ${INSTALL_INCLUDE} 214 | COMPONENT dev 215 | ) 216 | 217 | # CMake config 218 | install(EXPORT ${target}-export 219 | NAMESPACE ${META_PROJECT_NAME}:: 220 | DESTINATION ${INSTALL_CMAKE}/${target} 221 | COMPONENT dev 222 | ) 223 | -------------------------------------------------------------------------------- /source/baselib/include/baselib/baselib.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | namespace baselib 11 | { 12 | 13 | 14 | /** 15 | * @brief 16 | * Print information about the library to the console 17 | */ 18 | BASELIB_API void printInfo(); 19 | 20 | 21 | } // namespace baselib 22 | -------------------------------------------------------------------------------- /source/baselib/source/baselib.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include