@@ -14,27 +14,35 @@ option (DEMO1_GEN_SWIG "Use commsdsl2swig to generate swig bindings project." OF
1414option (DEMO1_BUILD_SWIG "Build and install project generated by the commsdsl2swig." ${DEMO1_GEN_SWIG} )
1515option (DEMO1_GEN_EMSCRIPTEN "Use commsdsl2emscripten to generate emscripten bindings project." OFF )
1616option (DEMO1_BUILD_EMSCRIPTEN "Build and install project generated by the commsdsl2emscripten." ${DEMO1_GEN_EMSCRIPTEN} )
17+ option (DEMO1_GEN_C "Use commsdsl2c to generate \" C\" wrappers project." OFF )
18+ option (DEMO1_BUILD_C "Build and install project generated by the commsdsl2c." ${DEMO1_GEN_C} )
19+ option (DEMO1_GEN_LATEX "Use commsdsl2latex to generate protocol specification." OFF )
20+ option (DEMO1_BUILD_LATEX "Build and install project generated by the commsdsl2latex." ${DEMO1_GEN_C} )
1721option (DEMO1_BUILD_EXAMPLES "Build examples." ON )
1822
1923# Additional variables to be used if needed
2024# ---------------------------
2125# DEMO1_PROT_OUTPUT_DIR - Path to protocol output directory. If not provided <build_dir>/output one is used.
22- # DEMO1_TEST_OUTPUT_DIR - Path to test output directory. If not provided <build_dir>/output_tools one is used.
26+ # DEMO1_TEST_OUTPUT_DIR - Path to test output directory. If not provided <build_dir>/output_test one is used.
2327# DEMO1_TOOLS_OUTPUT_DIR - Path to tools output directory. If not provided <build_dir>/output_tools one is used.
2428# DEMO1_TOOLS_QT_VER - Major Qt version to be used when building tools output. Defaults to 5
2529# DEMO1_SWIG_OUTPUT_DIR - Path to swig output directory. If not provided <build_dir>/output_swig one is used.
2630# DEMO1_SWIG_SRC_DIR - Path to the commsdsl2swig sources. If not provided local "src/swig" dir is used.
2731# DEMO1_SWIG_LANGUAGES - Languages list to support by swig. If not provided "python java csharp" are chosen
2832# DEMO1_EMSCRIPTEN_OUTPUT_DIR - Path to emscripten output directory. If not provided <build_dir>/output_emscripten one is used.
33+ # DEMO1_C_OUTPUT_DIR - Path to "c" output directory. If not provided <build_dir>/output_c one is used.
34+ # DEMO1_LATEX_OUTPUT_DIR - Path to latex output directory. If not provided <build_dir>/output_latex one is used.
2935# DEMO1_CCACHE_EXECUTABLE - Custom ccache executable
3036# COMMSDSL2COMMS_EXTRA_ARGS - Extra arguments to pass to "commsdsl2comms"
3137# COMMSDSL2TEST_EXTRA_ARGS - Extra arguments to pass to "commsdsl2test"
3238# COMMSDSL2TOOLS_QT_EXTRA_ARGS - Extra arguments to pass to "commsdsl2tools_qt"
3339# COMMSDSL2SWIG_EXTRA_ARGS - Extra arguments to pass to "commsdsl2swig"
3440# COMMSDSL2EMSCRIPTEN_EXTRA_ARGS - Extra arguments to pass to "commsdsl2emscripten"
41+ # COMMSDSL2C_EXTRA_ARGS - Extra arguments to pass to "commsdsl2c"
42+ # COMMSDSL2LATEX_EXTRA_ARGS - Extra arguments to pass to "commsdsl2latex"
3543
36- set (DEMO1_VERSION "3.0.3 " )
37- set (DEMO1_MIN_COMMSDSL_VERSION "7.1 " )
44+ set (DEMO1_VERSION "3.0.4 " )
45+ set (DEMO1_MIN_COMMSDSL_VERSION "7.3 " )
3846
3947if (("${CMAKE_VERSION} " VERSION_GREATER_EQUAL "3.30" ) AND
4048 (NOT DEFINED CMAKE_POLICY_DEFAULT_CMP0167 ))
@@ -80,6 +88,14 @@ if ("${DEMO1_EMSCRIPTEN_OUTPUT_DIR}" STREQUAL "")
8088 set (DEMO1_EMSCRIPTEN_OUTPUT_DIR "${CMAKE_BINARY_DIR} /output_emscripten" )
8189endif ()
8290
91+ if ("${DEMO1_C_OUTPUT_DIR} " STREQUAL "" )
92+ set (DEMO1_C_OUTPUT_DIR "${CMAKE_BINARY_DIR} /output_c" )
93+ endif ()
94+
95+ if ("${DEMO1_LATEX_OUTPUT_DIR} " STREQUAL "" )
96+ set (DEMO1_LATEX_OUTPUT_DIR "${CMAKE_BINARY_DIR} /output_latex" )
97+ endif ()
98+
8399if ("${DEMO1_TOOLS_QT_VER} " STREQUAL "" )
84100 set (DEMO1_TOOLS_QT_VER 5)
85101endif ()
@@ -162,7 +178,7 @@ if (DEMO1_GEN_TEST)
162178
163179 add_custom_target ("test_output_tgt" ALL
164180 COMMAND ${CMAKE_COMMAND} -E remove_directory ${test_tmp_dir}
165- COMMAND ${COMMSDSL2TEST} ${warn_as_error} ${COMMSDSL2TEST_EXTRA_ARGS}
181+ COMMAND ${COMMSDSL2TEST} ${warn_as_error} -V ${DEMO1_VERSION} ${COMMSDSL2TEST_EXTRA_ARGS}
166182 -o ${test_tmp_dir} -c ${PROJECT_SOURCE_DIR} /src/test ${schema_file}
167183 COMMAND ${CMAKE_COMMAND}
168184 -DGENERATED="${test_tmp_dir} " -DOUTPUT="${DEMO1_TEST_OUTPUT_DIR} "
@@ -214,7 +230,7 @@ if (DEMO1_GEN_TOOLS)
214230
215231 add_custom_target ("tools_output_tgt" ALL
216232 COMMAND ${CMAKE_COMMAND} -E remove_directory ${tools_tmp_dir}
217- COMMAND ${COMMSDSL2TOOLS_QT} ${warn_as_error} ${COMMSDSL2TOOLS_QT_EXTRA_ARGS}
233+ COMMAND ${COMMSDSL2TOOLS_QT} ${warn_as_error} -V ${DEMO1_VERSION} ${COMMSDSL2TOOLS_QT_EXTRA_ARGS}
218234 --protocol "::CC Demo1:Synthenic demo protocol to demonstrate definition of various fields as well as simple protocol framing.:cc.Demo1ProtocolPlugin"
219235 -o ${tools_tmp_dir} -c ${PROJECT_SOURCE_DIR} /src/tools ${schema_file}
220236 COMMAND ${CMAKE_COMMAND}
@@ -267,7 +283,7 @@ if (DEMO1_GEN_SWIG)
267283
268284 add_custom_target ("swig_output_tgt" ALL
269285 COMMAND ${CMAKE_COMMAND} -E remove_directory ${swig_tmp_dir}
270- COMMAND ${COMMSDSL2SWIG} ${warn_as_error} ${COMMSDSL2SWIG_EXTRA_ARGS}
286+ COMMAND ${COMMSDSL2SWIG} ${warn_as_error} -V ${DEMO1_VERSION} ${COMMSDSL2SWIG_EXTRA_ARGS}
271287 -c ${DEMO1_SWIG_SRC_DIR} -o ${swig_tmp_dir} ${schema_file}
272288 COMMAND ${CMAKE_COMMAND}
273289 -DGENERATED="${swig_tmp_dir} " -DOUTPUT="${DEMO1_SWIG_OUTPUT_DIR} "
@@ -325,7 +341,7 @@ if (DEMO1_GEN_EMSCRIPTEN)
325341
326342 add_custom_target ("emscripten_output_tgt" ALL
327343 COMMAND ${CMAKE_COMMAND} -E remove_directory ${emscripten_tmp_dir}
328- COMMAND ${COMMSDSL2EMSCRIPTEN} ${warn_as_error} ${COMMSDSL2EMSCRIPTEN_EXTRA_ARGS}
344+ COMMAND ${COMMSDSL2EMSCRIPTEN} ${warn_as_error} -V ${DEMO1_VERSION} ${COMMSDSL2EMSCRIPTEN_EXTRA_ARGS}
329345 -o ${emscripten_tmp_dir} -c ${PROJECT_SOURCE_DIR} /src/emscripten ${schema_file}
330346 COMMAND ${CMAKE_COMMAND}
331347 -DGENERATED="${emscripten_tmp_dir} " -DOUTPUT="${DEMO1_EMSCRIPTEN_OUTPUT_DIR} "
@@ -373,6 +389,115 @@ if (DEMO1_GEN_EMSCRIPTEN)
373389 endif ()
374390endif ()
375391
392+ if (DEMO1_GEN_C)
393+ find_program (COMMSDSL2C commsdsl2c PATH_SUFFIXES bin REQUIRED)
394+ execute_process (COMMAND "${COMMSDSL2C} " --version OUTPUT_VARIABLE commsdsl2c_version)
395+ if ("${commsdsl2c_version} " VERSION_LESS "${DEMO1_MIN_COMMSDSL_VERSION} " )
396+ message (FATAL_ERROR "Version of commsdsl2c is too old, required minimum is v${DEMO1_MIN_COMMSDSL_VERSION} ." )
397+ endif ()
398+
399+ set (c_tmp_dir "${CMAKE_BINARY_DIR} /output_c.tmp" )
400+
401+ add_custom_target ("c_output_tgt" ALL
402+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${c_tmp_dir}
403+ COMMAND ${COMMSDSL2C} ${warn_as_error} -V ${DEMO1_VERSION} ${COMMSDSL2C_EXTRA_ARGS}
404+ -o ${c_tmp_dir} -c ${PROJECT_SOURCE_DIR} /src/c ${schema_file}
405+ COMMAND ${CMAKE_COMMAND}
406+ -DGENERATED="${c_tmp_dir} " -DOUTPUT="${DEMO1_C_OUTPUT_DIR} "
407+ -P "${CMAKE_CURRENT_LIST_DIR} /CopyGenerated.cmake"
408+ DEPENDS "${CMAKE_CURRENT_LIST_DIR} /CopyGenerated.cmake" ${schema_file} )
409+
410+ if (DEMO1_BUILD_C)
411+ if ((NOT DEMO1_GEN_PROTOCOL) OR (NOT DEMO1_BUILD_PROTOCOL))
412+ message (FATAL_ERROR "DEMO1_GEN_PROTOCOL and DEMO1_BUILD_PROTOCOL are required for DEMO1_BUILD_C" )
413+ endif ()
414+
415+ execute_process (
416+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DEMO1_C_OUTPUT_DIR}
417+ )
418+
419+ execute_process (
420+ COMMAND ${CMAKE_COMMAND} -E touch ${DEMO1_C_OUTPUT_DIR} /dummy.txt
421+ )
422+
423+ set (c_build_dir ${CMAKE_CURRENT_BINARY_DIR} /c_tgt_build)
424+ ExternalProject_Add(
425+ "c_tgt"
426+ BUILD_ALWAYS TRUE
427+ DEPENDS "prot_tgt" "c_output_tgt"
428+ SOURCE_DIR ${DEMO1_C_OUTPUT_DIR}
429+ BINARY_DIR ${c_build_dir}
430+ LIST_SEPARATOR |
431+ CMAKE_ARGS
432+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
433+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
434+ -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
435+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
436+ -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_PREFIX_PATH=${combined_prefix_path_str}
437+ -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
438+ -DOPT_USE_CCACHE=${DEMO1_USE_CCACHE}
439+ -DOPT_CCACHE_EXECUTABLE=${DEMO1_CCACHE_EXECUTABLE}
440+ )
441+
442+ find_package (Doxygen)
443+ if (DEMO1_BUILD_PROT_DOC AND DOXYGEN_FOUND)
444+ ExternalProject_Add_Step(
445+ "c_tgt"
446+ "doc"
447+ COMMAND ${CMAKE_COMMAND} --build ${c_build_dir} --target doc_cc_demo1_c
448+ DEPENDEES "build"
449+ DEPENDERS "install"
450+ )
451+ endif ()
452+ endif ()
453+ endif ()
454+
455+ if (DEMO1_GEN_LATEX)
456+ find_program (COMMSDSL2LATEX commsdsl2latex PATH_SUFFIXES bin REQUIRED)
457+ execute_process (COMMAND "${COMMSDSL2LATEX} " --version OUTPUT_VARIABLE commsdsl2latex_version)
458+ if ("${commsdsl2latex_version} " VERSION_LESS "${DEMO1_MIN_COMMSDSL_VERSION} " )
459+ message (FATAL_ERROR "Version of commsdsl2latex is too old, required minimum is v${DEMO1_MIN_COMMSDSL_VERSION} ." )
460+ endif ()
461+
462+ set (latex_tmp_dir "${CMAKE_BINARY_DIR} /output_latex.tmp" )
463+
464+ add_custom_target ("latext_output_tgt" ALL
465+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${latex_tmp_dir}
466+ COMMAND ${COMMSDSL2LATEX} ${warn_as_error} ${COMMSDSL2LATEX_EXTRA_ARGS}
467+ -o ${latex_tmp_dir} -c ${PROJECT_SOURCE_DIR} /src/latex ${schema_file}
468+ COMMAND ${CMAKE_COMMAND}
469+ -DGENERATED="${latex_tmp_dir} " -DOUTPUT="${DEMO1_LATEX_OUTPUT_DIR} "
470+ -P "${CMAKE_CURRENT_LIST_DIR} /CopyGenerated.cmake"
471+ DEPENDS "${CMAKE_CURRENT_LIST_DIR} /CopyGenerated.cmake" ${schema_file} )
472+
473+ if (DEMO1_BUILD_LATEX)
474+ execute_process (
475+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DEMO1_LATEX_OUTPUT_DIR}
476+ )
477+
478+ execute_process (
479+ COMMAND ${CMAKE_COMMAND} -E touch ${DEMO1_LATEX_OUTPUT_DIR} /dummy.txt
480+ )
481+
482+ set (latex_build_dir ${CMAKE_CURRENT_BINARY_DIR} /latex_tgt_build)
483+ ExternalProject_Add(
484+ "latex_tgt"
485+ BUILD_ALWAYS TRUE
486+ DEPENDS "latext_output_tgt"
487+ SOURCE_DIR ${DEMO1_LATEX_OUTPUT_DIR}
488+ BINARY_DIR ${latex_build_dir}
489+ LIST_SEPARATOR |
490+ CMAKE_ARGS
491+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
492+ -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_PREFIX_PATH=${combined_prefix_path_str}
493+ BUILD_COMMAND
494+ ${CMAKE_COMMAND} --build ${latex_build_dir} --config ${CMAKE_BUILD_TYPE} --target all_artifacts
495+ INSTALL_COMMAND
496+ ${CMAKE_COMMAND} -E echo "No install for documentation build"
497+ )
498+ endif ()
499+ endif ()
500+
376501if (NOT DEMO1_BUILD_EXAMPLES)
377502 return ()
378503endif ()
0 commit comments