diff --git a/cmake/Findugfx.cmake b/cmake/Findugfx.cmake index b51840cb..c007955f 100644 --- a/cmake/Findugfx.cmake +++ b/cmake/Findugfx.cmake @@ -6,8 +6,8 @@ if(NOT UGFX_ROOT) message(FATAL_ERROR "No UGFX_ROOT specified") endif() -# Assemble list of components -list(APPEND ugfx_COMPONENTS +# Assemble list of built-in 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 user specified components +foreach(component ${ugfx_FIND_COMPONENTS}) + include(${UGFX_ROOT}/${component}/driver.cmake) +endforeach() # Remove duplicates from non-cached variables list(REMOVE_DUPLICATES ugfx_SOURCES) @@ -48,4 +50,29 @@ list(REMOVE_DUPLICATES ugfx_INCLUDE_DIRS) # Outsource heavy-lifting to cmake 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} +) 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()