diff --git a/.travis.yml b/.travis.yml index 143d82dc..5b6fd9cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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%%-*}" @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index d4494301..74d28d5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}" -) diff --git a/cmake/MetalConfig.cmake.in b/cmake/MetalConfig.cmake.in index e4604699..36549d57 100644 --- a/cmake/MetalConfig.cmake.in +++ b/cmake/MetalConfig.cmake.in @@ -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@") diff --git a/cmake/config.cmake b/cmake/config.cmake new file mode 100644 index 00000000..1c46c21c --- /dev/null +++ b/cmake/config.cmake @@ -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() diff --git a/cmake/deployment.cmake b/cmake/deployment.cmake new file mode 100644 index 00000000..3f4a13e7 --- /dev/null +++ b/cmake/deployment.cmake @@ -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}" +) diff --git a/cmake/metal.cmake b/cmake/testing.cmake similarity index 62% rename from cmake/metal.cmake rename to cmake/testing.cmake index 63d137c8..a084e9b1 100644 --- a/cmake/metal.cmake +++ b/cmake/testing.cmake @@ -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() @@ -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}" ) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 5ee6cf86..f2205f9f 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -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" ) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 40cf283f..3e6ada9e 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -253,7 +253,7 @@ ALIASES +=semantics="\par Semantics" ALIASES +=tip{1}="