Skip to content

Commit

Permalink
fix cxx standard
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Oct 22, 2023
1 parent 3b4b59d commit 3ed5dfd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.")
set(CMAKE_CXX_EXTENSIONS OFF)

message(STATUS "C++ Standard version: ${CMAKE_CXX_STANDARD}")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

option(CMAKE_CXX_STANDARD 14 "The C++ version to be used." 14)
option(BUILD_SHARED_LIBS "Whether to build shared libraries" ON)
option(kaldifeat_BUILD_TESTS "Whether to build tests or not" ON)
option(kaldifeat_BUILD_PYMODULE "Whether to build python module or not" ON)

set(CMAKE_CXX_EXTENSIONS OFF)

message(STATUS "BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}")

if(BUILD_SHARED_LIBS AND MSVC)
Expand Down
17 changes: 13 additions & 4 deletions cmake/cmake_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
from pathlib import Path

import setuptools
import torch
from setuptools.command.build_ext import build_ext


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


def is_for_pypi():
ans = os.environ.get("KALDIFEAT_IS_FOR_PYPI", None)
return ans is not None
Expand Down Expand Up @@ -39,7 +45,6 @@ def finalize_options(self):
# -linux_x86_64.whl
self.root_is_pure = False


except ImportError:
bdist_wheel = None

Expand Down Expand Up @@ -70,6 +75,12 @@ def build_extension(self, ext: setuptools.extension.Extension):
extra_cmake_args = " -Dkaldifeat_BUILD_TESTS=OFF "
extra_cmake_args += f" -DCMAKE_INSTALL_PREFIX={Path(self.build_lib).resolve()}/kaldifeat " # noqa

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

if "PYTHON_EXECUTABLE" not in cmake_args:
print(f"Setting PYTHON_EXECUTABLE to {sys.executable}")
cmake_args += f" -DPYTHON_EXECUTABLE={sys.executable}"
Expand Down Expand Up @@ -103,9 +114,7 @@ def build_extension(self, ext: setuptools.extension.Extension):
else:
if make_args == "" and system_make_args == "":
print("For fast compilation, run:")
print(
'export KALDIFEAT_MAKE_ARGS="-j"; python setup.py install'
)
print('export KALDIFEAT_MAKE_ARGS="-j"; python setup.py install')
make_args = " -j4 "
print("Setting make_args to '-j4'")

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from cmake.cmake_extension import BuildExtension, bdist_wheel, cmake_extension
import get_version


get_package_version = get_version.get_package_version


Expand Down

0 comments on commit 3ed5dfd

Please sign in to comment.