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

Update cmake to cpp 17 #511

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ version to be used.")
ezerhouni marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_CXX_EXTENSIONS OFF)

option(SHERPA_ENABLE_TESTS "Whether to build tests" OFF)
Expand Down
13 changes: 12 additions & 1 deletion cmake/cmake_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import setuptools
from setuptools.command.build_ext import build_ext

import torch

def is_for_pypi():
ans = os.environ.get("SHERPA_IS_FOR_PYPI", None)
Expand All @@ -24,6 +24,11 @@ def is_windows():
return platform.system() == "Windows"


def get_pytorch_version():
# if it is 1.7.1+cuda101, then strip +cuda101
return torch.__version__.split("+")[0]


try:
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel

Expand Down Expand Up @@ -77,6 +82,12 @@ def build_extension(self, ext: setuptools.extension.Extension):
print(f"Setting PYTHON_EXECUTABLE to {sys.executable}")
cmake_args += f" -DPYTHON_EXECUTABLE={sys.executable}"

major, minor = get_pytorch_version().split(".")[:2]
major = int(major)
minor = int(minor)
if major == 2 and minor >= 1:
extra_cmake_args += f" -DCMAKE_CXX_STANDARD=17 "

cmake_args += extra_cmake_args

if is_windows():
Expand Down