Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on Windows fixed (dynamic linking of stdc++) #365

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ endif()
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)

if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
# Note: it must be performed before the Threads package finding (CMAKE_HAVE_LIBC_PTHREAD testing)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
endif()
Comment on lines +60 to +63
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for? I've never had problems with -pthread

find_package(Threads REQUIRED)

# main
Expand Down
14 changes: 12 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,19 @@ endif()

if (GGML_CUDA_SOURCES)
message(STATUS "GGML CUDA sources found, configuring CUDA architecture")
set_property(TARGET ggml PROPERTY CUDA_ARCHITECTURES OFF)
if(NOT ${CMAKE_CUDA_ARCHITECTURES})
set_property(TARGET ggml PROPERTY CUDA_ARCHITECTURES all) # all o OFF
endif()
set_property(TARGET ggml PROPERTY CUDA_SELECT_NVCC_ARCH_FLAGS "Auto")
target_link_libraries(ggml PUBLIC stdc++)
# Set the minimum standard, CMake can still decide to use -std=c++17
# if the given compilers support C++17
target_compile_features(ggml PUBLIC cuda_std_11)
# Note: Windows native does not link [non-cuda] stdc++ statically
set_target_properties(ggml PROPERTIES
CUDA_RUNTIME_LIBRARY SHARED
# CUDA_STANDARD 11 # This one cannot be changed by CMake
# CUDA_SEPARABLE_COMPILATION ON # Optional
)
endif()

set (GGML_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/ggml/ggml.h)
Expand Down