-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
72 lines (67 loc) · 2.94 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
cmake_minimum_required(VERSION 3.22)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if (NOT CMAKE_BUILD_TYPE)
message("Defaulting to BUILD_TYPE to 'Release' since not specified")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
# Establish the platform to build for, default is host but the user can change this to any supported platform
if (NOT DEFINED FBW_PLATFORM)
message("Defaulting FBW_PLATFORM to 'host' since not specified")
message(STATUS "To specify a platform, run cmake with -DFBW_PLATFORM=<platform>")
endif()
set(FBW_PLATFORM "host" CACHE STRING "Platform to build pico-fbw for")
# Special cases
set(PICO_PLATFORMS "pico" "pico2" "pico_w")
set(ESP_PLATFORMS "esp32")
if (FBW_PLATFORM IN_LIST PICO_PLATFORMS)
set(PLATFORM_NAME "pico")
elseif (FBW_PLATFORM IN_LIST ESP_PLATFORMS)
set(PLATFORM_NAME "esp")
else()
# Default to the platform name as its directory
set(PLATFORM_NAME ${FBW_PLATFORM})
endif()
set(PLATFORM_LIB "platform_${PLATFORM_NAME}")
set(PLATFORM_PATH "${CMAKE_SOURCE_DIR}/platform/${PLATFORM_NAME}")
set(PLATFORM_CMAKE_PATH "${PLATFORM_PATH}/resources/${PLATFORM_NAME}.cmake")
if (NOT EXISTS ${PLATFORM_CMAKE_PATH})
message(FATAL_ERROR "Unknown platform '${FBW_PLATFORM}'")
endif()
message("Building for platform '${FBW_PLATFORM}'")
include(${PLATFORM_CMAKE_PATH})
# Define the project, the languages it uses, and the version
project(pico-fbw LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(PICO_FBW_VERSION "1.0.0-alpha.4")
add_compile_definitions(PICO_FBW_VERSION="${PICO_FBW_VERSION}")
# Enable all warnings + stop compilation on the first error for non-release builds (useful for project developers)
message("Build type is '${CMAKE_BUILD_TYPE}'")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Release")
message("Non-release build, all warnings enabled")
add_compile_options(-Wall -Wextra -Wfatal-errors)
endif()
message("Configuring pico-fbw version '${PICO_FBW_VERSION}'")
# Run pre-subdir setup (these setup functions are defined in the platform-specific CMake files that were included above)
message("Running prerequisite setup for '${FBW_PLATFORM}'")
setup_before_subdirs()
# Add the rest of the directories (these have more CMake files that will be processed in turn)
message("Adding subdirectories")
add_subdirectory(src)
add_subdirectory(lib)
add_subdirectory(platform)
# Add extra targets (formatting, documentation, etc.)
message("Configuring utilities")
include(ClangFormat)
include(Doxygen)
include(WebBuild)
# Final setup tasks
message("Finishing up setup for '${FBW_PLATFORM}', this may take a moment...")
setup_after_subdirs()
message("Configuration summary:")
message(" Version: ${PICO_FBW_VERSION}")
message(" Build type: ${CMAKE_BUILD_TYPE}")
message(" Platform: ${FBW_PLATFORM}")
message(" Compiler: ${CMAKE_C_COMPILER} (C${CMAKE_C_STANDARD})")
message(" Build web interface? ${FBW_BUILD_WWW}")
message(" Build documentation? ${FBW_DOCS}")
message(" Format code? ${FBW_FORMAT}")