Initial commit
This commit is contained in:
commit
e7a53a9ac0
86 changed files with 4765 additions and 0 deletions
44
.github/workflows/ci.yml
vendored
Normal file
44
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
name: C++ CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install cmake
|
||||
run: sudo apt install -y cmake
|
||||
- name: configure
|
||||
run: ./configure && ./configure
|
||||
- name: make
|
||||
run: make
|
||||
working-directory: build
|
||||
test:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install cmake and googletest
|
||||
run: sudo apt install -y cmake libgmock-dev lcov
|
||||
- name: configure
|
||||
run: ./configure && CMAKE_OPTIONS="-DOPTION_ENABLE_COVERAGE=On" ./configure
|
||||
- name: tests
|
||||
run: make test
|
||||
working-directory: build
|
||||
check:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install cmake
|
||||
run: sudo apt install -y cmake cppcheck clang-tidy
|
||||
- name: configure
|
||||
run: ./configure && ./configure
|
||||
- name: check
|
||||
run: make check-all
|
||||
working-directory: build
|
||||
42
.gitignore
vendored
Normal file
42
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
|
||||
# Build dir
|
||||
*-build*
|
||||
build*
|
||||
debug_build
|
||||
release_build
|
||||
/bin
|
||||
/lib
|
||||
/install
|
||||
|
||||
# Qt cache
|
||||
CMakeLists.txt.user
|
||||
CMakeLists.txt.user.*
|
||||
|
||||
# IDE project files
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
|
||||
# Local config windows
|
||||
_configure.bat
|
||||
_open-project.bat
|
||||
_start-cmake-gui.bat
|
||||
_start-cmd.bat
|
||||
|
||||
# Local config unix
|
||||
.localconfig
|
||||
|
||||
# Wiki
|
||||
wiki
|
||||
1
.ignore
Normal file
1
.ignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
source/tests/googletest/*
|
||||
74
.travis.yml
Normal file
74
.travis.yml
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
language: sh
|
||||
|
||||
env:
|
||||
global:
|
||||
- CMAKE_OPTIONS="-DOPTION_BUILD_EXAMPLES=On"
|
||||
|
||||
matrix:
|
||||
include:
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.1
|
||||
env: CMAKE_CONFIGURATION=release BUILD_DIR=build
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.1
|
||||
env: CMAKE_CONFIGURATION=debug BUILD_DIR=build-debug
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: CMAKE_CONFIGURATION=release BUILD_DIR=build
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: CMAKE_CONFIGURATION=debug BUILD_DIR=build-debug
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- CMAKE_CONFIGURATION=release BUILD_DIR=build
|
||||
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- cmake
|
||||
- g++-5
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env:
|
||||
- CMAKE_CONFIGURATION=debug BUILD_DIR=build-debug
|
||||
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- cmake
|
||||
- g++-5
|
||||
|
||||
- os: windows
|
||||
env:
|
||||
- CMAKE_GENERATOR_OVERRIDE="Visual Studio 15 2017 Win64"
|
||||
- BUILD_DIR=build-debug
|
||||
- CMAKE_CONFIGURATION=debug
|
||||
|
||||
- os: windows
|
||||
env:
|
||||
- CMAKE_GENERATOR_OVERRIDE="Visual Studio 15 2017 Win64"
|
||||
- BUILD_DIR=build
|
||||
- CMAKE_CONFIGURATION=release
|
||||
|
||||
before_script:
|
||||
- eval "${MATRIX_EVAL}"
|
||||
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then export PATH="$PATH:/c/Program Files/CMake/bin"; fi
|
||||
- chmod +x ./configure
|
||||
- ./configure
|
||||
- ./configure $CMAKE_CONFIGURATION
|
||||
|
||||
script:
|
||||
- cmake --build $BUILD_DIR
|
||||
- cmake --build $BUILD_DIR --target test
|
||||
- cmake --build $BUILD_DIR --target coverage
|
||||
98
ADAPT.md
Normal file
98
ADAPT.md
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
|
||||
To adapt this template to your own project, follow these steps:
|
||||
|
||||
|
||||
In the root directory adapt/change/do the following:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
* [ ] Edit AUTHORS
|
||||
* [ ] Edit LICENSE
|
||||
* [ ] Edit README.md
|
||||
* [ ] Rename ./template-config.cmake -> ./\<project>-config.cmake
|
||||
|
||||
CMakeLists.txt:
|
||||
* [ ] Set META_PROJECT_*
|
||||
* [ ] Set META_VERSION_*
|
||||
* [ ] Set META_AUTHOR_*
|
||||
* [ ] Set META_CMAKE_INIT_SHA (to the commit hash of the applied cmake-init template, e.g., to 83d7cbc29a6fcb74a98498e5b0fcebd953d9d5cc)
|
||||
* [ ] Adjust INSTALL_* to the desired install locations for all systems (defaults should be fine for a start)
|
||||
|
||||
|
||||
In subdirectory "./deploy/" do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
deploy/CMakeLists.txt:
|
||||
* [ ] Rename deploy/packages/pack-template.cmake -> pack-\<project>.cmake
|
||||
|
||||
deploy/packages/pack-\<project>.cmake:
|
||||
* [ ] Adjust OPTION_PACK_GENERATOR to your liking for all systems
|
||||
* [ ] 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, ...
|
||||
|
||||
|
||||
In subdirectory "./source/" do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
* [ ] Rename template-version.h -> \<project>-version.h
|
||||
|
||||
|
||||
In subdirectory "./source/baselib/source" do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
source/baselib/source/baselib.cpp:
|
||||
* [ ] Substitute template/template-version.h -> \<project>/\<project>-version.h
|
||||
* [ ] Substitute TEMPLATE_VERSION -> \<PROJECT>_VERSION
|
||||
|
||||
* [ ] Rename template-version.h -> \<project>-version.h
|
||||
|
||||
|
||||
In subdirectory "./source/examples/fibcmd" do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
source/fibcmd/main.cpp:
|
||||
* [ ] Substitute template-version.h -> \<project>-version.h
|
||||
* [ ] Substitute TEMPLATE_VERSION -> \<PROJECT>_VERSION
|
||||
|
||||
|
||||
In subdirectory "./source/codegeneration/" do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
* [ ] Remove/replace *_features.h for project-specific compiler feature detection headers (generate with current CMake and place here old cmake compatibility)
|
||||
|
||||
|
||||
In subdirectory "./docs/api-docs/" do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
docs/api-docs/doxyfile.in:
|
||||
* [ ] Adjust INPUT tag (list of doxygen annotated sources)
|
||||
|
||||
docs/api-docs/CMakeLists.txt
|
||||
* [ ] Adjust DEPENDS parameter to include all targets of project
|
||||
|
||||
|
||||
In subdirectory "./docs/manual/" do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
docs/manual/cmake-init.tex:
|
||||
* [ ] Rename to match own project name
|
||||
|
||||
docs/manual/CMakeLists.txt
|
||||
* [ ] Adjust source and pdf file name
|
||||
|
||||
|
||||
In subdirectory "./source/tests/" do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
source/tests/CMakeLists.txt:
|
||||
* [ ] Set META_PROJECT_NAME
|
||||
|
||||
|
||||
General stuff left to do:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
* [ ] Rename and adjust targets in source/
|
||||
* [ ] Add new targets to source/CMakeLists.txt
|
||||
* [ ] Add new targets to ./{project}-config.cmake
|
||||
* [ ] Add new targets to the INPUT tag in docs/api-docs/doxyfile.in
|
||||
* [ ] Remove data/DATA_FOLDER.txt
|
||||
* [ ] Populate data/
|
||||
* [ ] Remove ADAPT.md
|
||||
6
AUTHORS
Normal file
6
AUTHORS
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
Stefan Buschmann <stefan.buschmann@hpi.de> <buschmann@cginternals.com>
|
||||
Daniel Limberger <daniel.limberger@hpi.de> <limberger@cginternals.com>
|
||||
Willy Scheibel <willy.scheibel@hpi.de> <scheibel@cginternals.com>
|
||||
|
||||
Thanks to all Contributors
|
||||
231
CMakeLists.txt
Normal file
231
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
|
||||
#
|
||||
# CMake options
|
||||
#
|
||||
|
||||
# CMake version
|
||||
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
||||
|
||||
|
||||
#
|
||||
# Detect type of CMake setup
|
||||
#
|
||||
|
||||
# Use PROJECT_IS_TOP_LEVEL once we bump the required CMake version up to 3.21
|
||||
get_directory_property(META_HAS_PARENT PARENT_DIRECTORY)
|
||||
if(META_HAS_PARENT)
|
||||
set(META_BUILD_AS_ROOT Off)
|
||||
else()
|
||||
set(META_BUILD_AS_ROOT On)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Configure CMake environment
|
||||
#
|
||||
|
||||
# Register general cmake commands
|
||||
include(cmake/Custom.cmake)
|
||||
|
||||
# Set policies
|
||||
set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
|
||||
set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
|
||||
set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.
|
||||
set_policy(CMP0069 NEW) # ENABLE CMP0069: INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
|
||||
set_policy(CMP0077 NEW) # ENABLE CMP0077: option() honors normal variables.
|
||||
set_policy(CMP0120 OLD) # DISABLE CMP0120: The WriteCompilerDetectionHeader module is removed.
|
||||
|
||||
# Include cmake modules
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(GenerateExportHeader)
|
||||
include(WriteCompilerDetectionHeader)
|
||||
|
||||
# Include custom cmake modules
|
||||
include(cmake/Coverage.cmake)
|
||||
include(cmake/GenerateTemplateExportHeader.cmake)
|
||||
include(cmake/GetGitRevisionDescription.cmake)
|
||||
include(cmake/HealthCheck.cmake)
|
||||
|
||||
|
||||
#
|
||||
# Project configuration options
|
||||
#
|
||||
|
||||
# Project options
|
||||
option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON)
|
||||
option(OPTION_SELF_CONTAINED "Create a self-contained install with all dependencies." OFF)
|
||||
option(OPTION_BUILD_TESTS "Build tests." ON)
|
||||
option(OPTION_BUILD_DOCS "Build documentation." OFF)
|
||||
option(OPTION_BUILD_EXAMPLES "Build examples." OFF)
|
||||
option(OPTION_ENABLE_COVERAGE "Add coverage information." OFF)
|
||||
|
||||
# Get git revision
|
||||
if (OPTION_USE_GIT_INFORMATION AND META_BUILD_AS_ROOT)
|
||||
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
||||
string(SUBSTRING "${GIT_SHA1}" 0 12 GIT_REV)
|
||||
if(NOT GIT_SHA1)
|
||||
set(GIT_REV "0")
|
||||
endif()
|
||||
else()
|
||||
set(GIT_SHA1 "")
|
||||
set(GIT_REV "0")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Project description and (meta) information
|
||||
#
|
||||
|
||||
# Meta information about the project
|
||||
set(META_PROJECT_NAME "template")
|
||||
set(META_PROJECT_DESCRIPTION "CMake Project Template")
|
||||
set(META_AUTHOR_ORGANIZATION "CG Internals GmbH")
|
||||
set(META_AUTHOR_DOMAIN "https://github.com/cginternals/cmake-init/")
|
||||
set(META_AUTHOR_MAINTAINER "opensource@cginternals.com")
|
||||
set(META_VERSION_MAJOR "2")
|
||||
set(META_VERSION_MINOR "1")
|
||||
set(META_VERSION_PATCH "0")
|
||||
set(META_VERSION_REVISION "${GIT_REV}")
|
||||
set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}")
|
||||
set(META_NAME_VERSION "${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})")
|
||||
set(META_CMAKE_INIT_SHA "${GIT_REV}")
|
||||
set(META_CMAKE_INIT_BRANCH "cmake-3.20")
|
||||
|
||||
string(MAKE_C_IDENTIFIER ${META_PROJECT_NAME} META_PROJECT_ID)
|
||||
string(TOUPPER ${META_PROJECT_ID} META_PROJECT_ID)
|
||||
|
||||
|
||||
#
|
||||
# Declare project
|
||||
#
|
||||
|
||||
# Generate folders for IDE targets (e.g., VisualStudio solutions)
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set(IDE_FOLDER "")
|
||||
|
||||
# Declare project
|
||||
project(${META_PROJECT_NAME}
|
||||
VERSION ${META_VERSION}
|
||||
DESCRIPTION ${META_PROJECT_DESCRIPTION}
|
||||
)
|
||||
|
||||
enable_language(C)
|
||||
enable_language(CXX)
|
||||
|
||||
# Set output directories
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
# Create version file
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/VERSION" "${META_NAME_VERSION}")
|
||||
|
||||
|
||||
#
|
||||
# Project Health Check Setup
|
||||
#
|
||||
|
||||
# Add cmake-init template check cmake targets
|
||||
add_check_template_target(${META_CMAKE_INIT_SHA} ${META_CMAKE_INIT_BRANCH})
|
||||
|
||||
# Configure health check tools
|
||||
enable_cppcheck(ON)
|
||||
enable_clang_tidy(ON)
|
||||
enable_coverage(${OPTION_ENABLE_COVERAGE})
|
||||
|
||||
|
||||
#
|
||||
# Compiler settings and options
|
||||
#
|
||||
|
||||
include(cmake/CompileOptions.cmake)
|
||||
|
||||
|
||||
#
|
||||
# Deployment/installation setup
|
||||
#
|
||||
|
||||
# Get project name
|
||||
set(project ${META_PROJECT_NAME})
|
||||
|
||||
# Check for system dir install
|
||||
set(SYSTEM_DIR_INSTALL FALSE)
|
||||
if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
|
||||
set(SYSTEM_DIR_INSTALL TRUE)
|
||||
endif()
|
||||
|
||||
# Installation paths
|
||||
if(UNIX AND SYSTEM_DIR_INSTALL)
|
||||
# Install into the system (/usr/bin or /usr/local/bin)
|
||||
set(INSTALL_ROOT "share/${project}") # /usr/[local]/share/<project>
|
||||
set(INSTALL_CMAKE "share/${project}/cmake") # /usr/[local]/share/<project>/cmake
|
||||
set(INSTALL_EXAMPLES "share/${project}") # /usr/[local]/share/<project>
|
||||
set(INSTALL_DATA "share/${project}") # /usr/[local]/share/<project>
|
||||
set(INSTALL_BIN "bin") # /usr/[local]/bin
|
||||
set(INSTALL_SHARED "lib") # /usr/[local]/lib
|
||||
set(INSTALL_LIB "lib") # /usr/[local]/lib
|
||||
set(INSTALL_INCLUDE "include") # /usr/[local]/include
|
||||
set(INSTALL_DOC "share/doc/${project}") # /usr/[local]/share/doc/<project>
|
||||
set(INSTALL_SHORTCUTS "share/applications") # /usr/[local]/share/applications
|
||||
set(INSTALL_ICONS "share/pixmaps") # /usr/[local]/share/pixmaps
|
||||
set(INSTALL_INIT "/etc/init") # /etc/init (upstart init scripts)
|
||||
else()
|
||||
# Install into local directory
|
||||
set(INSTALL_ROOT ".") # ./
|
||||
set(INSTALL_CMAKE "cmake") # ./cmake
|
||||
set(INSTALL_EXAMPLES ".") # ./
|
||||
set(INSTALL_DATA ".") # ./
|
||||
set(INSTALL_BIN ".") # ./
|
||||
set(INSTALL_SHARED "lib") # ./lib
|
||||
set(INSTALL_LIB "lib") # ./lib
|
||||
set(INSTALL_INCLUDE "include") # ./include
|
||||
set(INSTALL_DOC "doc") # ./doc
|
||||
set(INSTALL_SHORTCUTS "misc") # ./misc
|
||||
set(INSTALL_ICONS "misc") # ./misc
|
||||
set(INSTALL_INIT "misc") # ./misc
|
||||
endif()
|
||||
|
||||
# Set runtime path
|
||||
set(CMAKE_SKIP_BUILD_RPATH FALSE) # Add absolute path to all dependencies for BUILD
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use CMAKE_INSTALL_RPATH for INSTALL
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # Do NOT add path to dependencies for INSTALL
|
||||
|
||||
if(NOT SYSTEM_DIR_INSTALL)
|
||||
# Find libraries relative to binary
|
||||
if(APPLE)
|
||||
set(EXECUTABLE_INSTALL_RPATH "@loader_path/../../../${INSTALL_LIB}")
|
||||
set(LIBRARY_INSTALL_RPATH "@loader_path/../../../${INSTALL_LIB}")
|
||||
else()
|
||||
set(EXECUTABLE_INSTALL_RPATH "$ORIGIN/${INSTALL_LIB}")
|
||||
set(LIBRARY_INSTALL_RPATH "$ORIGIN")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Project modules
|
||||
#
|
||||
|
||||
add_subdirectory(source)
|
||||
add_subdirectory(docs)
|
||||
add_subdirectory(deploy)
|
||||
|
||||
|
||||
#
|
||||
# Deployment (global project files)
|
||||
#
|
||||
|
||||
# Install version file
|
||||
install(FILES "${PROJECT_BINARY_DIR}/VERSION" DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
|
||||
|
||||
# Install cmake find script for the project
|
||||
install(FILES ${META_PROJECT_NAME}-config.cmake DESTINATION ${INSTALL_ROOT} COMPONENT dev)
|
||||
|
||||
# Install the project meta files
|
||||
install(FILES AUTHORS DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
|
||||
install(FILES LICENSE DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
|
||||
install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
|
||||
|
||||
# Install runtime data
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA} COMPONENT runtime)
|
||||
56
Dockerfile
Normal file
56
Dockerfile
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
ARG BASE=ubuntu:20.04
|
||||
ARG PROJECT_NAME=cmake-init
|
||||
ARG WORKSPACE=/workspace
|
||||
|
||||
# BUILD
|
||||
|
||||
FROM $BASE AS cmake-init-build
|
||||
|
||||
ARG PROJECT_NAME
|
||||
ARG WORKSPACE
|
||||
ARG COMPILER_FLAGS="-j 4"
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update
|
||||
RUN apt install -y --no-install-recommends sudo \
|
||||
&& echo 'user ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/user
|
||||
RUN apt install -y --no-install-recommends cmake git build-essential
|
||||
|
||||
ENV PROJECT_DIR="$WORKSPACE/$PROJECT_NAME"
|
||||
|
||||
WORKDIR $WORKSPACE
|
||||
|
||||
ADD cmake $PROJECT_NAME/cmake
|
||||
ADD docs $PROJECT_NAME/docs
|
||||
ADD data $PROJECT_NAME/data
|
||||
ADD deploy $PROJECT_NAME/deploy
|
||||
ADD source $PROJECT_NAME/source
|
||||
ADD CMakeLists.txt $PROJECT_NAME/CMakeLists.txt
|
||||
ADD configure $PROJECT_NAME/configure
|
||||
ADD template-config.cmake $PROJECT_NAME/template-config.cmake
|
||||
ADD $PROJECT_NAME-logo.png $PROJECT_NAME/$PROJECT_NAME-logo.png
|
||||
ADD $PROJECT_NAME-logo.svg $PROJECT_NAME/$PROJECT_NAME-logo.svg
|
||||
ADD LICENSE $PROJECT_NAME/LICENSE
|
||||
ADD README.md $PROJECT_NAME/README.md
|
||||
ADD AUTHORS $PROJECT_NAME/AUTHORS
|
||||
|
||||
WORKDIR $PROJECT_DIR
|
||||
RUN ./configure
|
||||
RUN CMAKE_OPTIONS="-DOPTION_BUILD_TESTS=Off -DCMAKE_INSTALL_PREFIX=$WORKSPACE/$PROJECT_NAME-install" ./configure
|
||||
RUN cmake --build build -- $COMPILER_FLAGS
|
||||
RUN cmake --build build --target install
|
||||
|
||||
# DEPLOY
|
||||
|
||||
FROM $BASE AS cmake-init
|
||||
|
||||
ARG PROJECT_NAME
|
||||
ARG WORKSPACE
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update
|
||||
RUN apt install -y --no-install-recommends cmake
|
||||
|
||||
COPY --from=cmake-init-build $WORKSPACE/$PROJECT_NAME-install $WORKSPACE/$PROJECT_NAME
|
||||
8
LICENSE
Normal file
8
LICENSE
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
Copyright (c) 2012-2015 Computer Graphics Systems Group at the Hasso-Plattner-Institute, Germany.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
265
README.md
Normal file
265
README.md
Normal file
|
|
@ -0,0 +1,265 @@
|
|||
|
||||
<br><a href="https://github.com/cginternals/cmake-init/"><img src="https://raw.githubusercontent.com/cginternals/cmake-init/master/cmake-init-logo.svg?sanitize=true" width="50%"></a>
|
||||
|
||||
The C++ CMake Project Template
|
||||
|
||||
[](https://travis-ci.org/cginternals/cmake-init)
|
||||
[](https://ci.appveyor.com/project/scheibel/cmake-init/branch/master)
|
||||
[](https://github.com/Aaronepower/tokei)
|
||||
[](https://github.com/cginternals/cmake-init/wiki/Setup-Guide)
|
||||
|
||||
|
||||
*cmake-init* is a sophisticated copy & paste template for modern C and C++ projects.
|
||||
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.
|
||||
|
||||
The main target platforms are typical desktop, laptop, and server platforms. Currently supported are:
|
||||
|
||||
* Windows
|
||||
* macOS
|
||||
* GNU/Linux
|
||||
|
||||
However, other UNIX versions may work as well if they are supported by CMake.
|
||||
|
||||
The cmake-init template assumes you want to setup a project using
|
||||
* CMake (3.20 or above)
|
||||
* C/C++ compiler
|
||||
|
||||
|
||||
# Contents
|
||||
|
||||
* [Usage](#usage)
|
||||
* [Adaption Guide](#adaption-guide)
|
||||
* [Non-Goals](#non-goals)
|
||||
* [Module Documentation](#module-documentation)
|
||||
* [Core Modules](#core-modules)
|
||||
* [CMake Initialization](#cmake-initialization)
|
||||
* [CMake Backward Compatibility](#cmake-backward-compatability)
|
||||
* [Project Meta Information](#project-meta-information)
|
||||
* [Project Meta Information Code Generation](#project-meta-information-code-generation)
|
||||
* [Project Build Options](#project-build-options)
|
||||
* [Maintainer Modules](#maintainer-modules)
|
||||
* [cmake-init Template Check](#cmake-init-template-check)
|
||||
* [Development Modules](#development-modules)
|
||||
* [Version Control System Integration](#version-control-system-integration)
|
||||
* [Build Targets](#build-targets)
|
||||
* [Documentation](#documentation)
|
||||
* [Tests](#tests)
|
||||
* [Linter](#linter)
|
||||
* [Continuous Integration](#continuous-integration)
|
||||
* [Deployment](#deployment)
|
||||
* [Packaging](#packaging)
|
||||
* [Run-time Assets](#run-time-assets)
|
||||
|
||||
# Usage
|
||||
|
||||
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).
|
||||
Another approach is the initialization of a new CMake project where the required features are adopted from cmake-init. We propose the former workflow.
|
||||
|
||||
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.
|
||||
|
||||
## Adaption Guide
|
||||
|
||||
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.
|
||||
|
||||
## Update
|
||||
|
||||
After some time working on a project, cmake-init may be updated and you want to integrate the changes.
|
||||
For an overview of changes we suggest to use the [cmake-init Template Check](#cmake-init-template-check) module.
|
||||
Alternatively, you can update the required modules selectively.
|
||||
|
||||
|
||||
|
||||
# Non-Goals
|
||||
|
||||
In order to be usable in a deterministic, idiomatic fashion, cmake-init avoids the following approaches and features:
|
||||
|
||||
## Super-Build
|
||||
|
||||
Due to the current semantics of targets and CMake internals, combining multiple
|
||||
cmake-init projects into one super-build project is not officially supported.
|
||||
There are limited and restricting workarounds.
|
||||
Actual solution: treat each project separately and use explicit dependency management.
|
||||
|
||||
## High Abstraction
|
||||
|
||||
We use low abstractions to not build a language upon CMake a user has to learn.
|
||||
|
||||
## File Glob
|
||||
|
||||
Explicit source specification prevents erroneous cases when adding and removing
|
||||
sources from the project tree.
|
||||
|
||||
# Module Documentation
|
||||
|
||||
## Core Modules
|
||||
|
||||
### CMake Initialization
|
||||
|
||||
As with most CMake projects, cmake-init initializes the CMake environment. This includes the minimum required CMake version,
|
||||
|
||||
```cmake
|
||||
# CMake version
|
||||
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
||||
```
|
||||
|
||||
required policies,
|
||||
|
||||
```cmake
|
||||
# Set policies
|
||||
set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
|
||||
set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
|
||||
set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.
|
||||
```
|
||||
|
||||
adaption of the cmake module path,
|
||||
|
||||
```cmake
|
||||
# Include cmake modules
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
```
|
||||
|
||||
and an include of default modules that are typically required for each project.
|
||||
|
||||
```cpp
|
||||
include(GenerateExportHeader)
|
||||
include(WriteCompilerDetectionHeader)
|
||||
```
|
||||
|
||||
### Project Meta Information
|
||||
|
||||
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`.
|
||||
|
||||
```cmake
|
||||
#
|
||||
# Project description and (meta) information
|
||||
#
|
||||
|
||||
# Meta information about the project
|
||||
set(META_PROJECT_NAME "template")
|
||||
set(META_PROJECT_DESCRIPTION "CMake Project Template")
|
||||
set(META_AUTHOR_ORGANIZATION "CG Internals GmbH")
|
||||
set(META_AUTHOR_DOMAIN "https://github.com/cginternals/cmake-init/")
|
||||
set(META_AUTHOR_MAINTAINER "opensource@cginternals.com")
|
||||
set(META_VERSION_MAJOR "2")
|
||||
set(META_VERSION_MINOR "0")
|
||||
set(META_VERSION_PATCH "0")
|
||||
set(META_VERSION_REVISION "<REVISION>")
|
||||
set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}")
|
||||
set(META_NAME_VERSION "${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})")
|
||||
set(META_CMAKE_INIT_SHA "<CMAKE_INIT_REVISION>")
|
||||
|
||||
string(MAKE_C_IDENTIFIER ${META_PROJECT_NAME} META_PROJECT_ID)
|
||||
string(TOUPPER ${META_PROJECT_ID} META_PROJECT_ID)
|
||||
```
|
||||
|
||||
*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/).
|
||||
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.
|
||||
|
||||
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).
|
||||
|
||||
|
||||
### Project Meta Information Code Generation
|
||||
|
||||
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.
|
||||
For this, the CMake file configuration feature is used on the `version.h.in` header template.
|
||||
|
||||
```c
|
||||
#define @META_PROJECT_ID@_PROJECT_NAME "@META_PROJECT_NAME@"
|
||||
#define @META_PROJECT_ID@_PROJECT_DESCRIPTION "@META_PROJECT_DESCRIPTION@"
|
||||
|
||||
#define @META_PROJECT_ID@_AUTHOR_ORGANIZATION "@META_AUTHOR_ORGANIZATION@"
|
||||
#define @META_PROJECT_ID@_AUTHOR_DOMAIN "@META_AUTHOR_DOMAIN@"
|
||||
#define @META_PROJECT_ID@_AUTHOR_MAINTAINER "@META_AUTHOR_MAINTAINER@"
|
||||
|
||||
#define @META_PROJECT_ID@_VERSION_MAJOR "@META_VERSION_MAJOR@"
|
||||
#define @META_PROJECT_ID@_VERSION_MINOR "@META_VERSION_MINOR@"
|
||||
#define @META_PROJECT_ID@_VERSION_PATCH "@META_VERSION_PATCH@"
|
||||
#define @META_PROJECT_ID@_VERSION_REVISION "@META_VERSION_REVISION@"
|
||||
|
||||
#define @META_PROJECT_ID@_VERSION "@META_VERSION@"
|
||||
#define @META_PROJECT_ID@_NAME_VERSION "@META_NAME_VERSION@"
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
```cmake
|
||||
# Generate version-header
|
||||
configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_NAME}/${META_PROJECT_NAME}-version.h)
|
||||
```
|
||||
|
||||
We suggest to deploy this header disregarding its internal or even public use.
|
||||
|
||||
```cmake
|
||||
#
|
||||
# Deployment
|
||||
#
|
||||
|
||||
# Deploy generated headers
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_NAME} DESTINATION include COMPONENT dev)
|
||||
```
|
||||
|
||||
|
||||
### Project Build Options
|
||||
|
||||
## Maintainer Modules
|
||||
|
||||
### cmake-init Template Check
|
||||
|
||||
This module allows to check the actuality of the used cmake-init template for own projects.
|
||||
This module is usable when the following is integrated into the `CMakeLists.txt`.
|
||||
|
||||
```cmake
|
||||
# Add cmake-init template check cmake targets
|
||||
add_check_template_target(<CMAKE_INIT_SHA> <CMAKE_INIT_BRANCH>)
|
||||
```
|
||||
|
||||
Here, the `<CMAKE_INIT_SHA>` contains the git hash of the used cmake-init template.
|
||||
Further, the files `cmake/HealthCheck.cmake` and `cmake/CheckTemplate.cmake` are required.
|
||||
|
||||
The hash is usually configured using
|
||||
|
||||
```cmake
|
||||
# Meta information about the project
|
||||
set(META_CMAKE_INIT_SHA "<CMAKE_INIT_SHA>")
|
||||
set(META_CMAKE_INIT_BRANCH "<CMAKE_INIT_BRANCH>")
|
||||
|
||||
# Add cmake-init template check cmake targets
|
||||
add_check_template_target(<CMAKE_INIT_SHA> <CMAKE_INIT_BRANCH>)
|
||||
```
|
||||
|
||||
Correctly configures, this module adds a cmake build target named `check-template` that compares the passed `<CMAKE_INIT_SHA>` with the current master commit hash of this repository and provides a link for a diff view.
|
||||
|
||||
## Development Modules
|
||||
|
||||
### Version Control System Integration
|
||||
|
||||
```cmake
|
||||
# Get git revision
|
||||
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
||||
string(SUBSTRING "${GIT_SHA1}" 0 12 GIT_REV)
|
||||
if(NOT GIT_SHA1)
|
||||
set(GIT_REV "0")
|
||||
endif()
|
||||
```
|
||||
|
||||
### Build Targets
|
||||
|
||||
### Documentation
|
||||
|
||||
### Tests
|
||||
|
||||
Tests are available using the Google testing frameworks `googletest` and `googlemock`.
|
||||
cmake-init assumes an external installment of both frameworks.
|
||||
Typically, package managers of each system provides a sufficient installment.
|
||||
For example, on Ubuntu you can install the `libgmock-dev` package.
|
||||
On macOS using Homebrew, this package is named `googletest
|
||||
|
||||
### Linter
|
||||
|
||||
### Continuous Integration
|
||||
|
||||
### Deployment
|
||||
|
||||
### Packaging
|
||||
|
||||
### Run-time Assets
|
||||
49
appveyor.yml
Normal file
49
appveyor.yml
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
version: '{build}'
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
clone_folder: c:\projects\cmake-init
|
||||
image:
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2017
|
||||
- Visual Studio 2019
|
||||
configuration:
|
||||
- Release
|
||||
- Debug
|
||||
platform:
|
||||
- x64
|
||||
environment:
|
||||
matrix:
|
||||
- arch: Win64
|
||||
# - arch: #does not work, Release|x64 not a valid target
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
# skip unsupported combinations
|
||||
init:
|
||||
- set arch=
|
||||
- if "%arch%"=="Win64" ( set arch= x64)
|
||||
- echo %arch%
|
||||
- echo %APPVEYOR_BUILD_WORKER_IMAGE%
|
||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( set generator="Visual Studio 15 2017" )
|
||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" ( set generator="Visual Studio 14 2015" )
|
||||
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" ( set generator="Visual Studio 16 2019" )
|
||||
- echo %generator%
|
||||
|
||||
before_build:
|
||||
- cmd: |-
|
||||
mkdir build
|
||||
cd build
|
||||
cmake --version
|
||||
cmake .. -G %generator% -A %arch%
|
||||
|
||||
build:
|
||||
project: c:\projects\cmake-init\build\template.sln
|
||||
verbosity: minimal
|
||||
parallel: true
|
||||
only_commits:
|
||||
files:
|
||||
- CMakeLists.txt
|
||||
- appveyor.yml
|
||||
- source/
|
||||
- cmake/
|
||||
BIN
cmake-init-logo.png
Normal file
BIN
cmake-init-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
1
cmake-init-logo.svg
Normal file
1
cmake-init-logo.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 16"><title>cmake-init-logo</title><path d="M17.7518,8.6244A3.5807,3.5807,0,0,1,21.389,4.809a3.13,3.13,0,0,1,2.1289.8135L22.69,6.7318a1.7721,1.7721,0,0,0-1.2124-.5332c-1.1679,0-1.9809.962-1.9809,2.4258,0,1.4483.7983,2.4092,1.937,2.4092a2.4223,2.4223,0,0,0,1.4932-.62l.6948,1.123a3.6239,3.6239,0,0,1-2.3657.8877A3.4543,3.4543,0,0,1,17.7518,8.6244Z" fill="#4d6479"/><path d="M25.055,4.9867h1.4043l.1181.99h.06a3.0692,3.0692,0,0,1,2.2178-1.168,1.9744,1.9744,0,0,1,2.0107,1.3018,3.298,3.298,0,0,1,2.336-1.3018c1.538,0,2.2475,1.05,2.2475,2.8838v4.5537H33.7342V7.9145c0-1.1983-.355-1.6416-1.1089-1.6416a2.2561,2.2561,0,0,0-1.523.9023v5.0713H29.4017V7.9145c0-1.1983-.355-1.6416-1.1236-1.6416a2.2866,2.2866,0,0,0-1.5229.9023v5.0713h-1.7Z" fill="#4d6479"/><path d="M37.1336,10.2943c0-1.5517,1.2866-2.3652,4.2729-2.69-.0293-.7685-.34-1.42-1.3305-1.42a4.1355,4.1355,0,0,0-2.0406.71l-.6206-1.1387a5.676,5.676,0,0,1,2.9864-.9463c1.8042,0,2.706,1.1094,2.706,3.1348v4.3027H41.7024l-.1181-.7988h-.0591a3.5326,3.5326,0,0,1-2.2476.9765A2.03,2.03,0,0,1,37.1336,10.2943Zm4.2729,0V8.6684c-1.9809.2509-2.6318.7685-2.6318,1.4931,0,.65.4439.9317,1.05.9317A2.3062,2.3062,0,0,0,41.4065,10.2943Z" fill="#4d6479"/><path d="M45.1468,1.808h1.67V8.3285h.0444l2.6909-3.3418h1.8633L48.9319,7.9438l2.7354,4.3027H49.8187L47.9559,9.0971l-1.1387,1.3008v1.8486h-1.67Z" fill="#4d6479"/><path d="M52.0511,8.6244A3.5332,3.5332,0,0,1,55.3924,4.809c1.9663,0,3.0014,1.42,3.0014,3.4453a3.965,3.965,0,0,1-.0737.8281H53.7068a2.0781,2.0781,0,0,0,2.1441,2.0254,3.0342,3.0342,0,0,0,1.6855-.5322l.5767,1.0645a4.5767,4.5767,0,0,1-2.4839.7841A3.5007,3.5007,0,0,1,52.0511,8.6244Zm4.8642-.6953c0-1.124-.4878-1.8037-1.4785-1.8037a1.8232,1.8232,0,0,0-1.7446,1.8037Z" fill="#4d6479"/><path d="M15.12,12.2311,10.2325,3.7688,9.011,1.6532,1.6835,14.3467H16.3411Zm-9.772,0L9.0116,5.8838l3.6652,6.3473Z" fill="#4d6479"/><path d="M60.5555,1.6869h1.2671V7.308H60.5555Z" fill="#bbcada"/><path d="M63.15,1.6869h1.3018L65.9168,4.48l.5518,1.2422h.0346c-.0517-.5957-.1553-1.3887-.1553-2.0518V1.6869H67.555V7.308H66.2532L64.7874,4.5063l-.5518-1.2246h-.0341c.0517.621.1547,1.371.1547,2.0351V7.308H63.15Z" fill="#bbcada"/><path d="M68.8816,1.6869h1.2671V7.308H68.8816Z" fill="#bbcada"/><path d="M72.5706,2.7563H71.0267V1.6869H75.389V2.7563H73.846V7.308H72.5706Z" fill="#bbcada"/></svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
53
cmake/CheckTemplate.cmake
Normal file
53
cmake/CheckTemplate.cmake
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
#
|
||||
# Get cmake-init latest commit SHA on master
|
||||
#
|
||||
|
||||
if(NOT APPLIED_CMAKE_INIT_BRANCH)
|
||||
set(APPLIED_CMAKE_INIT_BRANCH "master")
|
||||
endif ()
|
||||
|
||||
file(DOWNLOAD
|
||||
"https://api.github.com/repos/cginternals/cmake-init/commits/${APPLIED_CMAKE_INIT_BRANCH}"
|
||||
"${PROJECT_BINARY_DIR}/cmake-init.github.data"
|
||||
)
|
||||
file(READ
|
||||
"${PROJECT_BINARY_DIR}/cmake-init.github.data"
|
||||
CMAKE_INIT_INFO
|
||||
)
|
||||
|
||||
string(REGEX MATCH
|
||||
"\"sha\": \"([0-9a-f]+)\","
|
||||
CMAKE_INIT_SHA
|
||||
${CMAKE_INIT_INFO})
|
||||
|
||||
string(SUBSTRING
|
||||
${CMAKE_INIT_SHA}
|
||||
8
|
||||
40
|
||||
CMAKE_INIT_SHA
|
||||
)
|
||||
|
||||
#
|
||||
# Get latest cmake-init commit on this repository
|
||||
#
|
||||
|
||||
# APPLIED_CMAKE_INIT_SHA can be set by parent script
|
||||
if(NOT APPLIED_CMAKE_INIT_SHA)
|
||||
# [TODO]: Get from git commit list (see cmake_init/source/scripts/check_template.sh)
|
||||
set(APPLIED_CMAKE_INIT_SHA "")
|
||||
endif ()
|
||||
|
||||
if("${APPLIED_CMAKE_INIT_SHA}" STREQUAL "")
|
||||
message(WARNING
|
||||
"No cmake-init version detected, could not verify up-to-dateness. "
|
||||
"Set the cmake-init version by defining a META_CMAKE_INIT_SHA for your project."
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(${APPLIED_CMAKE_INIT_SHA} STREQUAL ${CMAKE_INIT_SHA})
|
||||
message(STATUS "cmake-init template is up-to-date (${CMAKE_INIT_SHA})")
|
||||
else()
|
||||
message(STATUS "cmake-init template needs an update https://github.com/cginternals/cmake-init/compare/${APPLIED_CMAKE_INIT_SHA}...${APPLIED_CMAKE_INIT_BRANCH}")
|
||||
endif()
|
||||
24
cmake/ClangTidy.cmake
Normal file
24
cmake/ClangTidy.cmake
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
# Function to register a target for clang-tidy
|
||||
function(perform_clang_tidy check_target target)
|
||||
set(includes "$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>")
|
||||
|
||||
add_custom_target(
|
||||
${check_target}
|
||||
COMMAND
|
||||
${clang_tidy_EXECUTABLE}
|
||||
-p\t${PROJECT_BINARY_DIR}
|
||||
${ARGN}
|
||||
-checks=*
|
||||
"$<$<NOT:$<BOOL:${CMAKE_EXPORT_COMPILE_COMMANDS}>>:--\t$<$<BOOL:${includes}>:-I$<JOIN:${includes},\t-I>>>"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set_target_properties(${check_target}
|
||||
PROPERTIES
|
||||
FOLDER "Maintenance"
|
||||
EXCLUDE_FROM_DEFAULT_BUILD 1
|
||||
)
|
||||
|
||||
add_dependencies(${check_target} ${target})
|
||||
endfunction()
|
||||
177
cmake/CompileOptions.cmake
Normal file
177
cmake/CompileOptions.cmake
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
|
||||
#
|
||||
# Platform and architecture setup
|
||||
#
|
||||
|
||||
# Get upper case system name
|
||||
string(TOUPPER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_UPPER)
|
||||
|
||||
# Determine architecture (32/64 bit)
|
||||
set(X64 OFF)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(X64 ON)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Project options
|
||||
#
|
||||
|
||||
set(DEFAULT_PROJECT_OPTIONS
|
||||
DEBUG_POSTFIX "d"
|
||||
CXX_STANDARD 11
|
||||
LINKER_LANGUAGE "CXX"
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
CXX_VISIBILITY_PRESET "hidden"
|
||||
CXX_EXTENSIONS Off
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
|
||||
set(DEFAULT_INCLUDE_DIRECTORIES)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
LIST(APPEND DEFAULT_INCLUDE_DIRECTORIES "/usr/local/include")
|
||||
endif ()
|
||||
|
||||
|
||||
#
|
||||
# Libraries
|
||||
#
|
||||
|
||||
set(DEFAULT_LIBRARIES)
|
||||
|
||||
|
||||
#
|
||||
# Compile definitions
|
||||
#
|
||||
|
||||
set(DEFAULT_COMPILE_DEFINITIONS
|
||||
SYSTEM_${SYSTEM_NAME_UPPER}
|
||||
)
|
||||
|
||||
# MSVC compiler options
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" OR
|
||||
"${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" MATCHES "xMSVC")
|
||||
set(DEFAULT_COMPILE_DEFINITIONS ${DEFAULT_COMPILE_DEFINITIONS}
|
||||
_SCL_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the Standard C++ Library
|
||||
_CRT_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the CRT Library
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
||||
#
|
||||
# Compile options
|
||||
#
|
||||
|
||||
set(DEFAULT_COMPILE_OPTIONS_PRIVATE)
|
||||
set(DEFAULT_COMPILE_OPTIONS_PUBLIC)
|
||||
|
||||
# MSVC compiler options
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
|
||||
set(DEFAULT_COMPILE_OPTIONS_PRIVATE ${DEFAULT_COMPILE_OPTIONS_PRIVATE}
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/MP # -> build with multiple processes
|
||||
>
|
||||
/W4 # -> warning level 4
|
||||
# /WX # -> treat warnings as errors
|
||||
/wd4251 # -> disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2'
|
||||
/wd4592 # -> disable warning: 'identifier': symbol will be dynamically initialized (implementation limitation)
|
||||
# /wd4201 # -> disable warning: nonstandard extension used: nameless struct/union (caused by GLM)
|
||||
/wd4127 # -> disable warning: conditional expression is constant (caused by Qt)
|
||||
|
||||
# /Zm114 # -> Memory size for precompiled headers (insufficient for msvc 2013)
|
||||
/Zm200 # -> Memory size for precompiled headers
|
||||
|
||||
$<$<CXX_COMPILER_ID:Clang>:
|
||||
-Wno-microsoft-cast
|
||||
>
|
||||
|
||||
#$<$<CONFIG:Debug>:
|
||||
#/RTCc # -> value is assigned to a smaller data type and results in a data loss
|
||||
#>
|
||||
|
||||
$<$<CONFIG:Release>:
|
||||
/Gw # -> whole program global optimization
|
||||
/GS- # -> buffer security check: no
|
||||
/GL # -> whole program optimization: enable link-time code generation (disables Zi)
|
||||
/GF # -> enable string pooling
|
||||
>
|
||||
|
||||
# No manual c++11 enable for MSVC as all supported MSVC versions for cmake-init have C++11 implicitly enabled (MSVC >=2013)
|
||||
)
|
||||
endif ()
|
||||
|
||||
# GCC and Clang compiler options
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT MSVC)
|
||||
set(DEFAULT_COMPILE_OPTIONS_PRIVATE ${DEFAULT_COMPILE_OPTIONS_PRIVATE}
|
||||
#-fno-exceptions # since we use stl and stl is intended to use exceptions, exceptions should not be disabled
|
||||
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wunused
|
||||
|
||||
-Wreorder
|
||||
-Wignored-qualifiers
|
||||
-Wmissing-braces
|
||||
-Wreturn-type
|
||||
-Wswitch
|
||||
-Wswitch-default
|
||||
-Wuninitialized
|
||||
-Wmissing-field-initializers
|
||||
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
-Wmaybe-uninitialized
|
||||
|
||||
-Wno-unknown-pragmas
|
||||
|
||||
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.8>:
|
||||
-Wpedantic
|
||||
|
||||
-Wreturn-local-addr
|
||||
>
|
||||
>
|
||||
|
||||
$<$<CXX_COMPILER_ID:Clang>:
|
||||
-Wpedantic
|
||||
|
||||
$<$<PLATFORM_ID:Windows>:
|
||||
-Wno-language-extension-token
|
||||
-Wno-microsoft-cast
|
||||
>
|
||||
|
||||
# -Wreturn-stack-address # gives false positives
|
||||
>
|
||||
)
|
||||
set(DEFAULT_COMPILE_OPTIONS_PUBLIC ${DEFAULT_COMPILE_OPTIONS_PUBLIC}
|
||||
$<$<PLATFORM_ID:Darwin>:
|
||||
-pthread
|
||||
>
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
||||
#
|
||||
# Linker options
|
||||
#
|
||||
|
||||
set(DEFAULT_LINKER_OPTIONS)
|
||||
|
||||
# Use pthreads on mingw and linux
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(DEFAULT_LINKER_OPTIONS ${DEFAULT_LINKER_OPTIONS}
|
||||
PUBLIC
|
||||
-pthread
|
||||
)
|
||||
|
||||
if (${OPTION_COVERAGE_ENABLED})
|
||||
set(DEFAULT_LINKER_OPTIONS ${DEFAULT_LINKER_OPTIONS}
|
||||
PUBLIC
|
||||
-fprofile-arcs
|
||||
-ftest-coverage
|
||||
)
|
||||
endif ()
|
||||
endif()
|
||||
6
cmake/ComponentInstall.cmake
Normal file
6
cmake/ComponentInstall.cmake
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
# Execute cmake_install.cmake wrapper that allows to pass both DESTDIR and COMPONENT environment variable
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=$ENV{COMPONENT} -P cmake_install.cmake
|
||||
)
|
||||
51
cmake/Coverage.cmake
Normal file
51
cmake/Coverage.cmake
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Gcov.cmake)
|
||||
|
||||
set(OPTION_COVERAGE_ENABLED OFF)
|
||||
|
||||
set(LCOV_EXCLUDE_COVERAGE
|
||||
${LCOV_EXCLUDE_COVERAGE}
|
||||
"\"*/googletest/*\""
|
||||
"\"*v1*\""
|
||||
"\"/usr/*\""
|
||||
)
|
||||
|
||||
# Function to register a target for enabled coverage report
|
||||
function(generate_coverage_report target)
|
||||
if(NOT TARGET coverage)
|
||||
add_custom_target(coverage)
|
||||
|
||||
set_target_properties(coverage
|
||||
PROPERTIES
|
||||
FOLDER "Maintenance"
|
||||
EXCLUDE_FROM_DEFAULT_BUILD 1
|
||||
)
|
||||
endif()
|
||||
|
||||
if (${OPTION_COVERAGE_ENABLED})
|
||||
generate_lcov_report(coverage-${target} ${target} ${ARGN})
|
||||
add_dependencies(coverage coverage-${target})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Enable or disable coverage
|
||||
function(enable_coverage status)
|
||||
if(NOT ${status})
|
||||
set(OPTION_COVERAGE_ENABLED ${status} PARENT_SCOPE)
|
||||
message(STATUS "Coverage lcov skipped: Manually disabled")
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(lcov)
|
||||
|
||||
if(NOT lcov_FOUND)
|
||||
set(OPTION_COVERAGE_ENABLED OFF PARENT_SCOPE)
|
||||
message(STATUS "Coverage lcov skipped: lcov not found")
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(OPTION_COVERAGE_ENABLED ${status} PARENT_SCOPE)
|
||||
message(STATUS "Coverage report enabled")
|
||||
endfunction()
|
||||
26
cmake/Cppcheck.cmake
Normal file
26
cmake/Cppcheck.cmake
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
# Function to register a target for cppcheck
|
||||
function(perform_cppcheck check_target target)
|
||||
set(includes "$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>")
|
||||
|
||||
add_custom_target(
|
||||
${check_target}
|
||||
COMMAND
|
||||
${cppcheck_EXECUTABLE}
|
||||
"$<$<BOOL:${includes}>:-I$<JOIN:${includes},\t-I>>"
|
||||
--enable=all
|
||||
--std=c++11
|
||||
--verbose
|
||||
--suppress=missingIncludeSystem
|
||||
${ARGN}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set_target_properties(${check_target}
|
||||
PROPERTIES
|
||||
FOLDER "Maintenance"
|
||||
EXCLUDE_FROM_DEFAULT_BUILD 1
|
||||
)
|
||||
|
||||
add_dependencies(${check_target} ${target})
|
||||
endfunction()
|
||||
46
cmake/Custom.cmake
Normal file
46
cmake/Custom.cmake
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
# Set policy if policy is available
|
||||
function(set_policy POL VAL)
|
||||
|
||||
if(POLICY ${POL})
|
||||
cmake_policy(SET ${POL} ${VAL})
|
||||
endif()
|
||||
|
||||
endfunction(set_policy)
|
||||
|
||||
|
||||
# Define function "source_group_by_path with three mandatory arguments (PARENT_PATH, REGEX, GROUP, ...)
|
||||
# to group source files in folders (e.g. for MSVC solutions).
|
||||
#
|
||||
# Example:
|
||||
# source_group_by_path("${CMAKE_CURRENT_SOURCE_DIR}/src" "\\\\.h$|\\\\.inl$|\\\\.cpp$|\\\\.c$|\\\\.ui$|\\\\.qrc$" "Source Files" ${sources})
|
||||
function(source_group_by_path PARENT_PATH REGEX GROUP)
|
||||
|
||||
foreach (FILENAME ${ARGN})
|
||||
|
||||
get_filename_component(FILEPATH "${FILENAME}" REALPATH)
|
||||
file(RELATIVE_PATH FILEPATH ${PARENT_PATH} ${FILEPATH})
|
||||
get_filename_component(FILEPATH "${FILEPATH}" DIRECTORY)
|
||||
|
||||
string(REPLACE "/" "\\" FILEPATH "${FILEPATH}")
|
||||
|
||||
source_group("${GROUP}\\${FILEPATH}" REGULAR_EXPRESSION "${REGEX}" FILES ${FILENAME})
|
||||
|
||||
endforeach()
|
||||
|
||||
endfunction(source_group_by_path)
|
||||
|
||||
|
||||
# Function that extract entries matching a given regex from a list.
|
||||
# ${OUTPUT} will store the list of matching filenames.
|
||||
function(list_extract OUTPUT REGEX)
|
||||
|
||||
foreach(FILENAME ${ARGN})
|
||||
if(${FILENAME} MATCHES "${REGEX}")
|
||||
list(APPEND ${OUTPUT} ${FILENAME})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(${OUTPUT} ${${OUTPUT}} PARENT_SCOPE)
|
||||
|
||||
endfunction(list_extract)
|
||||
102
cmake/FindASSIMP.cmake
Normal file
102
cmake/FindASSIMP.cmake
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
|
||||
# ASSIMP_FOUND
|
||||
# ASSIMP_INCLUDE_DIR
|
||||
# ASSIMP_LIBRARY_RELEASE
|
||||
# ASSIMP_LIBRARY_DEBUG
|
||||
# ASSIMP_LIBRARIES
|
||||
# ASSIMP_BINARY (win32 only)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(ASSIMP_INCLUDE_DIR assimp/Importer.hpp
|
||||
|
||||
PATHS
|
||||
$ENV{ASSIMP_DIR}
|
||||
$ENV{PROGRAMFILES}/Assimp
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
PATH_SUFFIXES
|
||||
/include
|
||||
|
||||
DOC "The directory where assimp/Importer.hpp etc. resides")
|
||||
|
||||
if(MSVC AND X64)
|
||||
set(ASSIMP_PF "64")
|
||||
else()
|
||||
set(ASSIMP_PF "86")
|
||||
endif()
|
||||
|
||||
find_library(ASSIMP_LIBRARY_RELEASE NAMES assimp
|
||||
|
||||
HINTS
|
||||
${ASSIMP_INCLUDE_DIR}/..
|
||||
|
||||
PATHS
|
||||
$ENV{ASSIMP_DIR}
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
PATH_SUFFIXES
|
||||
/lib
|
||||
/lib${ASSIMP_PF}
|
||||
/build/code
|
||||
/build-debug/code
|
||||
|
||||
DOC "The Assimp library (release)")
|
||||
|
||||
find_library(ASSIMP_LIBRARY_DEBUG NAMES assimpd
|
||||
|
||||
HINTS
|
||||
${ASSIMP_INCLUDE_DIR}/..
|
||||
|
||||
PATHS
|
||||
$ENV{ASSIMP_DIR}
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
PATH_SUFFIXES
|
||||
/lib
|
||||
/lib${ASSIMP_PF}
|
||||
/build/code
|
||||
/build-debug/code
|
||||
|
||||
DOC "The Assimp library (debug)")
|
||||
|
||||
set(ASSIMP_LIBRARIES "")
|
||||
if(ASSIMP_LIBRARY_RELEASE AND ASSIMP_LIBRARY_DEBUG)
|
||||
set(ASSIMP_LIBRARIES
|
||||
optimized ${ASSIMP_LIBRARY_RELEASE}
|
||||
debug ${ASSIMP_LIBRARY_DEBUG})
|
||||
elseif(ASSIMP_LIBRARY_RELEASE)
|
||||
set(ASSIMP_LIBRARIES ${ASSIMP_LIBRARY_RELEASE})
|
||||
elseif(ASSIMP_LIBRARY_DEBUG)
|
||||
set(ASSIMP_LIBRARIES ${ASSIMP_LIBRARY_DEBUG})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
|
||||
find_file(ASSIMP_BINARY NAMES assimp.dll "assimp${ASSIMP_PF}.dll"
|
||||
|
||||
HINTS
|
||||
${ASSIMP_INCLUDE_DIR}/..
|
||||
|
||||
PATHS
|
||||
$ENV{ASSIMP_DIR}
|
||||
|
||||
PATH_SUFFIXES
|
||||
/bin
|
||||
/bin${ASSIMP_PF}
|
||||
|
||||
DOC "The Assimp binary")
|
||||
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(ASSIMP DEFAULT_MSG ASSIMP_LIBRARIES ASSIMP_INCLUDE_DIR)
|
||||
mark_as_advanced(ASSIMP_FOUND ASSIMP_INCLUDE_DIR ASSIMP_LIBRARIES)
|
||||
55
cmake/FindEGL.cmake
Normal file
55
cmake/FindEGL.cmake
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
# EGL::EGL
|
||||
# EGL_FOUND
|
||||
# EGL_INCLUDE_DIR
|
||||
# EGL_LIBRARY
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(EGL_INCLUDE_DIR EGL/egl.h
|
||||
|
||||
PATHS
|
||||
$ENV{EGL_DIR}
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
PATH_SUFFIXES
|
||||
/include
|
||||
|
||||
DOC "The directory where EGL/egl.h resides")
|
||||
|
||||
find_library(EGL_LIBRARY NAMES EGL
|
||||
|
||||
PATHS
|
||||
$ENV{EGL_DIR}
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
# authors prefered choice for development
|
||||
|
||||
PATH_SUFFIXES
|
||||
/lib
|
||||
/lib64
|
||||
/lib/x86_64-linux-gnu
|
||||
|
||||
DOC "The EGL library")
|
||||
|
||||
add_library(EGL::EGL SHARED IMPORTED)
|
||||
|
||||
set_target_properties(EGL::EGL PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES "${EGL_LIBRARY}"
|
||||
)
|
||||
|
||||
set_property(TARGET EGL::EGL APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(EGL::EGL PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${EGL_LIBRARY}"
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(EGL REQUIRED_VARS EGL_INCLUDE_DIR EGL_LIBRARY)
|
||||
mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY)
|
||||
|
||||
79
cmake/FindFFMPEG.cmake
Normal file
79
cmake/FindFFMPEG.cmake
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil)
|
||||
# Once done this will define
|
||||
#
|
||||
# FFMPEG_FOUND - system has ffmpeg or libav
|
||||
# FFMPEG_INCLUDE_DIR - the ffmpeg include directory
|
||||
# FFMPEG_LIBRARIES - Link these to use ffmpeg
|
||||
# FFMPEG_LIBAVCODEC
|
||||
# FFMPEG_LIBAVFORMAT
|
||||
# FFMPEG_LIBAVUTIL
|
||||
# FFMPEG_LIBSWSCALE
|
||||
#
|
||||
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
|
||||
# Modified for other libraries by Lasse Kärkkäinen <tronic>
|
||||
# Modified for Hedgewars by Stepik777
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
#
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
|
||||
# in cache already
|
||||
set(FFMPEG_FOUND TRUE)
|
||||
else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
|
||||
find_path(FFMPEG_AVCODEC_INCLUDE_DIR
|
||||
NAMES libavcodec/avcodec.h
|
||||
PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
|
||||
PATH_SUFFIXES ffmpeg libav
|
||||
)
|
||||
|
||||
find_library(FFMPEG_LIBAVCODEC
|
||||
NAMES avcodec
|
||||
PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
||||
)
|
||||
|
||||
find_library(FFMPEG_LIBAVFORMAT
|
||||
NAMES avformat
|
||||
PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
||||
)
|
||||
|
||||
find_library(FFMPEG_LIBAVUTIL
|
||||
NAMES avutil
|
||||
PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
||||
)
|
||||
|
||||
find_library(FFMPEG_LIBSWSCALE
|
||||
NAMES swscale
|
||||
PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
|
||||
)
|
||||
|
||||
if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
|
||||
set(FFMPEG_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
if (FFMPEG_FOUND)
|
||||
set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})
|
||||
|
||||
set(FFMPEG_LIBRARIES
|
||||
${FFMPEG_LIBAVCODEC}
|
||||
${FFMPEG_LIBAVFORMAT}
|
||||
${FFMPEG_LIBAVUTIL}
|
||||
${FFMPEG_LIBSWSCALE}
|
||||
)
|
||||
|
||||
endif (FFMPEG_FOUND)
|
||||
|
||||
if (FFMPEG_FOUND)
|
||||
if (NOT FFMPEG_FIND_QUIETLY)
|
||||
message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
|
||||
endif (NOT FFMPEG_FIND_QUIETLY)
|
||||
else (FFMPEG_FOUND)
|
||||
if (FFMPEG_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil")
|
||||
endif (FFMPEG_FIND_REQUIRED)
|
||||
endif (FFMPEG_FOUND)
|
||||
|
||||
endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
|
||||
55
cmake/FindGLESv2.cmake
Normal file
55
cmake/FindGLESv2.cmake
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
# GLESv2::GLESv2
|
||||
# GLESv2_FOUND
|
||||
# GLESv2_INCLUDE_DIR
|
||||
# GLESv2_LIBRARY
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(GLESv2_INCLUDE_DIR GLES2/gl2.h
|
||||
|
||||
PATHS
|
||||
$ENV{GLESv2_DIR}
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
PATH_SUFFIXES
|
||||
/include
|
||||
|
||||
DOC "The directory where GLESv2/GLESv2.h resides")
|
||||
|
||||
find_library(GLESv2_LIBRARY NAMES GLESv2
|
||||
|
||||
PATHS
|
||||
$ENV{GLESv2_DIR}
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
# authors prefered choice for development
|
||||
|
||||
PATH_SUFFIXES
|
||||
/lib
|
||||
/lib64
|
||||
/lib/x86_64-linux-gnu
|
||||
|
||||
DOC "The GLESv2 library")
|
||||
|
||||
add_library(GLESv2::GLESv2 SHARED IMPORTED)
|
||||
|
||||
set_target_properties(GLESv2::GLESv2 PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${GLESv2_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES "${GLESv2_LIBRARY}"
|
||||
)
|
||||
|
||||
set_property(TARGET GLESv2::GLESv2 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(GLESv2::GLESv2 PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${GLESv2_LIBRARY}"
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(GLESv2 REQUIRED_VARS GLESv2_INCLUDE_DIR GLESv2_LIBRARY)
|
||||
mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY)
|
||||
|
||||
73
cmake/FindGLEW.cmake
Normal file
73
cmake/FindGLEW.cmake
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
|
||||
# GLEW_FOUND
|
||||
# GLEW_INCLUDE_DIR
|
||||
# GLEW_LIBRARY
|
||||
|
||||
# GLEW_BINARY (win32 only)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(GLEW_INCLUDE_DIR GL/glew.h
|
||||
|
||||
PATHS
|
||||
$ENV{GLEW_DIR}
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
PATH_SUFFIXES
|
||||
/include
|
||||
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
|
||||
if (X64)
|
||||
set(GLEW_BUILD_DIR Release/x64)
|
||||
else()
|
||||
set(GLEW_BUILD_DIR Release/Win32)
|
||||
endif()
|
||||
|
||||
find_library(GLEW_LIBRARY NAMES GLEW glew glew32 glew32s
|
||||
|
||||
PATHS
|
||||
$ENV{GLEW_DIR}
|
||||
/usr
|
||||
/usr/local
|
||||
/sw
|
||||
/opt/local
|
||||
|
||||
# authors prefered choice for development
|
||||
/build
|
||||
/build-release
|
||||
/build-debug
|
||||
$ENV{GLEW_DIR}/build
|
||||
$ENV{GLEW_DIR}/build-release
|
||||
$ENV{GLEW_DIR}/build-debug
|
||||
|
||||
PATH_SUFFIXES
|
||||
/lib
|
||||
/lib64
|
||||
/lib/${GLEW_BUILD_DIR}
|
||||
|
||||
DOC "The GLEW library")
|
||||
|
||||
if(WIN32)
|
||||
|
||||
find_file(GLEW_BINARY NAMES glew32.dll glew32s.dll
|
||||
|
||||
HINTS
|
||||
${GLEW_INCLUDE_DIR}/..
|
||||
|
||||
PATHS
|
||||
$ENV{GLEW_DIR}
|
||||
|
||||
PATH_SUFFIXES
|
||||
/bin
|
||||
/bin/${GLEW_BUILD_DIR}
|
||||
|
||||
DOC "The GLEW binary")
|
||||
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(GLEW REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)
|
||||
mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)
|
||||
32
cmake/FindGTK3.cmake
Normal file
32
cmake/FindGTK3.cmake
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
# GTK3::GTK3
|
||||
# GTK3_FOUND
|
||||
# GTK3_INCLUDE_DIRS
|
||||
# GTK3_LIBRARIES
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(GTK3 QUIET gtk+-3.0)
|
||||
|
||||
if(GTK3_FOUND)
|
||||
|
||||
add_library(GTK3::GTK3 INTERFACE IMPORTED)
|
||||
|
||||
set_target_properties(GTK3::GTK3 PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${GTK3_INCLUDE_DIRS}"
|
||||
)
|
||||
|
||||
set_target_properties(GTK3::GTK3 PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${GTK3_LIBRARIES}"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(GTK3
|
||||
DEFAULT_MSG
|
||||
REQUIRED_VARS
|
||||
GTK3_FOUND
|
||||
)
|
||||
|
||||
mark_as_advanced(GTK3_FOUND GTK3_INCLUDE_DIRS GTK3_LIBRARIES)
|
||||
30
cmake/FindGTK4.cmake
Normal file
30
cmake/FindGTK4.cmake
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
# GTK4::GTK4
|
||||
# GTK4_FOUND
|
||||
# GTK4_INCLUDE_DIRS
|
||||
# GTK4_LIBRARIES
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(GTK4 QUIET IMPORTED_TARGET gtk4)
|
||||
|
||||
set(GTK4_FOUND OFF)
|
||||
|
||||
if(TARGET PkgConfig::GTK4)
|
||||
set(GTK4_FOUND ON)
|
||||
|
||||
add_library(GTK4::GTK4 INTERFACE IMPORTED)
|
||||
|
||||
set_target_properties(GTK4::GTK4 PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES PkgConfig::GTK4
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(GTK4
|
||||
DEFAULT_MSG
|
||||
REQUIRED_VARS
|
||||
GTK4_FOUND
|
||||
)
|
||||
mark_as_advanced(GTK4_FOUND)
|
||||
33
cmake/FindHIDAPI.cmake
Normal file
33
cmake/FindHIDAPI.cmake
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
# HIDAPI_FOUND
|
||||
# HIDAPI_INCLUDE_DIRS
|
||||
# HIDAPI_LIBRARIES
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(HIDAPI_INCLUDE_DIRS
|
||||
NAMES hidapi/hidapi.h
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
DOC "The directory where hidapi/hidapi.h resides")
|
||||
|
||||
find_library(HIDAPI_LIBRARIES
|
||||
NAMES hidapi-hidraw hidapi-libusb
|
||||
PATHS
|
||||
/usr/lib64
|
||||
/usr/local/lib64
|
||||
/sw/lib64
|
||||
/opt/loca/lib64
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
DOC "The hidapi library")
|
||||
|
||||
|
||||
find_package_handle_standard_args(HIDAPI REQUIRED_VARS HIDAPI_LIBRARIES HIDAPI_INCLUDE_DIRS)
|
||||
|
||||
mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY)
|
||||
|
||||
33
cmake/FindSDL2.cmake
Normal file
33
cmake/FindSDL2.cmake
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
# SDL2::SDL2
|
||||
# SDL2_FOUND
|
||||
# SDL2_INCLUDE_DIRS
|
||||
# SDL2_LIBRARIES
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(SDL2 QUIET sdl2)
|
||||
|
||||
if(SDL2_FOUND)
|
||||
|
||||
add_library(SDL2::SDL2 INTERFACE IMPORTED)
|
||||
|
||||
set_target_properties(SDL2::SDL2 PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
|
||||
)
|
||||
|
||||
set_target_properties(SDL2::SDL2 PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${SDL2_LIBRARIES}"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(SDL2
|
||||
DEFAULT_MSG
|
||||
REQUIRED_VARS
|
||||
SDL2_INCLUDE_DIRS
|
||||
SDL2_LIBRARIES
|
||||
)
|
||||
|
||||
mark_as_advanced(SDL2_FOUND SDL2_INCLUDE_DIRS SDL2_LIBRARIES)
|
||||
28
cmake/Findclang_tidy.cmake
Normal file
28
cmake/Findclang_tidy.cmake
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
# Findclang_tidy results:
|
||||
# clang_tidy_FOUND
|
||||
# clang_tidy_EXECUTABLE
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_program(clang_tidy_EXECUTABLE
|
||||
NAMES
|
||||
clang-tidy-3.5
|
||||
clang-tidy-3.6
|
||||
clang-tidy-3.7
|
||||
clang-tidy-3.8
|
||||
clang-tidy-3.9
|
||||
clang-tidy-4.0
|
||||
clang-tidy
|
||||
PATHS
|
||||
"${CLANG_TIDY_DIR}"
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(clang_tidy
|
||||
FOUND_VAR
|
||||
clang_tidy_FOUND
|
||||
REQUIRED_VARS
|
||||
clang_tidy_EXECUTABLE
|
||||
)
|
||||
|
||||
mark_as_advanced(clang_tidy_EXECUTABLE)
|
||||
28
cmake/Findcppcheck.cmake
Normal file
28
cmake/Findcppcheck.cmake
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
# Findcppcheck results:
|
||||
# cppcheck_FOUND
|
||||
# cppcheck_EXECUTABLE
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html
|
||||
set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)")
|
||||
|
||||
find_program(cppcheck_EXECUTABLE
|
||||
NAMES
|
||||
cppcheck
|
||||
PATHS
|
||||
"${CPPCHECK_DIR}"
|
||||
"$ENV{CPPCHECK_DIR}"
|
||||
"$ENV{PROGRAMFILES}/Cppcheck"
|
||||
"$ENV{${PROGRAMFILES_x86_ENV}}/Cppcheck"
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(cppcheck
|
||||
FOUND_VAR
|
||||
cppcheck_FOUND
|
||||
REQUIRED_VARS
|
||||
cppcheck_EXECUTABLE
|
||||
)
|
||||
|
||||
mark_as_advanced(cppcheck_EXECUTABLE)
|
||||
28
cmake/Findgcov.cmake
Normal file
28
cmake/Findgcov.cmake
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
# Findgcov results:
|
||||
# gcov_FOUND
|
||||
# gcov_EXECUTABLE
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html
|
||||
set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)")
|
||||
|
||||
find_program(gcov_EXECUTABLE
|
||||
NAMES
|
||||
gcov
|
||||
PATHS
|
||||
"${GCOV_DIR}"
|
||||
"$ENV{GCOV_DIR}"
|
||||
"$ENV{PROGRAMFILES}/gcov"
|
||||
"$ENV{${PROGRAMFILES_x86_ENV}}/gcov"
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(gcov
|
||||
FOUND_VAR
|
||||
gcov_FOUND
|
||||
REQUIRED_VARS
|
||||
gcov_EXECUTABLE
|
||||
)
|
||||
|
||||
mark_as_advanced(gcov_EXECUTABLE)
|
||||
42
cmake/Findgoogletest.cmake
Normal file
42
cmake/Findgoogletest.cmake
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
# googletest_FOUND
|
||||
# Target googletest::googletest
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
# enable MSVC syntax if required
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
|
||||
set(PKG_CONFIG_ARGN ${PKG_CONFIG_ARGN} "--msvc-syntax")
|
||||
endif()
|
||||
|
||||
pkg_search_module(GMOCK QUIET gmock_main)
|
||||
|
||||
find_package_handle_standard_args(googletest REQUIRED_VARS GMOCK_CFLAGS GMOCK_LDFLAGS)
|
||||
mark_as_advanced(GMOCK_CFLAGS GMOCK_LDFLAGS)
|
||||
|
||||
if (googletest_FOUND)
|
||||
# the linker flags aren't correct for use with target_link_libraries
|
||||
# example: /libpath:[path]/lib.lib;gmock_main.lib;gmock.lib;gtest.lib
|
||||
# note that the path arg falsely includes a .lib suffix
|
||||
# additionally, cmake expects linker flags to start with -
|
||||
# thus, the leading / has to be replaced
|
||||
# example result: -libpath:[path]/lib;gmock_main.lib;gmock.lib;gtest.lib
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
|
||||
string(REGEX REPLACE "(\\/)(libpath[^;]*)(\\.lib)" "-\\2" GMOCK_LDFLAGS "${GMOCK_LDFLAGS}")
|
||||
endif()
|
||||
|
||||
# Create interface library to link against gmock
|
||||
add_library(googletest::googletest INTERFACE IMPORTED)
|
||||
|
||||
target_link_libraries(googletest::googletest
|
||||
INTERFACE
|
||||
${GMOCK_LDFLAGS}
|
||||
)
|
||||
|
||||
target_compile_options(googletest::googletest
|
||||
INTERFACE
|
||||
${GMOCK_CFLAGS}
|
||||
)
|
||||
endif ()
|
||||
42
cmake/Findlcov.cmake
Normal file
42
cmake/Findlcov.cmake
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
# Findlcov results:
|
||||
# lcov_FOUND
|
||||
# lcov_EXECUTABLE
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# work around CMP0053, see http://public.kitware.com/pipermail/cmake/2014-November/059117.html
|
||||
set(PROGRAMFILES_x86_ENV "PROGRAMFILES(x86)")
|
||||
|
||||
find_program(lcov_EXECUTABLE
|
||||
NAMES
|
||||
lcov
|
||||
PATHS
|
||||
"${LCOV_DIR}"
|
||||
"$ENV{LCOV_DIR}"
|
||||
"$ENV{PROGRAMFILES}/lcov"
|
||||
"$ENV{${PROGRAMFILES_x86_ENV}}/lcov"
|
||||
)
|
||||
|
||||
find_program(genhtml_EXECUTABLE
|
||||
NAMES
|
||||
genhtml
|
||||
PATHS
|
||||
"${LCOV_DIR}"
|
||||
"$ENV{LCOV_DIR}"
|
||||
"$ENV{PROGRAMFILES}/lcov"
|
||||
"$ENV{${PROGRAMFILES_x86_ENV}}/lcov"
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(lcov
|
||||
FOUND_VAR
|
||||
lcov_FOUND
|
||||
REQUIRED_VARS
|
||||
lcov_EXECUTABLE
|
||||
genhtml_EXECUTABLE
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
lcov_EXECUTABLE
|
||||
genhtml_EXECUTABLE
|
||||
)
|
||||
58
cmake/Findnodejs.cmake
Normal file
58
cmake/Findnodejs.cmake
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
|
||||
# NODEJS_FOUND
|
||||
# NODEJS_INCLUDE_DIRS
|
||||
# NODEJS_INCLUDE_DIR
|
||||
# NODEJS_LIBUV_INCLUDE_DIR
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(NODEJS_INCLUDE_DIR node.h
|
||||
$ENV{NODEJS_HOME}
|
||||
$ENV{NODEJSDIR}
|
||||
$ENV{NODEJS_HOME}/src
|
||||
$ENV{NODEJSDIR}/src
|
||||
/usr/include/nodejs/src
|
||||
/usr/local/include/nodejs/src
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/usr/local/include/node
|
||||
/opt/local/include
|
||||
DOC "The directory where node.h resides.")
|
||||
|
||||
find_path(NODEJS_LIBUV_INCLUDE_DIR uv.h
|
||||
$ENV{NODEJS_HOME}
|
||||
$ENV{NODEJSDIR}
|
||||
$ENV{NODEJS_HOME}/src
|
||||
$ENV{NODEJSDIR}/src
|
||||
$ENV{NODEJS_HOME}/deps/uv/include
|
||||
$ENV{NODEJSDIR}/deps/uv/include
|
||||
/usr/include/nodejs/deps/uv/include
|
||||
/usr/local/include/nodejs/deps/uv/include
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
/usr/local/include/node
|
||||
DOC "The directory where uv.h resides.")
|
||||
|
||||
find_path(NODEJS_LIBV8_INCLUDE_DIR v8.h
|
||||
$ENV{NODEJS_HOME}
|
||||
$ENV{NODEJSDIR}
|
||||
$ENV{NODEJS_HOME}/src
|
||||
$ENV{NODEJSDIR}/src
|
||||
$ENV{NODEJS_HOME}/deps/v8/include
|
||||
$ENV{NODEJSDIR}/deps/v8/include
|
||||
/usr/include/nodejs/deps/uv/include
|
||||
/usr/local/include/nodejs/deps/uv/include
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
/usr/local/include/node
|
||||
DOC "The directory where v8.h resides.")
|
||||
|
||||
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIR} ${NODEJS_LIBUV_INCLUDE_DIR} ${NODEJS_LIBV8_INCLUDE_DIR})
|
||||
|
||||
find_package_handle_standard_args(NODEJS REQUIRED_VARS NODEJS_INCLUDE_DIRS)
|
||||
mark_as_advanced(NODEJS_INCLUDE_DIRS)
|
||||
104
cmake/Gcov.cmake
Normal file
104
cmake/Gcov.cmake
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
|
||||
#mkdir build/coverage
|
||||
#lcov -d build/source/tests/fiblib-test/CMakeFiles/fiblib-test.dir -c -o build/coverage/fiblib-test.info
|
||||
#genhtml -o build/coverage/html build/coverage/fiblib-test.info
|
||||
|
||||
set(LCOV_EXCLUDE_COVERAGE)
|
||||
|
||||
# Function to register a target for coverage
|
||||
function(generate_lcov_report coverage_target target)
|
||||
if(NOT TARGET coverage-init)
|
||||
add_custom_target(
|
||||
coverage-zero
|
||||
COMMAND
|
||||
${lcov_EXECUTABLE}
|
||||
--zerocounters
|
||||
--base-directory ${CMAKE_BINARY_DIR}
|
||||
--directory ${CMAKE_SOURCE_DIR}
|
||||
-q
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
coverage-init
|
||||
COMMAND
|
||||
${lcov_EXECUTABLE}
|
||||
--no-external
|
||||
--capture
|
||||
--initial
|
||||
--base-directory ${CMAKE_BINARY_DIR}
|
||||
--directory ${CMAKE_SOURCE_DIR}
|
||||
--output-file ${CMAKE_BINARY_DIR}/coverage-base.info
|
||||
-q
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-base.info
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
coverage-info
|
||||
COMMAND
|
||||
${lcov_EXECUTABLE}
|
||||
--capture
|
||||
--no-external
|
||||
--base-directory ${CMAKE_BINARY_DIR}
|
||||
--directory ${CMAKE_SOURCE_DIR}
|
||||
--output-file ${CMAKE_BINARY_DIR}/coverage-captured.info
|
||||
-q
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-captured.info
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
coverage-merge
|
||||
COMMAND
|
||||
${lcov_EXECUTABLE}
|
||||
--add-tracefile ${CMAKE_BINARY_DIR}/coverage-base.info
|
||||
--add-tracefile ${CMAKE_BINARY_DIR}/coverage-captured.info
|
||||
--output-file ${CMAKE_BINARY_DIR}/coverage-merged.info
|
||||
-q
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-merged.info
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
coverage-filter
|
||||
COMMAND
|
||||
${lcov_EXECUTABLE}
|
||||
--base-directory ${CMAKE_BINARY_DIR}
|
||||
--directory ${CMAKE_SOURCE_DIR}
|
||||
--remove ${CMAKE_BINARY_DIR}/coverage-merged.info
|
||||
${LCOV_EXCLUDE_COVERAGE}
|
||||
--output-file ${CMAKE_BINARY_DIR}/coverage-filtered.info
|
||||
-q
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/coverage-filtered.info
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
coverage-report
|
||||
COMMAND
|
||||
${genhtml_EXECUTABLE}
|
||||
--output-directory ${CMAKE_BINARY_DIR}/coverage
|
||||
--title "${META_PROJECT_NAME} Test Coverage"
|
||||
--num-spaces 4
|
||||
${CMAKE_BINARY_DIR}/coverage-filtered.info
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/coverage-filtered.info
|
||||
)
|
||||
|
||||
add_dependencies(coverage-init coverage-zero)
|
||||
#add_dependencies(coverage-info coverage-init)
|
||||
add_dependencies(coverage-merge coverage-info)
|
||||
add_dependencies(coverage-filter coverage-merge)
|
||||
add_dependencies(coverage-report coverage-filter)
|
||||
add_dependencies(coverage coverage-report)
|
||||
endif()
|
||||
|
||||
add_custom_target(${coverage_target}
|
||||
COMMAND $<TARGET_FILE:${target}>
|
||||
)
|
||||
|
||||
add_dependencies(coverage-info ${coverage_target})
|
||||
add_dependencies(${coverage_target} coverage-init)
|
||||
|
||||
endfunction()
|
||||
12
cmake/GenerateTemplateExportHeader.cmake
Normal file
12
cmake/GenerateTemplateExportHeader.cmake
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
# Creates an export header similar to generate_export_header, but for templates.
|
||||
# The main difference is that for MSVC, templates must not get exported.
|
||||
# When the file ${export_file} is included in source code, the macro ${target_id}_TEMPLATE_API
|
||||
# may get used to define public visibility for templates on GCC and Clang platforms.
|
||||
function(generate_template_export_header target target_id export_file)
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
|
||||
configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_msvc_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file})
|
||||
else()
|
||||
configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file})
|
||||
endif()
|
||||
endfunction()
|
||||
130
cmake/GetGitRevisionDescription.cmake
Normal file
130
cmake/GetGitRevisionDescription.cmake
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
# - Returns a version string from Git
|
||||
#
|
||||
# These functions force a re-configure on each git commit so that you can
|
||||
# trust the values of the variables in your build system.
|
||||
#
|
||||
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the source tree, and adjusting
|
||||
# the output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe --exact-match on the source tree,
|
||||
# and adjusting the output so that it tests false if there was no exact
|
||||
# matching tag.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__get_git_revision_description)
|
||||
return()
|
||||
endif()
|
||||
set(__get_git_revision_description YES)
|
||||
|
||||
# We must run the following at "include" time, not at function call time,
|
||||
# to find the path to this module rather than the path to a calling list file
|
||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
function(get_git_head_revision _refspecvar _hashvar)
|
||||
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
||||
# We have reached the root directory, we are not in git
|
||||
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
endwhile()
|
||||
# check if this is a submodule
|
||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||
file(READ ${GIT_DIR} submodule)
|
||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
|
||||
endif()
|
||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||
if(NOT EXISTS "${GIT_DATA}")
|
||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
||||
return()
|
||||
endif()
|
||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
||||
|
||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||
"${GIT_DATA}/grabRef.cmake"
|
||||
@ONLY)
|
||||
include("${GIT_DATA}/grabRef.cmake")
|
||||
|
||||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
||||
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO sanitize
|
||||
#if((${ARGN}" MATCHES "&&") OR
|
||||
# (ARGN MATCHES "||") OR
|
||||
# (ARGN MATCHES "\\;"))
|
||||
# message("Please report the following error to the project!")
|
||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||
#endif()
|
||||
|
||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
describe
|
||||
${hash}
|
||||
${ARGN}
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_exact_tag _var)
|
||||
git_describe(out --exact-match ${ARGN})
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
46
cmake/GetGitRevisionDescription.cmake.in
Normal file
46
cmake/GetGitRevisionDescription.cmake.in
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# Internal file for GetGitRevisionDescription.cmake
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
set(HEAD_HASH)
|
||||
set(HEAD_REF)
|
||||
|
||||
if (NOT EXISTS "@HEAD_FILE@")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||
|
||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||
if(HEAD_CONTENTS MATCHES "ref")
|
||||
# named branch
|
||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
elseif(EXISTS "@GIT_DIR@/packed-refs")
|
||||
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# detached HEAD
|
||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
endif()
|
||||
|
||||
if(NOT HEAD_HASH AND EXISTS "@GIT_DATA@/head-ref")
|
||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||
endif()
|
||||
105
cmake/HealthCheck.cmake
Normal file
105
cmake/HealthCheck.cmake
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Cppcheck.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ClangTidy.cmake)
|
||||
|
||||
set(OPTION_CPPCHECK_ENABLED Off)
|
||||
set(OPTION_CLANG_TIDY_ENABLED Off)
|
||||
|
||||
# Function to register a target for enabled health checks
|
||||
function(perform_health_checks target)
|
||||
if(NOT TARGET check-all)
|
||||
add_custom_target(check-all)
|
||||
|
||||
set_target_properties(check-all
|
||||
PROPERTIES
|
||||
FOLDER "Maintenance"
|
||||
EXCLUDE_FROM_DEFAULT_BUILD 1
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_target(check-${target})
|
||||
|
||||
set_target_properties(check-${target}
|
||||
PROPERTIES
|
||||
FOLDER "Maintenance"
|
||||
EXCLUDE_FROM_DEFAULT_BUILD 1
|
||||
)
|
||||
|
||||
if (OPTION_CPPCHECK_ENABLED)
|
||||
perform_cppcheck(cppcheck-${target} ${target} ${ARGN})
|
||||
add_dependencies(check-${target} cppcheck-${target})
|
||||
endif()
|
||||
|
||||
if (OPTION_CLANG_TIDY_ENABLED)
|
||||
perform_clang_tidy(clang-tidy-${target} ${target} ${ARGN})
|
||||
add_dependencies(check-${target} clang-tidy-${target})
|
||||
endif()
|
||||
|
||||
add_dependencies(check-all check-${target})
|
||||
endfunction()
|
||||
|
||||
# Enable or disable cppcheck for health checks
|
||||
function(enable_cppcheck status)
|
||||
if(NOT ${status})
|
||||
set(OPTION_CPPCHECK_ENABLED ${status} PARENT_SCOPE)
|
||||
message(STATUS "Check cppcheck skipped: Manually disabled")
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(cppcheck)
|
||||
|
||||
if(NOT cppcheck_FOUND)
|
||||
set(OPTION_CPPCHECK_ENABLED Off PARENT_SCOPE)
|
||||
message(STATUS "Check cppcheck skipped: cppcheck not found")
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(OPTION_CPPCHECK_ENABLED ${status} PARENT_SCOPE)
|
||||
message(STATUS "Check cppcheck")
|
||||
endfunction()
|
||||
|
||||
# Enable or disable clang-tidy for health checks
|
||||
function(enable_clang_tidy status)
|
||||
if(NOT ${status})
|
||||
set(OPTION_CLANG_TIDY_ENABLED ${status} PARENT_SCOPE)
|
||||
message(STATUS "Check clang-tidy skipped: Manually disabled")
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(clang_tidy)
|
||||
|
||||
if(NOT clang_tidy_FOUND)
|
||||
set(OPTION_CLANG_TIDY_ENABLED Off PARENT_SCOPE)
|
||||
message(STATUS "Check clang-tidy skipped: clang-tidy not found")
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(OPTION_CLANG_TIDY_ENABLED ${status} PARENT_SCOPE)
|
||||
message(STATUS "Check clang-tidy")
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS On PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Configure cmake target to check for cmake-init template
|
||||
function(add_check_template_target current_template_sha current_template_branch)
|
||||
add_custom_target(
|
||||
check-template
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
|
||||
-DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
|
||||
-DAPPLIED_CMAKE_INIT_SHA=${current_template_sha}
|
||||
-DAPPLIED_CMAKE_INIT_BRANCH=${current_template_branch}
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/CheckTemplate.cmake
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set_target_properties(check-template
|
||||
PROPERTIES
|
||||
FOLDER "Maintenance"
|
||||
EXCLUDE_FROM_DEFAULT_BUILD 1
|
||||
)
|
||||
endfunction()
|
||||
0
cmake/README.md
Normal file
0
cmake/README.md
Normal file
19
cmake/RuntimeDependencies.cmake
Normal file
19
cmake/RuntimeDependencies.cmake
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
#
|
||||
# Default dependencies for the runtime-package
|
||||
#
|
||||
|
||||
# Install 3rd-party runtime dependencies into runtime-component
|
||||
# install(FILES ... COMPONENT runtime)
|
||||
|
||||
|
||||
#
|
||||
# Full dependencies for self-contained packages
|
||||
#
|
||||
|
||||
if(OPTION_SELF_CONTAINED)
|
||||
|
||||
# Install 3rd-party runtime dependencies into runtime-component
|
||||
# install(FILES ... COMPONENT runtime)
|
||||
|
||||
endif()
|
||||
140
configure
vendored
Executable file
140
configure
vendored
Executable file
|
|
@ -0,0 +1,140 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Default options
|
||||
|
||||
BUILD_DIR="build"
|
||||
CMAKE_GENERATOR="Unix Makefiles"
|
||||
BUILD_TYPE="Release"
|
||||
CMAKE_OPTIONS="$CMAKE_OPTIONS"
|
||||
|
||||
# Create default configs
|
||||
if [ ! -d "./.localconfig" ]
|
||||
then
|
||||
mkdir ".localconfig"
|
||||
|
||||
touch ".localconfig/default"
|
||||
echo "#!/bin/bash" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# Default configuration for configure (is always sourced)" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# CMake generator" >> ".localconfig/default"
|
||||
echo "CMAKE_GENERATOR=\"Unix Makefiles\"" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# Build directory and build type" >> ".localconfig/default"
|
||||
echo "BUILD_DIR=\"build\"" >> ".localconfig/default"
|
||||
echo "BUILD_TYPE=\"Release\"" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# Installation directory" >> ".localconfig/default"
|
||||
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=../install\"" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# Build static libraries" >> ".localconfig/default"
|
||||
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF\"" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# Enable examples" >> ".localconfig/default"
|
||||
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_EXAMPLES:BOOL=ON\"" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# Enable documentation" >> ".localconfig/default"
|
||||
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_DOCS:BOOL=ON\"" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# Disable tests" >> ".localconfig/default"
|
||||
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_TESTS:BOOL=OFF\"" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# CMake and environment variables (e.g., search paths for external libraries)" >> ".localconfig/default"
|
||||
echo "" >> ".localconfig/default"
|
||||
echo "# Qt" >> ".localconfig/default"
|
||||
echo "#export CMAKE_PREFIX_PATH=\"\${CMAKE_PREFIX_PATH}:/opt/Qt5.2.1/5.2.1/gcc_64/\"" >> ".localconfig/default"
|
||||
|
||||
touch ".localconfig/debug"
|
||||
echo "#!/bin/bash" >> ".localconfig/debug"
|
||||
echo "" >> ".localconfig/debug"
|
||||
echo "# Configuration for debug builds" >> ".localconfig/debug"
|
||||
echo "" >> ".localconfig/debug"
|
||||
echo "# Build directory and build type" >> ".localconfig/debug"
|
||||
echo "BUILD_DIR=\"\${BUILD_DIR}-debug\"" >> ".localconfig/debug"
|
||||
echo "BUILD_TYPE=\"Debug\"" >> ".localconfig/debug"
|
||||
|
||||
touch ".localconfig/pack"
|
||||
echo "#!/bin/bash" >> ".localconfig/pack"
|
||||
echo "" >> ".localconfig/pack"
|
||||
echo "# Configuration for creating packages" >> ".localconfig/pack"
|
||||
echo "" >> ".localconfig/pack"
|
||||
echo "# Installation directory" >> ".localconfig/pack"
|
||||
echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr\"" >> ".localconfig/pack"
|
||||
echo "" >> ".localconfig/pack"
|
||||
echo "# Enable self-contained installation" >> ".localconfig/pack"
|
||||
echo "#CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_SELF_CONTAINED:BOOL=ON\"" >> ".localconfig/pack"
|
||||
echo "" >> ".localconfig/pack"
|
||||
echo "# Enable all components for the package" >> ".localconfig/pack"
|
||||
echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_EXAMPLES:BOOL=ON\"" >> ".localconfig/pack"
|
||||
echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_DOCS:BOOL=ON\"" >> ".localconfig/pack"
|
||||
echo "CMAKE_OPTIONS=\"\${CMAKE_OPTIONS} -DOPTION_BUILD_TESTS:BOOL=OFF\"" >> ".localconfig/pack"
|
||||
|
||||
echo "Default configuration has been written to .localconfig"
|
||||
echo "Please review and adjust the configuration, then run again"
|
||||
echo ""
|
||||
echo " ./configure $@"
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
# Read local default options
|
||||
if [ -f "./.localconfig/default" ]
|
||||
then
|
||||
. ./.localconfig/default
|
||||
fi
|
||||
|
||||
# Parse command line arguments
|
||||
for ARG in "$@"
|
||||
do
|
||||
# Read in configuration for that command-line argument
|
||||
CONFIGFILE="./.localconfig/$ARG"
|
||||
if [ -f "./.localconfig/$ARG" ]
|
||||
then
|
||||
. "./.localconfig/$ARG"
|
||||
elif [ -f "$HOME/.localconfig/$ARG" ]
|
||||
then
|
||||
. "$HOME/.localconfig/$ARG"
|
||||
else
|
||||
echo "Configuration \"$ARG\" not found (searched in ./.localconfig and ~/.localconfig)"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$CMAKE_GENERATOR_OVERRIDE" != "" ]
|
||||
then
|
||||
echo "Override CMAKE_GENERATOR to $CMAKE_GENERATOR_OVERRIDE"
|
||||
CMAKE_GENERATOR="$CMAKE_GENERATOR_OVERRIDE"
|
||||
fi
|
||||
|
||||
if [ -n "$BUILD_DIR_PREFIX" ]; then
|
||||
BUILD_DIR="${BUILD_DIR_PREFIX}-${BUILD_DIR}"
|
||||
fi
|
||||
|
||||
# Configure build
|
||||
echo "Configuring in \"$BUILD_DIR\""
|
||||
echo ""
|
||||
|
||||
# Create build directory
|
||||
if [ ! -d "$BUILD_DIR" ]
|
||||
then
|
||||
mkdir -p "$BUILD_DIR"
|
||||
fi
|
||||
|
||||
# Configure project
|
||||
|
||||
PREVIOUS_DIR=$(pwd)
|
||||
|
||||
pushd $BUILD_DIR
|
||||
echo cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR"
|
||||
cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR"
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
echo ""
|
||||
echo "Project configured. To build the project, use";
|
||||
echo ""
|
||||
echo " cmake --build $BUILD_DIR"
|
||||
else
|
||||
echo ""
|
||||
echo "Configuration failed.";
|
||||
fi
|
||||
popd
|
||||
10
data/README.md
Normal file
10
data/README.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
This is the runtime data folder for your project.
|
||||
|
||||
Use it only for data that is needed and loaded at runtime by your application.
|
||||
It is installed and shipped during packaging of your application.
|
||||
|
||||
Other data files such as desktop icons, init scripts, or files needed for packaging,
|
||||
belong into the deploy directory.
|
||||
|
||||
Have a look at the cmake-init documentation to learn how your application is able
|
||||
to locate its data folder at runtime.
|
||||
30
deploy/CMakeLists.txt
Normal file
30
deploy/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
#
|
||||
# Target 'pack'
|
||||
#
|
||||
|
||||
add_custom_target(pack)
|
||||
set_target_properties(pack PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
|
||||
|
||||
|
||||
# Install additional runtime dependencies
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/RuntimeDependencies.cmake)
|
||||
|
||||
|
||||
#
|
||||
# Packages
|
||||
#
|
||||
|
||||
include(packages/pack-${META_PROJECT_NAME}.cmake)
|
||||
|
||||
|
||||
#
|
||||
# Target 'component_install'
|
||||
#
|
||||
|
||||
add_custom_target(
|
||||
component_install
|
||||
COMMAND make preinstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/ComponentInstall.cmake
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
16
deploy/README.md
Normal file
16
deploy/README.md
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
# Deployment Types
|
||||
|
||||
## System Install
|
||||
|
||||
## Global Install
|
||||
|
||||
## Source Build
|
||||
|
||||
## Relocatable
|
||||
|
||||
# Packages and Installer
|
||||
|
||||
## Package Manager
|
||||
|
||||
# Components
|
||||
259
deploy/packages/pack-template.cmake
Normal file
259
deploy/packages/pack-template.cmake
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
|
||||
#
|
||||
# Check if cpack is available
|
||||
#
|
||||
|
||||
if(NOT EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Output packages
|
||||
#
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
||||
# Windows installer
|
||||
set(OPTION_PACK_GENERATOR "NSIS;ZIP" CACHE STRING "Package targets")
|
||||
set(PACK_COMPONENT_INSTALL ON)
|
||||
set(PACK_INCLUDE_TOPDIR OFF)
|
||||
elseif(UNIX AND SYSTEM_DIR_INSTALL)
|
||||
# System installation packages for unix systems
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set(OPTION_PACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "Package targets")
|
||||
set(PACK_COMPONENT_INSTALL ON)
|
||||
set(PACK_INCLUDE_TOPDIR OFF)
|
||||
else()
|
||||
set(OPTION_PACK_GENERATOR "TGZ" CACHE STRING "Package targets")
|
||||
set(PACK_COMPONENT_INSTALL OFF)
|
||||
set(PACK_INCLUDE_TOPDIR OFF)
|
||||
endif()
|
||||
#elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||
# MacOS X disk image
|
||||
# At the moment, DMG generator and CPACK_INCLUDE_TOPLEVEL_DIRECTORY=ON do not work together.
|
||||
# Therefore, we disable dmg images for MacOS until we've found a solution
|
||||
# set(OPTION_PACK_GENERATOR "DragNDrop" CACHE STRING "Package targets")
|
||||
# set(PACK_COMPONENT_INSTALL OFF)
|
||||
# set(PACK_INCLUDE_TOPDIR ON)
|
||||
else()
|
||||
# Default (portable package for any platform)
|
||||
set(OPTION_PACK_GENERATOR "ZIP;TGZ" CACHE STRING "Package targets")
|
||||
set(PACK_COMPONENT_INSTALL OFF)
|
||||
set(PACK_INCLUDE_TOPDIR ON)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Package components
|
||||
#
|
||||
|
||||
set(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "${META_PROJECT_NAME} library")
|
||||
set(CPACK_COMPONENT_RUNTIME_DESCRIPTION "Runtime components for ${META_PROJECT_NAME} library")
|
||||
|
||||
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "C/C++ development files")
|
||||
set(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for ${META_PROJECT_NAME} library")
|
||||
set(CPACK_COMPONENT_DEV_DEPENDS runtime)
|
||||
|
||||
set(CPACK_COMPONENTS_ALL runtime dev)
|
||||
|
||||
if (OPTION_BUILD_EXAMPLES)
|
||||
set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example applications")
|
||||
set(CPACK_COMPONENT_EXAMPLES_DESCRIPTION "Example applications for ${META_PROJECT_NAME} library")
|
||||
set(CPACK_COMPONENT_EXAMPLES_DEPENDS runtime)
|
||||
|
||||
set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} examples)
|
||||
endif()
|
||||
|
||||
if (OPTION_BUILD_DOCS)
|
||||
set(CPACK_COMPONENT_DOCS_DISPLAY_NAME "Documentation")
|
||||
set(CPACK_COMPONENT_DOCS_DESCRIPTION "Documentation of ${META_PROJECT_NAME} library")
|
||||
|
||||
set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} docs)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Initialize CPack
|
||||
#
|
||||
|
||||
# Reset CPack configuration
|
||||
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
set(CPACK_IGNORE_FILES "")
|
||||
set(CPACK_INSTALLED_DIRECTORIES "")
|
||||
set(CPACK_SOURCE_IGNORE_FILES "")
|
||||
set(CPACK_SOURCE_INSTALLED_DIRECTORIES "")
|
||||
set(CPACK_STRIP_FILES "")
|
||||
set(CPACK_SOURCE_TOPLEVEL_TAG "")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "")
|
||||
set(CPACK_PACKAGE_RELOCATABLE OFF)
|
||||
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ${PACK_INCLUDE_TOPDIR})
|
||||
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY ${PACK_INCLUDE_TOPDIR})
|
||||
endif()
|
||||
|
||||
# Find cpack executable
|
||||
get_filename_component(CPACK_PATH ${CMAKE_COMMAND} PATH)
|
||||
set(CPACK_COMMAND "${CPACK_PATH}/cpack")
|
||||
|
||||
# Set install prefix
|
||||
if(SYSTEM_DIR_INSTALL)
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
else()
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "")
|
||||
endif()
|
||||
|
||||
# Package project
|
||||
set(project_name ${META_PROJECT_NAME}) # Name of package project
|
||||
set(project_root ${META_PROJECT_NAME}) # Name of root project that is to be installed
|
||||
|
||||
# Package information
|
||||
string(TOLOWER ${META_PROJECT_NAME} package_name)
|
||||
set(package_description ${META_PROJECT_DESCRIPTION})
|
||||
set(package_vendor ${META_AUTHOR_ORGANIZATION})
|
||||
set(package_maintainer ${META_AUTHOR_MAINTAINER})
|
||||
|
||||
# Package specific options
|
||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/deploy/packages/${project_name})
|
||||
|
||||
|
||||
#
|
||||
# Package information
|
||||
#
|
||||
|
||||
set(CPACK_PACKAGE_NAME "${package_name}")
|
||||
set(CPACK_PACKAGE_VENDOR "${package_vendor}")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${package_description}")
|
||||
set(CPACK_PACKAGE_VERSION "${META_VERSION}")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${META_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${META_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${META_VERSION_PATCH}")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
|
||||
set(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/README.md")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
|
||||
set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake-init-logo.png")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${package_name}-${CPACK_PACKAGE_VERSION}")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${package_name}")
|
||||
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${package_name}")
|
||||
|
||||
|
||||
#
|
||||
# NSIS package
|
||||
#
|
||||
|
||||
# Fix icon path
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows" AND CPACK_PACKAGE_ICON)
|
||||
# NOTE: for using MUI (UN)WELCOME images we suggest to replace nsis defaults,
|
||||
# since there is currently no way to do so without manipulating the installer template (which we won't).
|
||||
# http://public.kitware.com/pipermail/cmake-developers/2013-January/006243.html
|
||||
|
||||
# SO the following only works for the installer icon, not for the welcome image.
|
||||
|
||||
# NSIS requires "\\" - escaped backslash to work properly. We probably won't rely on this feature,
|
||||
# so just replacing / with \\ manually.
|
||||
|
||||
#file(TO_NATIVE_PATH "${CPACK_PACKAGE_ICON}" CPACK_PACKAGE_ICON)
|
||||
string(REGEX REPLACE "/" "\\\\\\\\" CPACK_PACKAGE_ICON "${CPACK_PACKAGE_ICON}")
|
||||
endif()
|
||||
|
||||
# Fix installation path for x64 builds
|
||||
if(X64)
|
||||
# http://public.kitware.com/Bug/view.php?id=9094
|
||||
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
|
||||
endif()
|
||||
|
||||
# Package options
|
||||
#set(CPACK_NSIS_DISPLAY_NAME "${package_name}-${META_VERSION}")
|
||||
#set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/deploy/images/logo.ico")
|
||||
#set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/deploy/images/logo.ico")
|
||||
|
||||
# Optional Preliminaries (i.e., silent Visual Studio Redistributable install)
|
||||
if(NOT INSTALL_MSVC_REDIST_FILEPATH)
|
||||
set(INSTALL_MSVC_REDIST_FILEPATH "" CACHE FILEPATH "Visual C++ Redistributable Installer (note: manual match the selected generator)" FORCE)
|
||||
endif()
|
||||
|
||||
if(EXISTS ${INSTALL_MSVC_REDIST_FILEPATH})
|
||||
get_filename_component(MSVC_REDIST_NAME ${INSTALL_MSVC_REDIST_FILEPATH} NAME)
|
||||
string(REGEX REPLACE "/" "\\\\\\\\" INSTALL_MSVC_REDIST_FILEPATH ${INSTALL_MSVC_REDIST_FILEPATH})
|
||||
list(APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
|
||||
SetOutPath \\\"$TEMP\\\"
|
||||
File \\\"${INSTALL_MSVC_REDIST_FILEPATH}\\\"
|
||||
ExecWait '\\\"$TEMP\\\\${MSVC_REDIST_NAME} /quiet\\\"'
|
||||
Delete \\\"$TEMP\\\\${MSVC_REDIST_NAME}\\\"
|
||||
")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Debian package
|
||||
#
|
||||
|
||||
set(CPACK_DEBIAN_PACKAGE_NAME "${package_name}")
|
||||
set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all")
|
||||
#set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12)")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${package_maintainer}")
|
||||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
|
||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
#set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "")
|
||||
#set(CPACK_DEBIAN_PACKAGE_SUGGESTS "")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "")
|
||||
set(CPACK_DEB_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL})
|
||||
|
||||
|
||||
#
|
||||
# RPM package
|
||||
#
|
||||
|
||||
set(CPACK_RPM_PACKAGE_NAME "${package_name}")
|
||||
set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||
set(CPACK_RPM_PACKAGE_RELEASE 1)
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES "")
|
||||
set(CPACK_RPM_PACKAGE_PROVIDES "")
|
||||
set(CPACK_RPM_PACKAGE_VENDOR "${package_vendor}")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
|
||||
set(CPACK_RPM_PACKAGE_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
|
||||
set(CPACK_RPM_PACKAGE_DESCRIPTION "")
|
||||
set(CPACK_RPM_PACKAGE_GROUP "unknown")
|
||||
#set(CPACK_RPM_SPEC_INSTALL_POST "")
|
||||
#set(CPACK_RPM_SPEC_MORE_DEFINE "")
|
||||
#set(CPACK_RPM_USER_BINARY_SPECFILE "")
|
||||
#set(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE "")
|
||||
#set(CPACK_RPM_<POST/PRE>_<UN>INSTALL_SCRIPT_FILE "")
|
||||
#set(CPACK_RPM_PACKAGE_DEBUG 1)
|
||||
set(CPACK_RPM_PACKAGE_RELOCATABLE OFF)
|
||||
set(CPACK_RPM_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL})
|
||||
|
||||
|
||||
#
|
||||
# Archives (zip, tgz, ...)
|
||||
#
|
||||
|
||||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ${PACK_COMPONENT_INSTALL})
|
||||
|
||||
|
||||
#
|
||||
# Execute CPack
|
||||
#
|
||||
|
||||
set(CPACK_OUTPUT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackConfig-${project_name}.cmake")
|
||||
set(CPACK_GENERATOR "${OPTION_PACK_GENERATOR}")
|
||||
set(CPack_CMake_INCLUDED FALSE)
|
||||
include(CPack)
|
||||
|
||||
|
||||
#
|
||||
# Package target
|
||||
#
|
||||
|
||||
# Create target
|
||||
add_custom_target(
|
||||
pack-${project_name}
|
||||
COMMAND ${CPACK_COMMAND} --config ${PROJECT_BINARY_DIR}/CPackConfig-${project_name}.cmake -C $<CONFIG>
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
set_target_properties(pack-${project_name} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
|
||||
|
||||
# Set dependencies
|
||||
add_dependencies(pack pack-${project_name})
|
||||
6
deploy/ubuntu-ppa/debian/changelog
Normal file
6
deploy/ubuntu-ppa/debian/changelog
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
cmake-init (2.0.0-0) UNRELEASED; urgency=low
|
||||
|
||||
* Initial release.
|
||||
|
||||
-- Willy Scheibel <willy.scheibel@cginternals.com> Tue, 31 Jan 2017 13:30:00 +0100
|
||||
1
deploy/ubuntu-ppa/debian/compat
Normal file
1
deploy/ubuntu-ppa/debian/compat
Normal file
|
|
@ -0,0 +1 @@
|
|||
9
|
||||
46
deploy/ubuntu-ppa/debian/control
Normal file
46
deploy/ubuntu-ppa/debian/control
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
Source: cmake-init
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Maintainer: Willy Scheibel <willy.scheibel@cginternals.com>
|
||||
Build-Depends: build-essential, cmake, qtbase5-dev, doxygen, graphviz
|
||||
Standards-Version: 3.8.0
|
||||
|
||||
Package: libcmake-init
|
||||
Architecture: any
|
||||
Depends:
|
||||
Homepage: https://github.com/cginternals/cmake-init
|
||||
Description: Template for reliable, cross-platform C++ project setup using cmake.
|
||||
|
||||
Package: libcmake-init-dev
|
||||
Architecture: any
|
||||
Depends: libcmake-init
|
||||
Homepage: https://github.com/cginternals/cmake-init
|
||||
Description: Template for reliable, cross-platform C++ project setup using cmake.
|
||||
|
||||
Package: libcmake-init-examples-data
|
||||
Architecture: any
|
||||
Homepage: https://github.com/cginternals/cmake-init
|
||||
Description: Template for reliable, cross-platform C++ project setup using cmake.
|
||||
|
||||
Package: libcmake-init-examples
|
||||
Architecture: any
|
||||
Depends: libcmake-init, libcmake-init-examples-data, libqt5core5a
|
||||
Homepage: https://github.com/cginternals/cmake-init
|
||||
Description: Template for reliable, cross-platform C++ project setup using cmake.
|
||||
|
||||
Package: libcmake-init-docs
|
||||
Architecture: any
|
||||
Homepage: https://github.com/cginternals/cmake-init
|
||||
Description: Template for reliable, cross-platform C++ project setup using cmake.
|
||||
|
||||
Package: libcmake-init-dbg
|
||||
Architecture: any
|
||||
Depends: libcmake-init, libcmake-init-dev
|
||||
Homepage: https://github.com/cginternals/cmake-init
|
||||
Description: Template for reliable, cross-platform C++ project setup using cmake.
|
||||
|
||||
Package: libcmake-init-all
|
||||
Architecture: any
|
||||
Depends: libcmake-init, libcmake-init-dev, libcmake-init-docs, libcmake-init-examples
|
||||
Homepage: https://github.com/cginternals/cmake-init
|
||||
Description: Template for reliable, cross-platform C++ project setup using cmake.
|
||||
18
deploy/ubuntu-ppa/debian/copyright
Normal file
18
deploy/ubuntu-ppa/debian/copyright
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
This package was debianised by Willy Scheibel <willy.scheibel@cginternals.com> on
|
||||
Tue, 31 Jan 2017 13:30:00 +0100
|
||||
|
||||
It was downloaded from:
|
||||
|
||||
https://github.com/cginternals/cmake-init
|
||||
|
||||
Upstream Author:
|
||||
|
||||
CG Internals
|
||||
|
||||
Copyright:
|
||||
|
||||
Copyright (c) 2015-2025 CG Internals GmbH and Computer Graphics Systems Group at the Hasso-Plattner-Institute, Germany.
|
||||
|
||||
License:
|
||||
|
||||
This software is available to you under the terms of the MIT license, see "https://github.com/cginternals/cmake-init/blob/master/LICENSE".
|
||||
83
deploy/ubuntu-ppa/debian/rules
Normal file
83
deploy/ubuntu-ppa/debian/rules
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
BUILDDIR = build
|
||||
BUILDDEBUGDIR = build-debug
|
||||
|
||||
# firstly called by launchpad
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)
|
||||
rm -rf $(BUILDDEBUGDIR)
|
||||
|
||||
# secondly called by launchpad
|
||||
build: build-arch
|
||||
|
||||
build-arch:
|
||||
mkdir $(BUILDDIR)
|
||||
cd $(BUILDDIR);cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DOPTION_BUILD_TESTS=Off -DOPTION_BUILD_EXAMPLES=On -DOPTION_BUILD_DOCS=On ..
|
||||
make -C $(BUILDDIR)
|
||||
mkdir $(BUILDDEBUGDIR)
|
||||
cd $(BUILDDEBUGDIR);cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr -DOPTION_BUILD_TESTS=Off -DOPTION_BUILD_EXAMPLES=Off -DOPTION_BUILD_DOCS=Off ..
|
||||
make -C $(BUILDDEBUGDIR)
|
||||
|
||||
# thirdly called by launchpad
|
||||
binary: binary-arch
|
||||
|
||||
binary-arch: libcmake-init libcmake-init-dev libcmake-init-docs libcmake-init-dbg libcmake-init-examples-data libcmake-init-examples libcmake-init-all
|
||||
|
||||
libcmake-init: build
|
||||
cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=runtime make component_install
|
||||
mkdir -p debian/tmp/DEBIAN
|
||||
dpkg-gencontrol -plibcmake-init
|
||||
dpkg --build debian/tmp ..
|
||||
rm -rf debian/tmp
|
||||
|
||||
libcmake-init-dev: build
|
||||
cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=dev make component_install
|
||||
mkdir -p debian/tmp/DEBIAN
|
||||
dpkg-gencontrol -plibcmake-init-dev
|
||||
dpkg --build debian/tmp ..
|
||||
rm -rf debian/tmp
|
||||
|
||||
libcmake-init-docs: build
|
||||
cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=docs make component_install
|
||||
mkdir -p debian/tmp/DEBIAN
|
||||
dpkg-gencontrol -plibcmake-init-docs
|
||||
dpkg --build debian/tmp ..
|
||||
rm -rf debian/tmp
|
||||
|
||||
libcmake-init-dbg: build
|
||||
cd $(BUILDDEBUGDIR); DESTDIR=../debian/tmp COMPONENT=runtime make component_install
|
||||
cd $(BUILDDEBUGDIR); DESTDIR=../debian/tmp COMPONENT=dev make component_install
|
||||
rm -rf debian/tmp/usr/include
|
||||
rm debian/tmp/usr/share/*/*-config.cmake
|
||||
rm debian/tmp/usr/share/*/AUTHORS
|
||||
rm debian/tmp/usr/share/*/LICENSE
|
||||
rm debian/tmp/usr/share/*/README.md
|
||||
rm debian/tmp/usr/share/*/VERSION
|
||||
rm debian/tmp/usr/share/*/cmake/*/*-export.cmake
|
||||
mkdir -p debian/tmp/DEBIAN
|
||||
dpkg-gencontrol -plibcmake-init-dbg
|
||||
dpkg --build debian/tmp ..
|
||||
rm -rf debian/tmp
|
||||
|
||||
libcmake-init-examples-data: build
|
||||
cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=examples_data make component_install
|
||||
mkdir -p debian/tmp/DEBIAN
|
||||
dpkg-gencontrol -plibcmake-init-examples-data
|
||||
dpkg --build debian/tmp ..
|
||||
rm -rf debian/tmp
|
||||
|
||||
libcmake-init-examples: build
|
||||
cd $(BUILDDIR); DESTDIR=../debian/tmp COMPONENT=examples_qt make component_install
|
||||
mkdir -p debian/tmp/DEBIAN
|
||||
dpkg-gencontrol -plibcmake-init-examples
|
||||
dpkg --build debian/tmp ..
|
||||
rm -rf debian/tmp
|
||||
|
||||
libcmake-init-all: build
|
||||
mkdir -p debian/tmp/DEBIAN
|
||||
dpkg-gencontrol -plibcmake-init-all
|
||||
dpkg --build debian/tmp ..
|
||||
rm -rf debian/tmp
|
||||
|
||||
.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
|
||||
1
deploy/ubuntu-ppa/debian/source/format
Normal file
1
deploy/ubuntu-ppa/debian/source/format
Normal file
|
|
@ -0,0 +1 @@
|
|||
3.0 (native)
|
||||
3
deploy/ubuntu-ppa/recipe.txt
Normal file
3
deploy/ubuntu-ppa/recipe.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# git-build-recipe format 0.4 deb-version {debupstream}+{revno}
|
||||
lp:cmake-init
|
||||
nest-part packaging lp:cmake-init deploy/ubuntu-ppa/debian debian master
|
||||
18
docs/CMakeLists.txt
Normal file
18
docs/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
#
|
||||
# Target 'docs'
|
||||
#
|
||||
|
||||
if(NOT OPTION_BUILD_DOCS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_custom_target(docs)
|
||||
|
||||
|
||||
#
|
||||
# Documentation
|
||||
#
|
||||
|
||||
add_subdirectory(api-docs)
|
||||
add_subdirectory(manual)
|
||||
0
docs/README.md
Normal file
0
docs/README.md
Normal file
59
docs/api-docs/CMakeLists.txt
Normal file
59
docs/api-docs/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
#
|
||||
# Find doxygen
|
||||
#
|
||||
|
||||
find_package(Doxygen)
|
||||
if(NOT DOXYGEN_FOUND)
|
||||
message(STATUS "Disabled generation of doxygen documentation (missing doxygen).")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Target name
|
||||
#
|
||||
|
||||
set(target api-docs)
|
||||
message(STATUS "Doc ${target}")
|
||||
|
||||
|
||||
#
|
||||
# Configure Doxygen
|
||||
#
|
||||
|
||||
set(DOXYGEN_QUIET YES)
|
||||
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${PROJECT_SOURCE_DIR}/README.md)
|
||||
set(DOXYGEN_PROJECT_LOGO ${PROJECT_SOURCE_DIR}/cmake-init-logo.png) # TODO replace by ${META_PROJECT_NAME}-logo.png
|
||||
set(DOXYGEN_USE_MATHJAX YES)
|
||||
set(DOXYGEN_EXTRACT_ALL YES)
|
||||
set(DOXYGEN_EXTRACT_LOCAL_CLASSES NO)
|
||||
|
||||
|
||||
#
|
||||
# Create Target
|
||||
#
|
||||
|
||||
doxygen_add_docs(${target}
|
||||
${PROJECT_SOURCE_DIR}/README.md
|
||||
# library headers
|
||||
${PROJECT_SOURCE_DIR}/source/baselib/include
|
||||
${PROJECT_SOURCE_DIR}/source/fiblib/include
|
||||
# generated headers
|
||||
${CMAKE_BINARY_DIR}/source/include
|
||||
${CMAKE_BINARY_DIR}/source/baselib/include
|
||||
${CMAKE_BINARY_DIR}/source/fiblib/include
|
||||
ALL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
add_dependencies(docs ${target})
|
||||
|
||||
|
||||
#
|
||||
# Deployment
|
||||
#
|
||||
|
||||
install(
|
||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||
DESTINATION ${INSTALL_DOC}
|
||||
COMPONENT docs
|
||||
)
|
||||
57
docs/manual/CMakeLists.txt
Normal file
57
docs/manual/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
#
|
||||
# Find LaTeX
|
||||
#
|
||||
|
||||
find_package(LATEX)
|
||||
if(NOT LATEX_FOUND)
|
||||
message(STATUS "Disabled generation of documentation (missing LaTeX).")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Target name
|
||||
#
|
||||
|
||||
set(target docs-manual)
|
||||
message(STATUS "Doc ${target}")
|
||||
|
||||
|
||||
#
|
||||
# Input and output files
|
||||
#
|
||||
|
||||
set(source "${CMAKE_CURRENT_SOURCE_DIR}/cmake-init.tex")
|
||||
set(pdf "${CMAKE_CURRENT_BINARY_DIR}/cmake-init.pdf")
|
||||
|
||||
|
||||
#
|
||||
# Create documentation
|
||||
#
|
||||
|
||||
# Invoke LaTeX
|
||||
add_custom_command(
|
||||
OUTPUT ${pdf}
|
||||
DEPENDS ${source}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
COMMAND ${PDFLATEX_COMPILER} \"${source}\"
|
||||
COMMAND ${PDFLATEX_COMPILER} \"${source}\"
|
||||
COMMAND ${PDFLATEX_COMPILER} \"${source}\"
|
||||
COMMENT "Creating LaTeX documentation."
|
||||
)
|
||||
|
||||
# Declare target
|
||||
add_custom_target(${target} ALL DEPENDS ${pdf})
|
||||
add_dependencies(docs ${target})
|
||||
|
||||
|
||||
#
|
||||
# Deployment
|
||||
#
|
||||
|
||||
# PDF file
|
||||
install(FILES ${pdf}
|
||||
DESTINATION "${INSTALL_DOC}"
|
||||
COMPONENT docs
|
||||
)
|
||||
36
docs/manual/cmake-init.tex
Normal file
36
docs/manual/cmake-init.tex
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
\documentclass{article}
|
||||
|
||||
\usepackage[pdfborder={0 0 0}]{hyperref}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\title{cmake-init: C++ CMake Project Template}
|
||||
|
||||
\maketitle
|
||||
|
||||
\begin{abstract}
|
||||
\noindent
|
||||
cmake-init is a copy and paste template, that provides the following features:
|
||||
|
||||
\begin{itemize}
|
||||
\item Cross Platform
|
||||
\begin{itemize}
|
||||
\item Windows
|
||||
\item Linux
|
||||
\item Mac
|
||||
\end{itemize}
|
||||
\item Libraries, Applications, Testing template
|
||||
\item Documentation template
|
||||
\item Installation, Packaging template
|
||||
\item CMake find script template for defined libraries
|
||||
\end{itemize}
|
||||
|
||||
\end{abstract}
|
||||
|
||||
\setcounter{tocdepth}{2}
|
||||
\tableofcontents
|
||||
|
||||
\newpage
|
||||
|
||||
\end{document}
|
||||
35
source/CMakeLists.txt
Normal file
35
source/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
#
|
||||
# Configuration for all sub-projects
|
||||
#
|
||||
|
||||
# Generate version-header
|
||||
configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_NAME}/${META_PROJECT_NAME}-version.h)
|
||||
|
||||
|
||||
#
|
||||
# Sub-projects
|
||||
#
|
||||
|
||||
# Libraries
|
||||
set(IDE_FOLDER "")
|
||||
add_subdirectory(baselib)
|
||||
add_subdirectory(fiblib)
|
||||
|
||||
# Examples
|
||||
set(IDE_FOLDER "Examples")
|
||||
add_subdirectory(examples)
|
||||
|
||||
# Tests
|
||||
if(OPTION_BUILD_TESTS)
|
||||
set(IDE_FOLDER "Tests")
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Deployment
|
||||
#
|
||||
|
||||
# Deploy generated headers
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_NAME} DESTINATION include COMPONENT dev)
|
||||
38
source/README.md
Normal file
38
source/README.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
# Target Types
|
||||
|
||||
## Command-line Executable
|
||||
|
||||
## GUI Executable
|
||||
|
||||
## Flexible Library
|
||||
|
||||
## Shared Library
|
||||
|
||||
## Static Library
|
||||
|
||||
## Plugin
|
||||
|
||||
## Header-only Library
|
||||
|
||||
## Virtual Library
|
||||
|
||||
## CMake-only Library
|
||||
|
||||
# Dependencies
|
||||
|
||||
# Build Options
|
||||
|
||||
# Compiler Features
|
||||
|
||||
# Source Code
|
||||
|
||||
# Tests
|
||||
|
||||
## Testing Systems
|
||||
|
||||
## External Testing
|
||||
|
||||
# Continuous Integration
|
||||
|
||||
# Linter
|
||||
222
source/baselib/CMakeLists.txt
Normal file
222
source/baselib/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
|
||||
#
|
||||
# External dependencies
|
||||
#
|
||||
|
||||
# find_package(THIRDPARTY REQUIRED)
|
||||
|
||||
|
||||
#
|
||||
# Library name and options
|
||||
#
|
||||
|
||||
# Target name
|
||||
set(target baselib)
|
||||
|
||||
# Exit here if required dependencies are not met
|
||||
message(STATUS "Lib ${target}")
|
||||
|
||||
# Set API export file and macro
|
||||
string(MAKE_C_IDENTIFIER ${target} target_id)
|
||||
string(TOUPPER ${target_id} target_id)
|
||||
set(feature_file "include/${target}/${target}_features.h")
|
||||
set(export_file "include/${target}/${target}_export.h")
|
||||
set(template_export_file "include/${target}/${target}_api.h")
|
||||
set(export_macro "${target_id}_API")
|
||||
|
||||
|
||||
#
|
||||
# Sources
|
||||
#
|
||||
|
||||
set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}")
|
||||
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")
|
||||
|
||||
set(headers
|
||||
${include_path}/baselib.h
|
||||
)
|
||||
|
||||
set(sources
|
||||
${source_path}/baselib.cpp
|
||||
)
|
||||
|
||||
# Group source files
|
||||
set(header_group "Header Files (API)")
|
||||
set(source_group "Source Files")
|
||||
source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$"
|
||||
${header_group} ${headers})
|
||||
source_group_by_path(${source_path} "\\\\.cpp$|\\\\.c$|\\\\.h$|\\\\.hpp$"
|
||||
${source_group} ${sources})
|
||||
|
||||
|
||||
#
|
||||
# Create library
|
||||
#
|
||||
|
||||
# Build library
|
||||
add_library(${target}
|
||||
${sources}
|
||||
${headers}
|
||||
)
|
||||
|
||||
# Create namespaced alias
|
||||
add_library(${META_PROJECT_NAME}::${target} ALIAS ${target})
|
||||
|
||||
# Export library for downstream projects
|
||||
export(TARGETS ${target} NAMESPACE ${META_PROJECT_NAME}:: FILE ${PROJECT_BINARY_DIR}/cmake/${target}/${target}-export.cmake)
|
||||
|
||||
# Create feature detection header
|
||||
# Compilers: https://cmake.org/cmake/help/v3.1/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID
|
||||
# Feature: https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
|
||||
write_compiler_detection_header(
|
||||
FILE ${feature_file}
|
||||
PREFIX ${target_id}
|
||||
COMPILERS AppleClang Clang GNU MSVC
|
||||
FEATURES cxx_alignas cxx_alignof cxx_constexpr cxx_final cxx_noexcept cxx_nullptr cxx_sizeof_member cxx_thread_local
|
||||
VERSION 3.20
|
||||
)
|
||||
|
||||
# Create API export header
|
||||
generate_export_header(${target}
|
||||
EXPORT_FILE_NAME ${export_file}
|
||||
EXPORT_MACRO_NAME ${export_macro}
|
||||
)
|
||||
|
||||
generate_template_export_header(${target}
|
||||
${target_id}
|
||||
${template_export_file}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Project options
|
||||
#
|
||||
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
${DEFAULT_PROJECT_OPTIONS}
|
||||
INSTALL_RPATH "${LIBRARY_INSTALL_RPATH}"
|
||||
FOLDER "${IDE_FOLDER}"
|
||||
VERSION "${META_VERSION}"
|
||||
SOVERSION "${META_VERSION_MAJOR}"
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
${PROJECT_BINARY_DIR}/source/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
|
||||
PUBLIC
|
||||
${DEFAULT_INCLUDE_DIRECTORIES}
|
||||
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Libraries
|
||||
#
|
||||
|
||||
target_link_libraries(${target}
|
||||
PRIVATE
|
||||
|
||||
PUBLIC
|
||||
${DEFAULT_LIBRARIES}
|
||||
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile definitions
|
||||
#
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
|
||||
PUBLIC
|
||||
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:${target_id}_STATIC_DEFINE>
|
||||
${DEFAULT_COMPILE_DEFINITIONS}
|
||||
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile options
|
||||
#
|
||||
|
||||
target_compile_options(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_COMPILE_OPTIONS_PRIVATE}
|
||||
PUBLIC
|
||||
${DEFAULT_COMPILE_OPTIONS_PUBLIC}
|
||||
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Linker options
|
||||
#
|
||||
|
||||
target_link_options(${target}
|
||||
PRIVATE
|
||||
|
||||
PUBLIC
|
||||
${DEFAULT_LINKER_OPTIONS}
|
||||
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Target Health
|
||||
#
|
||||
|
||||
perform_health_checks(
|
||||
${target}
|
||||
${sources}
|
||||
${headers}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Deployment
|
||||
#
|
||||
|
||||
# Library
|
||||
install(TARGETS ${target}
|
||||
EXPORT "${target}-export" COMPONENT dev
|
||||
RUNTIME DESTINATION ${INSTALL_BIN} COMPONENT runtime
|
||||
LIBRARY DESTINATION ${INSTALL_SHARED} COMPONENT runtime
|
||||
ARCHIVE DESTINATION ${INSTALL_LIB} COMPONENT dev
|
||||
)
|
||||
|
||||
# Header files
|
||||
install(DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/${target} DESTINATION ${INSTALL_INCLUDE}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
# Generated header files
|
||||
install(DIRECTORY
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/${target} DESTINATION ${INSTALL_INCLUDE}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
# CMake config
|
||||
install(EXPORT ${target}-export
|
||||
NAMESPACE ${META_PROJECT_NAME}::
|
||||
DESTINATION ${INSTALL_CMAKE}/${target}
|
||||
COMPONENT dev
|
||||
)
|
||||
21
source/baselib/include/baselib/baselib.h
Normal file
21
source/baselib/include/baselib/baselib.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <baselib/baselib_api.h>
|
||||
|
||||
|
||||
namespace baselib
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Print information about the library to the console
|
||||
*/
|
||||
BASELIB_API void printInfo();
|
||||
|
||||
|
||||
} // namespace baselib
|
||||
58
source/baselib/source/baselib.cpp
Normal file
58
source/baselib/source/baselib.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <template/template-version.h>
|
||||
|
||||
#include <baselib/baselib.h>
|
||||
|
||||
|
||||
namespace baselib
|
||||
{
|
||||
|
||||
|
||||
void printInfo()
|
||||
{
|
||||
std::string dataPath = "data";
|
||||
|
||||
// Library name
|
||||
std::cout << "Library template::baselib" << std::endl;
|
||||
std::cout << "========================================" << std::endl;
|
||||
|
||||
// Library version
|
||||
std::cout << "Version: " << TEMPLATE_VERSION << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
// Library type (static or dynamic)
|
||||
#ifdef BASELIB_STATIC_DEFINE
|
||||
std::cout << "Library type: STATIC" << std::endl;
|
||||
#else
|
||||
std::cout << "Library type: SHARED" << std::endl;
|
||||
#endif
|
||||
|
||||
// Data directory
|
||||
std::cout << "Data path: " << dataPath << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
// Read file
|
||||
std::cout << "Data directory access" << std::endl;
|
||||
std::cout << "========================================" << std::endl;
|
||||
|
||||
std::string fileName = dataPath + "/DATA_FOLDER.txt";
|
||||
std::cout << "Reading from '" << fileName << "': " << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
std::ifstream f(fileName);
|
||||
if (f.is_open()) {
|
||||
std::string line;
|
||||
while (getline(f, line)) {
|
||||
std::cout << line << '\n';
|
||||
}
|
||||
f.close();
|
||||
} else {
|
||||
std::cout << "Unable to open file." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace baselib
|
||||
22
source/codegeneration/template_api.h.in
Normal file
22
source/codegeneration/template_api.h.in
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
#ifndef @target_id@_TEMPLATE_API_H
|
||||
#define @target_id@_TEMPLATE_API_H
|
||||
|
||||
#include <@target@/@target@_export.h>
|
||||
|
||||
#ifdef @target_id@_STATIC_DEFINE
|
||||
# define @target_id@_TEMPLATE_API
|
||||
#else
|
||||
# ifndef @target_id@_TEMPLATE_API
|
||||
# ifdef @target_id@_EXPORTS
|
||||
/* We are building this library */
|
||||
# define @target_id@_TEMPLATE_API __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define @target_id@_TEMPLATE_API __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
22
source/codegeneration/template_msvc_api.h.in
Normal file
22
source/codegeneration/template_msvc_api.h.in
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
#ifndef @target_id@_TEMPLATE_API_H
|
||||
#define @target_id@_TEMPLATE_API_H
|
||||
|
||||
#include <@target@/@target@_export.h>
|
||||
|
||||
#ifdef @target_id@_STATIC_DEFINE
|
||||
# define @target_id@_TEMPLATE_API
|
||||
#else
|
||||
# ifndef @target_id@_TEMPLATE_API
|
||||
# ifdef @target_id@_EXPORTS
|
||||
/* We are building this library */
|
||||
# define @target_id@_TEMPLATE_API
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define @target_id@_TEMPLATE_API
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
9
source/examples/CMakeLists.txt
Normal file
9
source/examples/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
# Check if examples are enabled
|
||||
if(NOT OPTION_BUILD_EXAMPLES)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Example applications
|
||||
add_subdirectory(fibcmd)
|
||||
add_subdirectory(fibgui)
|
||||
130
source/examples/fibcmd/CMakeLists.txt
Normal file
130
source/examples/fibcmd/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
|
||||
#
|
||||
# External dependencies
|
||||
#
|
||||
|
||||
# find_package(THIRDPARTY REQUIRED)
|
||||
|
||||
|
||||
#
|
||||
# Executable name and options
|
||||
#
|
||||
|
||||
# Target name
|
||||
set(target fibcmd)
|
||||
|
||||
# Exit here if required dependencies are not met
|
||||
message(STATUS "Example ${target}")
|
||||
|
||||
|
||||
#
|
||||
# Sources
|
||||
#
|
||||
|
||||
set(sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Create executable
|
||||
#
|
||||
|
||||
# Build executable
|
||||
add_executable(${target}
|
||||
MACOSX_BUNDLE
|
||||
${sources}
|
||||
)
|
||||
|
||||
# Create namespaced alias
|
||||
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})
|
||||
|
||||
|
||||
#
|
||||
# Project options
|
||||
#
|
||||
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
${DEFAULT_PROJECT_OPTIONS}
|
||||
INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
|
||||
FOLDER "${IDE_FOLDER}"
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_INCLUDE_DIRECTORIES}
|
||||
${PROJECT_BINARY_DIR}/source/include
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Libraries
|
||||
#
|
||||
|
||||
target_link_libraries(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_LIBRARIES}
|
||||
${META_PROJECT_NAME}::baselib
|
||||
${META_PROJECT_NAME}::fiblib
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile definitions
|
||||
#
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_COMPILE_DEFINITIONS}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile options
|
||||
#
|
||||
|
||||
target_compile_options(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_COMPILE_OPTIONS_PRIVATE}
|
||||
PUBLIC
|
||||
${DEFAULT_COMPILE_OPTIONS_PUBLIC}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Linker options
|
||||
#
|
||||
|
||||
target_link_options(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_LINKER_OPTIONS}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Target Health
|
||||
#
|
||||
|
||||
perform_health_checks(
|
||||
${target}
|
||||
${sources}
|
||||
)
|
||||
|
||||
generate_coverage_report(${target})
|
||||
|
||||
|
||||
#
|
||||
# Deployment
|
||||
#
|
||||
|
||||
# Executable
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION ${INSTALL_BIN} COMPONENT examples
|
||||
BUNDLE DESTINATION ${INSTALL_BIN} COMPONENT examples
|
||||
)
|
||||
24
source/examples/fibcmd/main.cpp
Normal file
24
source/examples/fibcmd/main.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <baselib/baselib.h>
|
||||
|
||||
#include <fiblib/CTFibonacci.h>
|
||||
#include <fiblib/Fibonacci.h>
|
||||
|
||||
|
||||
int main(int /*argc*/, char* /*argv*/[])
|
||||
{
|
||||
// Print library info
|
||||
baselib::printInfo();
|
||||
std::cout << std::endl;
|
||||
|
||||
// Calculate and print fibonacci number
|
||||
std::cout << "Fibonacci library" << std::endl;
|
||||
std::cout << "========================================" << std::endl;
|
||||
std::cout << "CTFibonacci(6) = " << fiblib::CTFibonacci<6>::value << std::endl;
|
||||
std::cout << "Fibonacci(8) = " << fiblib::Fibonacci()(8) << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
151
source/examples/fibgui/CMakeLists.txt
Normal file
151
source/examples/fibgui/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
|
||||
#
|
||||
# External dependencies
|
||||
#
|
||||
|
||||
find_package(Qt5Core 5.1)
|
||||
find_package(Qt5Gui 5.1)
|
||||
find_package(Qt5Widgets 5.1)
|
||||
|
||||
# Enable automoc
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(AUTOMOC_MOC_OPTIONS PROPERTIES FOLDER CMakeAutomocTargets)
|
||||
set_property(GLOBAL PROPERTY AUTOMOC_FOLDER CMakeAutomocTargets)
|
||||
|
||||
# ENABLE CMP0020: Automatically link Qt executables to qtmain target on Windows.
|
||||
set_policy(CMP0020 NEW)
|
||||
|
||||
|
||||
#
|
||||
# Executable name and options
|
||||
#
|
||||
|
||||
# Target name
|
||||
set(target fibgui)
|
||||
|
||||
# Exit here if required dependencies are not met
|
||||
if (NOT Qt5Core_FOUND)
|
||||
message(STATUS "Example ${target} skipped: Qt5 not found")
|
||||
return()
|
||||
else()
|
||||
message(STATUS "Example ${target}")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Sources
|
||||
#
|
||||
|
||||
set(sources
|
||||
main.cpp
|
||||
MainWindow.cpp
|
||||
MainWindow.h
|
||||
MainWindow.ui
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Create executable
|
||||
#
|
||||
|
||||
# Build executable
|
||||
add_executable(${target}
|
||||
MACOSX_BUNDLE
|
||||
${sources}
|
||||
)
|
||||
|
||||
# Create namespaced alias
|
||||
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})
|
||||
|
||||
|
||||
#
|
||||
# Project options
|
||||
#
|
||||
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
${DEFAULT_PROJECT_OPTIONS}
|
||||
INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
|
||||
FOLDER "${IDE_FOLDER}"
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_INCLUDE_DIRECTORIES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROJECT_BINARY_DIR}/source/include
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Libraries
|
||||
#
|
||||
|
||||
target_link_libraries(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_LIBRARIES}
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
Qt5::Widgets
|
||||
${META_PROJECT_NAME}::baselib
|
||||
${META_PROJECT_NAME}::fiblib
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile definitions
|
||||
#
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_COMPILE_DEFINITIONS}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile options
|
||||
#
|
||||
|
||||
target_compile_options(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_COMPILE_OPTIONS_PRIVATE}
|
||||
PUBLIC
|
||||
${DEFAULT_COMPILE_OPTIONS_PUBLIC}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Linker options
|
||||
#
|
||||
|
||||
target_link_options(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_LINKER_OPTIONS}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Target Health
|
||||
#
|
||||
|
||||
perform_health_checks(
|
||||
${target}
|
||||
${sources}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Deployment
|
||||
#
|
||||
|
||||
# Executable
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION ${INSTALL_BIN} COMPONENT examples
|
||||
BUNDLE DESTINATION ${INSTALL_BIN} COMPONENT examples
|
||||
)
|
||||
37
source/examples/fibgui/MainWindow.cpp
Normal file
37
source/examples/fibgui/MainWindow.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <template/template-version.h>
|
||||
|
||||
#include <fiblib/Fibonacci.h>
|
||||
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: m_ui(new Ui::MainWindow)
|
||||
{
|
||||
// Setup UI
|
||||
m_ui->setupUi(this);
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::on_editNumber_valueChanged(int value)
|
||||
{
|
||||
fiblib::Fibonacci fib;
|
||||
m_ui->result->setText("Fib(" + QString::number(value) + ") = " + QString::number(fib(value)));
|
||||
}
|
||||
|
||||
void MainWindow::on_about()
|
||||
{
|
||||
QString about = QString() +
|
||||
"Version: " + TEMPLATE_VERSION + "\n";
|
||||
|
||||
QMessageBox::about(this, "template project", about);
|
||||
}
|
||||
44
source/examples/fibgui/MainWindow.h
Normal file
44
source/examples/fibgui/MainWindow.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QScopedPointer>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Main window of the fibgui example
|
||||
*/
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* Constructor
|
||||
*/
|
||||
MainWindow();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~MainWindow();
|
||||
|
||||
|
||||
protected slots:
|
||||
void on_editNumber_valueChanged(int value);
|
||||
void on_about();
|
||||
|
||||
|
||||
protected:
|
||||
const QScopedPointer<Ui::MainWindow> m_ui;
|
||||
};
|
||||
114
source/examples/fibgui/MainWindow.ui
Normal file
114
source/examples/fibgui/MainWindow.ui
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>694</width>
|
||||
<height>175</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Fibonacci Gui</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="title">
|
||||
<property name="text">
|
||||
<string>Please enter n:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="editNumber"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="result">
|
||||
<property name="text">
|
||||
<string>Fib(0) = 0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>694</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="fileMenu">
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="quitAction"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="helpMenu">
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="aboutAction"/>
|
||||
</widget>
|
||||
<addaction name="fileMenu"/>
|
||||
<addaction name="helpMenu"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="aboutAction">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&About ...</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::AboutRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="quitAction">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::QuitRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>quitAction</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>aboutAction</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>on_about()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
15
source/examples/fibgui/main.cpp
Normal file
15
source/examples/fibgui/main.cpp
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication application(argc, argv);
|
||||
|
||||
MainWindow mainWindow;
|
||||
mainWindow.show();
|
||||
|
||||
return application.exec();
|
||||
}
|
||||
224
source/fiblib/CMakeLists.txt
Normal file
224
source/fiblib/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
|
||||
#
|
||||
# External dependencies
|
||||
#
|
||||
|
||||
# find_package(THIRDPARTY REQUIRED)
|
||||
|
||||
|
||||
#
|
||||
# Library name and options
|
||||
#
|
||||
|
||||
# Target name
|
||||
set(target fiblib)
|
||||
|
||||
# Exit here if required dependencies are not met
|
||||
message(STATUS "Lib ${target}")
|
||||
|
||||
# Set API export file and macro
|
||||
string(MAKE_C_IDENTIFIER ${target} target_id)
|
||||
string(TOUPPER ${target_id} target_id)
|
||||
set(feature_file "include/${target}/${target}_features.h")
|
||||
set(export_file "include/${target}/${target}_export.h")
|
||||
set(template_export_file "include/${target}/${target}_api.h")
|
||||
set(export_macro "${target_id}_API")
|
||||
|
||||
|
||||
#
|
||||
# Sources
|
||||
#
|
||||
|
||||
set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}")
|
||||
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")
|
||||
|
||||
set(headers
|
||||
${include_path}/CTFibonacci.h
|
||||
${include_path}/CTFibonacci.inl
|
||||
${include_path}/Fibonacci.h
|
||||
)
|
||||
|
||||
set(sources
|
||||
${source_path}/Fibonacci.cpp
|
||||
)
|
||||
|
||||
# Group source files
|
||||
set(header_group "Header Files (API)")
|
||||
set(source_group "Source Files")
|
||||
source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$"
|
||||
${header_group} ${headers})
|
||||
source_group_by_path(${source_path} "\\\\.cpp$|\\\\.c$|\\\\.h$|\\\\.hpp$"
|
||||
${source_group} ${sources})
|
||||
|
||||
|
||||
#
|
||||
# Create library
|
||||
#
|
||||
|
||||
# Build library
|
||||
add_library(${target}
|
||||
${sources}
|
||||
${headers}
|
||||
)
|
||||
|
||||
# Create namespaced alias
|
||||
add_library(${META_PROJECT_NAME}::${target} ALIAS ${target})
|
||||
|
||||
# Export library for downstream projects
|
||||
export(TARGETS ${target} NAMESPACE ${META_PROJECT_NAME}:: FILE ${PROJECT_BINARY_DIR}/cmake/${target}/${target}-export.cmake)
|
||||
|
||||
# Create feature detection header
|
||||
# Compilers: https://cmake.org/cmake/help/v3.1/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID
|
||||
# Feature: https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
|
||||
write_compiler_detection_header(
|
||||
FILE ${feature_file}
|
||||
PREFIX ${target_id}
|
||||
COMPILERS AppleClang Clang GNU MSVC
|
||||
FEATURES cxx_alignas cxx_alignof cxx_constexpr cxx_final cxx_noexcept cxx_nullptr cxx_sizeof_member cxx_thread_local
|
||||
VERSION 3.20
|
||||
)
|
||||
|
||||
# Create API export header
|
||||
generate_export_header(${target}
|
||||
EXPORT_FILE_NAME ${export_file}
|
||||
EXPORT_MACRO_NAME ${export_macro}
|
||||
)
|
||||
|
||||
generate_template_export_header(${target}
|
||||
${target_id}
|
||||
${template_export_file}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Project options
|
||||
#
|
||||
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
${DEFAULT_PROJECT_OPTIONS}
|
||||
INSTALL_RPATH "${LIBRARY_INSTALL_RPATH}"
|
||||
FOLDER "${IDE_FOLDER}"
|
||||
VERSION "${META_VERSION}"
|
||||
SOVERSION "${META_VERSION_MAJOR}"
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
${PROJECT_BINARY_DIR}/source/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
|
||||
PUBLIC
|
||||
${DEFAULT_INCLUDE_DIRECTORIES}
|
||||
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Libraries
|
||||
#
|
||||
|
||||
target_link_libraries(${target}
|
||||
PRIVATE
|
||||
|
||||
PUBLIC
|
||||
${DEFAULT_LIBRARIES}
|
||||
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile definitions
|
||||
#
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
|
||||
PUBLIC
|
||||
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:${target_id}_STATIC_DEFINE>
|
||||
${DEFAULT_COMPILE_DEFINITIONS}
|
||||
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile options
|
||||
#
|
||||
|
||||
target_compile_options(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_COMPILE_OPTIONS_PRIVATE}
|
||||
PUBLIC
|
||||
${DEFAULT_COMPILE_OPTIONS_PUBLIC}
|
||||
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Linker options
|
||||
#
|
||||
|
||||
target_link_options(${target}
|
||||
PRIVATE
|
||||
|
||||
PUBLIC
|
||||
${DEFAULT_LINKER_OPTIONS}
|
||||
|
||||
INTERFACE
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Target Health
|
||||
#
|
||||
|
||||
perform_health_checks(
|
||||
${target}
|
||||
${sources}
|
||||
${headers}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Deployment
|
||||
#
|
||||
|
||||
# Library
|
||||
install(TARGETS ${target}
|
||||
EXPORT "${target}-export" COMPONENT dev
|
||||
RUNTIME DESTINATION ${INSTALL_BIN} COMPONENT runtime
|
||||
LIBRARY DESTINATION ${INSTALL_SHARED} COMPONENT runtime
|
||||
ARCHIVE DESTINATION ${INSTALL_LIB} COMPONENT dev
|
||||
)
|
||||
|
||||
# Header files
|
||||
install(DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/${target} DESTINATION ${INSTALL_INCLUDE}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
# Generated header files
|
||||
install(DIRECTORY
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/${target} DESTINATION ${INSTALL_INCLUDE}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
# CMake config
|
||||
install(EXPORT ${target}-export
|
||||
NAMESPACE ${META_PROJECT_NAME}::
|
||||
DESTINATION ${INSTALL_CMAKE}/${target}
|
||||
COMPONENT dev
|
||||
)
|
||||
29
source/fiblib/include/fiblib/CTFibonacci.h
Normal file
29
source/fiblib/include/fiblib/CTFibonacci.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <fiblib/fiblib_api.h>
|
||||
|
||||
|
||||
namespace fiblib
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Compile-time computation of fibonacci numbers
|
||||
*/
|
||||
template <unsigned long long i>
|
||||
class FIBLIB_TEMPLATE_API CTFibonacci
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
value = CTFibonacci<i-2>::value + CTFibonacci<i-1>::value
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
} // namespace fiblib
|
||||
|
||||
|
||||
#include <fiblib/CTFibonacci.inl>
|
||||
30
source/fiblib/include/fiblib/CTFibonacci.inl
Normal file
30
source/fiblib/include/fiblib/CTFibonacci.inl
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <fiblib/CTFibonacci.h>
|
||||
|
||||
|
||||
namespace fiblib
|
||||
{
|
||||
|
||||
|
||||
template <>
|
||||
class FIBLIB_TEMPLATE_API CTFibonacci<0>
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
value = 0
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
class FIBLIB_TEMPLATE_API CTFibonacci<1>
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
value = 1
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
} // namespace fiblib
|
||||
45
source/fiblib/include/fiblib/Fibonacci.h
Normal file
45
source/fiblib/include/fiblib/Fibonacci.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <fiblib/fiblib_api.h>
|
||||
|
||||
|
||||
namespace fiblib
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Calculator of fibonacci numbers
|
||||
*/
|
||||
class FIBLIB_API Fibonacci
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* Constructor
|
||||
*/
|
||||
Fibonacci();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~Fibonacci();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Calculate fibonacci number
|
||||
*
|
||||
* @param[in] i
|
||||
* Index
|
||||
*
|
||||
* @return
|
||||
* Value of the i'th fibonacci number
|
||||
*/
|
||||
unsigned int operator()(unsigned int i);
|
||||
};
|
||||
|
||||
|
||||
} // namespace fiblib
|
||||
27
source/fiblib/source/Fibonacci.cpp
Normal file
27
source/fiblib/source/Fibonacci.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
#include <fiblib/Fibonacci.h>
|
||||
|
||||
|
||||
namespace fiblib
|
||||
{
|
||||
|
||||
|
||||
Fibonacci::Fibonacci()
|
||||
{
|
||||
}
|
||||
|
||||
Fibonacci::~Fibonacci()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int Fibonacci::operator()(unsigned int i)
|
||||
{
|
||||
if (i < 2) {
|
||||
return i;
|
||||
} else {
|
||||
return this->operator()(i - 1) + this->operator()(i - 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace fiblib
|
||||
73
source/tests/CMakeLists.txt
Normal file
73
source/tests/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
|
||||
#
|
||||
# Configure test project and environment
|
||||
#
|
||||
|
||||
# CMake version
|
||||
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
||||
|
||||
# Meta information about the project
|
||||
set(META_PROJECT_NAME "template")
|
||||
|
||||
# Declare project
|
||||
project("${META_PROJECT_NAME}-tests")
|
||||
|
||||
enable_language(C)
|
||||
enable_language(CXX)
|
||||
|
||||
# Set policies
|
||||
set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
|
||||
set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
|
||||
set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.
|
||||
|
||||
# Compiler settings and options
|
||||
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CompileOptions.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Custom.cmake)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
|
||||
else()
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CompileOptions.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Custom.cmake)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
endif()
|
||||
|
||||
# Function: Build test and add command to execute it via target 'test'
|
||||
function(add_test_without_ctest target)
|
||||
add_subdirectory(${target})
|
||||
|
||||
if(NOT TARGET ${target})
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_dependencies(test ${target})
|
||||
add_custom_command(TARGET test POST_BUILD
|
||||
COMMAND $<TARGET_FILE:${target}> --gtest_output=xml:gtests-${target}.xml
|
||||
)
|
||||
|
||||
generate_coverage_report(${target})
|
||||
endfunction()
|
||||
|
||||
find_package(googletest QUIET)
|
||||
|
||||
if (NOT TARGET googletest::googletest)
|
||||
message(STATUS "Tests skipped: googletest not found")
|
||||
return()
|
||||
endif ()
|
||||
|
||||
|
||||
#
|
||||
# Target 'test'
|
||||
#
|
||||
|
||||
if (NOT TARGET test)
|
||||
add_custom_target(test)
|
||||
set_target_properties(test PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Tests
|
||||
#
|
||||
|
||||
add_test_without_ctest(fiblib-test)
|
||||
14
source/tests/README.md
Normal file
14
source/tests/README.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
## Enabling Tests based on googletest
|
||||
|
||||
cmake-init will not ship with the sources required to build the tests.
|
||||
Instead, any developer is asked to install a source release of googletest on their machine.
|
||||
|
||||
### Official Sources
|
||||
|
||||
### Ubuntu Package
|
||||
|
||||
On ubuntu, a compatible release of googletest can be installed using the package `libgmock-dev`:
|
||||
|
||||
```bash
|
||||
> sudo apt install libgmock-dev
|
||||
```
|
||||
103
source/tests/fiblib-test/CMakeLists.txt
Normal file
103
source/tests/fiblib-test/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
|
||||
#
|
||||
# External dependencies
|
||||
#
|
||||
|
||||
find_package(${META_PROJECT_NAME} REQUIRED HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../../../")
|
||||
|
||||
#
|
||||
# Executable name and options
|
||||
#
|
||||
|
||||
# Target name
|
||||
set(target fiblib-test)
|
||||
message(STATUS "Test ${target}")
|
||||
|
||||
|
||||
#
|
||||
# Sources
|
||||
#
|
||||
|
||||
set(sources
|
||||
main.cpp
|
||||
fibonacci_test.cpp
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Create executable
|
||||
#
|
||||
|
||||
# Build executable
|
||||
add_executable(${target}
|
||||
${sources}
|
||||
)
|
||||
|
||||
# Create namespaced alias
|
||||
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})
|
||||
|
||||
|
||||
#
|
||||
# Project options
|
||||
#
|
||||
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
${DEFAULT_PROJECT_OPTIONS}
|
||||
FOLDER "${IDE_FOLDER}"
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
|
||||
target_include_directories(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_INCLUDE_DIRECTORIES}
|
||||
${PROJECT_BINARY_DIR}/source/include
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Libraries
|
||||
#
|
||||
|
||||
target_link_libraries(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_LIBRARIES}
|
||||
${META_PROJECT_NAME}::fiblib
|
||||
googletest::googletest
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile definitions
|
||||
#
|
||||
|
||||
target_compile_definitions(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_COMPILE_DEFINITIONS}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Compile options
|
||||
#
|
||||
|
||||
target_compile_options(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_COMPILE_OPTIONS_PRIVATE}
|
||||
PUBLIC
|
||||
${DEFAULT_COMPILE_OPTIONS_PUBLIC}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Linker options
|
||||
#
|
||||
|
||||
target_link_options(${target}
|
||||
PRIVATE
|
||||
${DEFAULT_LINKER_OPTIONS}
|
||||
)
|
||||
21
source/tests/fiblib-test/fibonacci_test.cpp
Normal file
21
source/tests/fiblib-test/fibonacci_test.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
|
||||
#include <fiblib/Fibonacci.h>
|
||||
|
||||
class fibonacci_test: public testing::Test
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
TEST_F(fibonacci_test, CheckSomeResults)
|
||||
{
|
||||
fiblib::Fibonacci fib;
|
||||
|
||||
EXPECT_EQ((unsigned int) 0, fib(0));
|
||||
EXPECT_EQ((unsigned int) 1, fib(1));
|
||||
EXPECT_EQ((unsigned int) 1, fib(2));
|
||||
EXPECT_EQ((unsigned int)21, fib(8));
|
||||
// ...
|
||||
}
|
||||
8
source/tests/fiblib-test/main.cpp
Normal file
8
source/tests/fiblib-test/main.cpp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
15
source/version.h.in
Normal file
15
source/version.h.in
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
#define ${META_PROJECT_ID}_PROJECT_NAME "@META_PROJECT_NAME@"
|
||||
#define ${META_PROJECT_ID}_PROJECT_DESCRIPTION "@META_PROJECT_DESCRIPTION@"
|
||||
|
||||
#define ${META_PROJECT_ID}_AUTHOR_ORGANIZATION "@META_AUTHOR_ORGANIZATION@"
|
||||
#define ${META_PROJECT_ID}_AUTHOR_DOMAIN "@META_AUTHOR_DOMAIN@"
|
||||
#define ${META_PROJECT_ID}_AUTHOR_MAINTAINER "@META_AUTHOR_MAINTAINER@"
|
||||
|
||||
#define ${META_PROJECT_ID}_VERSION_MAJOR "@META_VERSION_MAJOR@"
|
||||
#define ${META_PROJECT_ID}_VERSION_MINOR "@META_VERSION_MINOR@"
|
||||
#define ${META_PROJECT_ID}_VERSION_PATCH "@META_VERSION_PATCH@"
|
||||
#define ${META_PROJECT_ID}_VERSION_REVISION "@META_VERSION_REVISION@"
|
||||
|
||||
#define ${META_PROJECT_ID}_VERSION "@META_VERSION@"
|
||||
#define ${META_PROJECT_ID}_NAME_VERSION "@META_NAME_VERSION@"
|
||||
59
template-config.cmake
Normal file
59
template-config.cmake
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
# This config script tries to locate the project either in its source tree
|
||||
# or from an install location.
|
||||
#
|
||||
# Please adjust the list of submodules to search for.
|
||||
|
||||
# Find depencencies
|
||||
include(CMakeFindDependencyMacro)
|
||||
#find_dependency(glm)
|
||||
|
||||
|
||||
# List of modules
|
||||
set(MODULE_NAMES
|
||||
baselib
|
||||
fiblib
|
||||
)
|
||||
|
||||
|
||||
# Macro to search for a specific module
|
||||
macro(find_module FILENAME)
|
||||
if(EXISTS "${FILENAME}")
|
||||
set(MODULE_FOUND TRUE)
|
||||
include("${FILENAME}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Macro to search for all modules
|
||||
macro(find_modules PREFIX)
|
||||
foreach(module_name ${MODULE_NAMES})
|
||||
if(TARGET ${module_name})
|
||||
set(MODULE_FOUND TRUE)
|
||||
else()
|
||||
find_module("${CMAKE_CURRENT_LIST_DIR}/${PREFIX}/${module_name}/${module_name}-export.cmake")
|
||||
endif()
|
||||
endforeach(module_name)
|
||||
endmacro()
|
||||
|
||||
|
||||
# Try install location
|
||||
set(MODULE_FOUND FALSE)
|
||||
find_modules("cmake")
|
||||
|
||||
if(MODULE_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
# Try common build locations
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
find_modules("build-debug/cmake")
|
||||
find_modules("build/cmake")
|
||||
else()
|
||||
find_modules("build/cmake")
|
||||
find_modules("build-debug/cmake")
|
||||
endif()
|
||||
|
||||
|
||||
# Signal success/failure to CMake
|
||||
set(template_FOUND ${MODULE_FOUND})
|
||||
Loading…
Add table
Add a link
Reference in a new issue