-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
79 lines (63 loc) · 2.21 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(lilcom)
# Remember to also change the line 3 of ./scripts/conda/lilcom/meta.yaml
set(LILCOM_VERSION "1.8.0")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(BUILD_RPATH_USE_ORIGIN TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(NOT APPLE)
set(LILCOM_RPATH_ORIGIN "$ORIGIN")
else()
set(LILCOM_RPATH_ORIGIN "@loader_path")
endif()
set(CMAKE_INSTALL_RPATH ${LILCOM_RPATH_ORIGIN})
set(CMAKE_BUILD_RPATH ${LILCOM_RPATH_ORIGIN})
set(BUILD_SHARED_LIBS ON)
# See
# https://stackoverflow.com/questions/33062728/cmake-link-shared-library-on-windows
if(BUILD_SHARED_LIBS AND MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "No CMAKE_BUILD_TYPE given, default to Release")
set(CMAKE_BUILD_TYPE Release)
endif()
option(LILCOM_ENABLE_TESTS "Whether to build tests" ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(pybind11)
include_directories(${CMAKE_SOURCE_DIR})
if(WIN32)
# disable various warnings for MSVC
# 4244: 'initializing': conversion from 'float' to 'int32_t',
# 4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
set(disabled_warnings
/wd4244
/wd4267
)
message(STATUS "Disabled warnings: ${disabled_warnings}")
foreach(w IN LISTS disabled_warnings)
string(APPEND CMAKE_CXX_FLAGS " ${w} ")
endforeach()
endif()
pybind11_add_module(lilcom_extension
lilcom/lilcom_extension.cc
lilcom/compression.cc
)
if(UNIX AND NOT APPLE)
# Fix https://github.com/lhotse-speech/lhotse/issues/800
target_link_libraries(lilcom_extension PUBLIC "-Wl,-rpath,${LILCOM_RPATH_ORIGIN}/../..")
endif()
if(LILCOM_ENABLE_TESTS)
add_executable(int_stream_test lilcom/int_stream_test.cc)
add_executable(bit_stream_test lilcom/bit_stream_test.cc)
if(NOT WIN32)
target_link_libraries(int_stream_test m) # -lm
target_link_libraries(bit_stream_test m) # -lm
endif()
enable_testing()
add_subdirectory(test)
endif()