Mercurial > hg > orthanc-stone
annotate Resources/CMake/ProtobufCodeGeneration.cmake @ 869:60a403f01c31 toa2019062503
Fixed WARN --> WARNING (unsure how this builds fine under Windows...)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 25 Jun 2019 18:04:54 +0200 |
parents | 5055031f4a06 |
children |
rev | line source |
---|---|
466
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
1 # HOW TO USE: |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
2 # the GenerateCodeFromProtobufSchema will generate files in ${CMAKE_BINARY_DIR} and will |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
3 # populate PROTOBUF_AUTOGENERATED_SOURCES with the list of generated files |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
4 # AS OF 2019-01-30, it requires protoc (version 3.6.1.x) to be available in the path |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
5 set(PROTOBUF_AUTOGENERATED_SOURCES) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
6 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
7 # TODO: use find_program (<VAR> name1 [path1 path2 ...]) to located the protobuf compiler |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
8 # TODO: automated the TS plugin installation |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
9 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
10 macro(GenerateCodeFromProtobufSchema schemaFilePath outputBaseDirectory) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
11 # extract file name |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
12 GetFilePathWithoutLastExtension(schemaFilePathWithoutExt ${schemaFilePath}) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
13 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
14 # remove extension |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
15 GetFilenameFromPath(schemaFileNameWithoutExt ${schemaFilePathWithoutExt}) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
16 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
17 set(generatedFilePathWithoutExtension "${CMAKE_BINARY_DIR}/AUTOGENERATED/${schemaFileNameWithoutExt}") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
18 set(generatedCppSourceFilePath "${generatedFilePathWithoutExtension}.pb.cc") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
19 set(generatedCppHeaderFilePath "${generatedFilePathWithoutExtension}.pb.h") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
20 set(generatedJsFilePath "${generatedFilePathWithoutExtension}_pb.js") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
21 set(generatedTsFilePath "${generatedFilePathWithoutExtension}_pb.d.ts") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
22 # set(generatedJsFileName "${generatedFilePathWithoutExtension}.js") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
23 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
24 # set(AUTOGENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/AUTOGENERATED") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
25 # set(AUTOGENERATED_SOURCES) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
26 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
27 set(PROTOC_EXECUTABLE "PROTOC") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
28 find_program(PROTOC_EXECUTABLE_SEARCH ${FLATC_EXECUTABLE}) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
29 if(NOT PROTOC_EXECUTABLE_SEARCH) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
30 message(FATAL_ERROR "The Protocol Buffers compiler (protoc[.exe]) cannot be found!") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
31 endif() |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
32 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
33 # TODO CUSTOMIZE FOR TYPESCRIPT |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
34 set(SCRIPT_CPP_OPTIONS) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
35 list(APPEND SCRIPT_CPP_OPTIONS "----cpp_out=${CMAKE_BINARY_DIR}/AUTOGENERATED") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
36 # list(APPEND SCRIPT_CPP_OPTIONS "gnagna") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
37 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
38 set(SCRIPT_TS_OPTIONS) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
39 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
40 list(APPEND SCRIPT_TS_OPTIONS "--ts") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
41 list(APPEND SCRIPT_TS_OPTIONS "gnagna") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
42 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
43 add_custom_command( |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
44 OUTPUT |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
45 ${generatedCppSourceFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
46 ${generatedCppHeaderFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
47 COMMAND |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
48 ${PROTOC_EXECUTABLE} ${SCRIPT_CPP_OPTIONS} ${schemaFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
49 DEPENDS |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
50 ${schemaFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
51 ) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
52 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
53 add_custom_command( |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
54 OUTPUT |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
55 ${generatedTsFileName} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
56 ${generatedJsFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
57 COMMAND |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
58 ${PROTOC_EXECUTABLE} ${SCRIPT_TS_OPTIONS} ${schemaFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
59 DEPENDS |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
60 ${schemaFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
61 ) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
62 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
63 # add_custom_command( |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
64 # OUTPUT |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
65 # ${generatedJsFileName} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
66 # COMMAND |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
67 # ${FLATC_EXECUTABLE} ${SCRIPT_JS_OPTIONS} ${schemaFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
68 # DEPENDS |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
69 # ${schemaFilePath} |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
70 # ) |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
71 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
72 list(APPEND FLATC_AUTOGENERATED_SOURCES "${generatedCppFileName}") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
73 # list(APPEND FLATC_AUTOGENERATED_SOURCES "${generatedJsFileName}") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
74 list(APPEND FLATC_AUTOGENERATED_SOURCES "${generatedTsFileName}") |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
75 |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
76 endmacro() |
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
diff
changeset
|
77 |