Unverified Commit 2f7dc52e authored by Lei Wang's avatar Lei Wang Committed by GitHub
Browse files

[CMake] Added support for statically linked system libc library (#825)

parent 8554cb01
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
cmake_minimum_required(VERSION 3.18) cmake_minimum_required(VERSION 3.18)
project(TILE_LANG C CXX) project(TILE_LANG C CXX)
option(TILE_LANG_STATIC_STDCPP "Statically link libstdc++ for TileLang libraries" ON)
# Set default build type to Release if not provided # Set default build type to Release if not provided
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type") set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
...@@ -61,6 +63,18 @@ if(TILE_LANG_INSTALL_STATIC_LIB) ...@@ -61,6 +63,18 @@ if(TILE_LANG_INSTALL_STATIC_LIB)
set(BUILD_STATIC_RUNTIME ON) set(BUILD_STATIC_RUNTIME ON)
endif() endif()
if(TILE_LANG_STATIC_STDCPP)
message(STATUS "Enabling static linking of C++ standard library")
# Set compile flags for static linking of the C++ standard library
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
# For some compilers, additional flags may be required
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libstdc++")
endif()
endif()
# Enforce CUDA standard # Enforce CUDA standard
if(USE_CUDA) if(USE_CUDA)
set(CMAKE_CUDA_STANDARD 17) set(CMAKE_CUDA_STANDARD 17)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment