Rework ordering of cmake, so that libraries in subdirectories can add to internal lists as PICO_SDK_POST_LIST_FILES, PICO_CONFIG_HEADER_FILES etc. (#382)
Move generation of config header later, so it gets to include all values for PICO_CONFIG_HEADER_FILES
This commit is contained in:
parent
9396b9c7e1
commit
e57b99a652
@ -60,4 +60,12 @@ if (NOT TARGET _pico_sdk_pre_init_marker)
|
|||||||
include(${LIST_FILE})
|
include(${LIST_FILE})
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
macro(pico_promote_common_scope_vars)
|
||||||
|
set(PICO_INCLUDE_DIRS ${PICO_INCLUDE_DIRS} PARENT_SCOPE)
|
||||||
|
set(PICO_SDK_POST_LIST_DIRS ${PICO_SDK_PRE_LIST_FILES} PARENT_SCOPE)
|
||||||
|
set(PICO_SDK_POST_LIST_FILES ${PICO_SDK_POST_LIST_FILES} PARENT_SCOPE)
|
||||||
|
set(PICO_CONFIG_HEADER_FILES ${PICO_CONFIG_HEADER_FILES} PARENT_SCOPE)
|
||||||
|
set(PICO_RP2040_CONFIG_HEADER_FILES ${PICO_RP2040_CONFIG_HEADER_FILES} PARENT_SCOPE)
|
||||||
|
endmacro()
|
||||||
endif()
|
endif()
|
||||||
|
@ -24,6 +24,7 @@ function(pico_add_subdirectory subdir)
|
|||||||
else ()
|
else ()
|
||||||
message("Not including ${subdir} because ${replace_flag} defined.")
|
message("Not including ${subdir} because ${replace_flag} defined.")
|
||||||
endif ()
|
endif ()
|
||||||
|
pico_promote_common_scope_vars()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# add a link option to wrap the given function name; i.e. -Wl:wrap=FUNCNAME for gcc
|
# add a link option to wrap the given function name; i.e. -Wl:wrap=FUNCNAME for gcc
|
||||||
@ -115,4 +116,6 @@ function(pico_add_doxygen_exclude SOURCE_DIR)
|
|||||||
set(PICO_DOXYGEN_EXCLUDE_PATHS "${PICO_DOXYGEN_EXCLUDE_PATHS} ${SOURCE_DIR}" CACHE INTERNAL "")
|
set(PICO_DOXYGEN_EXCLUDE_PATHS "${PICO_DOXYGEN_EXCLUDE_PATHS} ${SOURCE_DIR}" CACHE INTERNAL "")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
include(${PICO_PLATFORM_CMAKE_FILE})
|
include(${PICO_PLATFORM_CMAKE_FILE})
|
||||||
|
|
||||||
|
pico_promote_common_scope_vars()
|
@ -13,4 +13,6 @@ if (NOT PICO_BARE_METAL)
|
|||||||
pico_add_subdirectory(pico_stdlib)
|
pico_add_subdirectory(pico_stdlib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
|
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
|
pico_promote_common_scope_vars()
|
@ -1,40 +1,13 @@
|
|||||||
if (NOT TARGET pico_base_headers)
|
if (NOT TARGET pico_base_headers)
|
||||||
# build the auto gen config headers
|
|
||||||
|
|
||||||
set(header_content "// AUTOGENERATED FROM PICO_CONFIG_HEADER_FILES and then PICO_<PLATFORM>_CONFIG_HEADER_FILES\n// DO NOT EDIT!\n")
|
|
||||||
string(TOUPPER ${PICO_PLATFORM} PICO_PLATFORM_UPPER)
|
|
||||||
|
|
||||||
macro(add_header_content_from_var VAR)
|
|
||||||
set(header_content "${header_content}\n\n// based on ${VAR}:\n")
|
|
||||||
foreach(var IN LISTS ${VAR})
|
|
||||||
set(header_content "${header_content}\n#include \"${var}\"")
|
|
||||||
endforeach()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# PICO_CMAKE_CONFIG: PICO_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for all platforms, type=list, default="", group=pico_base
|
|
||||||
add_header_content_from_var(PICO_CONFIG_HEADER_FILES)
|
|
||||||
|
|
||||||
# PICO_CMAKE_CONFIG: PICO_CONFIG_RP2040_HEADER_FILES, List of extra header files to include from pico/config.h for rp2040 platform, type=list, default="", group=pico_base
|
|
||||||
# PICO_CMAKE_CONFIG: PICO_CONFIG_HOST_HEADER_FILES, List of extra header files to include from pico/config.h for host platform, type=list, default="", group=pico_base
|
|
||||||
add_header_content_from_var(PICO_${PICO_PLATFORM_UPPER}_CONFIG_HEADER_FILES)
|
|
||||||
|
|
||||||
file(GENERATE
|
|
||||||
OUTPUT ${CMAKE_BINARY_DIR}/generated/pico_base/pico/config_autogen.h
|
|
||||||
CONTENT "${header_content}"
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_file( include/pico/version.h.in ${CMAKE_BINARY_DIR}/generated/pico_base/pico/version.h)
|
|
||||||
|
|
||||||
add_library(pico_base_headers INTERFACE)
|
add_library(pico_base_headers INTERFACE)
|
||||||
target_include_directories(pico_base_headers INTERFACE include ${CMAKE_BINARY_DIR}/generated/pico_base)
|
target_include_directories(pico_base_headers INTERFACE include ${CMAKE_BINARY_DIR}/generated/pico_base)
|
||||||
|
|
||||||
foreach(DIR IN LISTS PICO_INCLUDE_DIRS)
|
|
||||||
target_include_directories(pico_base_headers INTERFACE ${DIR})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# PICO_BUILD_DEFINE: PICO_BOARD, Name of board, type=string, default=CMake PICO_BOARD variable, group=pico_base
|
# PICO_BUILD_DEFINE: PICO_BOARD, Name of board, type=string, default=CMake PICO_BOARD variable, group=pico_base
|
||||||
target_compile_definitions(pico_base_headers INTERFACE
|
target_compile_definitions(pico_base_headers INTERFACE
|
||||||
PICO_BOARD="${PICO_BOARD}")
|
PICO_BOARD="${PICO_BOARD}")
|
||||||
|
|
||||||
target_link_libraries(pico_base_headers INTERFACE pico_platform_headers)
|
target_link_libraries(pico_base_headers INTERFACE pico_platform_headers)
|
||||||
|
|
||||||
|
list(APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR}/generate_config_header.cmake)
|
||||||
|
pico_promote_common_scope_vars()
|
||||||
endif()
|
endif()
|
29
src/common/pico_base/generate_config_header.cmake
Normal file
29
src/common/pico_base/generate_config_header.cmake
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# build the auto gen config headers
|
||||||
|
|
||||||
|
set(header_content "// AUTOGENERATED FROM PICO_CONFIG_HEADER_FILES and then PICO_<PLATFORM>_CONFIG_HEADER_FILES\n// DO NOT EDIT!\n")
|
||||||
|
string(TOUPPER ${PICO_PLATFORM} PICO_PLATFORM_UPPER)
|
||||||
|
|
||||||
|
macro(add_header_content_from_var VAR)
|
||||||
|
set(header_content "${header_content}\n\n// based on ${VAR}:\n")
|
||||||
|
foreach(var IN LISTS ${VAR})
|
||||||
|
set(header_content "${header_content}\n#include \"${var}\"")
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# PICO_CMAKE_CONFIG: PICO_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for all platforms, type=list, default="", group=pico_base
|
||||||
|
add_header_content_from_var(PICO_CONFIG_HEADER_FILES)
|
||||||
|
|
||||||
|
# PICO_CMAKE_CONFIG: PICO_CONFIG_RP2040_HEADER_FILES, List of extra header files to include from pico/config.h for rp2040 platform, type=list, default="", group=pico_base
|
||||||
|
# PICO_CMAKE_CONFIG: PICO_CONFIG_HOST_HEADER_FILES, List of extra header files to include from pico/config.h for host platform, type=list, default="", group=pico_base
|
||||||
|
add_header_content_from_var(PICO_${PICO_PLATFORM_UPPER}_CONFIG_HEADER_FILES)
|
||||||
|
|
||||||
|
file(GENERATE
|
||||||
|
OUTPUT ${CMAKE_BINARY_DIR}/generated/pico_base/pico/config_autogen.h
|
||||||
|
CONTENT "${header_content}"
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file( ${CMAKE_CURRENT_LIST_DIR}/include/pico/version.h.in ${CMAKE_BINARY_DIR}/generated/pico_base/pico/version.h)
|
||||||
|
|
||||||
|
foreach(DIR IN LISTS PICO_INCLUDE_DIRS)
|
||||||
|
target_include_directories(pico_base_headers INTERFACE ${DIR})
|
||||||
|
endforeach()
|
@ -32,4 +32,6 @@ endmacro()
|
|||||||
set(PICO_HOST_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "")
|
set(PICO_HOST_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "")
|
||||||
function(pico_define_boot_stage2 NAME)
|
function(pico_define_boot_stage2 NAME)
|
||||||
add_executable(${NAME} ${PICO_HOST_DIR}/boot_stage2.c)
|
add_executable(${NAME} ${PICO_HOST_DIR}/boot_stage2.c)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
pico_promote_common_scope_vars()
|
@ -4,3 +4,5 @@ pico_add_subdirectory(hardware_structs)
|
|||||||
|
|
||||||
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
|
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
|
||||||
pico_add_doxygen_exclude(${CMAKE_CURRENT_LIST_DIR}/hardware_regs) # very very big
|
pico_add_doxygen_exclude(${CMAKE_CURRENT_LIST_DIR}/hardware_regs) # very very big
|
||||||
|
|
||||||
|
pico_promote_common_scope_vars()
|
@ -71,3 +71,5 @@ endif()
|
|||||||
set(CMAKE_EXECUTABLE_SUFFIX "${CMAKE_EXECUTABLE_SUFFIX}" PARENT_SCOPE)
|
set(CMAKE_EXECUTABLE_SUFFIX "${CMAKE_EXECUTABLE_SUFFIX}" PARENT_SCOPE)
|
||||||
|
|
||||||
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
|
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
|
pico_promote_common_scope_vars()
|
Loading…
Reference in New Issue
Block a user