|
2 | 2 | cmake_minimum_required(VERSION 3.11...3.26) |
3 | 3 | enable_testing() |
4 | 4 |
|
5 | | -# Be pedantic for clean code |
6 | | -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
7 | | - set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra -pedantic") |
| 5 | +if (WIN32) |
| 6 | + # Need bigobj because some tests use lots of templates |
| 7 | + if (MSVC) |
| 8 | + add_compile_options("/bigobj") |
| 9 | + elseif(MINGW) |
| 10 | + # Also add -Os to reduce maximum filesize |
| 11 | + add_compile_options("-Wa,-mbig-obj" "-Os") |
| 12 | + endif() |
| 13 | +else() |
| 14 | + # Be pedantic for clean code |
| 15 | + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
| 16 | + add_compile_options("-g" "-Wall" "-Wextra" "-pedantic") |
| 17 | + endif() |
| 18 | +endif() |
| 19 | + |
| 20 | +if (MINGW AND WIN32) |
| 21 | + # The MinGW on GitHub Actions requires these. |
| 22 | + # If omitted some executables crash with 'Exit code 0xc0000139' which appears to mean a missing DLL. |
| 23 | + add_link_options("-static-libstdc++" "-static-libgcc") |
8 | 24 | endif() |
9 | 25 |
|
10 | 26 | # Code Coverage |
@@ -55,19 +71,26 @@ add_executable(cpp11_test cpp11_test.cpp) |
55 | 71 | target_link_libraries(cpp11_test PUBLIC poolSTL::poolSTL) |
56 | 72 | target_compile_features(cpp11_test PUBLIC cxx_std_11) |
57 | 73 |
|
58 | | -# Test std::execution supplementation |
59 | | -# This uses only std::execution::par. On compilers with support this should result in a poolSTL no-op, |
60 | | -# and on ones without support it should use fallback to poolstl::par. |
| 74 | +# Test std::execution supplementation. |
| 75 | +# The test code uses only std::execution::par, seq, and par_unseq. |
| 76 | +# On compilers with support poolSTL does nothing, else poolSTL creates a fallback using poolstl::par. |
61 | 77 | add_executable(supplement_test supplement_test.cpp) |
62 | 78 | target_link_libraries(supplement_test PUBLIC poolSTL::poolSTL) |
63 | 79 | target_compile_features(supplement_test PUBLIC cxx_std_17) |
64 | 80 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
65 | | - # GCC and Clang require TBB for std::execution::par |
| 81 | + # GCC and Clang require TBB for std::execution::par. |
| 82 | + # MinGW will compile std::execution::par without TBB, but performance is sequential. |
66 | 83 | find_package(TBB) |
67 | 84 | if (TBB_FOUND) |
68 | 85 | target_link_libraries(supplement_test PUBLIC TBB::tbb) |
69 | 86 | else() |
70 | 87 | message("No TBB") |
71 | | - target_compile_definitions(supplement_test PUBLIC POOLSTL_MISSING_NEEDED_TBB) |
| 88 | + # Prevent including <execution>, as doing that requires linking against TBB on newer GCC/Clang. |
| 89 | + target_compile_definitions(supplement_test PUBLIC POOLSTL_STD_SUPPLEMENT_NO_INCLUDE) |
| 90 | + if (MINGW) |
| 91 | + # extra hack! |
| 92 | + # MinGW declares support, so must override poolSTL's auto-detection to enable the supplement. |
| 93 | + target_compile_definitions(supplement_test PUBLIC POOLSTL_STD_SUPPLEMENT_FORCE) |
| 94 | + endif() |
72 | 95 | endif() |
73 | 96 | endif() |
0 commit comments