Skip to content

Commit

Permalink
Merge pull request #923 from pbalcer/l0-win-fix-build
Browse files Browse the repository at this point in the history
[L0] fix windows cmake scripts
  • Loading branch information
pbalcer authored Oct 4, 2023
2 parents f1c17dc + ec915f8 commit e6343f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,16 @@ jobs:
strategy:
matrix:
os: ['windows-2019', 'windows-2022']
adapter: [
{name: None, var: ''}, {name: L0, var: '-DUR_BUILD_ADAPTER_L0=ON'}
]

# TODO: building level zero loader on windows-2019 is currently broken
exclude:
- os: 'windows-2019'
adapter: {name: L0, var: '-DUR_BUILD_ADAPTER_L0=ON'}
build_type: [Debug, Release]
compiler: [{c: cl.exe, cxx: cl.exe}, {c: clang-cl.exe, cxx: clang-cl.exe}]
runs-on: ${{matrix.os}}

steps:
Expand All @@ -283,11 +292,14 @@ jobs:
run: >
cmake
-B${{github.workspace}}/build
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DCMAKE_POLICY_DEFAULT_CMP0094=NEW
-DUR_ENABLE_TRACING=ON
-DUR_DEVELOPER_MODE=ON
-DUR_BUILD_TESTS=ON
-DUR_FORMAT_CPP_STYLE=ON
${{matrix.adapter.var}}
# TODO: re-enable when check-generated is fixed for windows runners see #888
# - name: Generate source from spec, check for uncommitted diff
Expand Down
29 changes: 10 additions & 19 deletions source/adapters/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,16 @@ if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR)
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
)
set(CMAKE_CXX_FLAGS_BAK "${CMAKE_CXX_FLAGS}")
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX-")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX-")
# FIXME: Unified runtime build fails with /DUNICODE
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /UUNICODE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /UUNICODE")
# USE_Z7 forces use of /Z7 instead of /Zi which is broken with sccache
set(USE_Z7 ON)
set(USE_Z7 ON)
endif()
FetchContent_MakeAvailable(level-zero-loader)
FetchContent_GetProperties(level-zero-loader)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BAK}")
target_compile_options(ze_loader PRIVATE
$<$<IN_LIST:$<CXX_COMPILER_ID>,GNU;Clang;Intel;IntelLLVM>:-Wno-error>
$<$<CXX_COMPILER_ID:MSVC>:/WX- /UUNICODE>
)

set(LEVEL_ZERO_LIBRARY ze_loader)
set(LEVEL_ZERO_INCLUDE_DIR
Expand All @@ -56,16 +52,6 @@ target_link_libraries(LevelZeroLoader
INTERFACE "${LEVEL_ZERO_LIB_NAME}"
)

# Windows build might have warnings (both MSVC and ICX), disable Werror etc.
if (NOT WIN32)
target_compile_options(${LEVEL_ZERO_LIB_NAME} PUBLIC
-Wno-unused-but-set-variable
-Wno-pedantic
-Wno-unused-parameter
-Wno-error
)
endif()

add_library (LevelZeroLoader-Headers INTERFACE)
target_include_directories(LevelZeroLoader-Headers
INTERFACE "${LEVEL_ZERO_INCLUDE_DIR}"
Expand Down Expand Up @@ -106,6 +92,11 @@ add_ur_adapter(${TARGET_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
)

# TODO: fix level_zero adapter conversion warnings
target_compile_options(${TARGET_NAME} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/wd4267 /wd4805 /wd4244 /D_CRT_SECURE_NO_WARNINGS>
)

set_target_properties(${TARGET_NAME} PROPERTIES
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
Expand Down

0 comments on commit e6343f4

Please sign in to comment.