Skip to content

Commit 4eb5cf8

Browse files
Update cmake script
Signed-off-by: Firas Sahli <firas.sahli@adlinktech.com>
1 parent 4c5f653 commit 4eb5cf8

2 files changed

Lines changed: 120 additions & 3 deletions

File tree

bit/CMakeLists.txt

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,44 @@
11
cmake_minimum_required(VERSION 3.7)
2+
project(dds-python)
23

34
find_package(CycloneDDS)
45

5-
idlc_generate(ddsbit bit.idl)
6-
add_library(ddstubs SHARED dds_stubs.c)
7-
target_link_libraries(ddstubs ddsbit CycloneDDS::ddsc)
6+
#idlc_generate(ddsbit bit.idl)
7+
SET(outsources)
8+
9+
SET(outsources bit)
10+
11+
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
12+
message(" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}")
13+
include(idlc_generate_macro)
14+
15+
# find_program(idcl_generate dds_idlc /home/firas/cyclone/cyclonedds/bld/src/idlc)
16+
#
17+
# if(NOT idcl_generate)
18+
# message(FATAL_ERROR "Failed to find idlc code generator ")
19+
# else()
20+
# message("Find idlc code generator")
21+
# endif()
22+
23+
# message (${idcl_generate})
24+
message (" outsources = ${outsources}")
25+
26+
message ("${idcl_generate} -d ${CMAKE_CURRENT_SOURCE_DIR}/ ${CMAKE_CURRENT_SOURCE_DIR}/${outsources}.idl")
27+
28+
29+
# ADD_CUSTOM_COMMAND (
30+
# OUTPUT ${outsource}.c ${outsources}.h
31+
# COMMAND ${idcl_generate} ARGS -d ${CMAKE_CURRENT_SOURCE_DIR} -verbose ${CMAKE_CURRENT_BINARY_DIR}/bit.idl
32+
# COMMENT "Generating files in ${CMAKE_CURRENT_SOURCE_DIR} "
33+
# )
34+
idlc_generate_func(${CMAKE_CURRENT_SOURCE_DIR}/bit.idl)
35+
idlc_generate_func(${CMAKE_CURRENT_SOURCE_DIR}/../tests/helloworld.idl)
36+
37+
add_library(ddstubs SHARED ${CMAKE_CURRENT_SOURCE_DIR}/dds_stubs.c)
38+
add_library(ddsbit SHARED ${CMAKE_CURRENT_SOURCE_DIR}/bit.c ${CMAKE_CURRENT_SOURCE_DIR}/bit.h )
39+
add_library(ddshelloworld SHARED ${CMAKE_CURRENT_SOURCE_DIR}/helloworld.c ${CMAKE_CURRENT_SOURCE_DIR}/helloworld.h )
40+
41+
message("CMAKE_CURRENT_BINARY_DIR ==== ${CMAKE_CURRENT_BINARY_DIR} ")
42+
message("CMAKE_CURRENT_SOURCE_DIR ==== ${CMAKE_CURRENT_SOURCE_DIR} ")
43+
844
target_link_libraries(ddstubs ddsbit ddshelloworld CycloneDDS::ddsc)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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

Comments
 (0)