-
Notifications
You must be signed in to change notification settings - Fork 255
/
CMakeLists.txt
124 lines (111 loc) · 3.97 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# CMake build system design considerations:
# - Include directories:
# + Do not define include directories globally using the include_directories
# command but rather at the target level using the
# target_include_directories command. That way, it is easier to guarantee
# that targets are built using the proper list of include directories.
# + Use the PUBLIC and PRIVATE keywords to specify the scope of include
# directories. That way, a target linking to a library (using the
# target_link_librairies command) inherits from the library PUBLIC include
# directories and not from the PRIVATE ones.
cmake_minimum_required(VERSION 3.0...3.30)
# Build Options
option(WORLD_BUILD_TESTS "Set to ON to build tests" OFF)
option(WORLD_BUILD_EXAMPLES "Set to ON to build examples" ON)
# use git version as library version
find_package(Git QUIET)
if (Git_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE git_version
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else ()
set(git_version 0)
endif ()
project(WORLD LANGUAGES CXX VERSION 1.0.${git_version})
add_library(world STATIC
src/world/cheaptrick.h
src/world/codec.h
src/world/common.h
src/world/constantnumbers.h
src/world/d4c.h
src/world/dio.h
src/world/fft.h
src/world/harvest.h
src/world/macrodefinitions.h
src/world/matlabfunctions.h
src/world/stonemask.h
src/world/synthesis.h
src/world/synthesisrealtime.h
src/cheaptrick.cpp
src/codec.cpp
src/common.cpp
src/d4c.cpp
src/dio.cpp
src/fft.cpp
src/harvest.cpp
src/matlabfunctions.cpp
src/stonemask.cpp
src/synthesis.cpp
src/synthesisrealtime.cpp
)
add_library(world_tool STATIC
tools/audioio.h
tools/parameterio.h
tools/audioio.cpp
tools/parameterio.cpp
)
target_include_directories(world PUBLIC $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
target_include_directories(world_tool PUBLIC $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools>)
add_library(world::core ALIAS world)
add_library(world::tool ALIAS world_tool)
foreach (lib world world_tool)
set_target_properties(${lib}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
endforeach ()
include(GNUInstallDirs)
install(TARGETS world world_tool
EXPORT world-export
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY src/world DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
include(CMakePackageConfigHelpers)
configure_package_config_file(world-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/world-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/world/cmake
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
world-config-version.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/world-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/world
)
install(EXPORT world-export
FILE world-config-version.cmake
NAMESPACE world::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/world
)
export(TARGETS world world_tool NAMESPACE world::
FILE ${PROJECT_BINARY_DIR}/world-targets.cmake)
if (WORLD_BUILD_TESTS)
add_executable(tests test/test.cpp)
target_link_libraries(tests
PRIVATE world
PRIVATE world_tool
)
endif ()
if(WORLD_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()