diff --git a/CMakeLists.txt b/CMakeLists.txt index 4841688bd00..55f0b50b67f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ cmake_minimum_required(VERSION 3.18) project(FPrime C CXX) set(FPRIME_INCLUDE_FRAMEWORK_CODE OFF) find_package(FPrime REQUIRED PATHS "${CMAKE_CURRENT_LIST_DIR}") +register_fprime_project() # Set default warning flags for all builds # Specific build modules that do not comply with these flags can disable one or more of them diff --git a/cmake/implementation.cmake b/cmake/implementation.cmake index 47668ef2bf3..f2812be148f 100644 --- a/cmake/implementation.cmake +++ b/cmake/implementation.cmake @@ -32,7 +32,12 @@ include(config_assembler) function(fprime_target_implementations BUILD_SYSTEM_TARGET) append_list_property("${ARGN}" TARGET "${BUILD_SYSTEM_TARGET}" PROPERTY FPRIME_CHOSEN_IMPLEMENTATIONS) fprime__internal_choose_implementations("${BUILD_SYSTEM_TARGET}" INTERNAL_ALL_IMPLEMENTATIONS) - fprime_target_dependencies("${BUILD_SYSTEM_TARGET}" PRIVATE "${INTERNAL_ALL_IMPLEMENTATIONS}") + + set(LINK_SCOPE) + if (NOT FPRIME_USE_PLAIN_LINK_SIGNATURE) + set(LINK_SCOPE PRIVATE) + endif() + fprime_target_dependencies("${BUILD_SYSTEM_TARGET}" "${LINK_SCOPE}" "${INTERNAL_ALL_IMPLEMENTATIONS}") endfunction() #### diff --git a/cmake/target/default.cmake b/cmake/target/default.cmake deleted file mode 100644 index d050ddda233..00000000000 --- a/cmake/target/default.cmake +++ /dev/null @@ -1,50 +0,0 @@ -#### -# default.cmake: -# -# Defaults for target implementations. This effectively "clears" the definitions, and thus allows a default behavior -# after another target was invoked. -#### - -#### -# `add_global_target`: -# -# The default implementation defines the target using `add_custom_target` and nothing more. -#### -function(add_global_target TARGET) - fprime_cmake_debug_message("[target] Adding default global target: ${TARGET}") - add_custom_target(${TARGET}) -endfunction(add_global_target) - -#### -# `add_deployment_target`: -# -# The default deployment target is a target which rolls-up all dependent targets through recursion. -# - **MODULE:** name of the deployment module. This is usually equivalent to $PROJECT_NAME. -# - **TARGET:** name of the top-target (e.g. dict). Use ${MODULE_NAME}_${TARGET_NAME} for a module specific target -# - **SOURCE:** list of source file inputs from the CMakeList.txt setup -# - **DEPENDENCIES:** MOD_DEPS input from CMakeLists.txt -#### -function(add_deployment_target MODULE TARGET SOURCES DIRECT_DEPENDENCIES FULL_DEPENDENCY_LIST) - fprime_cmake_debug_message("Adding default deployment target: ${MODULE}_${TARGET}") - add_custom_target("${MODULE}_${TARGET}") - foreach(DEPENDENCY IN LISTS RESULTS) - if (TARGET "${DEPENDENCY}_${TARGET}") - add_dependencies("${MODULE}_${TARGET}" "${DEPENDENCY}_${TARGET}") - endif() - endforeach() -endfunction(add_deployment_target) - -#### -# `add_module_target`: -# -# Forces a fatal to ensure that every given target defines the add module target functionality. Implementors may supply -# a blank function, but not leave it undefined. -# -# - **MODULE:** name of the module -# - **TARGET:** name of the top-target (e.g. dict). Use ${MODULE_NAME}_${TARGET_NAME} for a module specific target -# - **SOURCE:** list of source file inputs from the CMakeList.txt setup -# - **DEPENDENCIES:** MOD_DEPS input from CMakeLists.txt -#### -function(add_module_target MODULE TARGET SOURCES DEPENDENCIES) - fprime_cmake_debug_message("Skipping module target: ${MODULE}_${TARGET}, default performs no action.") -endfunction(add_module_target) diff --git a/cmake/utilities.cmake b/cmake/utilities.cmake index 46a51c6b2b2..04a70bb24be 100644 --- a/cmake/utilities.cmake +++ b/cmake/utilities.cmake @@ -247,115 +247,7 @@ function(linker_only OUTPUT_VAR TOKEN) endif() endfunction() -#### -# build_relative_path: -# -# Calculate the path to an item relative to known build paths. Search is performed in the following order erring if the -# item is found in multiple paths. -# -# INPUT_PATH: input path to search -# OUTPUT_VAR: output variable to fill -#### -function(build_relative_path INPUT_PATH OUTPUT_VAR) - # Implementation assertion - if (NOT DEFINED FPRIME_BUILD_LOCATIONS) - message(FATAL_ERROR "FPRIME_BUILD_LOCATIONS not set before build_relative_path was called") - endif() - normalize_paths(FPRIME_LOCS_NORM ${FPRIME_BUILD_LOCATIONS}) - normalize_paths(INPUT_PATH ${INPUT_PATH}) - foreach(PARENT IN LISTS FPRIME_LOCS_NORM) - string(REGEX REPLACE "${PARENT}/(.*)$" "\\1" LOC_TEMP "${INPUT_PATH}") - if (NOT LOC_TEMP STREQUAL INPUT_PATH AND NOT LOC_TEMP MATCHES "${LOC}$") - message(FATAL_ERROR "Found ${INPUT_PATH} at multiple locations: ${LOC} and ${LOC_TEMP}") - elseif(NOT LOC_TEMP STREQUAL INPUT_PATH AND NOT DEFINED LOC) - set(LOC "${LOC_TEMP}") - endif() - endforeach() - if (LOC STREQUAL "") - message(FATAL_ERROR "Failed to find location for: ${INPUT_PATH}") - endif() - set(${OUTPUT_VAR} ${LOC} PARENT_SCOPE) -endfunction(build_relative_path) - -#### -# on_any_changed: -# -# Sets VARIABLE to true if any file has been noted as changed from the "on_changed" function. Will create cache files -# in the binary directory. Please see: on_changed -# -# INPUT_FILES: files to check for changes -# ARGN: passed into execute_process via on_changed call -#### -function (on_any_changed INPUT_FILES VARIABLE) - foreach(INPUT_FILE IN LISTS INPUT_FILES) - on_changed("${INPUT_FILE}" TEMP_ON_CHANGED ${ARGN}) - if (TEMP_ON_CHANGED) - set(${VARIABLE} TRUE PARENT_SCOPE) - return() - endif() - endforeach() - set(${VARIABLE} FALSE PARENT_SCOPE) -endfunction() - -#### -# on_changed: -# -# Sets VARIABLE to true if and only if the given file has changed since the last time this function was invoked. It will -# create "${INPUT_FILE}.prev" in the binary directory as a cache from the previous invocation. The result is always TRUE -# unless a successful no-difference is calculated. -# -# INPUT_FILE: file to check if it has changed -# ARGN: passed into execute_process -#### -function (on_changed INPUT_FILE VARIABLE) - get_filename_component(INPUT_BASENAME "${INPUT_FILE}" NAME) - set(PREVIOUS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${INPUT_BASENAME}.prev") - - execute_process(COMMAND "${CMAKE_COMMAND}" -E compare_files "${INPUT_FILE}" "${PREVIOUS_FILE}" - RESULT_VARIABLE difference OUTPUT_QUIET ERROR_QUIET) - # Files are the same, leave this function - if (difference EQUAL 0) - set(${VARIABLE} FALSE PARENT_SCOPE) - return() - endif() - set(${VARIABLE} TRUE PARENT_SCOPE) - # Update the file with the latest - if (EXISTS "${INPUT_FILE}") - execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${INPUT_FILE}" "${PREVIOUS_FILE}" OUTPUT_QUIET) - endif() -endfunction() -#### -# read_from_lines: -# -# Reads a set of variables from a newline delimited test base. This will read each variable as a separate line. It is -# based on the number of arguments passed in. -#### -function (read_from_lines CONTENT) - # Loop through each arg - foreach(NAME IN LISTS ARGN) - string(REGEX MATCH "^([^\r\n]+)" VALUE "${CONTENT}") - string(REGEX REPLACE "^([^\r\n]*)\r?\n(.*)" "\\2" CONTENT "${CONTENT}") - set(${NAME} "${VALUE}" PARENT_SCOPE) - endforeach() -endfunction() - -#### -# Function `full_path_from_build_relative_path`: -# -# Creates a full path from the shortened build-relative path. -# -**SHORT_PATH:** build relative path -# Return: full path from relative path -#### -function(full_path_from_build_relative_path SHORT_PATH OUTPUT_VARIABLE) - foreach(FPRIME_LOCATION IN LISTS FPRIME_BUILD_LOCATIONS) - if (EXISTS "${FPRIME_LOCATION}/${SHORT_PATH}") - set("${OUTPUT_VARIABLE}" "${FPRIME_LOCATION}/${SHORT_PATH}" PARENT_SCOPE) - return() - endif() - endforeach() - set("${OUTPUT_VARIABLE}" "" PARENT_SCOPE) -endfunction(full_path_from_build_relative_path) #### # Function `get_nearest_build_root`: @@ -575,25 +467,7 @@ function(append_list_property NEW_ITEM) set_property(${ARGN} "${LOCAL_COPY}") endfunction() -#### -# Function `filter_lists`: -# -# Filters lists set in ARGN to to ensure that they are not in the exclude list. Sets the _FILTERED variable in -# PARENT_SCOPE with the results -# **EXCLUDE_LIST**: list of items to filter-out of ARGN lists -# **ARGN:** list of list names in parent scope to filter -#### -function (filter_lists EXCLUDE_LIST) - foreach(SOURCE_LIST IN LISTS ARGN) - set(${SOURCE_LIST}_FILTERED "") - foreach(SOURCE IN LISTS ${SOURCE_LIST}) - if (NOT SOURCE IN_LIST EXCLUDE_LIST) - list(APPEND ${SOURCE_LIST}_FILTERED "${SOURCE}") - endif() - endforeach() - set(${SOURCE_LIST}_FILTERED "${${SOURCE_LIST}_FILTERED}" PARENT_SCOPE) - endforeach() -endfunction(filter_lists) + #### # Function `get_fprime_library_option_string`: @@ -882,7 +756,7 @@ endfunction() # #### function(fprime_target_include_directories BUILD_TARGET_NAME SCOPE) - fprime__internal_target_interceptor("target_include_directories" "${BUILD_TARGET_NAME}" "${SCOPE}" ${ARGN}) + fprime__internal_target_interceptor("target_include_directories" "${BUILD_TARGET_NAME}" ${SCOPE} ${ARGN}) endfunction() ####