-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathidlc_generate_macro.cmake
More file actions
81 lines (62 loc) · 2.29 KB
/
idlc_generate_macro.cmake
File metadata and controls
81 lines (62 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
#set(IDLC_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING "")
#set(IDLC "dds_idlc${EXTENSION}" CACHE STRING "")
#mark_as_advanced(IDLC_DIR IDLC)
#set(IDLC_SCRIPT_IN "${CMAKE_CURRENT_LIST_DIR}/dds_idlc${EXTENSION}.in")
#configure_file(
# "${IDLC_SCRIPT_IN}" "${IDLC}"
# @ONLY
# NEWLINE_STYLE ${LINE_ENDINGS})
#
#if(NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows"))
# execute_process(COMMAND chmod +x "${IDLC_DIR}/${IDLC}")
#endif()
#add_custom_target(idlc ALL DEPENDS "${IDLC_JAR}")
MACRO (idlc_generate_func idl_file)
message("idl_file: ${idl_file} ")
if(idl_file STREQUAL "")
message(FATAL_ERROR "idlc_generate called without any idl files")
endif()
if (NOT IDLC_ARGS)
set(IDLC_ARGS)
endif()
set(_dir "${CMAKE_CURRENT_BINARY_DIR}")
set(_sources)
set(_headers)
find_program(idcl_generate_full_path
dds_idlc
PATHS /tmp/cyclonedds/build/src/idlc)
if( idcl_generate_full_path STREQUAL "")
message(FATAL_ERROR "Failed to find idlc code generator ")
else()
message("${idcl_generate_full_path}: Found idlc code generator")
endif()
foreach(FIL ${idl_file})
message("file to parse ${FIL} ")
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE)
set(_source "${CMAKE_CURRENT_SOURCE_DIR}/${FIL_WE}.c")
set(_header "${CMAKE_CURRENT_SOURCE_DIR}/${FIL_WE}.h")
list(APPEND _sources "${_source}")
list(APPEND _headers "${_header}")
add_custom_command(
OUTPUT "${_source}" "${_header}"
COMMAND "${idcl_generate_full_path}"
ARGS -d ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL}
COMMENT "Running idlc on ${FIL}"
VERBATIM)
endforeach()
message("sources ${_sources}" )
message("headers ${_headers}" )
set_source_files_properties(${_sources} ${_headers} PROPERTIES GENERATED TRUE)
endmacro()