Sync edgetx to Gitea
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
macro(add_bitmaps_target targetname filter format args)
|
||||
set(bitmaps_files)
|
||||
file(GLOB bitmaps ${filter})
|
||||
foreach(bitmap ${bitmaps})
|
||||
get_filename_component(target ${bitmap} NAME_WE)
|
||||
set(target ${target}.lbm)
|
||||
add_custom_command(
|
||||
OUTPUT ${target}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${UTILS_DIR}/encode-bitmap.py --format ${format} ${args} ${bitmap} ${target}
|
||||
DEPENDS ${bitmap} ${UTILS_DIR}/encode-bitmap.py
|
||||
)
|
||||
list(APPEND bitmaps_files ${target})
|
||||
endforeach()
|
||||
add_custom_target(${targetname} DEPENDS ${bitmaps_files})
|
||||
endmacro()
|
||||
|
||||
macro(add_png_target targetname filter)
|
||||
set(bitmaps_files)
|
||||
file(GLOB bitmaps ${filter})
|
||||
foreach(bitmap ${bitmaps})
|
||||
get_filename_component(target ${bitmap} NAME_WE)
|
||||
set(target ${target}.lbm)
|
||||
add_custom_command(
|
||||
OUTPUT ${target}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${UTILS_DIR}/bin2lbm.py ${bitmap} ${target}
|
||||
DEPENDS ${bitmap} ${UTILS_DIR}/bin2lbm.py
|
||||
)
|
||||
list(APPEND bitmaps_files ${target})
|
||||
endforeach()
|
||||
add_custom_target(${targetname} DEPENDS ${bitmaps_files})
|
||||
endmacro()
|
||||
|
||||
macro(add_fonts_target targetname filter)
|
||||
set(fonts_files)
|
||||
file(GLOB fonts ${filter})
|
||||
foreach(font ${fonts})
|
||||
get_filename_component(target ${font} NAME_WE)
|
||||
set(target ${target}.lbm)
|
||||
add_custom_command(
|
||||
OUTPUT ${target}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${TOOLS_DIR}/encode-font.py ${font} ${target}
|
||||
DEPENDS ${font} ${TOOLS_DIR}/encode-font.py
|
||||
)
|
||||
list(APPEND fonts_files ${target})
|
||||
endforeach()
|
||||
add_custom_target(${targetname} DEPENDS ${fonts_files})
|
||||
endmacro()
|
||||
|
||||
macro(add_truetype_font_target name size subset effect args)
|
||||
set(target font_${name})
|
||||
if(${effect} STREQUAL "bold")
|
||||
set(font ${FONT_BOLD})
|
||||
else()
|
||||
set(font ${FONT})
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${target}.png ${target}.specs ${target}.lbm
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${TOOLS_DIR}/build-font-bitmap.py --subset ${subset} --size ${size} --font ${font} --output ${target}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${UTILS_DIR}/bin2lbm.py ${target}.png ${target}.lbm
|
||||
DEPENDS ${TOOLS_DIR}/build-font-bitmap.py ${TOOLS_DIR}/charset.py ${UTILS_DIR}/encode-bitmap.py
|
||||
)
|
||||
add_custom_target(truetype_font_${name} DEPENDS ${target}.png ${target}.specs)
|
||||
set(truetype_fonts_targets ${truetype_fonts_targets} truetype_font_${name})
|
||||
endmacro()
|
||||
@@ -0,0 +1,5 @@
|
||||
# Copy all WASM simulator modules from SRC_DIR to DST_DIR at build time.
|
||||
# Invoked via cmake -P so the pattern is evaluated on every build.
|
||||
file(INSTALL "${SRC_DIR}/" DESTINATION "${DST_DIR}"
|
||||
MESSAGE_NEVER
|
||||
FILES_MATCHING PATTERN "edgetx-*-simulator.wasm")
|
||||
@@ -0,0 +1,21 @@
|
||||
# Fetch gtest source code from Github
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest
|
||||
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # v1.14.0
|
||||
)
|
||||
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
||||
option(BUILD_GMOCK "Build GMock" OFF)
|
||||
option(INSTALL_GTEST "Install GTest" OFF)
|
||||
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
include_directories(
|
||||
${googletest_SOURCE_DIR}/googletest/include
|
||||
)
|
||||
@@ -0,0 +1,31 @@
|
||||
# Fetch imgui source code from Github
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
imgui
|
||||
GIT_REPOSITORY https://github.com/ocornut/imgui
|
||||
GIT_TAG dbb5eeaadffb6a3ba6a60de1290312e5802dba5a # v1.91.8
|
||||
GIT_SHALLOW TRUE
|
||||
UPDATE_DISCONNECTED TRUE
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
|
||||
message("Fetched imgui source code from Github: ${imgui_SOURCE_DIR}")
|
||||
|
||||
add_library(imgui STATIC
|
||||
${imgui_SOURCE_DIR}/imgui.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_draw.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_tables.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_widgets.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer2.cpp
|
||||
)
|
||||
|
||||
target_include_directories(imgui PUBLIC
|
||||
${imgui_SOURCE_DIR}
|
||||
${imgui_SOURCE_DIR}/backends
|
||||
)
|
||||
|
||||
target_link_libraries(imgui PUBLIC SDL2::SDL2)
|
||||
@@ -0,0 +1,17 @@
|
||||
# Fetch maxLibQt source code from Github
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
maxLibQt
|
||||
GIT_REPOSITORY https://github.com/edgetx/maxLibQt
|
||||
GIT_TAG 7e433da60d3f2e975d46afc91804a88029cd1b78
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(maxLibQt)
|
||||
|
||||
message("Fetched maxLibQt source code from Github: ${maxLibQt_SOURCE_DIR}")
|
||||
include_directories(
|
||||
${maxLibQt_SOURCE_DIR}
|
||||
${maxLibQt_BINARY_DIR}
|
||||
)
|
||||
@@ -0,0 +1,20 @@
|
||||
# Fetch miniz source code from Github
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
miniz
|
||||
GIT_REPOSITORY https://github.com/richgel999/miniz
|
||||
GIT_TAG 89d7a5f6c3ce8893ea042b0a9d2a2d9975589ac9
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(miniz)
|
||||
|
||||
message("Fetched miniz source code from Github: ${miniz_SOURCE_DIR}")
|
||||
include_directories(
|
||||
${miniz_SOURCE_DIR}
|
||||
${miniz_BINARY_DIR}
|
||||
)
|
||||
|
||||
# suppress compiler warnings for this add-in only
|
||||
target_compile_options(miniz PRIVATE -Wno-unused-function -Wno-newline-eof)
|
||||
@@ -0,0 +1,42 @@
|
||||
# Fetch rs_dfu
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Determine platform and architecture
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(RS_DFU_PLATFORM "unknown-linux-gnu")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(RS_DFU_PLATFORM "apple-darwin")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(RS_DFU_PLATFORM "pc-windows-msvc")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(RS_DFU_ARCH "universal")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
|
||||
set(RS_DFU_ARCH "x86_64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
|
||||
set(RS_DFU_ARCH "aarch64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
set(RS_DFU_BASE_URL "https://github.com/EdgeTX/rs-dfu/releases/latest/download")
|
||||
set(RS_DFU_FILENAME "rs_dfu-${RS_DFU_ARCH}-${RS_DFU_PLATFORM}")
|
||||
set(RS_DFU_URL "${RS_DFU_BASE_URL}/${RS_DFU_FILENAME}.tar.gz")
|
||||
|
||||
FetchContent_Declare(
|
||||
RsDfu
|
||||
URL ${RS_DFU_URL}
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP true
|
||||
FIND_PACKAGE_ARGS
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(RsDfu)
|
||||
|
||||
set(rs_dfu_DIR "${rsdfu_SOURCE_DIR}/cmake")
|
||||
|
||||
message("Fetched rsdfu source code from Github: ${rsdfu_SOURCE_DIR}")
|
||||
@@ -0,0 +1,63 @@
|
||||
# Fetch and configure WAMR (WebAssembly Micro Runtime)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# WAMR build configuration
|
||||
set(WAMR_BUILD_INTERP 1)
|
||||
set(WAMR_BUILD_FAST_INTERP 0)
|
||||
set(WAMR_BUILD_AOT 0)
|
||||
set(WAMR_BUILD_JIT 0)
|
||||
set(WAMR_BUILD_LIBC_BUILTIN 1)
|
||||
set(WAMR_BUILD_LIBC_WASI 1)
|
||||
set(WAMR_BUILD_LIB_WASI_THREADS 1)
|
||||
set(WAMR_BUILD_SHARED_MEMORY 1)
|
||||
set(WAMR_BUILD_BULK_MEMORY 1)
|
||||
set(WAMR_BUILD_REF_TYPES 1)
|
||||
set(WAMR_BUILD_SIMD 0)
|
||||
set(WAMR_BUILD_EXCE_HANDLING 1)
|
||||
set(WAMR_DISABLE_HW_BOUND_CHECK 1)
|
||||
|
||||
FetchContent_Declare(
|
||||
wamr
|
||||
GIT_REPOSITORY https://github.com/bytecodealliance/wasm-micro-runtime
|
||||
GIT_TAG WAMR-2.4.4
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
|
||||
# Populate separately so we can patch before building
|
||||
FetchContent_GetProperties(wamr)
|
||||
if(NOT wamr_POPULATED)
|
||||
FetchContent_Populate(wamr)
|
||||
|
||||
# WAMR 2.4.4 win_file.c has trailing backslashes in comments that
|
||||
# clang treats as line continuations, causing compile errors.
|
||||
execute_process(
|
||||
COMMAND git apply "${CMAKE_CURRENT_LIST_DIR}/wamr-fix-win-backslash-comments.patch"
|
||||
WORKING_DIRECTORY "${wamr_SOURCE_DIR}"
|
||||
RESULT_VARIABLE _patch_result
|
||||
)
|
||||
if(_patch_result)
|
||||
message(WARNING "WAMR win_file.c patch failed (may already be applied)")
|
||||
endif()
|
||||
|
||||
add_subdirectory("${wamr_SOURCE_DIR}" "${wamr_BINARY_DIR}" EXCLUDE_FROM_ALL)
|
||||
|
||||
if(WIN32)
|
||||
# WAMR unconditionally adds -lm and -ldl as PUBLIC link libraries,
|
||||
# which don't exist on Windows.
|
||||
get_target_property(_vmlib_libs vmlib INTERFACE_LINK_LIBRARIES)
|
||||
if(_vmlib_libs)
|
||||
list(REMOVE_ITEM _vmlib_libs "-lm" "-ldl")
|
||||
set_target_properties(vmlib PROPERTIES INTERFACE_LINK_LIBRARIES "${_vmlib_libs}")
|
||||
endif()
|
||||
|
||||
# WAMR headers use __declspec(dllimport/dllexport) on MSVC-compatible
|
||||
# compilers, but we link vmlib statically. Override both API macros to
|
||||
# empty for vmlib itself (PUBLIC = PRIVATE + INTERFACE).
|
||||
target_compile_definitions(vmlib PUBLIC
|
||||
WASM_RUNTIME_API_EXTERN=
|
||||
WASM_API_EXTERN=
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -0,0 +1,41 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
set(WASI_SDK_VERSION "25")
|
||||
set(WASI_SDK_FULL_VERSION "${WASI_SDK_VERSION}.0")
|
||||
|
||||
# Determine platform and architecture
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(WASI_SDK_PLATFORM "linux")
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(WASI_SDK_PLATFORM "macos")
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(WASI_SDK_PLATFORM "windows")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported platform: ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
|
||||
set(WASI_SDK_ARCH "x86_64")
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
|
||||
set(WASI_SDK_ARCH "arm64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported Linux architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
set(WASI_SDK_BASE_URL "https://github.com/WebAssembly/wasi-sdk/releases/download")
|
||||
set(WASI_SDK_FILENAME "wasi-sdk-${WASI_SDK_VERSION}.0-${WASI_SDK_ARCH}-${WASI_SDK_PLATFORM}")
|
||||
set(WASI_SDK_URL "${WASI_SDK_BASE_URL}/wasi-sdk-${WASI_SDK_VERSION}/${WASI_SDK_FILENAME}.tar.gz")
|
||||
|
||||
set(FETCHCONTENT_QUIET FALSE)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
WasiSDK
|
||||
URL ${WASI_SDK_URL}
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP true
|
||||
FIND_PACKAGE_ARGS
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(WasiSDK)
|
||||
|
||||
set(WASI_SDK_PATH ${wasisdk_SOURCE_DIR})
|
||||
@@ -0,0 +1,12 @@
|
||||
# Fetch yaml-cpp
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
yaml-cpp
|
||||
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp
|
||||
GIT_TAG 28f93bdec6387d42332220afa9558060c8016795
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(yaml-cpp)
|
||||
message("Fetched yaml-cpp source code from Github: ${yaml-cpp_SOURCE_DIR}")
|
||||
@@ -0,0 +1,27 @@
|
||||
if(WIN32)
|
||||
include(InstallRequiredSystemLibraries)
|
||||
|
||||
# Determine architecture
|
||||
# if(CMAKE_CL_64)
|
||||
set(MSVC_ARCH x64)
|
||||
# else()
|
||||
# set(MSVC_ARCH x86)
|
||||
# endif()
|
||||
|
||||
# Attempt to find the vcredist executable
|
||||
find_program(MSVC_REDIST_EXE
|
||||
NAMES vc_redist.${MSVC_ARCH}.exe
|
||||
PATHS
|
||||
"${MSVC_REDIST_DIR}" # If set by InstallRequiredSystemLibraries
|
||||
"$ENV{VCINSTALLDIR}Redist/MSVC/v143/" # For VS 2022
|
||||
"C:/Program Files (x86)/Microsoft Visual Studio/*/VC/Redist/MSVC/*/"
|
||||
"C:/Program Files/Microsoft Visual Studio/*/*/VC/Redist/MSVC/*/"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if(MSVC_REDIST_EXE)
|
||||
message(STATUS "Found VC Redistributable: ${MSVC_REDIST_EXE}")
|
||||
else()
|
||||
message(WARNING "VC Redistributable not found.")
|
||||
endif()
|
||||
endif()
|
||||
@@ -0,0 +1,256 @@
|
||||
#.rst:
|
||||
# FindSDL
|
||||
# -------
|
||||
#
|
||||
# Locate SDL library
|
||||
#
|
||||
# This module defines
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL_FOUND, if false, do not try to link to SDL
|
||||
# SDL_LIBRARY, the name(s) of the library(ies) to link against
|
||||
# SDL_LIBSDL, the full path and name of libSDL (or SDL.[lib|dll].
|
||||
# SDL_LIBSDLMAIN, full path and name of libSDLmain (or SDLmain.lib).
|
||||
# SDL_LIBRARY_PATH, the full path to the found libSDL
|
||||
# SDL_INCLUDE_DIR, where to find SDL.h
|
||||
# SDL_VERSION_STRING, human-readable string containing the version of SDL
|
||||
#
|
||||
#
|
||||
#
|
||||
# This module responds to the flag:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL_BUILDING_LIBRARY
|
||||
# If this is defined, then no SDL_main will be linked in because
|
||||
# only applications need main().
|
||||
# Otherwise, it is assumed you are building an application and this
|
||||
# module will attempt to locate and set the proper link flags
|
||||
# as part of the returned SDL_LIBRARY variable.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Don't forget to include SDLmain.h and SDLmain.m your project for the
|
||||
# OS X framework based version. (Other versions link to -lSDLmain which
|
||||
# this module will try to find on your behalf.) Also for OS X, this
|
||||
# module will automatically add the -framework Cocoa on your behalf.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Additional Note: If you see an empty SDL_LIBSDL in your
|
||||
# configuration and no SDL_LIBRARY, it means CMake did not find your SDL
|
||||
# library (SDL.dll, libsdl.so, SDL.framework, etc). Set
|
||||
# SDL_LIBSDL to point to your SDL library, and configure again.
|
||||
# Similarly, if you see an empty SDL_LIBSDLMAIN, you should set this
|
||||
# value as appropriate. These values are used to generate the final
|
||||
# SDL_LIBRARY variable, but when these values are unset, SDL_LIBRARY
|
||||
# does not get created.
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDLDIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02
|
||||
#
|
||||
# Modified by Eric Wing. Added code to assist with automated building
|
||||
# by using environmental variables and providing a more
|
||||
# controlled/consistent search behavior. Added new modifications to
|
||||
# recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
|
||||
# Also corrected the header search path to follow "proper" SDL
|
||||
# guidelines. Added a search for SDLmain which is needed by some
|
||||
# platforms. Added a search for threads which is needed by some
|
||||
# platforms. Added needed compile switches for MinGW.
|
||||
#
|
||||
# On OSX, this will prefer the Framework version (if found) over others.
|
||||
# People will have to manually change the cache values of SDL_LIBRARY to
|
||||
# override this selection or set the CMake environment
|
||||
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||
#
|
||||
# Note that the header path has changed from SDL/SDL.h to just SDL.h
|
||||
# This needed to change because "proper" SDL convention is #include
|
||||
# "SDL.h", not <SDL/SDL.h>. This is done for portability reasons
|
||||
# because not all systems place things in SDL/ (see FreeBSD).
|
||||
|
||||
#
|
||||
# Modified for OpenTx by Maxim Paperno 19-Dec-2016
|
||||
# Added SDL_LIBSDL, SDL_LIBSDLMAIN & SDL_LIBRARY_PATH, removed SDLMAIN_LIBRARY,
|
||||
# SDL_LIBRARY_TEMP, and fixed bug with recursive appending of supporting
|
||||
# libraries to cached SDL_LIBRARY_TEMP variable.
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
#CMake - Cross Platform Makefile Generator
|
||||
#Copyright 2000-2015 Kitware, Inc.
|
||||
#Copyright 2000-2011 Insight Software Consortium
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions
|
||||
#are met:
|
||||
#
|
||||
#* Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
#* Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
#* Neither the names of Kitware, Inc., the Insight Software Consortium,
|
||||
# nor the names of their contributors may be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
#HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
#The above copyright and license notice applies to distributions of
|
||||
#CMake in source and binary form. Some source files contain additional
|
||||
#notices of original copyright by their contributors; see each source
|
||||
#for details. Third-party software packages supplied with CMake under
|
||||
#compatible licenses provide their own copyright notices documented in
|
||||
#corresponding subdirectories.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
#CMake was initially developed by Kitware with the following sponsorship:
|
||||
#
|
||||
# * National Library of Medicine at the National Institutes of Health
|
||||
# as part of the Insight Segmentation and Registration Toolkit (ITK).
|
||||
#
|
||||
# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
|
||||
# Visualization Initiative.
|
||||
#
|
||||
# * National Alliance for Medical Image Computing (NAMIC) is funded by the
|
||||
# National Institutes of Health through the NIH Roadmap for Medical Research,
|
||||
# Grant U54 EB005149.
|
||||
#
|
||||
# * Kitware, Inc.
|
||||
#=============================================================================
|
||||
|
||||
|
||||
find_path(SDL_INCLUDE_DIR SDL.h
|
||||
HINTS
|
||||
ENV SDLDIR
|
||||
PATH_SUFFIXES SDL SDL12 SDL11
|
||||
# path suffixes to search inside ENV{SDLDIR}
|
||||
include/SDL include/SDL12 include/SDL11 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
# SDL-1.1 is the name used by FreeBSD ports...
|
||||
# don't confuse it for the version number.
|
||||
find_library(SDL_LIBSDL
|
||||
NAMES SDL SDL-1.1
|
||||
HINTS
|
||||
ENV SDLDIR
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
# Non-OS X framework versions expect you to also dynamically link to
|
||||
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDLmain for compatibility even though they don't
|
||||
# necessarily need it.
|
||||
find_library(SDL_LIBSDLMAIN
|
||||
NAMES SDLmain SDLmain-1.1
|
||||
HINTS
|
||||
ENV SDLDIR
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
# SDL may require threads on your system.
|
||||
# The Apple build may not need an explicit flag because one of the
|
||||
# frameworks may already provide it.
|
||||
# But for non-OSX systems, I will use the CMake Threads package.
|
||||
if(NOT APPLE)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
|
||||
# MinGW needs an additional library, mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL
|
||||
if(MINGW)
|
||||
set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
||||
endif()
|
||||
|
||||
if(SDL_LIBSDL)
|
||||
# For SDLmain
|
||||
if(SDL_LIBSDLMAIN AND NOT SDL_BUILDING_LIBRARY AND NOT SDL_INCLUDE_DIR MATCHES ".framework")
|
||||
list(FIND SDL_LIBSDL "${SDL_LIBSDLMAIN}" _SDL_MAIN_INDEX)
|
||||
if(_SDL_MAIN_INDEX EQUAL -1)
|
||||
list(APPEND _SDL_LIBRARY_TEMP "${SDL_LIBSDLMAIN}")
|
||||
endif()
|
||||
unset(_SDL_MAIN_INDEX)
|
||||
endif()
|
||||
|
||||
list(APPEND _SDL_LIBRARY_TEMP "${SDL_LIBSDL}")
|
||||
|
||||
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
|
||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||
# though it actually is there if I modify a pre-used variable.
|
||||
# I think it has something to do with the CACHE STRING.
|
||||
# So I use a temporary variable until the end so I can set the
|
||||
# "real" variable in one-shot.
|
||||
if(APPLE)
|
||||
list(APPEND _SDL_LIBRARY_TEMP "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
if(Threads_FOUND)
|
||||
list(APPEND _SDL_LIBRARY_TEMP ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
# MinGW needs an additional library, mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL
|
||||
if(MINGW)
|
||||
list(INSERT 0 _SDL_LIBRARY_TEMP mingw32)
|
||||
endif()
|
||||
|
||||
# Set the final string here so the GUI reflects the final state.
|
||||
set(SDL_LIBRARY ${_SDL_LIBRARY_TEMP} CACHE STRING "Full list of required SDL & supporting libraries.")
|
||||
unset(_SDL_LIBRARY_TEMP)
|
||||
|
||||
get_filename_component(_SDL_LIBRARY_TEMP ${SDL_LIBSDL} PATH)
|
||||
set(SDL_LIBRARY_PATH ${_SDL_LIBRARY_TEMP} CACHE PATH "Path to SDL library.")
|
||||
unset(_SDL_LIBRARY_TEMP)
|
||||
endif()
|
||||
|
||||
if(SDL_INCLUDE_DIR AND EXISTS "${SDL_INCLUDE_DIR}/SDL_version.h")
|
||||
file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$")
|
||||
file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MAJOR "${SDL_VERSION_MAJOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MINOR "${SDL_VERSION_MINOR_LINE}")
|
||||
string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_VERSION_PATCH "${SDL_VERSION_PATCH_LINE}")
|
||||
set(SDL_VERSION_STRING ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH})
|
||||
unset(SDL_VERSION_MAJOR_LINE)
|
||||
unset(SDL_VERSION_MINOR_LINE)
|
||||
unset(SDL_VERSION_PATCH_LINE)
|
||||
unset(SDL_VERSION_MAJOR)
|
||||
unset(SDL_VERSION_MINOR)
|
||||
unset(SDL_VERSION_PATCH)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL
|
||||
REQUIRED_VARS SDL_LIBRARY SDL_LIBRARY_PATH SDL_INCLUDE_DIR
|
||||
VERSION_VAR SDL_VERSION_STRING)
|
||||
@@ -0,0 +1,47 @@
|
||||
# FindWasiSDK.cmake
|
||||
# Module to find WASI SDK installation
|
||||
#
|
||||
# This module defines the following variables:
|
||||
# WasiSDK_FOUND - True if WASI SDK is found
|
||||
# WasiSDK_ROOT_DIR - Root directory of WASI SDK installation
|
||||
#
|
||||
# Usage:
|
||||
# set(WASI_SDK_PATH "/path/to/wasi-sdk")
|
||||
# find_package(WasiSDK REQUIRED)
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# Use WASI_SDK_PATH if provided, otherwise try to find it
|
||||
if(WASI_SDK_PATH)
|
||||
set(_wasi_sdk_search_paths "${WASI_SDK_PATH}")
|
||||
else()
|
||||
# Default search paths for common WASI SDK installations
|
||||
set(_wasi_sdk_search_paths
|
||||
"$ENV{WASI_SDK_PATH}"
|
||||
"/opt/wasi-sdk"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Find the WASI SDK root directory by looking for the toolchain file
|
||||
find_path(WasiSDK_ROOT_DIR
|
||||
NAMES share/cmake/wasi-sdk.cmake
|
||||
PATHS ${_wasi_sdk_search_paths}
|
||||
DOC "WASI SDK root directory"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
# Handle find_package arguments
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(WasiSDK
|
||||
DEFAULT_MSG
|
||||
WasiSDK_ROOT_DIR
|
||||
)
|
||||
|
||||
# Mark variables as advanced
|
||||
mark_as_advanced(
|
||||
WasiSDK_ROOT_DIR
|
||||
)
|
||||
|
||||
if(WasiSDK_FOUND)
|
||||
set(WASI_SDK_PATH ${WasiSDK_ROOT_DIR})
|
||||
endif()
|
||||
@@ -0,0 +1,90 @@
|
||||
# Automatically link Qt executables to qtmain target on Windows
|
||||
# https://cmake.org/cmake/help/latest/policy/CMP0020.html
|
||||
cmake_policy(SET CMP0020 NEW)
|
||||
|
||||
# Use @rpath in a target's install name on MacOS X for locating shared libraries
|
||||
# https://cmake.org/cmake/help/latest/policy/CMP0042.html
|
||||
if(POLICY CMP0042)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif()
|
||||
|
||||
# Ignore COMPILE_DEFINITIONS_<Config> properties (prefer generator expressions)
|
||||
# https://cmake.org/cmake/help/latest/policy/CMP0043.html
|
||||
if(POLICY CMP0043)
|
||||
cmake_policy(SET CMP0043 NEW)
|
||||
endif()
|
||||
|
||||
# Only interpret if() arguments as variables or keywords when unquoted
|
||||
# https://cmake.org/cmake/help/latest/policy/CMP0054.html
|
||||
if(POLICY CMP0054)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif()
|
||||
|
||||
# Custom command byproducts must be explicit - for ninja
|
||||
# https://cmake.org/cmake/help/latest/policy/CMP0058.html
|
||||
if(POLICY CMP0058)
|
||||
cmake_policy(SET CMP0058 NEW)
|
||||
endif()
|
||||
|
||||
set(CMAKE_COLOR_MAKEFILE ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
add_definitions(-D_GLIBCXX_USE_C99=1) # proper to_string definition
|
||||
|
||||
set(RADIO_DIRECTORY ${PROJECT_SOURCE_DIR}/radio)
|
||||
set(RADIO_SRC_DIR ${RADIO_DIRECTORY}/src)
|
||||
set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src)
|
||||
set(SIMU_SRC_DIRECTORY ${COMPANION_SRC_DIRECTORY}/simulation)
|
||||
set(TOOLS_DIR ${PROJECT_SOURCE_DIR}/tools)
|
||||
set(UTILS_DIR ${PROJECT_SOURCE_DIR}/radio/util)
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
|
||||
|
||||
string(TIMESTAMP DATE "%Y-%m-%d")
|
||||
string(TIMESTAMP TIME "%H:%M:%S")
|
||||
|
||||
include(Macros)
|
||||
git_id(GIT_STR)
|
||||
|
||||
# Python check
|
||||
set(Python3_FIND_VIRTUALENV FIRST)
|
||||
set(Python3_FIND_STRATEGY LOCATION)
|
||||
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
|
||||
if(Python3_Interpreter_FOUND)
|
||||
message(STATUS "Python found, version: ${Python3_VERSION}")
|
||||
cmake_path(NATIVE_PATH Python3_EXECUTABLE PYTHON_EXECUTABLE)
|
||||
else()
|
||||
message(WARNING "Python not found! Most firmware and simu flavors not buildable.")
|
||||
set(LUA NO)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # regular Clang or AppleClang
|
||||
set(CLANG TRUE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_HOST_APPLE)
|
||||
execute_process(COMMAND xcrun --show-sdk-path
|
||||
OUTPUT_VARIABLE SDKROOT
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
message("-- SDKROOT: ${SDKROOT}")
|
||||
#set(CMAKE_OSX_SYSROOT ${SDKROOT})
|
||||
set(SYSROOT_ARG -isysroot ${SDKROOT})
|
||||
endif()
|
||||
|
||||
# options shared by all targets
|
||||
|
||||
option(APP_CUSTOM_DBG_HANDLER "Use custom message handler for debug output in all Qt apps." ON)
|
||||
set(APP_CUSTOM_DBG_LEVEL "0" CACHE STRING
|
||||
"Debug output level: 0=debug+; 1=info+; 2=warn+; 3=critical+; 4=fatal only.")
|
||||
set(APP_CUSTOM_DBG_SHOW_FILE "DEFAULT" CACHE STRING
|
||||
"Show source file names in debug output. 1/0/DEFAULT (default is ON with DEBUG builds).")
|
||||
|
||||
option(VERBOSE_CMAKELISTS "Show extra information while processing CMakeLists.txt files." OFF)
|
||||
option(WARNINGS_AS_ERRORS "Treat any compiler warning as an error (adds -Werror flag)." OFF)
|
||||
@@ -0,0 +1,174 @@
|
||||
find_package(Git)
|
||||
|
||||
macro(git_id RESULT)
|
||||
set(${RESULT} 0)
|
||||
if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" "--git-dir=${PROJECT_SOURCE_DIR}/.git" "rev-parse" "--short=8" "HEAD" OUTPUT_VARIABLE proc_out ERROR_VARIABLE proc_err)
|
||||
if(proc_err)
|
||||
message(WARNING "Git failed with error: ${proc_err}")
|
||||
else()
|
||||
string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${proc_out})
|
||||
endif()
|
||||
elseif(NOT GIT_FOUND)
|
||||
message(WARNING "Git executable not found, revision number not available.")
|
||||
else()
|
||||
message(STATUS "Git repository not found, revision number not available.")
|
||||
endif()
|
||||
endmacro(git_id)
|
||||
|
||||
|
||||
macro(PrintTargetReport targetName)
|
||||
if(CMAKE_CXX_COMPILER MATCHES "/(clang-)?cl\\.exe$")
|
||||
set(cpp_version ${CMAKE_CXX_COMPILER_VERSION})
|
||||
else()
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE cpp_version)
|
||||
endif()
|
||||
if(cpp_version)
|
||||
string(STRIP "v${cpp_version}" cpp_version)
|
||||
else()
|
||||
set(cpp_version "WARNING: COMPILER NOT FOUND!")
|
||||
endif()
|
||||
message("TARGET ${targetName}: cpp compiler ${CMAKE_CXX_COMPILER} ${cpp_version}")
|
||||
|
||||
if(VERBOSE_CMAKELISTS)
|
||||
get_directory_property(DirOpts COMPILE_OPTIONS)
|
||||
get_directory_property(DirDefs COMPILE_DEFINITIONS)
|
||||
string(REPLACE ";" " " DirOpts "${DirOpts}")
|
||||
string(REPLACE ";" "; " DirDefs "${DirDefs}")
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
|
||||
message("\twith cpp flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${build_type}} ${DirOpts}")
|
||||
message("\twith link flags: ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
message("\twith defs: ${DirDefs}")
|
||||
message("--------------")
|
||||
endif()
|
||||
endmacro(PrintTargetReport)
|
||||
|
||||
function(AddCompilerFlags output)
|
||||
get_property(flags DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
|
||||
foreach(flag ${flags})
|
||||
set(ARGS ${ARGS} -D${flag})
|
||||
endforeach()
|
||||
|
||||
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||
foreach(dir ${dirs})
|
||||
set(ARGS ${ARGS} -I${dir})
|
||||
endforeach()
|
||||
|
||||
# Add hotfix for arm64
|
||||
|
||||
set(${output} ${${output}} ${ARGS} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(GenerateDatacopy source output)
|
||||
|
||||
set(GEN_DATACOPY ${RADIO_DIRECTORY}/util/generate_datacopy.py)
|
||||
set(GEN_DATACOPY_DEPEND ${CMAKE_CURRENT_SOURCE_DIR}/${source} ${GEN_DATACOPY})
|
||||
|
||||
# Fetch defines / include directories in use
|
||||
AddCompilerFlags(GEN_DATACOPY_ARGS)
|
||||
|
||||
# Hack to get rid of warnings in StdPeriph lib
|
||||
|
||||
set(GEN_DATACOPY_ARGS
|
||||
# source file MUST be the first argument
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${source}
|
||||
-DBACKUP ${GEN_DATACOPY_ARGS} ${SYSROOT_ARG})
|
||||
|
||||
set(GEN_DATACOPY_CMD
|
||||
${PYTHON_EXECUTABLE} ${GEN_DATACOPY} ${GEN_DATACOPY_ARGS})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${output}
|
||||
COMMAND ${GEN_DATACOPY_CMD} > ${output}
|
||||
DEPENDS ${GEN_DATACOPY_DEPEND} ${CMAKE_BINARY_DIR}/CMakeCache.txt
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(AddHardwareDefTarget output)
|
||||
|
||||
AddCompilerFlags(HW_DEF_ARGS)
|
||||
|
||||
set(HW_DEF_SRC ${RADIO_DIRECTORY}/src/targets/${TARGET_DIR}/hal.h)
|
||||
|
||||
separate_arguments(flags UNIX_COMMAND ${CMAKE_CXX_FLAGS})
|
||||
foreach(flag ${flags})
|
||||
set(HW_DEF_ARGS ${HW_DEF_ARGS} ${flag})
|
||||
endforeach()
|
||||
|
||||
set(GEN_HW_DEFS ${CMAKE_CXX_COMPILER} ${HW_DEF_ARGS} -x c++-header -E -dM ${HW_DEF_SRC})
|
||||
# set(GEN_JSON ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py)
|
||||
# set(GEN_JSON ${GEN_JSON} -i defines -T ${FLAVOUR} -)
|
||||
|
||||
# add_custom_command(OUTPUT ${output}
|
||||
# COMMAND ${GEN_HW_DEFS} | ${GEN_JSON} > ${output}
|
||||
# DEPENDS ${HW_DEF_SRC} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py
|
||||
# )
|
||||
|
||||
add_custom_command(OUTPUT ${output}.h
|
||||
COMMAND ${GEN_HW_DEFS} > ${output}.h
|
||||
DEPENDS ${HW_DEF_SRC} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(AddHWGenTarget input template output)
|
||||
|
||||
# Script
|
||||
set(GEN_JSON ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/hw_defs/generate_hw_def.py)
|
||||
|
||||
# Inputs
|
||||
set(INPUT_JSON ${RADIO_SRC_DIR}/boards/hw_defs/${input})
|
||||
set(TEMPLATE ${RADIO_DIRECTORY}/util/hw_defs/${template}.jinja)
|
||||
set(GEN_PY_DEPS
|
||||
${RADIO_DIRECTORY}/util/hw_defs/generator.py
|
||||
${RADIO_DIRECTORY}/util/hw_defs/legacy_names.py
|
||||
)
|
||||
|
||||
# Command
|
||||
set(GEN_JSON ${GEN_JSON} -t ${TEMPLATE} -T ${FLAVOUR} ${INPUT_JSON})
|
||||
|
||||
add_custom_command(OUTPUT ${output}
|
||||
COMMAND ${GEN_JSON} > ${output}
|
||||
DEPENDS ${INPUT_JSON} ${TEMPLATE} ${GEN_PY_DEPS} ${CMAKE_BINARY_DIR}/CMakeCache.txt
|
||||
)
|
||||
endfunction()
|
||||
|
||||
macro(AddHeadersSources)
|
||||
foreach(name
|
||||
${${PROJECT_NAME}_NAMES})
|
||||
|
||||
set(${PROJECT_NAME}_SRCS
|
||||
${${PROJECT_NAME}_SRCS}
|
||||
${name}.cpp
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_HDRS
|
||||
${${PROJECT_NAME}_HDRS}
|
||||
${name}.h
|
||||
)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# Collect all user-specified command-line cache variables into a list
|
||||
# suitable for forwarding to ExternalProject or sub-project cmake invocations.
|
||||
# Optional EXCLUDE parameter: regex to skip matching variable names.
|
||||
function(CollectCommandLineArgs out_var)
|
||||
cmake_parse_arguments(_cla "" "EXCLUDE" "" ${ARGN})
|
||||
set(_args "")
|
||||
get_cmake_property(_cache_vars CACHE_VARIABLES)
|
||||
foreach(_var ${_cache_vars})
|
||||
if(_cla_EXCLUDE AND _var MATCHES "${_cla_EXCLUDE}")
|
||||
continue()
|
||||
endif()
|
||||
get_property(_help CACHE ${_var} PROPERTY HELPSTRING)
|
||||
if(_help STREQUAL "No help, variable specified on the command line.")
|
||||
get_property(_type CACHE ${_var} PROPERTY TYPE)
|
||||
if(_type STREQUAL "UNINITIALIZED")
|
||||
set(_type)
|
||||
else()
|
||||
set(_type :${_type})
|
||||
endif()
|
||||
list(APPEND _args "-D${_var}${_type}=${${_var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${out_var} ${_args} PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -0,0 +1,65 @@
|
||||
|
||||
option(DISABLE_COMPANION "Disable building companion and simulators" OFF)
|
||||
|
||||
if(NOT DISABLE_COMPANION)
|
||||
include(QtDefs)
|
||||
endif(NOT DISABLE_COMPANION)
|
||||
|
||||
find_package(SDL2 QUIET COMPONENTS SDL2 CONFIG)
|
||||
if(TARGET SDL2::SDL2)
|
||||
message(STATUS "SDL2 found")
|
||||
else()
|
||||
message(STATUS "SDL not found! Simulator audio, and joystick inputs, will not work.")
|
||||
endif()
|
||||
|
||||
if(Qt6Core_FOUND AND NOT DISABLE_COMPANION)
|
||||
# environment variable set in github workflows and build-edgetx Dockerfile
|
||||
if(DEFINED ENV{OPENSSL_ROOT_DIR})
|
||||
set(OPENSSL_ROOT_DIR "$ENV{OPENSSL_ROOT_DIR}")
|
||||
endif()
|
||||
|
||||
find_package(OpenSSL)
|
||||
|
||||
include(FetchRsDfu)
|
||||
find_package(rs_dfu REQUIRED)
|
||||
endif()
|
||||
|
||||
# Windows-specific includes and libs shared by sub-projects
|
||||
if(WIN32)
|
||||
# TODO: is that still necessary?
|
||||
set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
|
||||
set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
|
||||
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
|
||||
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)
|
||||
endif()
|
||||
|
||||
# google tests
|
||||
include(FetchGtest)
|
||||
|
||||
add_custom_target(tests-radio
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gtests-radio
|
||||
DEPENDS gtests-radio
|
||||
)
|
||||
|
||||
if(Qt6Core_FOUND AND NOT DISABLE_COMPANION)
|
||||
add_subdirectory(${COMPANION_SRC_DIRECTORY})
|
||||
add_custom_target(tests-companion
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gtests-companion
|
||||
DEPENDS gtests-companion
|
||||
)
|
||||
add_custom_target(gtests
|
||||
DEPENDS gtests-radio gtests-companion
|
||||
)
|
||||
add_custom_target(tests
|
||||
DEPENDS tests-radio tests-companion
|
||||
)
|
||||
else()
|
||||
add_custom_target(gtests
|
||||
DEPENDS gtests-radio
|
||||
)
|
||||
add_custom_target(tests
|
||||
DEPENDS tests-radio
|
||||
)
|
||||
endif()
|
||||
|
||||
set(IGNORE "${ARM_TOOLCHAIN_DIR}")
|
||||
@@ -0,0 +1,65 @@
|
||||
if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX})
|
||||
# If Homebrew is used, HOMEBREW_PREFIX should be defined
|
||||
if(EXISTS $ENV{HOMEBREW_PREFIX}/opt/qt@6)
|
||||
list(APPEND CMAKE_PREFIX_PATH "$ENV{HOMEBREW_PREFIX}/opt/qt@6")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core)
|
||||
|
||||
if(Qt6_FOUND)
|
||||
message(STATUS "Qt Version: ${Qt6_VERSION}")
|
||||
|
||||
# call after Qt6Core package is found
|
||||
qt_standard_project_setup()
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Widgets LinguistTools Multimedia PrintSupport SerialPort Svg Xml)
|
||||
|
||||
### Get locations of Qt binary executables & libs (libs are for distros, not for linking)
|
||||
# first set up some hints
|
||||
get_target_property(QtCore_LOCATION Qt::Core LOCATION)
|
||||
cmake_path(GET QtCore_LOCATION ROOT_PATH qt_core_path)
|
||||
if(APPLE)
|
||||
set(qt_core_path "${qt_core_path}/..")
|
||||
cmake_path(ABSOLUTE_PATH qt_core_path OUTPUT_VARIABLE qt_core_path)
|
||||
endif()
|
||||
|
||||
set(QT_LIB_DIR ${qt_core_path} CACHE PATH "Path to Qt libraries (.dll|.framework|.so).")
|
||||
find_path(QT_BIN_DIR NAMES "qmake" "qmake.exe" HINTS "${CMAKE_PREFIX_PATH}/bin" "${qt_core_path}/../bin" "${qt_core_path}" DOC "Path to Qt binaries (qmake, lupdate, etc.).")
|
||||
find_program(QT_QMAKE_EXECUTABLE qmake HINTS "${QT_BIN_DIR}" DOC "Location of qmake program.")
|
||||
find_program(QT_LUPDATE_EXECUTABLE lupdate HINTS "${QT_BIN_DIR}" DOC "Location of Qt's 'lupdate' program for updating translation files.")
|
||||
|
||||
# Try to find Qt translations
|
||||
if(QT_QMAKE_EXECUTABLE)
|
||||
execute_process(
|
||||
COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_TRANSLATIONS
|
||||
OUTPUT_VARIABLE qt_translations_hint
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
find_path(QT_TRANSLATIONS_DIR NAMES "qt_en.qm" HINTS "${qt_translations_hint}" DOC "Path to prebuilt Qt translations (qt_*.qm).")
|
||||
|
||||
### Common definitions for the Qt-based apps
|
||||
list(APPEND APP_COMMON_DEFINES -DSIMU)
|
||||
list(APPEND APP_COMMON_DEFINES -DQXT_STATIC)
|
||||
list(APPEND APP_COMMON_DEFINES -DQT_USE_QSTRINGBUILDER) # more efficient QString construction using % operator
|
||||
|
||||
if(MSVC)
|
||||
list(APPEND APP_COMMON_DEFINES -D__STDC_LIMIT_MACROS)
|
||||
endif()
|
||||
if(APP_CUSTOM_DBG_HANDLER)
|
||||
# provide full qDebug log context to our custom handler.
|
||||
list(APPEND APP_COMMON_DEFINES -DQT_MESSAGELOGCONTEXT)
|
||||
list(APPEND APP_COMMON_DEFINES -DAPP_DBG_HANDLER_ENABLE=1)
|
||||
if(APP_CUSTOM_DBG_LEVEL GREATER -1 AND APP_CUSTOM_DBG_LEVEL LESS 5)
|
||||
list(APPEND APP_COMMON_DEFINES -DAPP_DBG_HANDLER_DEFAULT_LEVEL=${APP_CUSTOM_DBG_LEVEL})
|
||||
endif()
|
||||
if(NOT APP_CUSTOM_DBG_SHOW_FILE STREQUAL "DEFAULT" AND (APP_CUSTOM_DBG_SHOW_FILE STREQUAL "1" OR APP_CUSTOM_DBG_SHOW_FILE STREQUAL "0"))
|
||||
list(APPEND APP_COMMON_DEFINES -DAPP_DBG_HANDLER_SHOW_SRC_PATH=${APP_CUSTOM_DBG_SHOW_FILE})
|
||||
endif()
|
||||
else()
|
||||
list(APPEND APP_COMMON_DEFINES -DAPP_DBG_HANDLER_ENABLE=0)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Required Qt version not found! Companion, Simulator and libsim builds disabled.")
|
||||
endif()
|
||||
@@ -0,0 +1,53 @@
|
||||
# arm-none-eabi toolchain
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
if(MINGW OR WIN32)
|
||||
set(EXE_SUFFIX ".exe")
|
||||
set(CMAKE_OBJECT_PATH_MAX 200)
|
||||
endif()
|
||||
|
||||
if(ARM_TOOLCHAIN_DIR)
|
||||
cmake_path(SET ARM_TOOLCHAIN_DIR NORMALIZE ${ARM_TOOLCHAIN_DIR})
|
||||
set(ARM_TOOLCHAIN_DIR "${ARM_TOOLCHAIN_DIR}/")
|
||||
endif()
|
||||
|
||||
set(CMAKE_AR ${ARM_TOOLCHAIN_DIR}arm-none-eabi-ar${EXE_SUFFIX})
|
||||
set(CMAKE_ASM_COMPILER ${ARM_TOOLCHAIN_DIR}arm-none-eabi-gcc${EXE_SUFFIX})
|
||||
set(CMAKE_C_COMPILER ${ARM_TOOLCHAIN_DIR}arm-none-eabi-gcc${EXE_SUFFIX})
|
||||
set(CMAKE_CXX_COMPILER ${ARM_TOOLCHAIN_DIR}arm-none-eabi-g++${EXE_SUFFIX})
|
||||
set(CMAKE_LINKER ${ARM_TOOLCHAIN_DIR}arm-none-eabi-ld${EXE_SUFFIX})
|
||||
set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}arm-none-eabi-objcopy${EXE_SUFFIX} CACHE INTERNAL "")
|
||||
set(CMAKE_RANLIB ${ARM_TOOLCHAIN_DIR}arm-none-eabi-ranlib${EXE_SUFFIX} CACHE INTERNAL "")
|
||||
set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}arm-none-eabi-size${EXE_SUFFIX} CACHE INTERNAL "")
|
||||
set(CMAKE_STRIP ${ARM_TOOLCHAIN_DIR}arm-none-eabi-strip${EXE_SUFFIX} CACHE INTERNAL "")
|
||||
set(CMAKE_GCOV ${ARM_TOOLCHAIN_DIR}arm-none-eabi-gcov${EXE_SUFFIX} CACHE INTERNAL "")
|
||||
|
||||
# Generate .elf files
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
|
||||
|
||||
# Default C compiler flags
|
||||
set(CMAKE_C_FLAGS_DEBUG_INIT "-g3 -Og -Wall -pedantic -DDEBUG")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -Wall")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING "" FORCE)
|
||||
|
||||
# Default C++ compiler flags
|
||||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g3 -Og -Wall -pedantic -DDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT}" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -Wall")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT}" CACHE STRING "" FORCE)
|
||||
|
||||
# customize linker command
|
||||
set(CMAKE_EXE_LINKER_FLAGS "")
|
||||
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
@@ -0,0 +1,15 @@
|
||||
# Native toolchain
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_C_FLAGS "-Wno-deprecated-declarations")
|
||||
set(CMAKE_CXX_FLAGS "-Wno-deprecated-declarations")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Wno-deprecated-declarations")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wno-deprecated-declarations")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member -Wno-deprecated-declarations")
|
||||
|
||||
if(MINGW OR WIN32)
|
||||
set(CMAKE_OBJECT_PATH_MAX 200)
|
||||
endif()
|
||||
@@ -0,0 +1,20 @@
|
||||
# Wrapper around wasi-sdk's pthread toolchain that uses the non-deprecated
|
||||
# wasm32-wasip1-threads triple (compatible with SDK 25+).
|
||||
|
||||
# Propagate WASI_SDK_PREFIX into try_compile sub-projects (used during ABI detection)
|
||||
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES WASI_SDK_PREFIX)
|
||||
|
||||
if(NOT WASI_SDK_PREFIX)
|
||||
if(DEFINED ENV{WASI_SDK_PATH})
|
||||
set(WASI_SDK_PREFIX $ENV{WASI_SDK_PATH})
|
||||
elseif(EXISTS "/opt/wasi-sdk")
|
||||
set(WASI_SDK_PREFIX "/opt/wasi-sdk")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(${WASI_SDK_PREFIX}/share/cmake/wasi-sdk-pthread.cmake)
|
||||
|
||||
set(triple wasm32-wasip1-threads)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_ASM_COMPILER_TARGET ${triple})
|
||||
@@ -0,0 +1,29 @@
|
||||
diff --git a/core/shared/platform/windows/win_file.c b/core/shared/platform/windows/win_file.c
|
||||
index 55ea77a..df67705 100644
|
||||
--- a/core/shared/platform/windows/win_file.c
|
||||
+++ b/core/shared/platform/windows/win_file.c
|
||||
@@ -1295,13 +1295,13 @@ os_readlinkat(os_file_handle handle, const char *path, char *buf,
|
||||
|
||||
if (wbufsize >= 4 && wbuf[0] == L'\\' && wbuf[1] == L'?'
|
||||
&& wbuf[2] == L'?' && wbuf[3] == L'\\') {
|
||||
- // Starts with \??\
|
||||
+ // Has \??\ prefix
|
||||
if (wbufsize >= 6
|
||||
&& ((wbuf[4] >= L'A' && wbuf[4] <= L'Z')
|
||||
|| (wbuf[4] >= L'a' && wbuf[4] <= L'z'))
|
||||
&& wbuf[5] == L':' && (wbufsize == 6 || wbuf[6] == L'\\'))
|
||||
{
|
||||
- // \??\<drive>:\
|
||||
+ // \??\<drive>:\ path
|
||||
wbuf += 4;
|
||||
wbufsize -= 4;
|
||||
}
|
||||
@@ -1310,7 +1310,7 @@ os_readlinkat(os_file_handle handle, const char *path, char *buf,
|
||||
&& (wbuf[6] == L'C' || wbuf[6] == L'c')
|
||||
&& wbuf[7] == L'\\')
|
||||
{
|
||||
- // \??\UNC\<server>\<share>\ - make sure the final path looks like \\<server>\<share>\
|
||||
+ // \??\UNC\<server>\<share>\ - make sure the final path looks like \\<server>\<share>\ path
|
||||
wbuf += 6;
|
||||
wbuf[0] = L'\\';
|
||||
wbufsize -= 6;
|
||||
@@ -0,0 +1,49 @@
|
||||
# Standalone CMake project for building WASM simulator modules.
|
||||
# Invoked on-demand by the superbuild's wasi-module target so that
|
||||
# the WASI SDK is only fetched when WASM targets are actually built.
|
||||
#
|
||||
# Usage from superbuild:
|
||||
# cmake -S . -B build -DPCB=X10 -DPCBREV=TX16S
|
||||
# cmake --build build --target wasi-module
|
||||
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(EdgeTX-WASM NONE) # NONE = no compiler check (we set a toolchain below)
|
||||
|
||||
# Inherit the module path from the main project
|
||||
list(APPEND CMAKE_MODULE_PATH "${EDGETX_SOURCE_DIR}/cmake")
|
||||
|
||||
# Collect command-line args to forward, excluding EDGETX_* (consumed here)
|
||||
include(Macros)
|
||||
CollectCommandLineArgs(_forwarded_args EXCLUDE "^EDGETX_")
|
||||
|
||||
# Fetch / find WASI SDK
|
||||
include(FetchWasiSDK)
|
||||
find_package(WasiSDK REQUIRED)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(wasm
|
||||
SOURCE_DIR ${EDGETX_SOURCE_DIR}
|
||||
BINARY_DIR ${CMAKE_BINARY_DIR}/wasm-build
|
||||
CMAKE_ARGS
|
||||
${_forwarded_args}
|
||||
-Wno-dev
|
||||
-DCMAKE_BUILD_TYPE=${EDGETX_BUILD_TYPE}
|
||||
-DWASI_SDK_PREFIX=${WASI_SDK_PATH}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${EDGETX_SOURCE_DIR}/cmake/toolchain/wasi-threads.cmake
|
||||
CMAKE_CACHE_ARGS
|
||||
-DEdgeTX_SUPERBUILD:BOOL=0
|
||||
-DNATIVE_BUILD:BOOL=1
|
||||
-DDISABLE_COMPANION:BOOL=1
|
||||
BUILD_ALWAYS TRUE
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target wasi-module
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
# Copy .wasm files up after build
|
||||
ExternalProject_Add_Step(wasm copy-wasm
|
||||
DEPENDEES build
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DSRC_DIR=${CMAKE_BINARY_DIR}/wasm-build -DDST_DIR=${CMAKE_BINARY_DIR}
|
||||
-P ${EDGETX_SOURCE_DIR}/cmake/CopyWasmModules.cmake
|
||||
)
|
||||
Reference in New Issue
Block a user