-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
129 lines (99 loc) · 4.37 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
125
126
127
128
cmake_minimum_required(VERSION 3.13)
# Pull in Raspberry Pi Pico SDK (must be before project)
include(pico_sdk_import.cmake)
if (PICO_SDK_VERSION_STRING VERSION_LESS "2.0.0")
message(FATAL_ERROR "Require at least Raspberry Pi Pico SDK version 2.0.0")
endif()
include(pico_extras_import.cmake)
project(pico_host_sdl)
if (PICO_PLATFORM STREQUAL "host")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
add_library(pico_host_sdl INTERFACE)
# need SDL2
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
# need math
find_library(M_LIBRARY m REQUIRED)
# optionally ALSA
find_package(ALSA)
target_include_directories(pico_host_sdl INTERFACE
${CMAKE_CURRENT_LIST_DIR}
# have both forms of these because windows doesn't have SDL2 prefix
${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR}/SDL2
${SDL2_IMAGE_INCLUDE_DIRS}/SDL2
)
target_link_libraries(pico_host_sdl INTERFACE ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
IF (ALSA_FOUND)
message("ALSA found")
target_link_libraries(pico_host_sdl INTERFACE ${ALSA_LIBRARY})
target_compile_definitions(pico_host_sdl INTERFACE -DNATIVE_AUDIO_ALSA)
else()
# todo we should use SDL by default, but because it is asynchronous callbacks\
# it should really be integrated under our mu driver at the DMA level, which
# would be fine, except that currently we allow sending DMA transfers of differing lengths
# which SDL doesn't.
message("ALSA not found, using SDL")
target_compile_definitions(pico_host_sdl INTERFACE -DNATIVE_AUDIO_SDL2)
endif()
if (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
target_compile_definitions(pico_host_sdl INTERFACE _USE_MATH_DEFINES)
endif()
add_library(pico_host_video INTERFACE) # todo currently contains other stuff
add_library(pico_host_audio INTERFACE)
add_library(pico_host_timer INTERFACE)
target_sources(pico_host_video INTERFACE
${CMAKE_CURRENT_LIST_DIR}/sdl_video.c)
target_sources(pico_host_audio INTERFACE
${CMAKE_CURRENT_LIST_DIR}/sdl_audio.c)
target_sources(pico_host_timer INTERFACE
${CMAKE_CURRENT_LIST_DIR}/sdl_timer.c
)
target_include_directories(pico_host_sdl INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(pico_host_video INTERFACE
pico_sync
pico_scanvideo
pico_multicore
#pico_sd_card
#pthread
pico_host_sdl)
target_link_libraries(pico_host_audio INTERFACE
pico_audio
pico_host_sdl
)
target_link_libraries(pico_host_timer INTERFACE
pico_time
pico_time_adapter
)
add_library(pico_sd_card INTERFACE)
target_sources(pico_sd_card INTERFACE
${CMAKE_CURRENT_LIST_DIR}/sd_card.c)
target_link_libraries(pico_sd_card INTERFACE
pico_sd_card_headers)
# todo for now everything depends on pico_host_video as that has startup etc.
add_library(pico_scanvideo_dpi INTERFACE)
target_link_libraries(pico_scanvideo_dpi INTERFACE pico_host_video pico_scanvideo)
add_library(pico_audio_i2s INTERFACE)
target_link_libraries(pico_audio_i2s INTERFACE pico_host_audio pico_host_video)
add_library(pico_audio_pwm INTERFACE)
target_link_libraries(pico_audio_pwm INTERFACE pico_host_audio pico_host_video)
add_library(hardware_timer INTERFACE)
target_sources(hardware_timer INTERFACE
${PICO_SDK_PATH}/src/host/hardware_timer/timer.c)
target_include_directories(hardware_timer INTERFACE ${PICO_SDK_PATH}/src/host/hardware_timer/include)
target_link_libraries(hardware_timer INTERFACE pico_host_timer pico_host_video)
# we support alarms
set(PICO_TIME_NO_ALARM_SUPPORT "0" CACHE INTERNAL "")
endif()
pico_is_top_level_project(PICO_HOST_SDL_TOP_LEVEL_PROJECT)
# The real work gets done in post_init which is called at the end of pico_sdk_init
list(APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR}/post_init.cmake)
list(APPEND PICO_CONFIG_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/include/pico/pico_host_sdl.h)
if (PICO_HOST_SDL_TOP_LEVEL_PROJECT)
message("pico_HOST_SDL: initialize SDK since we're the top-level")
# Initialize the SDK
pico_sdk_init()
else()
pico_promote_common_scope_vars()
endif()