This repository has been archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from frederikvannoote/develop
First version
- Loading branch information
Showing
13 changed files
with
640 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
macro(add_qt_test TEST_NAME SRCS) | ||
find_package(Qt5Test REQUIRED) | ||
|
||
add_executable(${TEST_NAME} ${SRCS}) | ||
|
||
add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>) | ||
|
||
target_link_libraries(${TEST_NAME} PUBLIC Qt5::Test) | ||
endmacro() | ||
|
||
option(PRIVATE_TESTS_ENABLED "Enable private tests" OFF) | ||
macro(add_private_qt_test TEST_NAME SRCS) | ||
if(DEFINED PRIVATE_TESTS_ENABLED) | ||
if(${PRIVATE_TESTS_ENABLED}) | ||
add_qt_test(${TEST_NAME} ${SRCS}) | ||
endif(${PRIVATE_TESTS_ENABLED}) | ||
endif(DEFINED PRIVATE_TESTS_ENABLED) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Enable Code Coverage | ||
# | ||
# USAGE: | ||
# 1. Copy this file into your cmake modules path. | ||
# | ||
# 2. Add the following line to your CMakeLists.txt: | ||
# INCLUDE(CodeCoverage) | ||
# | ||
# 3. Call the function ENABLE_CODE_COVERAGE | ||
# This functions sets compiler flags to turn off optimization and enable coverage: | ||
# SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -fprofile-arcs -ftest-coverage") | ||
# | ||
# 4. Build a Debug build: | ||
# cmake -DCMAKE_BUILD_TYPE=Debug .. | ||
# make | ||
# make my_coverage_target | ||
# | ||
# Note: code coverage can only be enabled when in debug build! | ||
# | ||
# Requirements: gcov and gcovr | ||
|
||
# Check prereqs | ||
find_package(Gcov) | ||
find_package(Gcovr) | ||
|
||
function(ENABLE_CODE_COVERAGE) | ||
if (GCOV_FOUND AND GCOVR_FOUND) | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -fprofile-arcs -ftest-coverage") | ||
if (CMAKE_COMPILER_IS_GNUCXX AND NOT UNIX) | ||
link_libraries(debug gcov) | ||
endif(WIN32 AND NOT UNIX) | ||
if (NOT WIN32) | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC") | ||
endif (NOT WIN32) | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE) | ||
|
||
message(STATUS "Code Coverage Enabled") | ||
else() | ||
message("-- Code Coverage NOT Enabled because gcov and/or gcovr was not found.") | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
cmake_minimum_required(VERSION 3.5.2 FATAL_ERROR) | ||
|
||
################# | ||
# Build options # | ||
################# | ||
|
||
if (NOT DEFINED BUILD_SHARED_LIBS) | ||
option(BUILD_SHARED_LIBS "Build as shared library" ON) | ||
endif() | ||
# When set to OFF, the library will be built as a static library | ||
if (${BUILD_SHARED_LIBS}) | ||
add_definitions(-DBUILD_SHARED_LIBS) | ||
endif() | ||
|
||
|
||
# Usage of Qt libraries | ||
# --------------------- | ||
# Point CMake search path to Qt intallation directory | ||
# Either supply QTDIR as -DQTDIR=<path> to cmake or set an environment variable QTDIR pointing to the Qt installation | ||
if ((NOT DEFINED QTDIR) AND DEFINED ENV{QTDIR}) | ||
set(QTDIR $ENV{QTDIR}) | ||
endif ((NOT DEFINED QTDIR) AND DEFINED ENV{QTDIR}) | ||
|
||
if (NOT DEFINED QTDIR) | ||
message(FATAL_ERROR "QTDIR has not been set nor supplied as a define parameter to cmake.") | ||
endif (NOT DEFINED QTDIR) | ||
|
||
if (QTDIR) | ||
list (APPEND CMAKE_PREFIX_PATH ${QTDIR}) | ||
endif (QTDIR) | ||
|
||
# Instruct CMake to run moc automatically when needed. | ||
set(CMAKE_AUTOMOC ON) | ||
# let CMake decide which classes need to be rcc'ed by qmake (Qt) | ||
set(CMAKE_AUTORCC ON) | ||
# let CMake decide which classes need to be uic'ed by qmake (Qt) | ||
set(CMAKE_AUTOUIC ON) | ||
|
||
|
||
# Usage of CMake Packages | ||
# ----------------------- | ||
include(CMakePackageConfigHelpers) | ||
|
||
# Point cmake to the packages of libraries in this tree. | ||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/local-exports) | ||
|
||
|
||
# Compiler flags | ||
# -------------- | ||
add_definitions(-Wall -fvisibility=hidden) | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
# Find includes in corresponding build directories | ||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
# Compile with @rpath option on Apple | ||
if (APPLE) | ||
set(CMAKE_MACOSX_RPATH 1) | ||
endif (APPLE) | ||
|
||
|
||
# Switch testing on | ||
# ----------------- | ||
enable_testing() | ||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) | ||
include(AddQtTest) | ||
|
||
# Common compiler flags | ||
include(CompilerFlags) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
# Force synchronous PDB writes for Visual Studio | ||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
add_compile_options("/FS") | ||
endif() | ||
|
||
# Set default build type to release with debug info | ||
IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) | ||
SET(CMAKE_BUILD_TYPE RelWithDebInfo) | ||
ENDIF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX) | ||
set(COMPILER_FLAGS | ||
"-std=c++11" | ||
"-Wall" # turn on all warnings | ||
"-pedantic" | ||
"-Wextra" | ||
"-fno-rtti" # disable runtime type information | ||
"-fno-exceptions" | ||
"-ffor-scope" | ||
"-fuse-cxa-atexit" | ||
"-fno-default-inline" | ||
"-fvisibility=hidden" # do not export symbols by default | ||
"-fvisibility-inlines-hidden" | ||
"-pedantic-errors" | ||
"-Wsign-promo" | ||
"-Wsign-compare" | ||
"-Wnon-virtual-dtor" | ||
"-Wold-style-cast" | ||
"-Woverloaded-virtual" | ||
"-Wswitch" | ||
"-Wswitch-default" | ||
"-Wswitch-enum" | ||
"-Wcast-qual" | ||
"-Wcast-align" | ||
"-Wuninitialized" | ||
"-Wno-float-equal" | ||
"-Wlogical-op" | ||
"-Wpacked" | ||
"-Wredundant-decls" | ||
"-Wdisabled-optimization" | ||
"-Wdeprecated" | ||
"-Wempty-body" | ||
"-Wreturn-type" | ||
"-Wunused-variable" | ||
"-Wno-unknown-pragmas" # suppress unknown pragma warnings | ||
"-Wformat" | ||
"-Wunreachable-code" | ||
"-mfpmath=sse" # needed on Debian 32-bit to get high precision floating point operations | ||
"-msse2" # needed on Debian 32-bit to get high precision floating point operations | ||
|
||
"-Weffc++" # warnings from Effective C++ book; | ||
|
||
"-Werror" | ||
"-Wformat-nonliteral" # const char* argumements could not langer be passed due to this entry | ||
# "-Winline" # gcc on Linux seems to decide frequently not to inline, and warns about it. | ||
# # We don't need to know about it, since not inlining is not a problem. | ||
# "-Wnull-character" # not supported by gcc | ||
# "-Wshadow" # disable shadow warning as gcc generates | ||
# warnings for parameters with same name | ||
# as methods in the class. | ||
# This option is enabled for clang builds, | ||
# so the 'real' shadow variables will be | ||
# caught be clang | ||
"-Wsign-conversion" | ||
# "-Wuseless-cast" | ||
# "-Wzero-as-null-pointer-constant" | ||
) | ||
if(WIN32) | ||
# Fix for using LxCan sensor SDK | ||
# Since LxNative.dll uses stdcall convention, MinGW expects @.. decoration of the exposed functions, | ||
# which are not present in the DLL. This MinGW option tells the linker to also look for undecorated | ||
# functions. | ||
set(COMPILER_FLAGS "${COMPILER_FLAGS}" "-Wl,--enable-stdcall-fixup") | ||
endif() | ||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
set(COMPILER_FLAGS | ||
"-stdlib=libc++" | ||
"-std=c++11" | ||
"-Wall" # turn on all warnings | ||
"-Wpedantic" | ||
"-Wextra" | ||
"-Weffc++" # turn on warnings from Effective C++ handbook | ||
"-fno-rtti" # disable runtime type information | ||
"-fno-exceptions" | ||
"-ffor-scope" | ||
"-fuse-cxa-atexit" | ||
"-fvisibility=hidden" # do not export symbols by default | ||
"-fvisibility-inlines-hidden" | ||
"-pedantic" # warn about language extensions | ||
"-pedantic-errors" # treat language extension warnings as errors | ||
"-Wsign-promo" | ||
"-Wsign-compare" | ||
"-Wnon-virtual-dtor" | ||
"-Wold-style-cast" | ||
"-Woverloaded-virtual" | ||
"-Wint-to-void-pointer-cast" | ||
"-Wswitch" | ||
"-Wswitch-default" | ||
"-Wswitch-enum" | ||
"-Wcast-qual" | ||
"-Wcast-align" | ||
"-Wuninitialized" | ||
"-Wno-float-equal" | ||
"-Wshadow" | ||
"-Wpacked" | ||
"-Wredundant-decls" | ||
"-Wdisabled-optimization" | ||
"-Wdeprecated" | ||
"-Wdeprecated-declarations" | ||
"-Wempty-body" | ||
"-Wbitwise-op-parentheses" | ||
"-Wlogical-op-parentheses" | ||
"-Wold-style-cast" | ||
"-Wold-style-definition" | ||
"-Wout-of-line-declaration" | ||
"-Waddress-of-temporary" | ||
"-Wbool-conversions" | ||
"-Wbad-function-cast" | ||
"-Wbind-to-temporary-copy" | ||
"-Wdiv-by-zero" | ||
"-Wheader-hygiene" | ||
"-Wnull-dereference" | ||
"-Widiomatic-parentheses" | ||
"-Wparentheses" | ||
"-Winitializer-overrides" | ||
"-Wint-to-pointer-cast" | ||
"-Wpointer-to-int-cast" | ||
"-Wpointer-arith" | ||
"-Wmissing-braces" | ||
"-Wmissing-field-initializers" | ||
"-Wnonnull" | ||
"-Woverflow" | ||
"-Wshorten-64-to-32" | ||
"-Wno-used-but-marked-unused" | ||
"-Weffc++" | ||
"-Wreturn-type" | ||
"-Wnull-character" | ||
"-Wunused-variable" | ||
"-Wselector" | ||
"-Wno-unknown-pragmas" # suppress unknown pragma warnings | ||
"-Wformat" | ||
"-Wformat-nonliteral" | ||
"-Wtautological-compare" | ||
"-Wunreachable-code" | ||
|
||
"-Werror" | ||
# "-Winline" # gcc on Linux seems to decide frequently not to inline, and warns about it. | ||
# # We don't need to know about it, since not inlining is not a problem. | ||
"-Wshadow" | ||
"-Wsign-conversion" | ||
# "-Wuseless-cast" # not supported by Clang | ||
# "-Wzero-as-null-pointer-constant" # not supported by Clang | ||
) | ||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
# Remove /W3 since /W4 will be added (otherwise we get a warning about replacing /W3 with /W4) | ||
string(REPLACE "/W3" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
|
||
# Remove /EHsc since /EHsc- will be added (otherwise we get a warning about replacing /EHsc with /EHsc-) | ||
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
|
||
# Remove /GR since /GR- will be added (otherwise we get a warning about replacing /GR with /GR-) | ||
string(REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
|
||
set(COMPILER_FLAGS | ||
"/W4" | ||
"/WX" # treat all warnings as errors | ||
# "/wdxxxx" # suppress specific warnings | ||
# "/wd4820" # suppress warning about padding | ||
"/wd4625" # suppress warning: | ||
# copy constructor could not be generated because a base class | ||
# copy constructor is inaccessible or deleted | ||
"/wd4626" # assignment operator could not be generated because a base | ||
# class assignment operator is inaccessible or deleted | ||
"/wd4127" # suppress warning: conditional expression is constant | ||
"/wd4505" # suppress warning: unreferenced function has been removed | ||
"/wd4206" # suppress warning: translation unit is empty | ||
"/wd4515" # suppress warning: namespace uses itself | ||
# "/wd4512" # suppress warning: assignment operator could not be generated | ||
# A fix is planned in Qt 5.4.2 (https://bugreports.qt.io/browse/QTBUG-7233) | ||
# Check later with Qt >= 5.4.2 if warning suppression can be removed | ||
"/nologo" | ||
"/EHsc-" # disable exceptions | ||
"/GR-" # disable RTTI | ||
) | ||
endif() | ||
|
||
string(REPLACE ";" " " COMPILER_FLAGS_STRING "${COMPILER_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS_STRING}") | ||
|
||
# disable compiler optimization which can cause release version to crash when using MinGW | ||
if(WIN32 AND NOT UNIX AND CMAKE_COMPILER_IS_GNUCXX) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-ipa-cp-clone") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
find_package(Cppcheck) | ||
|
||
if(CPPCHECK_FOUND) | ||
file(GLOB_RECURSE CPPCHECK_FILES RELATIVE ${CMAKE_SOURCE_DIR} *.cpp *.h) | ||
|
||
add_custom_target(cppcheck | ||
COMMAND ${CPPCHECK_EXECUTABLE} "--force" "--quiet" "--error-exitcode=1" ${CPPCHECK_FILES} | ||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" | ||
COMMENT "Running cppcheck..." | ||
VERBATIM) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
##################################################### | ||
# Start of configuration # | ||
# Lines below should not be touched in normal cases # | ||
##################################################### | ||
|
||
#======================================= | ||
# Set some variables to be used later on | ||
#======================================= | ||
set(PROJECT_NAME ${PROJECT_NAME_PREFIX}${PROJECT_BASE_NAME}) | ||
set(TARGET_NAME ${PROJECT_BASE_NAME}) | ||
set(PROJECT_NAMESPACE ${PROJECT_NAME_PREFIX}${SO_VERSION}) | ||
set(INSTALL_DIRECTORY_NAME ${PROJECT_NAME}/${PROJECT_NAME_PREFIX}${SO_VERSION}) | ||
set(CMAKE_DIRECTORY_NAME ${PROJECT_NAME_PREFIX}${SO_VERSION}${PROJECT_BASE_NAME}) | ||
set(PACKAGE_NAME ${PROJECT_NAME_PREFIX}${SO_VERSION}${PROJECT_BASE_NAME}) | ||
set(MODULE_NAME ${PROJECT_NAME}) | ||
#base name used for cmake config files: | ||
#<CMAKE_CONFIG_FILE_BASE_NAME>Config.cmake | ||
#<CMAKE_CONFIG_FILE_BASE_NAME>ConfigVersion.cmake | ||
#<CMAKE_CONFIG_FILE_BASE_NAME>Targets.cmake | ||
#<CMAKE_CONFIG_FILE_BASE_NAME>Targets_noconfig.cmake | ||
set(CMAKE_CONFIG_FILE_BASE_NAME ${PROJECT_NAME_PREFIX}${SO_VERSION}${PROJECT_BASE_NAME}) | ||
|
||
set(LIB_INSTALL_DIR lib/${INSTALL_DIRECTORY_NAME}) | ||
set(INCLUDE_INSTALL_DIR include/${INSTALL_DIRECTORY_NAME}) | ||
set(BIN_INSTALL_DIR bin) | ||
set(CMAKE_INSTALL_DIR lib/cmake/${CMAKE_DIRECTORY_NAME}) | ||
|
||
project(${PROJECT_NAME}) | ||
|
||
message(STATUS "Libraries will be installed to: ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}") | ||
message(STATUS "Header files will be installed to: ${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}") | ||
message(STATUS "Executables will be installed in: ${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}") | ||
message(STATUS "CMake config-files will be written to: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DIR}") | ||
message(STATUS "${PROJECT_NAME} import target: ${PROJECT_NAMESPACE}::${TARGET_NAME}") | ||
message(STATUS "Building ${PROJECT_NAME} ${FULL_VERSION} in ${CMAKE_BUILD_TYPE} mode") | ||
if (PRIVATE_TESTS_ENABLED) | ||
message(STATUS "Private tests are enabled") | ||
endif() |
Oops, something went wrong.