Skip to content

Commit

Permalink
Add GitHub Actions workflow for MSVC builds
Browse files Browse the repository at this point in the history
  • Loading branch information
psyrykh committed Jan 9, 2024
1 parent 86ae71a commit bcafe74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/msvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
arch: ${{ matrix.arch }}
- name: Build
run: |
cmake -S . -B build_${{ matrix.arch }}
cmake -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="" -S . -B build_${{ matrix.arch }}
cmake --build build_${{ matrix.arch }}
- uses: actions/upload-artifact@v4
with:
name: bin_${{ matrix.arch }}
path: build_${{ matrix.arch }}/benchmark_cli/benchmark-cli*
path: build_${{ matrix.arch }}/benchmark_cli/benchmark-cli.exe
13 changes: 13 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,21 @@ if (MSVC)
string(REGEX REPLACE "(/MDd|/Ob.|/O.|/MD|/RTC.)" "" CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
string(REGEX REPLACE "(/MDd|/Ob.|/O.|/MD|/RTC.)" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")

message(STATUS "")

target_compile_options(benchmark-core-optimized BEFORE PRIVATE /MT /O1 /Ob1 /DNDEBUG)
target_compile_options(benchmark-core-nonoptimized BEFORE PRIVATE /MTd /Zi /Ob0 /Od /RTC1)

foreach (OPTIMIZATION optimized nonoptimized)
get_target_property(compile_defs benchmark-core-${OPTIMIZATION} COMPILE_OPTIONS)
message(STATUS "benchmark-core-${OPTIMIZATION} compile definitions are ${compile_defs}")
endforeach()

foreach (var CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
message(STATUS "${var} compile definitions are ${${var}}")
message(STATUS "${var}_${CMAKE_BUILD_TYPE_UPPER} compile definitions are ${${var}_${CMAKE_BUILD_TYPE_UPPER}}")
endforeach ()

else ()
target_compile_options(benchmark-core-optimized BEFORE PRIVATE -O3 -DNDEBUG)
target_compile_options(benchmark-core-nonoptimized BEFORE PRIVATE -O0 -g)
Expand Down
7 changes: 4 additions & 3 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ if (CheckCSourceCompiles_FOUND AND NOT DEFINED WB_USE_UNISTD)
file(READ "${CMAKE_HOME_DIRECTORY}/compiler_probes/unistd.c" TEST_SOURCE_CODE)
check_c_source_compiles("${TEST_SOURCE_CODE}" CAN_USE_UNISTD)
if(CAN_USE_UNISTD)
set(CAN_USE_UNISTD ON)
set(WB_USE_UNISTD ON)
else ()
set(CAN_USE_UNISTD OFF)
set(WB_USE_UNISTD OFF)
endif ()
endif ()
if (CAN_USE_UNISTD)
if (${WB_USE_UNISTD} STREQUAL ON)
add_compile_definitions(WB_USE_UNISTD)
elseif (${WB_USE_UNISTD} STREQUAL OFF)
else ()
message(FATAL_ERROR "CAN_USE_UNISTD=${CAN_USE_UNISTD} is not a valid option. Valid are (ON,OFF)")
endif ()

0 comments on commit bcafe74

Please sign in to comment.