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