Skip to content

Commit

Permalink
Merge pull request #43 from brunocodutra/develop
Browse files Browse the repository at this point in the history
merge develop
  • Loading branch information
brunocodutra authored Aug 28, 2016
2 parents 01270c5 + b559ab8 commit cd30e08
Show file tree
Hide file tree
Showing 126 changed files with 2,021 additions and 1,523 deletions.
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ addons:
- llvm-toolchain-precise-3.6
- llvm-toolchain-precise-3.7
- llvm-toolchain-precise-3.8
- llvm-toolchain-precise-3.9

matrix:
allow_failures:
- compiler: clang++
env: CXX_VERSION=3.9

exclude:
- env: BOGUS_JOB=true

Expand Down Expand Up @@ -124,11 +129,13 @@ before_install:
if [[ -n "${TRAVIS_TAG}" ]]
then
METAL_VERSION="${TRAVIS_TAG}"
METAL_VERSION_EXACT=true
else
METAL_VERSION=$( \
curl -Ls https://github.com/brunocodutra/metal/tags | \
awk '/tag-name/{print $3;exit}' FS='[<>]' \
)
METAL_VERSION_EXACT=false
fi
- METAL_VERSION="${METAL_VERSION%%-*}"
Expand Down Expand Up @@ -160,12 +167,8 @@ before_script:
- (cd "${METAL_BUILD_PATH}" && cmake "${METAL_SOURCE_PATH}" ${CMAKE_ARGS[@]} && make install)

- CMAKE_ARGS+=("-DCMAKE_PREFIX_PATH=${METAL_INSTALL_PATH}")
- |
if [[ -n "${METAL_VERSION}" ]]
then
CMAKE_ARGS+=("-DMETAL_VERSION=${METAL_VERSION}")
fi
- CMAKE_ARGS+=("-DMETAL_VERSION=${METAL_VERSION}")
- CMAKE_ARGS+=("-DMETAL_VERSION_EXACT=${METAL_VERSION_EXACT}")
- |
if [[ "${BUILD_DOC}" != "true" ]]
then
Expand Down
124 changes: 3 additions & 121 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,128 +6,10 @@ cmake_minimum_required(VERSION 2.8.12)

project(Metal CXX)

set(METAL_MAJOR_VERSION 0)
set(METAL_MINOR_VERSION 2)
set(METAL_PATCH_VERSION 0)
set(
METAL_VERSION
${METAL_MAJOR_VERSION}.${METAL_MINOR_VERSION}.${METAL_PATCH_VERSION}
)

if(WIN32 AND NOT CYGWIN)
set(METAL_CMAKE_INSTALL_DIR_DEF CMake)
else()
set(METAL_CMAKE_INSTALL_DIR_DEF lib/cmake/Metal)
endif()

set(METAL_CMAKE_INSTALL_DIR
${METAL_CMAKE_INSTALL_DIR_DEF} CACHE PATH
"installation directory for Metal CMake files"
)

set(METAL_INCLUDE_INSTALL_DIR
include CACHE PATH
"installation directory for Metal header files"
)

option(METAL_VERBOSE "increase output verbosity" OFF)
option(METAL_ENABLE_BASIC_WARNINGS "enable basic compiler warnings" OFF)
option(METAL_ENABLE_EXTRA_WARNINGS "enable extra compiler warnings" OFF)
option(METAL_STRICT "treat compiler warnings as errors" OFF)

if(METAL_ENABLE_EXTRA_WARNINGS)
set(METAL_ENABLE_BASIC_WARNINGS ON)
endif()

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(metal)

if(METAL_VERBOSE)
metal_try_add_flag(-v)
metal_try_add_flag(-ftemplate-backtrace-limit=0)
metal_try_add_flag(-fdiagnostics-show-template-tree)
metal_try_add_flag(-fno-elide-type)
endif()

if(METAL_ENABLE_BASIC_WARNINGS)
metal_try_add_flag(-W)
metal_try_add_flag(-Wall)
metal_try_add_flag(/W3)
endif()

if(METAL_ENABLE_EXTRA_WARNINGS)
metal_try_add_flag(-Wextra)
metal_try_add_flag(-Weverything)
metal_try_add_flag(-Wno-c++98-compat)
metal_try_add_flag(-Wno-c++98-compat-pedantic)
metal_try_add_flag(-Wno-documentation)
metal_try_add_flag(-Wno-documentation-unknown-command)
metal_try_add_flag(/W4)
endif()

if(METAL_STRICT)
metal_try_add_flag(-pedantic-errors)
metal_try_add_flag(-Werror)
metal_try_add_flag(/Za)
metal_try_add_flag(/WX)
endif()

