Skip to content

Commit

Permalink
Use ns.cmake + Update cmakes
Browse files Browse the repository at this point in the history
  • Loading branch information
ccharly committed Jan 28, 2016
1 parent 8547762 commit b8015fd
Show file tree
Hide file tree
Showing 21 changed files with 1,098 additions and 261 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,16 @@ matrix:
compiler: clang
env: CXX_STD=11 TOOLSET=clang++ SIMD_EXT=-msse2

# Install boost
before_install:
- bash ./script/travis/install.sh
- export BOOST_ROOT="$HOME/boost-trunk"

# Prepare build
before_script:
- export BOOST_ROOT=build/_install/include
- mkdir build
- cd build
- cmake .. -DCMAKE_CXX_COMPILER=$TOOLSET -DCMAKE_CXX_FLAGS="$SIMD_EXT $OPT -I$HOME/dispatch/include" -DSIMD_EXT=$SIMD_EXT -DCXX_STD=$CXX_STD -DTOOLSET=$TOOLSET
- cmake .. -DIS_TRAVIS_CI= -DCMAKE_CXX_COMPILER=$TOOLSET -DCMAKE_CXX_FLAGS="$SIMD_EXT $OPT -I$HOME/dispatch/include" -DSIMD_EXT=$SIMD_EXT -DCXX_STD=$CXX_STD -DTOOLSET=$TOOLSET

# Build unit and run test
script:
- make update.boost-header-only | grep -v "^-- Install" # Silent installation
- make update.boost.dispatch
- make -k unit
- ctest -D Experimental
144 changes: 87 additions & 57 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,77 +1,107 @@
#===================================================================================================
# Copyright 2012 - 2015 NumScale SAS
#
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt
#===================================================================================================
## -------------------------------------------------------------------------------------------------
## Copyright 2016 NumScale SAS
##
## Distributed under the Boost Software License, Version 1.0.
## See accompanying file LICENSE.txt or copy at
## http://www.boost.org/LICENSE_1_0.txt
## -------------------------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.7)

#===================================================================================================
# Setup target for MSVC
#===================================================================================================
## Setup project
## -------------------------------------------------------------------------------------------------
project(Boost.SIMD CXX)
set(PROJECT_DOC_DIR ${PROJECT_SOURCE_DIR}/doc)

## Setup target for MSVC
## -------------------------------------------------------------------------------------------------
if(NOT CMAKE_GENERATOR MATCHES "Make|Ninja")
set(CMAKE_CONFIGURATION_TYPES Release Debug SIMDTest SIMDTestDebug SIMDBench CACHE STRING "" FORCE)
endif()

