Skip to content

Commit

Permalink
Add DESCRIPTION field to add_ip()
Browse files Browse the repository at this point in the history
  • Loading branch information
Risto97 committed Sep 15, 2024
1 parent ca3028c commit 5810a67
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmake/hwip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ include("${CMAKE_CURRENT_LIST_DIR}/utils/safe_get_target_property.cmake")
# VENDOR vendor
# LIBRARY lib
# VERSION 1.2.3
# DESCRIPTION "This is a sample IP"
# )
# ```
# In full form it is possible to ommit VENDOR, LIBRARY and VERSION, although it is not recommended.
# In full form it is possible to ommit VENDOR, LIBRARY and VERSION, DESCRIPTION, although it is not recommended.
#
# Ommiting them all would have following signature:
# ```
Expand All @@ -47,6 +48,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/utils/safe_get_target_property.cmake")
# :type LIBRARY: string
# :keyword VERSION: Version of the IP following a three-part version number (Major.Minor.Patch, e.g., 1.0.13).
# :type VERSION: string
# :keyword DESCRIPTION: Short description to be associated with the IP library, will appear in `help_ips()` message
# :type DESCRIPTION: string
#]]
function(add_ip IP_NAME)
cmake_parse_arguments(ARG "" "VENDOR;LIBRARY;VERSION;DESCRIPTION" "" ${ARGN})
Expand Down Expand Up @@ -94,6 +97,10 @@ function(add_ip IP_NAME)
endif()
endif()

if(ARG_DESCRIPTION)
set_property(TARGET ${IP_LIB} PROPERTY DESCRIPTION ${ARG_DESCRIPTION})
endif()

# Unset the parent variables that might have been set by previous add_ip() call
unset(IP_VENDOR PARENT_SCOPE)
unset(IP_LIBRARY PARENT_SCOPE)
Expand Down
31 changes: 31 additions & 0 deletions tests/add_ip/add_ip_description.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")

set(TEST_NAME add_ip_description)

ct_add_test(NAME ${TEST_NAME})
function(${${TEST_NAME}})
add_ip(ip
VENDOR vendor
LIBRARY lib
VERSION 1.2.3
DESCRIPTION "Simple description"
)
ct_assert_target_has_property(${IP} DESCRIPTION)
get_target_property(_desc ${IP} DESCRIPTION)
ct_assert_equal(_desc "Simple description")

add_ip(ip2
DESCRIPTION "Simpler description"
)
ct_assert_target_has_property(${IP} DESCRIPTION)
get_target_property(_desc ${IP} DESCRIPTION)
ct_assert_equal(_desc "Simpler description")

add_ip(vendor2::lib::ip::0.0.1
DESCRIPTION "Even simpler description"
)
ct_assert_target_has_property(${IP} DESCRIPTION)
get_target_property(_desc ${IP} DESCRIPTION)
ct_assert_equal(_desc "Even simpler description")

endfunction()

0 comments on commit 5810a67

Please sign in to comment.