Skip to content

Commit

Permalink
improve building
Browse files Browse the repository at this point in the history
  • Loading branch information
daanzu committed Feb 29, 2020
1 parent 98e9267 commit 0de3e3e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ set(LIBRARIES
src/lib/libkaldi-tree${CMAKE_SHARED_LIBRARY_SUFFIX}
src/lib/libkaldi-util${CMAKE_SHARED_LIBRARY_SUFFIX})

set(KALDI_CONFIG_FLAGS --shared --static-math)
if(DEFINED ENV{INTEL_MKL_DIR})
set(INTEL_MKL_DIR $ENV{INTEL_MKL_DIR})
else()
set(INTEL_MKL_DIR "/opt/intel/mkl/")
endif()
if(EXISTS "${INTEL_MKL_DIR}")
set(KALDI_CONFIG_FLAGS --shared --static-math --mkl-root=${INTEL_MKL_DIR})
else()
message("WARNING: cannot find INTEL_MKL_DIR: ${INTEL_MKL_DIR}")
set(KALDI_CONFIG_FLAGS --shared --static-math)
endif()

set(ENV{CXXFLAGS} -O2)

find_program(MAKE_EXE NAMES make gmake nmake)

Expand All @@ -58,6 +70,10 @@ message(" PYTHON_LIBRARY = ${PYTHON_LIBRARY}")
message(" PYTHON_VERSION_STRING = ${PYTHON_VERSION_STRING}")
message(" SKBUILD = ${SKBUILD}")

if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
message(FATAL_ERROR "CMake build not supported on Windows")
endif()

if(NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
set(STRIP_COMMAND find ${DST} -type f | xargs strip -x)
Expand All @@ -70,7 +86,7 @@ if(NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
GIT_TAG origin/dragonfly
CONFIGURE_COMMAND mkdir -p python && touch python/.use_default_python && tools/extras/check_dependencies.sh && cd tools/openfst && autoreconf
BUILD_IN_SOURCE TRUE
BUILD_COMMAND cd tools && ${MAKE_EXE} ${MAKE_FLAGS} && cd ../src && ./configure ${KALDI_CONFIG_FLAGS} && ${MAKE_EXE} ${MAKE_FLAGS} depend && ${MAKE_EXE} ${MAKE_FLAGS} dragonfly dragonflybin bin fstbin
BUILD_COMMAND cd tools && ${MAKE_EXE} ${MAKE_FLAGS} && cd ../src && ./configure ${KALDI_CONFIG_FLAGS} && ${MAKE_EXE} ${MAKE_FLAGS} depend && ${MAKE_EXE} ${MAKE_FLAGS} dragonfly dragonflybin bin fstbin lmbin
LIST_SEPARATOR " "
INSTALL_COMMAND mkdir -p ${DST} && cp ${BINARIES} ${LIBRARIES} ${DST} && ${STRIP_COMMAND})
endif()
Expand Down
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@

# Always prefer setuptools over distutils
from setuptools import find_packages
from skbuild import setup
import os.path, re
# io.open is needed for projects that support Python 2.7
# It ensures open() defaults to text mode with universal newlines,
# and accepts an argument to specify the text encoding
# Python 3 only projects can skip this import
from io import open

import sys
if sys.argv[1] == '--raw':
sys.argv.pop(1)
from setuptools import setup
else:
from skbuild import setup


# https://stackoverflow.com/questions/45150304/how-to-force-a-python-wheel-to-be-platform-specific-when-building-it
# https://github.com/Yelp/dumb-init/blob/48db0c0d0ecb4598d1a6400710445b85d67616bf/setup.py#L11-L27
Expand Down

0 comments on commit 0de3e3e

Please sign in to comment.