##===================================================================================================
## Setup project
##===================================================================================================
project(Boost.SIMD CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test")
## Requirements for ns.cmake:
## -------------------------------------------------------------------------------------------------
set(NS_CMAKE_GIT_TAG master)
include(cmake/ns.cmake.install.cmake)
if (NOT NS_CMAKE_INSTALLED)
return()
endif()
include(cmake/ns/ns.cmake)
## -------------------------------------------------------------------------------------------------

##===================================================================================================
## Prevent in-source build
##===================================================================================================
if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
message( FATAL_ERROR "Building in-source, not recommended! Build in a separate directory." )
## Potential warnings fixup
## -------------------------------------------------------------------------------------------------
NS_ignore(${IS_TRAVIS_CI})
NS_ignore(${USE_SELF_BOOST})

## Search for packages
## -------------------------------------------------------------------------------------------------
if (DEFINED IS_TRAVIS_CI)
# We do not want to find boost here, as we're gonna use the one on NumScale/boost-header-only
set(GIT_EXECUTABLE git)
set(USE_SELF_BOOST TRUE)
else()
NS_find_package(Git QUIET)
if (NOT DEFINED USE_SELF_BOOST)
NS_find_package(Boost 1.60 REQUIRED)
endif()
endif()

##===================================================================================================
## Search for packages.
##===================================================================================================
set(Boost_ADDITIONAL_VERSIONS "1.59")
find_package(Boost 1.58)
find_package(Doxygen QUIET)
##
NS_prevent_in_source_build()

##===================================================================================================
## Install pre-commit git hook
##===================================================================================================
execute_process(COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/script/git/pre-commit
${PROJECT_SOURCE_DIR}/.git/hooks
)
## External projects
## -------------------------------------------------------------------------------------------------
set(STF_STANDALONE_DESTINATION ${PROJECT_SOURCE_DIR}/test)
set(BRIGAND_STANDALONE_DESTINATION ${PROJECT_SOURCE_DIR}/include/boost/simd/detail)

##===================================================================================================
## Compute version string and mode
##===================================================================================================
include(parse_revision)
NS_project_include(brigand.standalone)
NS_project_include(stf.standalone)
if (DEFINED USE_SELF_BOOST)
set(BOOST_HEADER_ONLY_GIT_TAG develop)
NS_project_include(boost-header-only)

##===================================================================================================
## Add include directories
##===================================================================================================
include_directories ( ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/test
${Boost_INCLUDE_DIRS}
)
# NOTE: (workaround)
# We DO need to use `CMAKE_ARGS` here otherwise, travis is not able to find boost even when
# exporting BOOST_ROOT using shell export...
set(BOOST_DISPATCH_GIT_TAG develop)
set(BOOST_DISPATCH_OPTIONS
CMAKE_ARGS "-DBOOST_ROOT=${BOOST_HEADER_ONLY_DESTINATION}/include"
)
NS_project_include(boost.dispatch)
set(Boost_INCLUDE_DIRS
${BOOST_DISPATCH_DESTINATION}/include
${BOOST_HEADER_ONLY_DESTINATION}/include
)
endif()

##===================================================================================================
## Setup Documentation
##===================================================================================================
add_subdirectory(doc)
## Compute version string and mode + Documentation
## -------------------------------------------------------------------------------------------------
if (NOT DEFINED IS_TRAVIS_CI)
NS_include(parse_revision)
NS_include(doc/doxygen)
endif()

## Install target
## -------------------------------------------------------------------------------------------------
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include DESTINATION .)

## Add include directories
## -------------------------------------------------------------------------------------------------
include_directories(
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/test
${Boost_INCLUDE_DIRS}
)

##===================================================================================================
## Setup Unit & Coverage Test
##===================================================================================================
## -------------------------------------------------------------------------------------------------
include(CTest)
add_custom_target(tests)
add_custom_target(unit)

include(coverage)
include( CTest )

enable_coverage(boost.simd)
add_dependencies(tests unit)

add_subdirectory(test)

if (NOT DEFINED IS_TRAVIS_CI)
NS_include(coverage)
enable_coverage(boost.simd)
endif()
67 changes: 67 additions & 0 deletions cmake/ns.cmake.install.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
##==================================================================================================
## Copyright 2015 NumScale SAS
##
## Distributed under the Boost Software License, Version 1.0.
## See accompanying file LICENSE.txt or copy at
## http://www.boost.org/LICENSE_1_0.txt
##==================================================================================================

include(ExternalProject)

if (NOT NS_CMAKE_INSTALL_DIR)
set(NS_CMAKE_INSTALL_DIR ${PROJECT_SOURCE_DIR})
endif()

if (NOT NS_CMAKE_EXTERNAL_PROJECTS_DESTINATION)
set(NS_CMAKE_EXTERNAL_PROJECTS_DESTINATION ${PROJECT_BINARY_DIR}/_install)
endif()

if (NOT NS_CMAKE_GIT_TAG)
set(NS_CMAKE_GIT_TAG master)
endif()

ExternalProject_Add(NS_CMAKE
GIT_REPOSITORY https://github.com/NumScale/ns.cmake.git
GIT_TAG ${NS_CMAKE_GIT_TAG}
PREFIX ${NS_CMAKE_EXTERNAL_PROJECTS_DESTINATION}

STEP_TARGETS install

INSTALL_DIR ${NS_CMAKE_INSTALL_DIR}
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${NS_CMAKE_INSTALL_DIR}"
)
set(NS_CMAKE_INSTALL_TARGET NS_CMAKE-install)
set(NS_CMAKE_SOURCES ${NS_CMAKE_INSTALL_DIR}/cmake)

set(NS_CMAKE_EXTERNAL_PROJECTS
NS_CMAKE
)

add_custom_target(ns.cmake.update
DEPENDS ${NS_CMAKE_INSTALL_TARGET}
)

add_custom_target(ns.cmake.installed
DEPENDS ns.cmake.update
)

