Skip to content

Commit 35d0cc9

Browse files
committed
Improve CMake and switch to Azure pipelines
2 parents 100b370 + db9890f commit 35d0cc9

8 files changed

Lines changed: 141 additions & 113 deletions

File tree

.appveyor.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ install:
1717
- call "%VCVARS_FILE%" %VCVARS_ARG%
1818

1919
build_script:
20-
- mkdir build
21-
- cd build
22-
- cmake .. -G "NMake Makefiles" -DCMAKE_CXX_FLAGS="/EHsc /WX /W4 /wd4459 /wd4800 /wd4127"
23-
- nmake
24-
- ctest --output-on-failure
20+
- mkdir build && cd build
21+
- cmake ../
22+
- cmake --build .
23+
- ctest -C Debug --output-on-failure

.travis.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# This file is subject to the license terms in the LICENSE file
33
# found in the top-level directory of this distribution.
44

5-
cmake_minimum_required(VERSION 3.1)
6-
project(array)
5+
cmake_minimum_required(VERSION 3.8)
6+
project(foonathan_array VERSION 0.0.0)
77

8+
# source files
89
set(detail_header_files
910
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/array/detail/all_of.hpp
1011
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/array/detail/is_trivial.hpp
@@ -39,14 +40,37 @@ set(header_files
3940
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/array/small_bag.hpp
4041
${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/array/variant_bag.hpp
4142
)
43+
44+
# main target
4245
add_library(foonathan_array INTERFACE)
43-
target_sources(foonathan_array INTERFACE ${detail_header_files} ${header_files})
44-
target_include_directories(foonathan_array INTERFACE include)
45-
if(MSVC)
46-
target_compile_definitions(foonathan_array INTERFACE "-D_SCL_SECURE_NO_WARNINGS")
46+
add_library(foonathan::foonathan_array ALIAS foonathan_array)
47+
target_sources(foonathan_array INTERFACE $<BUILD_INTERFACE:${detail_header_files} ${header_files}>)
48+
target_compile_features(foonathan_array INTERFACE cxx_std_11)
49+
target_include_directories(foonathan_array SYSTEM INTERFACE
50+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
51+
$<INSTALL_INTERFACE:include/>)
52+
53+
# installation
54+
if(NOT dependency_via_submodule)
55+
include(CMakePackageConfigHelpers)
56+
write_basic_package_version_file(foonathan_array-config-version.cmake COMPATIBILITY ExactVersion)
57+
install(TARGETS foonathan_array EXPORT foonathan_array_targets
58+
INCLUDES DESTINATION include)
59+
install(EXPORT foonathan_array_targets
60+
DESTINATION lib/cmake/foonathan_array
61+
FILE foonathan_array-targets.cmake
62+
NAMESPACE foonathan::)
63+
install(DIRECTORY include/
64+
DESTINATION include)
65+
install(FILES foonathan_array-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/foonathan_array-config-version.cmake
66+
DESTINATION lib/cmake/foonathan_array)
67+
else()
68+
message(STATUS "Dependency installed via submodule, installation unavailable")
4769
endif()
4870

49-
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
71+
# subdirectories
72+
option(FOONATHAN_ARRAY_BUILD_TEST "build tests of foonathan/array" OFF)
73+
if(${FOONATHAN_ARRAY_BUILD_TEST} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
5074
enable_testing()
5175
add_subdirectory(test)
5276
endif()

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# array
22

3-
[![Build Status](https://travis-ci.com/foonathan/array.svg)](https://travis-ci.com/foonathan/array)
3+
[![Build Status](https://dev.azure.com/foonathan/array/_apis/build/status/foonathan.array)](https://dev.azure.com/foonathan/array/_build/latest?definitionId=4)
44
[![Build status](https://ci.appveyor.com/api/projects/status/iydnaute3tiqxi9u?svg=true)](https://ci.appveyor.com/project/foonathan/array)
55
[![Boost Licensed](https://img.shields.io/badge/license-Boost-blue.svg)](LICENSE)
66

@@ -101,9 +101,13 @@ Header-only (almost everything is a template anyway), no dependencies (currently
101101
It requires at least C++11, but works better with C++14 or 17.
102102
Compilers that are being tested on CI:
103103

104-
* Linux: GCC 4.8, 4.9, 5, 6, 7 and clang 3.9, 4, 5
105-
* OSX: the clang coming with Xcode 8 and 9
106-
* MSVC: Visual Studio 2015 and 2017
104+
* Linux:
105+
* GCC 4.9 to 8
106+
* clang 3.9 to 7
107+
* MacOS:
108+
* XCode 8, 9 and 10
109+
* Windows:
110+
* Visual Studio 2015 and 2017
107111

108112
Newer compilers should work too.
109113

azure-pipelines.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: 'CI build'
2+
trigger:
3+
branches:
4+
include:
5+
- master
6+
- feature/*
7+
paths:
8+
exclude:
9+
- README.md
10+
11+
jobs:
12+
- job: windows
13+
pool:
14+
vmImage: 'vs2017-win2016'
15+
steps:
16+
- script: |
17+
mkdir build && cd build/
18+
cmake ../ && cmake --build . && ctest -C Debug --output-on-failure
19+
displayName: "Compiling using Visual Studio 2017"
20+
21+
- job: linux
22+
pool:
23+
vmImage: 'Ubuntu 16.04'
24+
strategy:
25+
matrix:
26+
GCC49:
27+
IMAGE: 'conanio/gcc49'
28+
GCC5:
29+
IMAGE: 'conanio/gcc5'
30+
GCC6:
31+
IMAGE: 'conanio/gcc6'
32+
GCC7:
33+
IMAGE: 'conanio/gcc7'
34+
GCC8:
35+
IMAGE: 'conanio/gcc8'
36+
clang39:
37+
IMAGE: 'conanio/clang39'
38+
clang4:
39+
IMAGE: 'conanio/clang40'
40+
clang5:
41+
IMAGE: 'conanio/clang50'
42+
clang6:
43+
IMAGE: 'conanio/clang60'
44+
clang7:
45+
IMAGE: 'conanio/clang7'
46+
DefaultGCC:
47+
IMAGE: 'foonathan/micro_cpp_gcc'
48+
DefaultClang:
49+
IMAGE: 'foonathan/micro_cpp_clang'
50+
steps:
51+
- script: docker run -u root -v "$PWD:/array" $(IMAGE) bash -c "cmake /array/ && cmake --build . && ctest --output-on-failure"
52+
displayName: "Compiling using $(IMAGE)"
53+
54+
- job: macos
55+
pool:
56+
vmImage: 'macOS-10.13'
57+
strategy:
58+
matrix:
59+
XCode10:
60+
XCODE: '10.1'
61+
XCode9:
62+
XCODE: '9.4.1'
63+
XCode8:
64+
XCODE: '8.3.3'
65+
steps:
66+
- script: |
67+
sudo xcode-select -s /Applications/Xcode_$(XCODE).app/Contents/Developer
68+
mkdir build && cd build/
69+
cmake ../ && cmake --build . && ctest --output-on-failure
70+
displayName: "Compiling using XCode $(XCODE)"

foonathan_array-config.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (C) 2018 Jonathan Müller <[email protected]>
2+
# This file is subject to the license terms in the LICENSE file
3+
# found in the top-level directory of this distribution.
4+
5+
include(CMakeFindDependencyMacro)
6+
include("${CMAKE_CURRENT_LIST_DIR}/foonathan_array-targets.cmake")

test/CMakeLists.txt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This file is subject to the license terms in the LICENSE file
33
# found in the top-level directory of this distribution.
44

5+
# get Catch
56
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/catch.hpp)
67
file(DOWNLOAD
78
https://raw.githubusercontent.com/catchorg/Catch2/master/single_include/catch2/catch.hpp
@@ -18,6 +19,7 @@ if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/catch.hpp)
1819
endif()
1920
endif()
2021

22+
# unit tests
2123
set(tests
2224
array.cpp
2325
array_view.cpp
@@ -47,8 +49,24 @@ add_executable(foonathan_array_test
4749
equal_checker.hpp
4850
leak_checker.hpp
4951
${tests})
50-
target_include_directories(foonathan_array_test SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
51-
target_link_libraries(foonathan_array_test PUBLIC foonathan_array)
52-
set_target_properties(foonathan_array_test PROPERTIES CXX_STANDARD 11)
52+
target_include_directories(foonathan_array_test PUBLIC
53+
${CMAKE_CURRENT_SOURCE_DIR}
54+
${CMAKE_CURRENT_SOURCE_DIR}/../include
55+
SYSTEM PUBLIC
56+
${CMAKE_CURRENT_BINARY_DIR})
57+
target_compile_features(foonathan_array_test PUBLIC cxx_std_11)
58+
target_compile_options(foonathan_array_test PUBLIC
59+
# clang/GCC warnings
60+
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
61+
-pedantic-errors -Werror -Wall -Wextra -Wconversion -Wsign-conversion>
62+
# disable noexcept type warning on GCC
63+
$<$<CXX_COMPILER_ID:GNU>: -Wno-noexcept-type>
64+
# disable mismatched tags warning on clang
65+
$<$<CXX_COMPILER_ID:Clang>: -Wno-mismatched-tags>
66+
# MSVC warnings
67+
# disable constant expression in if due to false positive
68+
# disable truncating to bool even though there is a cast warning
69+
$<$<CXX_COMPILER_ID:MSVC>:
70+
/WX /W4 /D_SCL_SECURE_NO_WARNINGS /wd4127 /wd4800>)
5371

5472
add_test(NAME test COMMAND foonathan_array_test)

test/equal_checker.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ namespace
2424
FAIL("not expected elements");
2525
}
2626
}
27-
}; // namespace
27+
} // namespace
2828

2929
#endif // FOONATHAN_ARRAY_EQUAL_CHECKER_HPP_INCLUDED

0 commit comments

Comments
 (0)