Skip to content

Commit

Permalink
Use add_custom_target instead of add_custom_command to implement the …
Browse files Browse the repository at this point in the history
…add_vendor_target.
  • Loading branch information
domchen committed Dec 24, 2023
1 parent 6c8dbaa commit 50808ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
31 changes: 19 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ elseif (CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
endif ()
endif ()

add_vendor_target(TGFX STATIC_VENDORS ${TGFX_STATIC_VENDORS} SHARED_VENDORS ${TGFX_SHARED_VENDORS})
list(APPEND TGFX_STATIC_LIBS ${TGFX_VENDOR_STATIC_LIBRARIES})
list(APPEND TGFX_SHARED_LIBS ${TGFX_VENDOR_SHARED_LIBRARIES})
list(APPEND TGFX_VENDOR_TARGETS ${TGFX_VENDOR_TARGET})
add_vendor_target(tgfx-vendor STATIC_VENDORS ${TGFX_STATIC_VENDORS})
list(APPEND TGFX_DEPEND_TARGETS tgfx-vendor)
find_vendor_libraries(tgfx-vendor STATIC VENDOR_STATIC_LIBRARIES)
list(APPEND TGFX_STATIC_LIBS ${VENDOR_STATIC_LIBRARIES})

if (HasParent)
set(TGFX_STATIC_LIBS ${TGFX_STATIC_LIBS} PARENT_SCOPE)
Expand All @@ -392,14 +392,17 @@ if (TGFX_EXCLUDE_FILES)
list(REMOVE_ITEM TGFX_FILES ${TGFX_EXCLUDE_FILES})
endif ()

add_library(tgfx STATIC ${TGFX_VENDOR_TARGETS} ${TGFX_FILES})
add_library(tgfx STATIC ${TGFX_FILES})
target_compile_definitions(tgfx PUBLIC ${TGFX_DEFINES})
target_compile_options(tgfx PUBLIC ${TGFX_COMPILE_OPTIONS})
target_include_directories(tgfx PUBLIC include PRIVATE src)
target_include_directories(tgfx SYSTEM PRIVATE ${TGFX_INCLUDES})
merge_libraries_into(tgfx ${TGFX_STATIC_LIBS})
target_link_libraries(tgfx ${TGFX_SHARED_LIBS})
set_target_properties(tgfx PROPERTIES PREFIX "")
if (TGFX_DEPEND_TARGETS)
add_dependencies(tgfx ${TGFX_DEPEND_TARGETS})
endif ()

if (TGFX_BUILD_DRAWERS)
file(GLOB_RECURSE DRAWER_FILES drawers/src/*.*)
Expand Down Expand Up @@ -428,9 +431,9 @@ if (TGFX_BUILD_TESTS)
list(APPEND TGFX_TEST_LIBS tgfx-drawers tgfx ${TGFX_SHARED_LIBS})
list(APPEND TGFX_TEST_INCLUDES src test/src third_party/json/include)

add_vendor_target(TEST STATIC_VENDORS harfbuzz googletest)
list(APPEND TGFX_TEST_LIBS ${TEST_VENDOR_STATIC_LIBRARIES})
list(APPEND TGFX_TEST_VENDOR_TARGETS ${TEST_VENDOR_TARGET})
add_vendor_target(test-vendor STATIC_VENDORS harfbuzz googletest)
find_vendor_libraries(test-vendor STATIC VENDOR_STATIC_LIBRARIES)
list(APPEND TGFX_TEST_LIBS ${VENDOR_STATIC_LIBRARIES})
list(APPEND TGFX_TEST_INCLUDES
third_party/harfbuzz/src
third_party/googletest/googletest
Expand All @@ -451,29 +454,33 @@ if (TGFX_BUILD_TESTS)
endif ()

# used to update the local md5 data for baseline testing.
add_executable(UpdateBaseline ${TGFX_TEST_VENDOR_TARGETS} ${TGFX_TEST_FILES})
add_executable(UpdateBaseline ${TGFX_TEST_FILES})
add_dependencies(UpdateBaseline test-vendor)
target_include_directories(UpdateBaseline PUBLIC ${TGFX_TEST_INCLUDES})
target_compile_definitions(UpdateBaseline PUBLIC ${TGFX_TEST_DEFINES} UPDATE_BASELINE)
target_compile_options(UpdateBaseline PUBLIC ${TGFX_TEST_COMPILE_OPTIONS})
target_link_options(UpdateBaseline PUBLIC ${TGFX_TEST_LINK_OPTIONS})
target_link_libraries(UpdateBaseline ${TGFX_TEST_LIBS})

# used to generate baseline images to the out/ directory. each image has a "_base" suffix.
add_executable(GenerateImages ${TGFX_TEST_VENDOR_TARGETS} ${TGFX_TEST_FILES})
add_executable(GenerateImages ${TGFX_TEST_FILES})
add_dependencies(GenerateImages test-vendor)
target_include_directories(GenerateImages PUBLIC ${TGFX_TEST_INCLUDES})
target_compile_definitions(GenerateImages PUBLIC ${TGFX_TEST_DEFINES} GENERATOR_BASELINE_IMAGES)
target_compile_options(GenerateImages PUBLIC ${TGFX_TEST_COMPILE_OPTIONS})
target_link_options(GenerateImages PUBLIC ${TGFX_TEST_LINK_OPTIONS})
target_link_libraries(GenerateImages ${TGFX_TEST_LIBS})

add_executable(TGFXUnitTest ${TGFX_TEST_VENDOR_TARGETS} ${TGFX_TEST_FILES})
add_executable(TGFXUnitTest ${TGFX_TEST_FILES})
add_dependencies(TGFXUnitTest test-vendor)
target_include_directories(TGFXUnitTest PUBLIC ${TGFX_TEST_INCLUDES})
target_compile_definitions(TGFXUnitTest PUBLIC ${TGFX_TEST_DEFINES} SKIP_FRAME_COMPARE)
target_compile_options(TGFXUnitTest PUBLIC ${TGFX_TEST_COMPILE_OPTIONS})
target_link_options(TGFXUnitTest PUBLIC ${TGFX_TEST_LINK_OPTIONS})
target_link_libraries(TGFXUnitTest ${TGFX_TEST_LIBS})

add_executable(TGFXFullTest ${TGFX_TEST_VENDOR_TARGETS} ${TGFX_TEST_FILES})
add_executable(TGFXFullTest ${TGFX_TEST_FILES})
add_dependencies(TGFXFullTest test-vendor)
target_compile_definitions(TGFXFullTest PUBLIC ${TGFX_TEST_DEFINES})
target_compile_options(TGFXFullTest PUBLIC ${TGFX_TEST_COMPILE_OPTIONS})
target_include_directories(TGFXFullTest PUBLIC ${TGFX_TEST_INCLUDES})
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"common": [
{
"url": "${PAG_GROUP}/vendor_tools.git",
"commit": "9416b88ff48a300bb6541aef60cea897f5512105",
"commit": "efdd708c4c221837963407e33bce266840926d07",
"dir": "third_party/vendor_tools"
},
{
Expand Down

0 comments on commit 50808ed

Please sign in to comment.