foreach(dialect
-std=c++17 -std=c++1z
-std=c++14 -std=c++1y
/std:c++latest
)
metal_try_add_flag(${dialect} result)
if(${result})
break()
endif()
endforeach()

set(METAL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/)

include_directories("${METAL_INCLUDE_DIR}")

enable_testing()
include("${CMAKE_SOURCE_DIR}/cmake/config.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/testing.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/deployment.cmake")

add_subdirectory(doc)
add_subdirectory(example)
add_subdirectory(test)

foreach(_ INCLUDE CMAKE)
if(NOT IS_ABSOLUTE "${METAL_${_}_INSTALL_DIR}")
set(
METAL_${_}_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/${METAL_${_}_INSTALL_DIR}"
)
endif()
endforeach()

file(
RELATIVE_PATH METAL_INCLUDE_DIRS_CONF
"${METAL_CMAKE_INSTALL_DIR}" "${METAL_INCLUDE_INSTALL_DIR}"
)

set(METAL_INCLUDE_DIRS_CONF "\${METAL_CMAKE_DIR}/${METAL_INCLUDE_DIRS_CONF}")
configure_file(
cmake/MetalConfig.cmake.in
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/MetalConfig.cmake"
@ONLY
)

configure_file(
cmake/MetalConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/MetalConfigVersion.cmake"
@ONLY
)

install(
DIRECTORY "${METAL_INCLUDE_DIR}"
DESTINATION "${METAL_INCLUDE_INSTALL_DIR}"
)

install(
FILES
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/MetalConfig.cmake"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/MetalConfigVersion.cmake"
DESTINATION "${METAL_CMAKE_INSTALL_DIR}"
)
2 changes: 1 addition & 1 deletion cmake/MetalConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# METAL_INCLUDE_DIRS - include directories for Metal

