diff --git a/cmake/Findugfx.cmake b/cmake/Findugfx.cmake index b5aa61c5..1f9bba28 100644 --- a/cmake/Findugfx.cmake +++ b/cmake/Findugfx.cmake @@ -7,7 +7,7 @@ if(NOT UGFX_ROOT) endif() # Assemble list of components -list(APPEND ugfx_COMPONENTS +list(APPEND ugfx_COMPONENTS_BUILTIN gadc gaudio gdisp @@ -34,13 +34,15 @@ list(APPEND ugfx_INCLUDE_DIRS ${UGFX_ROOT}/src ) -# Include each component -foreach(component ${ugfx_COMPONENTS}) +# Include each built-in component +foreach(component ${ugfx_COMPONENTS_BUILTIN}) include(${UGFX_ROOT}/src/${component}/${component}.cmake) endforeach() -# Include target setup for ease-of-use -include(${CMAKE_CURRENT_LIST_DIR}/target_setup.cmake) +# Include each component +foreach(component ${ugfx_FIND_COMPONENTS}) + include(${UGFX_ROOT}/${component}/driver.cmake) +endforeach() # Remove duplicates from non-cached variables list(REMOVE_DUPLICATES ugfx_SOURCES) @@ -49,3 +51,28 @@ list(REMOVE_DUPLICATES ugfx_INCLUDE_DIRS) # Outsource heavy-lifting to cmake include(FindPackageHandleStandardArgs) find_package_handle_standard_args(ugfx DEFAULT_MSG UGFX_ROOT ugfx_SOURCES ugfx_INCLUDE_DIRS) + +# Create the target +if(NOT TARGET ugfx) + add_library(ugfx INTERFACE IMPORTED) +endif() +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} +) diff --git a/cmake/target_setup.cmake b/cmake/target_setup.cmake deleted file mode 100644 index 15cdad23..00000000 --- a/cmake/target_setup.cmake +++ /dev/null @@ -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()