Permalink
Browse files

Apply cmake-init ffb1664f554764c8db0dee05292d4fbc39791808 (except PPA…

… packaging and AppVeyor CI)
  • Loading branch information...
scheibel committed Apr 27, 2017
1 parent 5af2bc5 commit b9ef24c05edc5008e5ab6fbfde46039d1fa66917
View
@@ -3,20 +3,39 @@ language: cpp
sudo: required
dist: trusty
os:
- linux
- osx
compiler:
- gcc
- clang
env:
global:
- CMAKE_OPTIONS="-DOPTION_BUILD_EXAMPLES=On"
matrix:
- CMAKE_CONFIGURATION=release BUILD_DIR=build
- CMAKE_CONFIGURATION=debug BUILD_DIR=build-debug
matrix:
exclude:
- os: osx
compiler: gcc
before_install:
- sudo apt-add-repository ppa:cginternals/backports-ppa -y
- sudo apt-get update -qq
- sudo apt-get install -qq cmake libgl1-mesa-dev mesa-common-dev libglm-dev libglfw3-dev qt5-default libcpplocate-dev libglbinding-dev
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-add-repository ppa:cginternals/backports-ppa -y; fi
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update -qq; fi
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -qq cmake libgl1-mesa-dev mesa-common-dev libglew-dev libglfw3-dev qt5-default libcpplocate-dev cppcheck clang-tidy-3.8 libglm-dev libglbinding-dev ; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install qt5 glm glbinding cppcheck; fi
before_script:
- mkdir build
- cd build
- cmake -DOPTION_BUILD_EXAMPLES=On ..
- ./configure
- if [ $CMAKE_CONFIGURATION == release ]; then ./configure; fi
- if [ $CMAKE_CONFIGURATION == debug ]; then ./configure debug; fi
script:
- make -j8
- make test
- cmake --build $BUILD_DIR
- cmake --build $BUILD_DIR --target test
- cmake --build $BUILD_DIR --target check-all
View
@@ -10,7 +10,6 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GenerateExportHeader)
set(WriterCompilerDetectionHeaderFound NOTFOUND)
@@ -22,6 +21,7 @@ endif()
include(cmake/GetGitRevisionDescription.cmake)
include(cmake/Custom.cmake)
include(cmake/HealthCheck.cmake)
# Set policies
set_policy(CMP0028 NEW) # ENABLE CMP0028: Double colon in target name means ALIAS or IMPORTED target.
@@ -37,6 +37,9 @@ set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all ta
# 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()
# Meta information about the project
set(META_PROJECT_NAME "globjects")
@@ -50,6 +53,7 @@ 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 "ffb1664f554764c8db0dee05292d4fbc39791808")
string(MAKE_C_IDENTIFIER ${META_PROJECT_NAME} META_PROJECT_ID)
string(TOUPPER ${META_PROJECT_ID} META_PROJECT_ID)
@@ -95,6 +99,18 @@ file(WRITE "${PROJECT_BINARY_DIR}/VERSION" "${META_NAME_VERSION}")
include(cmake/CompileOptions.cmake)
#
# Project Health Check Setup
#
# Add cmake-init template check cmake targets
add_check_template_target(${META_CMAKE_INIT_SHA})
# Configure health check tools
enable_cppcheck(On)
enable_clang_tidy(On)
#
# Deployment/installation setup
#
View
@@ -0,0 +1,49 @@
#
# Get cmake-init latest commit SHA on master
#
file(DOWNLOAD
"https://api.github.com/repos/cginternals/cmake-init/commits/master"
"${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}...master")
endif()
View
@@ -0,0 +1,23 @@
# 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"
)
add_dependencies(${check_target} ${target})
endfunction()
@@ -127,7 +127,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH
$<$<CXX_COMPILER_ID:Clang>:
-Wpedantic
-Wreturn-stack-address
# -Wreturn-stack-address # gives false positives
>
PUBLIC
$<$<PLATFORM_ID:Darwin>:
View
@@ -0,0 +1,27 @@
# 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>>"
--check-config
--enable=warning,performance,portability,information,missingInclude
--quiet
--std=c++11
--verbose
--suppress=missingIncludeSystem
${ARGN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_target_properties(${check_target}
PROPERTIES
FOLDER "Maintenance"
)
add_dependencies(${check_target} ${target})
endfunction()
View
@@ -1,8 +1,9 @@
# GLFW_FOUND
# GLFW_INCLUDE_DIR
# GLFW_LIBRARY
# GLFW_LIBRARY_RELEASE
# GLFW_LIBRARY_DEBUG
# GLFW_LIBRARIES
# GLFW_BINARY (win32 only)
include(FindPackageHandleStandardArgs)
@@ -25,7 +26,38 @@ find_path(GLFW_INCLUDE_DIR GLFW/glfw3.h
DOC "The directory where GLFW/glfw.h resides")
find_library(GLFW_LIBRARY_RELEASE NAMES glfw3 glfw glfw3dll glfwdll
set(GLFW_LIB_SUFFIX "")
if(MSVC14)
set(GLFW_LIB_SUFFIX "vc2015")
elseif(MSVS12)
set(GLFW_LIB_SUFFIX "vc2013")
elseif(MSVC11)
set(GLFW_LIB_SUFFIX "vc2012")
elseif(MSVC10)
set(GLFW_LIB_SUFFIX "vc2010")
elseif(MINGW)
if(X64)
set(GLFW_LIB_SUFFIX "mingw-w64")
else()
set(GLFW_LIB_SUFFIX "mingw")
endif()
endif()
set(GLFW_NAMES glfw3 glfw)
set(GLFW_DEBUG_NAMES glfw3d glfwd)
if(WIN32)
option(GLFW_SHARED "Use shared GLFW library (DLL)" ON)
if(GLFW_SHARED)
set(GLFW_NAMES glfw3dll glfwdll)
set(GLFW_DEBUG_NAMES glfw3ddll glfwddll)
endif()
endif()
find_library(GLFW_LIBRARY_RELEASE NAMES ${GLFW_NAMES}
HINTS
${GLFW_INCLUDE_DIR}/..
PATHS
$ENV{GLFW_DIR}
@@ -45,11 +77,15 @@ find_library(GLFW_LIBRARY_RELEASE NAMES glfw3 glfw glfw3dll glfwdll
PATH_SUFFIXES
/lib
/lib64
/lib-${GLFW_LIB_SUFFIX}
/src # for from-source builds
DOC "The GLFW library")
find_library(GLFW_LIBRARY_DEBUG NAMES glfw3d glfwd glfw3ddll glfwddll
find_library(GLFW_LIBRARY_DEBUG NAMES ${GLFW_DEBUG_NAMES}
HINTS
${GLFW_INCLUDE_DIR}/..
PATHS
$ENV{GLFW_DIR}
@@ -84,7 +120,7 @@ elseif(GLFW_LIBRARY_DEBUG)
set(GLFW_LIBRARIES ${GLFW_LIBRARY_DEBUG})
endif()
if(WIN32)
if(WIN32 AND GLFW_SHARED)
find_file(GLFW_BINARY glfw3.dll
@@ -99,6 +135,7 @@ if(WIN32)
PATH_SUFFIXES
/lib
/bin
/lib-${GLFW_LIB_SUFFIX}
DOC "The GLFW binary")
@@ -107,6 +144,7 @@ endif()
if(APPLE)
set(GLFW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
set(GLFW_iokit_LIBRARY "-framework IOKit" CACHE STRING "IOKit framework for OSX")
set(GLFW_corevideo_LIBRARY "-framework CoreVideo" CACHE STRING "CoreVideo framework for OSX")
endif()
# GLFW is required to link statically for now (no deploy specified)
View
@@ -0,0 +1,27 @@
# 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
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)
View
@@ -0,0 +1,22 @@
# Findcppcheck results:
# cppcheck_FOUND
# cppcheck_EXECUTABLE
include(FindPackageHandleStandardArgs)
find_program(cppcheck_EXECUTABLE
NAMES
cppcheck
PATHS
"${CPPCHECK_DIR}"
)
find_package_handle_standard_args(cppcheck
FOUND_VAR
cppcheck_FOUND
REQUIRED_VARS
cppcheck_EXECUTABLE
)
mark_as_advanced(cppcheck_EXECUTABLE)
Oops, something went wrong.

0 comments on commit b9ef24c

Please sign in to comment.