get_filename_component(METAL_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(METAL_INCLUDE_DIRS "@METAL_INCLUDE_DIRS_CONF@")
set(METAL_INCLUDE_DIRS "@METAL_INCLUDE_DIRS@")
78 changes: 78 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright Bruno Dutra 2015-2016
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt

set(METAL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/")

file(STRINGS "${METAL_INCLUDE_DIR}/metal/config/version.hpp"
METAL_CONFIG_VERSION_HPP REGEX "METAL_[A-Z]+ [0-9]+" LIMIT_COUNT 3
)

LIST(GET METAL_CONFIG_VERSION_HPP 0 METAL_MAJOR)
LIST(GET METAL_CONFIG_VERSION_HPP 1 METAL_MINOR)
LIST(GET METAL_CONFIG_VERSION_HPP 2 METAL_PATCH)

string(REGEX REPLACE ".*MAJOR ([0-9]+).*" "\\1" METAL_MAJOR "${METAL_MAJOR}")
string(REGEX REPLACE ".*MINOR ([0-9]+).*" "\\1" METAL_MINOR "${METAL_MINOR}")
string(REGEX REPLACE ".*PATCH ([0-9]+).*" "\\1" METAL_PATCH "${METAL_PATCH}")

set(METAL_VERSION "${METAL_MAJOR}.${METAL_MINOR}.${METAL_PATCH}")

message(STATUS "Configuring Metal ${METAL_VERSION}")

option(METAL_ENABLE_WARNINGS "enable compiler warnings" ON)
option(METAL_STRICT "treat compiler warnings as errors" OFF)
option(METAL_VERBOSE "increase output verbosity" OFF)

include(CheckCXXCompilerFlag)
function(metal_try_add_flag _flag)
set(result "${_flag}")
string(TOUPPER "${result}" result)
string(REGEX REPLACE "[+]" "X" result "${result}")
string(REGEX REPLACE "[-/;=]" "_" result "${result}")
string(REGEX REPLACE "[^ A-Z_0-9]" "" result "${result}")
string(REGEX REPLACE "^[ ]*([A-Z_0-9]+) ?.*$" "\\1" result "${result}")
set(result "HAS${result}")

check_cxx_compiler_flag(${_flag} ${result})
if(${result})
add_compile_options(${_flag})
endif()

if(ARGN)
set(${ARGN} ${result} PARENT_SCOPE)
endif()
endfunction()

if(METAL_ENABLE_WARNINGS)
metal_try_add_flag(-W)
metal_try_add_flag(-Wall)
metal_try_add_flag(-Wextra)
metal_try_add_flag(-Weverything)
metal_try_add_flag(-Wno-c++98-compat)
metal_try_add_flag(-Wno-c++98-compat-pedantic)
metal_try_add_flag(-Wno-documentation)
metal_try_add_flag(-Wno-documentation-unknown-command)
metal_try_add_flag(/W3)
endif()

if(METAL_STRICT)
metal_try_add_flag(-pedantic-errors)
metal_try_add_flag(-Werror)
metal_try_add_flag(/Za)
metal_try_add_flag(/WX)
endif()

if(METAL_VERBOSE)
metal_try_add_flag(-v)
metal_try_add_flag(-ftemplate-backtrace-limit=0)
metal_try_add_flag(-fdiagnostics-show-template-tree)
metal_try_add_flag(-fno-elide-type)
endif()

foreach(dialect -std=c++17 -std=c++1z -std=c++14 -std=c++1y /std:c++latest)
metal_try_add_flag(${dialect} result)
if(${result})
break()
endif()
endforeach()
52 changes: 52 additions & 0 deletions cmake/deployment.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright Bruno Dutra 2015-2016
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt

if(WIN32 AND NOT CYGWIN)
set(METAL_CMAKE_INSTALL_DIR_DEF CMake)
else()
set(METAL_CMAKE_INSTALL_DIR_DEF lib/cmake/Metal)
endif()

set(METAL_CMAKE_INSTALL_DIR ${METAL_CMAKE_INSTALL_DIR_DEF} CACHE PATH
"installation directory for Metal CMake files"
)

set(METAL_INCLUDE_INSTALL_DIR include CACHE PATH
"installation directory for Metal header files"
)

foreach(_ INCLUDE CMAKE)
if(NOT IS_ABSOLUTE "${METAL_${_}_INSTALL_DIR}")
set(METAL_${_}_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/${METAL_${_}_INSTALL_DIR}"
)
endif()
endforeach()

file(RELATIVE_PATH METAL_INCLUDE_DIRS
"${METAL_CMAKE_INSTALL_DIR}" "${METAL_INCLUDE_INSTALL_DIR}"
)

set(METAL_INCLUDE_DIRS "\${METAL_CMAKE_DIR}/${METAL_INCLUDE_DIRS}")

configure_file(cmake/MetalConfig.cmake.in
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/MetalConfig.cmake"
@ONLY
)

configure_file(cmake/MetalConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/MetalConfigVersion.cmake"
@ONLY
)

install(DIRECTORY
"${METAL_INCLUDE_DIR}"
DESTINATION "${METAL_INCLUDE_INSTALL_DIR}"
)

install(FILES
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/MetalConfig.cmake"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/MetalConfigVersion.cmake"
DESTINATION "${METAL_CMAKE_INSTALL_DIR}"
)
28 changes: 4 additions & 24 deletions cmake/metal.cmake → cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,9 @@
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt

include(CheckCXXCompilerFlag)
enable_testing()

function(metal_try_add_flag _flag)
set(result "${_flag}")
string(TOUPPER "${result}" result)
string(REGEX REPLACE "[+]" "X" result "${result}")
string(REGEX REPLACE "[-/;=]" "_" result "${result}")
string(REGEX REPLACE "[^ A-Z_0-9]" "" result "${result}")
string(REGEX REPLACE "^[ ]*([A-Z_0-9]+) ?.*$" "\\1" result "${result}")
set(result "HAS${result}")

check_cxx_compiler_flag(${_flag} ${result})
if(${result})
add_compile_options(${_flag})
endif()

if(ARGN)
set(${ARGN} ${result} PARENT_SCOPE)
endif()
endfunction()

function(metal_add_test_tree _root _prefix)
function(metal_build_test_tree _root _prefix)
if(NOT TARGET ${_root})
message(FATAL_ERROR "'${_root}' is not a target.")
endif()
Expand Down Expand Up @@ -55,11 +36,10 @@ function(metal_add_test_tree _root _prefix)
add_dependencies(${_root} ${target})

if(IS_DIRECTORY "${_prefix}/${node}")
metal_add_test_tree(${target} "${_prefix}/${node}")
metal_build_test_tree(${target} "${_prefix}/${node}")
endif()

add_test(
NAME ${target}
add_test(NAME ${target}
COMMAND ${CMAKE_COMMAND} --build . --target ${target}
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
)
Expand Down
6 changes: 4 additions & 2 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ endif()
configure_file(Doxyfile.in METAL_DOXYFILE @ONLY)

add_custom_target(doc
COMMAND ${CMAKE_COMMAND} -E remove_directory html
COMMAND ${CMAKE_COMMAND} -E remove_directory "html"
COMMAND ${DOXYGEN_EXECUTABLE} METAL_DOXYFILE
COMMENT "building documentation..."
COMMAND ${CMAKE_COMMAND} -E remove
"html/*.png" "html/dir_*.html" "html/namespacemetal.html"
"html/dynsections.js" "html/doxygen.css" "html/tabs.css"
)
Loading

0 comments on commit cd30e08

Please sign in to comment.