-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
107 lines (83 loc) · 3.1 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
cmake_minimum_required(VERSION 3.2)
set(CMAKE_C_COMPILER_WORKS 1)
project(cppbach)
# =================
# External Projects
# =================
include(ExternalProject)
# midifile
set(MIDIFILE_ROOT ${CMAKE_SOURCE_DIR}/lib/midifile)
set(MIDIFILE_LIB_DIR ${MIDIFILE_ROOT}/src/midifile/lib)
set(MIDIFILE_INCLUDE_DIR ${MIDIFILE_ROOT}/src/midifile/include)
ExternalProject_Add(
midifile
PREFIX ${MIDIFILE_ROOT}
GIT_REPOSITORY "https://github.com/craigsapp/midifile.git"
GIT_TAG "master"
BINARY_DIR ${MIDIFILE_ROOT}/src/midifile
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND make library
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${MIDIFILE_LIB_DIR}/libmidifile.a)
add_library(libmidifile STATIC IMPORTED)
set_target_properties(libmidifile PROPERTIES IMPORTED_LOCATION ${MIDIFILE_LIB_DIR}/libmidifile.a)
add_dependencies(libmidifile midifile)
# portmidi
set(PORTMIDI_ROOT ${CMAKE_SOURCE_DIR}/lib/portmidi)
set(PORTMIDI_LIB_DIR ${PORTMIDI_ROOT}/src/portmidi-build)
set(PORTMIDI_INCLUDE_DIR ${PORTMIDI_ROOT}/include)
ExternalProject_Add(
portmidi
PREFIX ${PORTMIDI_ROOT}
SVN_REPOSITORY "http://svn.code.sf.net/p/portmedia/code/portmidi/trunk/"
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
UPDATE_COMMAND ""
PATCH_COMMAND sed -i -e "s/CMAKE_OSX_ARCHITECTURES i386 ppc x86_64/CMAKE_OSX_ARCHITECTURES i386 x86_64/g" CMakeLists.txt
INSTALL_DIR ${PORTMIDI_INCLUDE_DIR}
INSTALL_COMMAND cp ../portmidi/pm_common/portmidi.h <INSTALL_DIR> && cp ../portmidi/porttime/porttime.h <INSTALL_DIR>)
add_library(libportmidi STATIC IMPORTED)
set_target_properties(libportmidi PROPERTIES IMPORTED_LOCATION ${PORTMIDI_LIB_DIR}/libportmidi_s.a)
add_dependencies(libportmidi portmidi)
# RtMidi
set(RTMIDI_ROOT ${CMAKE_SOURCE_DIR}/lib/rtmidi)
set(RTMIDI_LIB_DIR ${RTMIDI_ROOT}/lib)
set(RTMIDI_INCLUDE_DIR ${RTMIDI_ROOT}/include/rtmidi)
ExternalProject_Add(
rtmidi
PREFIX ${RTMIDI_ROOT}
URL "https://www.music.mcgill.ca/~gary/rtmidi/release/rtmidi-2.1.1.tar.gz"
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
BUILD_COMMAND make
INSTALL_COMMAND make install)
add_library(librtmidi STATIC IMPORTED)
set_target_properties(librtmidi PROPERTIES IMPORTED_LOCATION ${RTMIDI_LIB_DIR}/librtmidi.a)
add_dependencies(librtmidi rtmidi)
# ==========
# Frameworks
# ==========
find_library(CORE_MIDI CoreMIDI)
if (NOT CORE_MIDI)
message(FATAL_ERROR "CoreMIDI not found")
endif()
find_library(CORE_AUDIO CoreAudio)
if (NOT CORE_AUDIO)
message(FATAL_ERROR "CoreAudio not found")
endif()
find_library(CORE_FOUNDATION CoreFoundation)
if (NOT CORE_FOUNDATION)
message(FATAL_ERROR "CoreFoundation not found")
endif()
# ====
# Main
# ====
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(${MIDIFILE_INCLUDE_DIR})
include_directories(${PORTMIDI_INCLUDE_DIR})
include_directories(${RTMIDI_INCLUDE_DIR})
set(SOURCE_FILES src/main.cpp)
add_executable(cppbach ${SOURCE_FILES})
target_link_libraries(cppbach libmidifile libportmidi librtmidi ${CORE_MIDI} ${CORE_AUDIO} ${CORE_FOUNDATION})