Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Add support for extra dependencies to messages ids check function and make odb and cts use it #6468

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ flow
docs/main
README2.md
messages.txt
messages.checked
Messages.md
MessagesFinal.md

Expand Down
59 changes: 53 additions & 6 deletions src/cmake/messages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,63 @@ function(messages)
set(SOURCE_DIR ${OUTPUT_DIR})
endif()

set(glob "GLOB_RECURSE")
if (${ARG_LOCAL})
set(local '--local')
set(glob "GLOB")
endif()

add_custom_command(
TARGET ${ARG_TARGET}
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py
get_target_property(target_type ${ARG_TARGET} TYPE)
if (${target_type} STREQUAL "INTERFACE_LIBRARY")
get_target_property(library_list ${ARG_TARGET} INTERFACE_LINK_LIBRARIES)
else()
get_target_property(library_list ${ARG_TARGET} LINK_LIBRARIES)
endif()
if ("${library_list}" STREQUAL "library_list-NOTFOUND")
set(library_list "")
endif()

# Search for dependencies within the same tool module
set(dependency_list "")
file(${glob} makefile_list "${SOURCE_DIR}/CMakeLists.txt")
foreach(library ${library_list})
set(library_found FALSE)
foreach(FILE ${makefile_list})
execute_process(
COMMAND bash -c "grep 'add_library\\s*(\\s*${library}' ${FILE}"
OUTPUT_VARIABLE output
)
if(NOT "${output}" STREQUAL "")
set(library_found TRUE)
break()
endif()
endforeach()
if(${library_found})
list(APPEND dependency_list ${library})
endif()
endforeach()

if ("${dependency_list}" STREQUAL "")
add_custom_command(
TARGET ${ARG_TARGET}
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py
${local}
> ${OUTPUT_DIR}/messages.txt
WORKING_DIRECTORY ${SOURCE_DIR}
)
WORKING_DIRECTORY ${SOURCE_DIR}
)
else()
add_custom_command(
OUTPUT messages.checked
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py
${local}
> ${OUTPUT_DIR}/messages.txt
&& touch ${OUTPUT_DIR}/messages.checked
WORKING_DIRECTORY ${SOURCE_DIR}
DEPENDS ${dependency_list}
)
add_custom_target(${ARG_TARGET}_messages DEPENDS messages.checked)
add_dependencies(${ARG_TARGET} ${ARG_TARGET}_messages)
endif()

endfunction()
20 changes: 2 additions & 18 deletions src/odb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,6 @@ if(ENABLE_TESTS)
)
endif()

add_custom_command(
OUTPUT messages_checked
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py > messages.txt && touch ${CMAKE_CURRENT_BINARY_DIR}/messages_checked
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS
db
cdl
defin
defout
lefin
lefout
zutil
gdsin
gdsout
messages(
TARGET odb
)

add_custom_target(odb_messages DEPENDS messages_checked)

add_dependencies(odb odb_messages)
Loading