Add CMake package file for F Prime (#3898)

This commit is contained in:
M Starch 2025-07-18 12:56:11 -07:00 committed by GitHub
parent b217fc79a6
commit da4dc9d92d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 46 deletions

View File

@ -4,24 +4,18 @@
# This sets up the build for the 'Ref' Application, including the custom reference # This sets up the build for the 'Ref' Application, including the custom reference
# components. In addition, it imports FPrime.cmake, which includes the core F Prime # components. In addition, it imports FPrime.cmake, which includes the core F Prime
# components. # components.
#
# This file has several sections.
#
# 1. Header Section: define basic properties of the build
# 2. F prime core: includes all F prime core components, and build-system properties
# 3. Local subdirectories: contains all deployment specific directory additions
#### ####
## # Allow CMake 3.0 - 4.0 projects to set the VERSION variable in the `project` call
# Section 1: Basic Project Setup
#
# This contains the basic project information. Specifically, a cmake version and
# project definition.
##
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0048 NEW)
# CMake basic setup: version consistent with requirements.txt, and define a project
cmake_minimum_required(VERSION 3.26)
project(Ref VERSION 1.0.0 LANGUAGES C CXX) project(Ref VERSION 1.0.0 LANGUAGES C CXX)
##
# Find the fprime package and include the core codebase
set(FPRIME_INCLUDE_FRAMEWORK_CODE ON)
find_package(FPrime REQUIRED PATHS "${CMAKE_CURRENT_LIST_DIR}/..")
add_compile_options( add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast> $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast>
-Wall -Wall
@ -35,35 +29,15 @@ add_compile_options(
-pedantic -pedantic
) )
# Section 2: F prime Core # Add subdirectories for the Ref project specific components
#
# This includes all of the F prime core components, and imports the make-system. F prime core
# components will be placed in the F-Prime binary subdirectory to keep them from
# colliding with deployment specific items.
##
include("${CMAKE_CURRENT_LIST_DIR}/../cmake/FPrime.cmake")
# NOTE: register custom targets between these two lines
fprime_setup_included_code()
##
# Section 3: Components and Topology
#
# This section includes deployment specific directories. This allows use of non-
# core components in the topology, which is also added here.
##
# Add component subdirectories
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PingReceiver/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PingReceiver/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RecvBuffApp/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RecvBuffApp/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SendBuffApp/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SendBuffApp/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SignalGen/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SignalGen/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TypeDemo/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TypeDemo/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BlockDriver/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BlockDriver/")
# Add Topology subdirectory
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Top/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Top/")
#set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Main.cpp")
#set(MOD_DEPS ${PROJECT_NAME}/Top)
register_fprime_deployment( register_fprime_deployment(
SOURCES SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Main.cpp" "${CMAKE_CURRENT_LIST_DIR}/Main.cpp"
@ -85,4 +59,3 @@ target_compile_options("${PROJECT_NAME}" PUBLIC -Wold-style-cast)
target_compile_options("${PROJECT_NAME}" PUBLIC -Woverloaded-virtual) target_compile_options("${PROJECT_NAME}" PUBLIC -Woverloaded-virtual)
target_compile_options("${PROJECT_NAME}" PUBLIC -Wno-unused-parameter) target_compile_options("${PROJECT_NAME}" PUBLIC -Wno-unused-parameter)
target_compile_options("${PROJECT_NAME}" PUBLIC -Wundef) target_compile_options("${PROJECT_NAME}" PUBLIC -Wundef)
set_property(TARGET "${PROJECT_NAME}" PROPERTY CXX_STANDARD 11)

9
cmake/FPrimeConfig.cmake Normal file
View File

@ -0,0 +1,9 @@
message(STATUS "[F Prime] F Prime CMake package found at: ${CMAKE_CURRENT_LIST_FILE}")
include("${CMAKE_CURRENT_LIST_DIR}/FPrime.cmake")
# By default the F Prime package will load the codebase. This can be set OFF by setting the variable
# FPRIME_INCLUDE_FRAMEWORK_CODE to OFF. When set OFF, the user must call fprime_setup_included_code()
# to be able to use F Prime code.
if ((NOT DEFINED FPRIME_INCLUDE_FRAMEWORK_CODE) OR (FPRIME_INCLUDE_FRAMEWORK_CODE))
fprime_setup_included_code()
endif()

View File

@ -11,16 +11,19 @@
# - UT flags overrides # - UT flags overrides
#### ####
include_guard() include_guard()
# fprime framework is build with C++11 and C99 support, project may override these setting after the inclusion of # fprime framework is build with C++11 and C99 support, project may override these settings, but results are not guaranteed
# Fprime-Code.cmake. # when overriding for F Prime framework code.
set(CMAKE_CXX_STANDARD 11) if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 99) endif()
set(CMAKE_C_STANDARD_REQUIRED ON) if (NOT DEFINED CMAKE_C_STANDARD)
set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
endif()
# fprime unit testing methodology requires the following flags # fprime unit testing methodology requires the following flags
if (BUILD_TESTING) if (BUILD_TESTING)
add_compile_options(-g -DBUILD_UT -DPROTECTED=public -DPRIVATE=public -DSTATIC=) add_compile_options(-g -DBUILD_UT -DPROTECTED=public -DPRIVATE=public -DSTATIC=)