ugfx/cmake/Findugfx.cmake

79 lines
1.5 KiB
CMake
Raw Permalink Normal View History

2021-10-27 14:45:20 +00:00
# Define UGFX_ROOT
set(UGFX_ROOT ${CMAKE_CURRENT_LIST_DIR}/..)
2022-06-10 13:41:34 +00:00
# Ensure that UGFX_ROOT is set
2021-10-12 15:44:54 +00:00
if(NOT UGFX_ROOT)
message(FATAL_ERROR "No UGFX_ROOT specified")
endif()
# Assemble list of components
2021-11-03 19:50:24 +00:00
list(APPEND ugfx_COMPONENTS_BUILTIN
2021-10-12 15:44:54 +00:00
gadc
gaudio
gdisp
gdriver
gevent
gfile
ginput
gmisc
gos
gqueue
gtimer
gtrans
gwin
)
# Core sources
list(APPEND ugfx_SOURCES
${UGFX_ROOT}/src/gfx.c
)
# Core include directories
list(APPEND ugfx_INCLUDE_DIRS
${UGFX_ROOT}
2021-10-12 15:44:54 +00:00
${UGFX_ROOT}/src
)
2021-11-03 19:50:24 +00:00
# Include each built-in component
foreach(component ${ugfx_COMPONENTS_BUILTIN})
2021-10-12 15:44:54 +00:00
include(${UGFX_ROOT}/src/${component}/${component}.cmake)
endforeach()
2021-11-03 19:50:24 +00:00
# Include each component
foreach(component ${ugfx_FIND_COMPONENTS})
include(${UGFX_ROOT}/${component}/driver.cmake)
endforeach()
2021-10-12 15:44:54 +00:00
# Remove duplicates from non-cached variables
list(REMOVE_DUPLICATES ugfx_SOURCES)
list(REMOVE_DUPLICATES ugfx_INCLUDE_DIRS)
# Outsource heavy-lifting to cmake
include(FindPackageHandleStandardArgs)
2021-11-03 19:23:29 +00:00
find_package_handle_standard_args(ugfx DEFAULT_MSG UGFX_ROOT ugfx_SOURCES ugfx_INCLUDE_DIRS)
2021-11-03 19:50:24 +00:00
# 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}
)