-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_library.script.cmake
77 lines (65 loc) · 2.95 KB
/
setup_library.script.cmake
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
# -*- mode: cmake -*-
# Kaleidoscope-Papageno -- Papageno features for Kaleidoscope
# Copyright (C) 2017 noseglasses <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(module_source_dir "")
if(NOT "${KALEIDOSCOPE_MODULE_SOURCE_DIR}" STREQUAL "")
set(module_source_dir "${KALEIDOSCOPE_MODULE_SOURCE_DIR}")
else()
set(module_source_dir "${CMAKE_SOURCE_DIR}")
endif()
set(papageno_library_directory "${module_source_dir}/../papageno")
# message("KALEIDOSCOPE_MODULE_SOURCE_DIR: ${KALEIDOSCOPE_MODULE_SOURCE_DIR}")
# message("papageno_library_directory: ${papageno_library_directory}")
if(NOT "${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
message("Using toolchain file \"${CMAKE_TOOLCHAIN_FILE}\"")
set(CMAKE_TOOLCHAIN_FILE_SPEC "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
elseif(NOT KALEIDOSCOPE_HOST_BUILD)
set(toolchain_file "${module_source_dir}/3rd_party/Papageno/cmake/toolchains/Toolchain-avr-gcc.cmake")
message("Using toolchain file \"${toolchain_file}\"")
set(CMAKE_TOOLCHAIN_FILE_SPEC "-DCMAKE_TOOLCHAIN_FILE=${toolchain_file}")
endif()
if(NOT "${PAPAGENO_PLATFORM}" STREQUAL "")
message("Building papageno for platform ${PAPAGENO_PLATFORM}")
set(PAPAGENO_PLATFORM_SPEC "-DPAPAGENO_PLATFORM=${PAPAGENO_PLATFORM}")
elseif(NOT KALEIDOSCOPE_HOST_BUILD)
message("Building papageno for platform atmega32u4")
set(PAPAGENO_PLATFORM_SPEC "-DPAPAGENO_PLATFORM=atmega32u4")
else()
message("Virtual build => Building papageno for platform generic")
set(PAPAGENO_PLATFORM_SPEC "-DPAPAGENO_PLATFORM=generic")
endif()
if(NOT EXISTS "${papageno_library_directory}")
file(MAKE_DIRECTORY "${papageno_library_directory}")
# Configure build of a Papageno Arduino library.
#
execute_process(
COMMAND "${CMAKE_COMMAND}"
"-DPAPAGENO_ARDUINO_BUILD_DIR=${papageno_library_directory}"
"${CMAKE_TOOLCHAIN_FILE_SPEC}"
"${PAPAGENO_PLATFORM_SPEC}"
"-DPAPAGENO_BUILD_GLOCKENSPIEL=FALSE"
"${module_source_dir}/3rd_party/Papageno"
WORKING_DIRECTORY "${papageno_library_directory}"
)
# Build a Papageno Arduino library.
#
execute_process(
COMMAND "${CMAKE_COMMAND}" --build "${papageno_library_directory}" --target arduino_symlinks
)
if(NOT EXISTS "${papageno_library_directory}/src/papageno.h")
message(FATAL_ERROR "Failed setting up papageno")
endif()
endif()