Skip to content

Commit

Permalink
Merge pull request #825 from CaseyCarter/build_fixes
Browse files Browse the repository at this point in the history
Build improvements:

* Use cmake 3.6.3 on Travis since `cmake_minimum_required(VERSION 3.6)`
* Add a new `rv3-test` interface library to hold test-specific configuration
* Define function `rv3_add_test(<name of test>, <name of executable>, <sources>...)` to simplify `CMakeLists.txt`
* Ensure that the threading and coroutine checks happen before including subdirs (This isn't an improvement, it's a bug fix without which the `generator` test will never be built.)
  • Loading branch information
CaseyCarter authored May 9, 2018
2 parents 4527cb5 + 0cd5836 commit 916fb88
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 852 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
- DEPS_DIR=${TRAVIS_BUILD_DIR}/deps
- BOOST_URL="http://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.tar.gz"
- BOOST_VERSION="1_63_0"
- CMAKE_VERSION="3.9.1"
- CMAKE_VERSION="3.6.3"

cache:
directories:
Expand Down Expand Up @@ -228,7 +228,7 @@ before_install:
- |
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
if [ -z "$(ls -A ${DEPS_DIR}/cmake-${CMAKE_VERSION}/cached)" ]; then
CMAKE_URL="https://cmake.org/files/v3.9/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz"
CMAKE_URL="https://cmake.org/files/v3.6/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz"
mkdir -p ${DEPS_DIR}/cmake-${CMAKE_VERSION}
travis_retry wget --no-check-certificate --quiet -O - "${CMAKE_URL}" | tar --strip-components=1 -xz -C ${DEPS_DIR}/cmake-${CMAKE_VERSION}
touch ${DEPS_DIR}/cmake-${CMAKE_VERSION}/cached
Expand Down
10 changes: 7 additions & 3 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
],
"cStandard": "c11",
"cppStandard": "c++17"
},
{
"name": "Linux",
Expand All @@ -44,7 +46,9 @@
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
"cStandard": "c11",
"cppStandard": "c++17"
},
{
"name": "Win32",
Expand All @@ -69,5 +73,5 @@
"cppStandard": "c++17"
}
],
"version": 3
"version": 4
}
28 changes: 11 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ target_include_directories(range-v3 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_
target_include_directories(range-v3 SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
target_link_libraries(range-v3 INTERFACE meta)

# Test for <thread>
try_compile(RANGE_V3_TRY_THREAD ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/thread_test_code.cpp)

# Test for coroutine TS support
include(CheckCXXSourceCompiles)

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/coro_test_code.cpp" RANGE_V3_CORO_TEST_CODE)
set(CMAKE_REQUIRED_FLAGS "-fcoroutines-ts")
check_cxx_source_compiles("${RANGE_V3_CORO_TEST_CODE}" RANGE_V3_HAS_FCOROUTINES_TS)
unset(CMAKE_REQUIRED_FLAGS)

add_subdirectory(doc)

if(RANGE_V3_TESTS)
Expand All @@ -42,23 +53,6 @@ if(RANGE_V3_PERF)
add_subdirectory(perf)
endif()

# Test for <thread>
try_compile(RANGE_V3_TRY_THREAD ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/thread_test_code.cpp)
if(NOT RANGE_V3_TRY_THREAD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRANGES_CXX_THREAD=0")
endif()

# Test for coroutine TS support
include(CheckCXXSourceCompiles)

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/coro_test_code.cpp" RANGE_V3_CORO_TEST_CODE)
set(CMAKE_REQUIRED_FLAGS "-fcoroutines-ts")
check_cxx_source_compiles("${RANGE_V3_CORO_TEST_CODE}" RANGE_V3_HAS_FCOROUTINES_TS)

if (RANGE_V3_HAS_FCOROUTINES_TS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines-ts")
endif()

# Test all headers
file(GLOB_RECURSE RANGE_V3_PUBLIC_HEADERS
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include"
Expand Down
16 changes: 8 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ configuration:
- Release

cache:
- C:\cmake-3.9.1-win32-x86
- C:\cmake-3.6.3-win32-x86

install:
- ps: |
if (![IO.File]::Exists("C:\cmake-3.9.1-win32-x86\bin\cmake.exe")) {
Start-FileDownload 'https://cmake.org/files/v3.9/cmake-3.9.1-win32-x86.zip'
7z x -y cmake-3.9.1-win32-x86.zip -oC:\
if (![IO.File]::Exists("C:\cmake-3.6.3-win32-x86\bin\cmake.exe")) {
Start-FileDownload 'https://cmake.org/files/v3.6/cmake-3.6.3-win32-x86.zip'
7z x -y cmake-3.6.3-win32-x86.zip -oC:\
}
$env:PATH="C:\cmake-3.9.1-win32-x86\bin;$env:PATH"
$env:PATH="C:\cmake-3.6.3-win32-x86\bin;$env:PATH"
- mkdir build && cd build
- ps: |
if ($env:PLATFORM -eq "x64" -and $env:CONFIGURATION -eq "Debug") {
$env:NO_HEADER_CHECK=0
$env:HEADER_CHECK=1
} else {
$env:NO_HEADER_CHECK=1
$env:HEADER_CHECK=0
}
- cmake .. -DRANGE_V3_NO_HEADER_CHECK=%NO_HEADER_CHECK% -DCMAKE_BUILD_TYPE=%CONFIGURATION% -T v140_clang_c2
- cmake .. -DRANGE_V3_HEADER_CHECKS=%HEADER_CHECK% -DCMAKE_BUILD_TYPE=%CONFIGURATION% -T v140_clang_c2

build:
project: c:/projects/range-v3/build/ALL_BUILD.vcxproj
Expand Down
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if(RANGES_BUILD_CALENDAR_EXAMPLE)
target_link_libraries(calendar range-v3)
target_link_libraries(calendar ${Boost_LIBRARIES})
message ("boost: ${Boost_LIBRARY_DIRS}")
target_compile_definitions(calendar PUBLIC -DBOOST_NO_AUTO_PTR)
target_compile_definitions(calendar PUBLIC BOOST_NO_AUTO_PTR)
target_compile_options(calendar PRIVATE -std=gnu++14)
set_target_properties(calendar PROPERTIES LINK_FLAGS "-L${Boost_LIBRARY_DIRS}")
endif()
Expand Down
89 changes: 30 additions & 59 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,68 +1,39 @@
include(../cmake/ranges_diagnostics.cmake)

add_library(rv3-tests INTERFACE)
target_link_libraries(rv3-tests INTERFACE range-v3)
if(NOT RANGE_V3_TRY_THREAD)
target_compile_definitions(rv3-tests INTERFACE "RANGES_CXX_THREAD=0")
endif()
if (RANGE_V3_HAS_FCOROUTINES_TS)
target_compile_options(rv3-tests INTERFACE "-fcoroutines-ts")
endif()

function(rv3_add_test TESTNAME EXENAME FIRSTSOURCE)
add_executable(${EXENAME} ${FIRSTSOURCE} ${ARGN})
target_link_libraries(${EXENAME} rv3-tests)
add_test(${TESTNAME} ${EXENAME})
endfunction(rv3_add_test)

add_subdirectory(action)
add_subdirectory(algorithm)
add_subdirectory(numeric)
add_subdirectory(utility)
add_subdirectory(view)
add_subdirectory(experimental)

add_executable(config config.cpp)
target_link_libraries(config range-v3)
add_test(test.config config)

add_executable(container_conversion container_conversion.cpp)
target_link_libraries(container_conversion range-v3)
add_test(test.container_conversion container_conversion)

add_executable(constexpr_core constexpr_core.cpp)
target_link_libraries(constexpr_core range-v3)
add_test(test.constexpr_core constexpr_core)

add_executable(view_facade view_facade.cpp)
target_link_libraries(view_facade range-v3)
add_test(test.view_facade view_facade)

add_executable(view_adaptor view_adaptor.cpp)
target_link_libraries(view_adaptor range-v3)
add_test(test.view_adaptor view_adaptor)

add_executable(index index.cpp)
target_link_libraries(index range-v3)
add_test(test.index index)

add_executable(iterator_range iterator_range.cpp)
target_link_libraries(iterator_range range-v3)
add_test(test.iterator_range iterator_range)

add_executable(multiple multiple1.cpp multiple2.cpp)
target_link_libraries(multiple range-v3)
add_test(test.multiple multiple)

add_executable(distance distance.cpp)
target_link_libraries(distance range-v3)
add_test(test.distance distance)

add_executable(to_container to_container.cpp)
target_link_libraries(to_container range-v3)
add_test(test.to_container to_container)

add_executable(getlines getlines.cpp)
target_link_libraries(getlines range-v3)
add_test(test.getlines getlines)

add_executable(istream_range istream_range.cpp)
target_link_libraries(istream_range range-v3)
add_test(test.istream_range istream_range)

add_executable(bug474 bug474.cpp)
target_link_libraries(bug474 range-v3)
add_test(test.bug474 bug474)

add_executable(bug566 bug566.cpp)
target_link_libraries(bug566 range-v3)
add_test(test.bug566 bug566)

add_executable(span span.cpp)
target_link_libraries(span range-v3)
add_test(test.span span)
rv3_add_test(test.config config config.cpp)
rv3_add_test(test.container_conversion container_conversion container_conversion.cpp)
rv3_add_test(test.constexpr_core constexpr_core constexpr_core.cpp)
rv3_add_test(test.view_facade view_facade view_facade.cpp)
rv3_add_test(test.view_adaptor view_adaptor view_adaptor.cpp)
rv3_add_test(test.index index index.cpp)
rv3_add_test(test.iterator_range iterator_range iterator_range.cpp)
rv3_add_test(test.multiple multiple multiple1.cpp multiple2.cpp)
rv3_add_test(test.distance distance distance.cpp)
rv3_add_test(test.to_container to_container to_container.cpp)
rv3_add_test(test.getlines getlines getlines.cpp)
rv3_add_test(test.istream_range istream_range istream_range.cpp)
rv3_add_test(test.bug474 bug474 bug474.cpp)
rv3_add_test(test.bug566 bug566 bug566.cpp)
rv3_add_test(test.span span span.cpp)
94 changes: 19 additions & 75 deletions test/action/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,75 +1,19 @@
add_executable(act.concepts cont_concepts.cpp)
target_link_libraries(act.concepts range-v3)
add_test(test.act.concepts act.concepts)

add_executable(act.drop drop.cpp)
target_link_libraries(act.drop range-v3)
add_test(test.act.drop act.drop)

add_executable(act.drop_while drop_while.cpp)
target_link_libraries(act.drop_while range-v3)
add_test(test.act.drop_while act.drop_while)

add_executable(act.insert insert.cpp)
target_link_libraries(act.insert range-v3)
add_test(test.act.insert act.insert)

add_executable(act.join join.cpp)
target_link_libraries(act.join range-v3)
add_test(test.act.join act.join)

add_executable(act.push_front push_front.cpp)
target_link_libraries(act.push_front range-v3)
add_test(test.act.push_front act.push_front)

add_executable(act.push_back push_back.cpp)
target_link_libraries(act.push_back range-v3)
add_test(test.act.push_back act.push_back)

add_executable(act.remove_if remove_if.cpp)
target_link_libraries(act.remove_if range-v3)
add_test(test.act.remove_if act.remove_if)

add_executable(act.reverse reverse.cpp)
target_link_libraries(act.reverse range-v3)
add_test(test.act.reverse act.reverse)

add_executable(act.shuffle shuffle.cpp)
target_link_libraries(act.shuffle range-v3)
add_test(test.act.shuffle act.shuffle)

add_executable(act.slice slice.cpp)
target_link_libraries(act.slice range-v3)
add_test(test.act.slice act.slice)

add_executable(act.sort sort.cpp)
target_link_libraries(act.sort range-v3)
add_test(test.act.sort act.sort)

add_executable(act.split split.cpp)
target_link_libraries(act.split range-v3)
add_test(test.act.split act.split)

add_executable(act.stable_sort stable_sort.cpp)
target_link_libraries(act.stable_sort range-v3)
add_test(test.act.stable_sort act.stable_sort)

add_executable(act.stride stride.cpp)
target_link_libraries(act.stride range-v3)
add_test(test.act.stride act.stride)

add_executable(act.take take.cpp)
target_link_libraries(act.take range-v3)
add_test(test.act.take act.take)

add_executable(act.take_while take_while.cpp)
target_link_libraries(act.take_while range-v3)
add_test(test.act.take_while act.take_while)

add_executable(act.transform transform.cpp)
target_link_libraries(act.transform range-v3)
add_test(test.act.transform act.transform)

add_executable(act.unique unique.cpp)
target_link_libraries(act.unique range-v3)
add_test(test.act.unique act.unique)
rv3_add_test(test.act.concepts act.concepts cont_concepts.cpp)
rv3_add_test(test.act.drop act.drop drop.cpp)
rv3_add_test(test.act.drop_while act.drop_while drop_while.cpp)
rv3_add_test(test.act.insert act.insert insert.cpp)
rv3_add_test(test.act.join act.join join.cpp)
rv3_add_test(test.act.push_front act.push_front push_front.cpp)
rv3_add_test(test.act.push_back act.push_back push_back.cpp)
rv3_add_test(test.act.remove_if act.remove_if remove_if.cpp)
rv3_add_test(test.act.reverse act.reverse reverse.cpp)
rv3_add_test(test.act.shuffle act.shuffle shuffle.cpp)
rv3_add_test(test.act.slice act.slice slice.cpp)
rv3_add_test(test.act.sort act.sort sort.cpp)
rv3_add_test(test.act.split act.split split.cpp)
rv3_add_test(test.act.stable_sort act.stable_sort stable_sort.cpp)
rv3_add_test(test.act.stride act.stride stride.cpp)
rv3_add_test(test.act.take act.take take.cpp)
rv3_add_test(test.act.take_while act.take_while take_while.cpp)
rv3_add_test(test.act.transform act.transform transform.cpp)
rv3_add_test(test.act.unique act.unique unique.cpp)
Loading

0 comments on commit 916fb88

Please sign in to comment.