Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding prevent_prescan to CMake API #2021

Merged
merged 1 commit into from
May 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions cmake/API.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,36 @@ set(FPRIME_AUTOCODER_TARGET_LIST "" CACHE INTERNAL "FPRIME_AUTOCODER_TARGET_LIST
#####
macro(restrict_platforms)
set(__CHECKER ${ARGN})
if (NOT CMAKE_SYSTEM_NAME IN_LIST __CHECKER)
get_module_name("${CMAKE_CURRENT_LIST_DIR}")
message(STATUS "Platform ${CMAKE_SYSTEM_NAME} not supported for module ${MODULE_NAME}")
return()
endif()
if (NOT CMAKE_SYSTEM_NAME IN_LIST __CHECKER)
get_module_name("${CMAKE_CURRENT_LIST_DIR}")
message(STATUS "Platform ${CMAKE_SYSTEM_NAME} not supported for module ${MODULE_NAME}")
return()
endif()
endmacro()

####
# Macro `prevent_prescan`:
#
# Prevents a CMakeLists.txt file from being processed in the prescan phase of the project. Will generate fake targets
# for all those targets specified to ensure that dependencies may be attached to these targets in the larger system.
#
# Usage:
# prevent_prescan(target1 target2 ...) # Generate fake targets and skip prescan
#
# Args:
# ARGN: list of targets to synthesize
#####
macro(prevent_prescan)
set(__CHECKER_TARGETS ${ARGN})
if (DEFINED FPRIME_PRESCAN)
foreach (__TARGET IN LISTS __CHECKER_TARGETS)
add_custom_target(${__TARGET})
endforeach()
string(REPLACE ";" " " __SPACE_LIST_TARGETS "${__CHECKER_TARGETS}")
get_module_name("${CMAKE_CURRENT_LIST_DIR}")
message(STATUS "Skipping ${MODULE_NAME} during prescan, adding faux libraries: ${__SPACE_LIST_TARGETS}")
return()
endif()
endmacro()

####
Expand Down