This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
115 lines (102 loc) · 3.78 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
cmake_minimum_required(VERSION 3.0)
project(PortMIDI VERSION 235.0)
option(BUILD_SHARED_LIBS "Build dynamic library" ON)
add_library(PortTime src/porttime/porttime.c)
target_include_directories(PortTime PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
set_target_properties(PortTime PROPERTIES OUTPUT_NAME porttime)
set_target_properties(PortTime PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
)
add_library(PortMIDI
src/portmidi/common/portmidi.c
src/portmidi/common/pmutil.c
)
set_target_properties(PortMIDI PROPERTIES OUTPUT_NAME portmidi)
set_target_properties(PortMIDI PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
)
target_include_directories(PortMIDI PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/portmidi/common>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_include_directories(PortMIDI PRIVATE pm_common porttime)
# FreeBSD has a reimplementation of alsalib, so don't restrict the ALSA backend strictly to Linux.
if(UNIX AND NOT APPLE)
find_package(ALSA REQUIRED)
target_sources(PortTime PRIVATE src/porttime/ptlinux.c)
target_sources(PortMIDI PRIVATE
src/portmidi/linux/pmlinux.c
src/portmidi/linux/pmlinuxalsa.c
src/portmidi/linux/finddefault.c)
target_link_libraries(PortMIDI PRIVATE ALSA::ALSA)
elseif(APPLE)
find_library(COREAUDIO_LIBRARY CoreAudio REQUIRED)
find_library(COREFOUNDATION_LIBRARY CoreFoundation REQUIRED)
find_library(COREMIDI_LIBRARY CoreMidi REQUIRED)
find_library(CORESERVICES_LIBRARY CoreServices REQUIRED)
target_sources(PortTime PRIVATE src/porttime/ptmacosx_mach.c)
target_link_libraries(PortTime PRIVATE ${COREAUDIO_LIBRARY} ${COREFOUNDATION_LIBRARY})
target_sources(PortMIDI PRIVATE
src/portmidi/mac/pmmac.c
src/portmidi/mac/pmmacosxcm.c
src/portmidi/mac/finddefault.c
src/portmidi/mac/readbinaryplist.c)
target_link_libraries(PortMIDI PRIVATE ${COREAUDIO_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREMIDI_LIBRARY} ${CORESERVICES_LIBRARY})
elseif(WIN32)
target_sources(PortTime PRIVATE src/porttime/ptwinmm.c)
target_link_libraries(PortTime PRIVATE winmm)
target_sources(PortMIDI PRIVATE
src/portmidi/windows/pmwin.c
src/portmidi/windows/pmwinmm.c)
target_link_libraries(PortMIDI PRIVATE winmm)
else()
message(FATAL_ERROR "Operating system not supported.")
endif()
target_link_libraries(PortMIDI PRIVATE PortTime)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Library
install(TARGETS PortMIDI PortTime
EXPORT PortMIDITargets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
# Headers
install(FILES
include/pmutil.h
include/portmidi.h
include/porttime.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# pkgconfig
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/portmidi.pc.in
${CMAKE_CURRENT_BINARY_DIR}/portmidi.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/portmidi.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
# CMake config
set(PORTMIDI_INSTALL_CMAKEDIR "lib/cmake/PortMIDI")
install(
EXPORT PortMIDITargets
FILE PortMIDITargets.cmake
NAMESPACE PortMIDI::
DESTINATION "${PORTMIDI_INSTALL_CMAKEDIR}"
)
configure_package_config_file(PortMIDIConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/PortMIDIConfig.cmake"
INSTALL_DESTINATION "${PORTMIDI_INSTALL_CMAKEDIR}"
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/PortMIDIConfigVersion.cmake"
VERSION "${CMAKE_PROJECT_VERSION}"
COMPATIBILITY SameMajorVersion
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/PortMIDIConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/PortMIDIConfigVersion.cmake"
DESTINATION "${PORTMIDI_INSTALL_CMAKEDIR}"
)