Skip to content

Commit

Permalink
flexible sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
vinovo committed Oct 24, 2024
1 parent 933f89e commit d99f636
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-wheels-cpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
CIBW_CMAKE_OPTIONS: >-
-DCMAKE_SYSTEM_VERSION=10.0.18362.0
-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=10.0.18362.0
-DCMAKE_GENERATOR_PLATFORM=x64
with:
package-dir: .
output-dir: wheelhouse
Expand Down
49 changes: 30 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ if (GGML_CUDA OR GGML_METAL OR GGML_HIPBLAS OR GGML_VULKAN)
add_custom_target(create_empty_file ALL DEPENDS ${SOURCE_EMPTY_FILE_PATH} ${WHEEL_EMPTY_FILE_PATH})
endif()

if(WIN32)
set(WINDOWS_SDK_VERSION "10.0.18362.0")
set(CMAKE_SYSTEM_VERSION ${WINDOWS_SDK_VERSION} CACHE STRING "" FORCE)
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION ${WINDOWS_SDK_VERSION} CACHE STRING "" FORCE)

# Add these to common CMake options
list(APPEND COMMON_CMAKE_OPTIONS
-DCMAKE_SYSTEM_VERSION=${WINDOWS_SDK_VERSION}
-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=${WINDOWS_SDK_VERSION}
)
endif()

if(WIN32 AND GGML_CUDA)
set(BUILD_PARALLEL_LEVEL "2" CACHE STRING "Number of parallel jobs for MSBuild in CUDA compilation")
set(MSBUILD_ARGS "/m:${BUILD_PARALLEL_LEVEL}")
Expand Down Expand Up @@ -83,6 +71,17 @@ set(COMMON_CMAKE_OPTIONS
-DCMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH}
)

if(WIN32)
# Only propagate SDK version if it was explicitly specified
if(CMAKE_SYSTEM_VERSION)
message(STATUS "Using specified Windows SDK version: ${CMAKE_SYSTEM_VERSION}")
list(APPEND COMMON_CMAKE_OPTIONS
-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}
-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=${CMAKE_SYSTEM_VERSION}
)
endif()
endif()

# stable_diffusion_cpp project
option(STABLE_DIFFUSION_BUILD "Build stable-diffusion.cpp" ON)
if(STABLE_DIFFUSION_BUILD)
Expand Down Expand Up @@ -138,13 +137,25 @@ endif()
option(BARK_BUILD "Build bark.cpp" ON)
if(BARK_BUILD)
if(WIN32)
set(BARK_WINDOWS_OPTIONS
-DCMAKE_SYSTEM_VERSION=${WINDOWS_SDK_VERSION}
-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=${WINDOWS_SDK_VERSION}
-DCMAKE_GENERATOR_PLATFORM=x64
)
else()
set(BARK_WINDOWS_OPTIONS "")
set(BARK_WINDOWS_OPTIONS)
# Propagate SDK version if specified
if(CMAKE_SYSTEM_VERSION)
list(APPEND BARK_WINDOWS_OPTIONS
-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}
-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=${CMAKE_SYSTEM_VERSION}
)
endif()
# Propagate generator settings
if(CMAKE_GENERATOR_PLATFORM)
list(APPEND BARK_WINDOWS_OPTIONS
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
)
endif()
if(CMAKE_GENERATOR)
list(APPEND BARK_WINDOWS_OPTIONS
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
)
endif()
endif()

ExternalProject_Add(bark_project
Expand Down

0 comments on commit d99f636

Please sign in to comment.