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

msg: Add support for extra dependencies to messages function, convert odb to it and add extra dep to cts #6407

Closed
wants to merge 3 commits into from
Closed
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
32 changes: 25 additions & 7 deletions src/cmake/messages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@
# SOURCE_DIR <dir>: the directory to search for sources from
# [defaults to OUTPUT_DIR]
# LOCAL: don't recurse [defaults to false]
# DEPENDS: <dep1 ...>: Add extra dependencies [optional]

function(messages)

# Parse args
set(options LOCAL)
set(oneValueArgs TARGET OUTPUT_DIR SOURCE_DIR)
set(multiValueArgs "")
set(multiValueArgs DEPENDS)

cmake_parse_arguments(
ARG # prefix on the parsed args
Expand All @@ -72,8 +73,10 @@ function(messages)

if (DEFINED ARG_OUTPUT_DIR)
set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_OUTPUT_DIR})
set(OUTPUT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${ARG_OUTPUT_DIR})
else()
set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(OUTPUT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()

if (DEFINED ARG_SOURCE_DIR)
Expand All @@ -86,12 +89,27 @@ function(messages)
set(local '--local')
endif()

add_custom_command(
TARGET ${ARG_TARGET}
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/etc/find_messages.py
if (NOT DEFINED ARG_DEPENDS)
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_BUILD_DIR}/messages_checked
WORKING_DIRECTORY ${SOURCE_DIR}
DEPENDS ${ARG_DEPS}
)
add_custom_target(${ARG_TARGET}_messages DEPENDS messages_checked)
add_dependencies(${ARG_TARGET} ${ARG_TARGET}_messages)
endif()

endfunction()
1 change: 1 addition & 0 deletions src/cts/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ target_link_libraries(cts
messages(
TARGET cts
OUTPUT_DIR ..
DEPENDS cts_lib
)

if (Python3_FOUND AND BUILD_PYTHON)
Expand Down
10 changes: 2 additions & 8 deletions src/odb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ 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}
messages(
TARGET odb
DEPENDS
db
cdl
Expand All @@ -99,7 +97,3 @@ add_custom_command(
gdsin
gdsout
)

add_custom_target(odb_messages DEPENDS messages_checked)

add_dependencies(odb odb_messages)
Loading