Files
Nova64/CMakeLists.txt
T
Lukas Höppner 2f48b3efc8 initial commit
2026-08-09 15:02:21 +02:00

105 lines
3.4 KiB
CMake

file(GLOB_RECURSE CORE_SOURCES CONFIGURE_DEPENDS "src/*.c")
if(ESP_PLATFORM)
# --------------------------------------------------------------------------
# 1. ESP-IDF BUILD MODE (Target: ESP32-P4)
# --------------------------------------------------------------------------
message(STATUS "[Nova64] Building as ESP-IDF Component for ESP32...")
idf_component_register(
SRCS
${CORE_SOURCES}
INCLUDE_DIRS
"include"
REQUIRES
freertos
wamr
)
else()
# --------------------------------------------------------------------------
# 2. DESKTOP BUILD MODE (Target: Windows .dll / Linux .so / macOS .dylib)
# --------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.16)
project(nova64_core VERSION 1.0.0 LANGUAGES C)
message(STATUS "[Nova64] Building Desktop Shared Library...")
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
# --------------------------------------------------------------------------
# FreeRTOS Configuration
# --------------------------------------------------------------------------
add_library(freertos_config INTERFACE)
target_include_directories(freertos_config SYSTEM
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_compile_definitions(freertos_config
INTERFACE
projCOVERAGE_TEST=0
)
# --------------------------------------------------------------------------
# FreeRTOS Kernel via FetchContent
# --------------------------------------------------------------------------
include(FetchContent)
# Download FreeRTOS-Kernel Repository
FetchContent_Declare(
FreeRTOS_Kernel
GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git
GIT_TAG V11.3.0
)
if(WIN32)
set(FREERTOS_PORT "MSVC_MINGW" CACHE STRING "")
else()
set(FREERTOS_PORT "GCC/POSIX" CACHE STRING "")
endif()
# Select FreeRTOS heap implementation (provides pvPortMalloc/vPortFree)
set(FREERTOS_HEAP 4 CACHE STRING "FreeRTOS Heap Implementation")
# Disable FreeRTOS Demos/Tests
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
# define Target 'freertos_kernel'
FetchContent_MakeAvailable(FreeRTOS_Kernel)
# --------------------------------------------------------------------------
# Nova64 Core Target
# --------------------------------------------------------------------------
# Shared Library (.dll / .so / .dylib)
add_library(nova64_core SHARED ${CORE_SOURCES})
target_include_directories(nova64_core PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
# Link FreeRTOS Kernel to the nova64_core library
target_link_libraries(nova64_core PRIVATE freertos_kernel freertos_config)
target_compile_definitions(nova64_core PRIVATE NOVA64_EXPORTS)
if (WIN32)
set_target_properties(nova64_core PROPERTIES
C_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN YES
PREFIX ""
)
else()
set_target_properties(nova64_core PROPERTIES
C_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN YES
)
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()