cmake: Improve Findugfx.cmake
This commit is contained in:
parent
0f11538656
commit
6b621ca6b8
@ -6,8 +6,8 @@ if(NOT UGFX_ROOT)
|
|||||||
message(FATAL_ERROR "No UGFX_ROOT specified")
|
message(FATAL_ERROR "No UGFX_ROOT specified")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Assemble list of components
|
# Assemble list of built-in components
|
||||||
list(APPEND ugfx_COMPONENTS
|
list(APPEND ugfx_COMPONENTS_BUILTIN
|
||||||
gadc
|
gadc
|
||||||
gaudio
|
gaudio
|
||||||
gdisp
|
gdisp
|
||||||
@ -34,13 +34,15 @@ list(APPEND ugfx_INCLUDE_DIRS
|
|||||||
${UGFX_ROOT}/src
|
${UGFX_ROOT}/src
|
||||||
)
|
)
|
||||||
|
|
||||||
# Include each component
|
# Include each built-in component
|
||||||
foreach(component ${ugfx_COMPONENTS})
|
foreach(component ${ugfx_COMPONENTS_BUILTIN})
|
||||||
include(${UGFX_ROOT}/src/${component}/${component}.cmake)
|
include(${UGFX_ROOT}/src/${component}/${component}.cmake)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Include target setup for ease-of-use
|
# Include user specified components
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/target_setup.cmake)
|
foreach(component ${ugfx_FIND_COMPONENTS})
|
||||||
|
include(${UGFX_ROOT}/${component}/driver.cmake)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# Remove duplicates from non-cached variables
|
# Remove duplicates from non-cached variables
|
||||||
list(REMOVE_DUPLICATES ugfx_SOURCES)
|
list(REMOVE_DUPLICATES ugfx_SOURCES)
|
||||||
@ -48,4 +50,29 @@ list(REMOVE_DUPLICATES ugfx_INCLUDE_DIRS)
|
|||||||
|
|
||||||
# Outsource heavy-lifting to cmake
|
# Outsource heavy-lifting to cmake
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(ugfx DEFAULT_MSG)
|
find_package_handle_standard_args(ugfx DEFAULT_MSG UGFX_ROOT ugfx_SOURCES ugfx_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
# Create the target
|
||||||
|
add_library(ugfx INTERFACE IMPORTED)
|
||||||
|
target_include_directories(
|
||||||
|
ugfx
|
||||||
|
INTERFACE
|
||||||
|
${ugfx_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
target_sources(
|
||||||
|
ugfx
|
||||||
|
INTERFACE
|
||||||
|
${ugfx_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(
|
||||||
|
ugfx
|
||||||
|
INTERFACE
|
||||||
|
${ugfx_DEFS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
ugfx
|
||||||
|
INTERFACE
|
||||||
|
${ugfx_LIBS}
|
||||||
|
)
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
function(ugfx_target_setup TARGET)
|
|
||||||
|
|
||||||
target_include_directories(
|
|
||||||
${TARGET}
|
|
||||||
PRIVATE
|
|
||||||
${ugfx_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_sources(
|
|
||||||
${TARGET}
|
|
||||||
PRIVATE
|
|
||||||
${ugfx_SOURCES}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_definitions(
|
|
||||||
${TARGET}
|
|
||||||
PRIVATE
|
|
||||||
${ugfx_DEFS}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
|
||||||
${TARGET}
|
|
||||||
PRIVATE
|
|
||||||
${ugfx_LIBS}
|
|
||||||
)
|
|
||||||
|
|
||||||
endfunction()
|
|
Loading…
Reference in New Issue
Block a user