if (EXISTS ${NS_CMAKE_INSTALL_DIR}/cmake/ns/ns.cmake)
message(STATUS "## -----------------------------------------------------------------------------")
message("")
message(" ns.cmake is now installed!")
message(" ns.cmake's (init) targets have been excluded from the `all` target!")
message("")
message(STATUS "## -----------------------------------------------------------------------------")
set_target_properties(NS_CMAKE
PROPERTIES EXCLUDE_FROM_ALL TRUE
)
set(NS_CMAKE_INSTALLED TRUE)
else()
message(WARNING "You intended to use ns.cmake, but it has not been installed yet!")

add_custom_command(
TARGET NS_CMAKE
COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}
)
set(NS_CMAKE_INSTALLED FALSE)
endif()
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
##==================================================================================================
## Copyright 2012 - 2015 NumScale SAS
## Copyright 2015 NumScale SAS
##
## Distributed under the Boost Software License, Version 1.0.
## See accompanying file LICENSE.txt or copy at
## http://www.boost.org/LICENSE_1_0.txt
##==================================================================================================

include(${NS_CMAKE_ROOT}/ns.cmake)
NS_guard(NS_CMAKE_ADD_TARGET_PARENT)

##==================================================================================================
## if they don't already exist, create a target and all of its logical parents
## e.g. foo.bar.baz.thing -> foo.baz.thing -> foo.thing -> thing
Expand Down
53 changes: 24 additions & 29 deletions cmake/compilers.cmake → cmake/ns/compilers.cmake
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@
##===================================================================================================
## Copyright 2012 - 2015 NumScale SAS
## Copyright 2015 NumScale SAS
##
## Distributed under the Boost Software License, Version 1.0.
## See accompanying file LICENSE.txt or copy at
## http://www.boost.org/LICENSE_1_0.txt
##===================================================================================================

include(${NS_CMAKE_ROOT}/ns.cmake)
NS_guard(NS_CMAKE_COMPILERS)

##===================================================================================================
## Detect if we need to add C++11 support & extra-warnings
##===================================================================================================
if(NOT BOOST_DISPATCH_COMPILER_OPTIONS_INCLUDED)
set(BOOST_DISPATCH_COMPILER_OPTIONS_INCLUDED 1)

if(CXX_STD)
string(REGEX MATCH "1(1|4|7)" MATCHED ${CXX_STD})
if(NOT MATCHED)
message(WARNING "CXX_STD did not match any valid C++ standard, falling back to c++11")
set(CXX_STD "11")
endif()
else()
if(DEFINED CXX_STD)
string(REGEX MATCH "1(1|4|7)" MATCHED ${CXX_STD})
if(NOT MATCHED)
NS_warn("CXX_STD did not match any valid C++ standard, falling back to c++11")
set(CXX_STD "11")
endif()
else()
set(CXX_STD "11")
endif()

if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CXX_STD} -Wall -Wshadow -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRIGAND_LEAN_AND_MEAN")
endif()

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
if("${CMAKE_CXX_FLAGS}" MATCHES "/W[1-4]")
string(REGEX REPLACE "/W[1-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DBRIGAND_LEAN_AND_MEAN")
if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CXX_STD} -Wall -Wshadow -Wextra")
else()
if("${CMAKE_CXX_FLAGS}" MATCHES "/W[1-4]")
string(REGEX REPLACE "/W[1-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
endif()

if(CMAKE_CXX_FLAGS MATCHES "[^ ]")
message(STATUS "[boost.simd] Compilation flags: ${CMAKE_CXX_FLAGS}")
endif()
if(CMAKE_CXX_FLAGS MATCHES "[^ ]")
NS_say("Compilation flags: ${CMAKE_CXX_FLAGS}")
endif()

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
## Remove /EHsc from CMAKE_CXX_FLAGS and re-add per configuration to avoid 'overriding' warnings
if(CMAKE_CXX_FLAGS MATCHES "/EHsc")
string(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
Expand All @@ -51,8 +47,7 @@ if(NOT BOOST_DISPATCH_COMPILER_OPTIONS_INCLUDED)
endif()

## MSVC12 needs /FS if building in debug in parallel
if(MSVC AND (MSVC_VERSION EQUAL 1800 OR MSVC_VERSION GREATER 1800))
if(MSVC_VERSION EQUAL 1800 OR MSVC_VERSION GREATER 1800)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /FS")
endif()

endif()
Loading

0 comments on commit b8015fd

Please sign in to comment.