Skip to content

Commit 385c27b

Browse files
committed
Bump min. CMake to 3.16 and fix custom build rules
1 parent 26d6374 commit 385c27b

File tree

17 files changed

+363
-178
lines changed

17 files changed

+363
-178
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
- Fix %d vs uint32 type in some printformatting (#315).
6262
- Fix UB in builder, memsetting 0 bytes of null pointer (#344).
6363
- Fix GCC 15 warning in grisu3 (#338).
64+
- Bump CMake to >= 3.26.1 (Debian Bookworm).
65+
- Fix CMAKE warnings on custom commands with TARGET and DEPENDS (CMP0175).
6466

6567
## [0.6.1]
6668

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Ubuntu 14.04 (Trusty)
2-
cmake_minimum_required (VERSION 2.8.12.2)
3-
# Centos 7
4-
#cmake_minimum_required (VERSION 2.8.11)
5-
#cmake_minimum_required (VERSION 2.8)
1+
# Debian 12 (Bookworm)
2+
# cmake_minimum_required (VERSION 3.25)
3+
4+
# Appveyor for MSVC 2015
5+
cmake_minimum_required (VERSION 3.16)
6+
67

78
# Experimental for generating compile_commands.json so editors with
89
# clangd language server support can use it. Symlink

README.md

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -322,47 +322,43 @@ fi
322322

323323
## Status
324324

325-
Release 0.6.2 (in development) is primarily a bug fix release, refer
326-
to CHANGELOG for details. A long standing bug has been fixed where
327-
where objects created before a call to _create_as_root would not be
328-
properly aligned, and buffer end is now also padded to largest object
329-
seen within the buffer.
330-
Note that for clang debug builds, -fsanitize=undefined has been
331-
added and this may require dependent source code to also use
332-
that flag to avoid missing linker symbols. The feature can be disabled
333-
in CMakeLists.txt.
334-
335-
Release 0.6.1 contains primarily bug fixes and numerous contributions
336-
from the community to handle platform edge cases. Additionally,
337-
pendantic GCC warnings are disabled, relying instead on clang, since GCC
338-
is too aggressive, breaks builds frequently and works against
339-
portability. An existing C++ test case ensures that C code also works
340-
with common C++ compilers, but it can break some environments, so there
341-
is now a flag to disable that test without disabling all tests. Support
342-
for Optional Scalar Values in the FlatBuffer format has been added.
343-
There is also improved support for abstracting memory allocation on
344-
various platforms. `<table>_identifier` has been deprecated in favor
345-
`<table>_file_identifier` in generated code due to `identifier` easily
346-
leading to name conflicts. `file_extension` constant in generated code
347-
is now without prefixed dot (.).
348-
349-
Release 0.6.0 introduces a "primary" attribute to be used together with
350-
a key attribute to chose default key for finding and sorting. If primary
351-
is absent, the key with the lowest id becomes primary. Tables and
352-
vectors can now be sorted recursively on primary keys. BREAKING:
353-
previously the first listed, not the lowest id, would be the primary
354-
key. Also introduces fixed length scalar arrays in struct fields (struct
355-
and enum elements are not supported). Structs support fixed length array
356-
fields, including char arrays. Empty structs never fully worked and are
357-
no longer supported, they are also no longer supported by flatc.
358-
NOTE: char arrays are not currently part of Googles flatc compiler -
359-
int8 arrays may be used instead. BREAKING: empty structs are no longer
360-
supported - they are also not valid in Googles flatc compiler. See
361-
CHANGELOG for additional changes. DEPRECATED: low-level `cast_to/from`
362-
from functions in `flatcc_accessors.h` will be removed in favor of
363-
`read/write_from/to` because the cast interface breaks float conversion
364-
on some uncommon platforms. This should not affect normal use but
365-
remains valid in this release.
325+
Release 0.6.2 (in development) is primarily a bug fix release, refer to
326+
CHANGELOG for details. A long standing bug has been fixed where where objects
327+
created before a call to _create_as_root would not be properly aligned, and
328+
buffer end is now also padded to largest object seen within the buffer. Note
329+
that for clang debug builds, -fsanitize=undefined has been added and this may
330+
require dependent source code to also use that flag to avoid missing linker
331+
symbols. The feature can be disabled in CMakeLists.txt. CMake has been bumped to
332+
version 3.16 which is the latest version where Appveyor will build MVSC 2015.
333+
334+
Release 0.6.1 contains primarily bug fixes and numerous contributions from the
335+
community to handle platform edge cases. Additionally, pendantic GCC warnings
336+
are disabled, relying instead on clang, since GCC is too aggressive, breaks
337+
builds frequently and works against portability. An existing C++ test case
338+
ensures that C code also works with common C++ compilers, but it can break some
339+
environments, so there is now a flag to disable that test without disabling
340+
all tests. Support for Optional Scalar Values in the FlatBuffer format has
341+
been added. There is also improved support for abstracting memory allocation
342+
on various platforms. `<table>_identifier` has been deprecated in favor
343+
`<table>_file_identifier` in generated code due to `identifier` easily leading
344+
to name conflicts. `file_extension` constant in generated code is now without
345+
prefixed dot (.).
346+
347+
Release 0.6.0 introduces a "primary" attribute to be used together with a key
348+
attribute to chose default key for finding and sorting. If primary is absent,
349+
the key with the lowest id becomes primary. Tables and vectors can now be sorted
350+
recursively on primary keys. BREAKING: previously the first listed, not the
351+
lowest id, would be the primary key. Also introduces fixed length scalar arrays
352+
in struct fields (struct and enum elements are not supported). Structs support
353+
fixed length array fields, including char arrays. Empty structs never fully
354+
worked and are no longer supported, they are also no longer supported by flatc.
355+
NOTE: char arrays are not currently part of Googles flatc compiler - int8 arrays
356+
may be used instead. BREAKING: empty structs are no longer supported - they are
357+
also not valid in Googles flatc compiler. See CHANGELOG for additional changes.
358+
DEPRECATED: low-level `cast_to/from` from functions in `flatcc_accessors.h` will
359+
be removed in favor of `read/write_from/to` because the cast interface breaks
360+
float conversion on some uncommon platforms. This should not affect normal use
361+
but remains valid in this release.
366362

367363
Release 0.5.3 inlcudes various bug fixes (see changelog) and one
368364
breaking but likely low impact change: BREAKING: 0.5.3 changes behavour
@@ -428,12 +424,15 @@ different target platforms.
428424

429425
### Supported platforms (CI tested)
430426

431-
This list is somewhat outdated, more recent compiler versions are added and
432-
some old ones are removed when CI platforms no longer supported but largely
433-
the supported targets remain unchanged. MSVC 2010 might become deprecated
434-
in the future.
427+
As of flatcc v.0.6.2 the weekly build on github actions tests a range of
428+
gcc and clang versions on Ubuntu and macOS but the lists changes slightly
429+
as the underlying CI runners sometimes drop a compiler version. Windows
430+
is tested on Appveyor with MSVC 2025 and a later version on Github actions.
431+
See the appveyour and github actions workflow files for details.
435432

436-
The ci-more branch tests additional compilers:
433+
In the past (ca. < flatcc-0.6.2) the following have been tested, and chances are
434+
that an older version of flatcc is still useful if the latest version does not
435+
compile on a given platform.
437436

438437
- Ubuntu Trusty gcc 4.4, 4.6-4.9, 5, 6, 7 and clang 3.6, 3.8
439438
- OS-X current clang / gcc
@@ -446,9 +445,6 @@ The GCC `--pedantic` compiler option is not supported as of GCC-8+
446445
because it forces non-portable code changes and because it tends to
447446
break the code base with each new GCC release.
448447

449-
MSVC 2017 is not always tested because the CI environment then won't
450-
support MSVC 2010.
451-
452448
Older/non-standard versions of C++ compilers cause problems because
453449
`static_assert` and `alignas` behave in strange ways where they are
454450
neither absent nor fully working as expected. There are often
@@ -459,10 +455,6 @@ The portably library does not support GCC C++ pre 4.7 because the
459455
portable library does not work around C++ limitations in stdalign.h and
460456
stdint.h before GCC 4.7. This could be fixed but is not a priority.
461457

462-
Some previously testet compiler versions may have been retired as the
463-
CI environment gets updated. See `.travis.yml` and `appveyor.yml` in
464-
the `ci-more` branch for the current configuration.
465-
466458
The monster sample does not work with MSVC 2010 because it intentionally
467459
uses C99 style code to better follow the C++ version.
468460

@@ -480,6 +472,7 @@ tests (a simple C++ file that includes generated C code).
480472
- Arduino
481473
- IBM XLC on AIX big endian Power PC has been tested for release 0.4.0
482474
but is not part of regular release tests.
475+
- IBM s390x big endian via QEMU.
483476

484477
### Portability
485478

samples/monster/CMakeLists.txt

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
include(CTest)
2-
31
set(INC_DIR "${PROJECT_SOURCE_DIR}/include")
42
set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
53
set(FBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
64

7-
include_directories("${GEN_DIR}" "${INC_DIR}")
5+
# Choose a reliable generated output file
6+
set(GEN_HDR "${GEN_DIR}/monster_reader.h")
87

9-
add_custom_target(gen_monster_fbs ALL)
10-
add_custom_command (
11-
TARGET gen_monster_fbs
8+
add_custom_command(
9+
OUTPUT ${GEN_HDR}
1210
COMMAND ${CMAKE_COMMAND} -E make_directory "${GEN_DIR}"
1311
COMMAND flatcc_cli -a -o "${GEN_DIR}" "${FBS_DIR}/monster.fbs"
14-
DEPENDS flatcc_cli "${FBS_DIR}/monster.fbs"
12+
DEPENDS flatcc_cli "${FBS_DIR}/monster.fbs"
13+
COMMENT "Generating FlatCC output from monster.fbs"
14+
)
15+
16+
add_custom_target(gen_monster_fbs ALL
17+
DEPENDS ${GEN_HDR}
1518
)
19+
1620
add_executable(monster monster.c)
17-
add_dependencies(monster gen_monster_fbs)
21+
22+
target_include_directories(monster PRIVATE
23+
"${GEN_DIR}"
24+
"${INC_DIR}"
25+
)
26+
1827
target_link_libraries(monster flatccrt)
28+
add_dependencies(monster gen_monster_fbs)
1929

2030
if (FLATCC_TEST)
2131
add_test(monster monster${CMAKE_EXECUTABLE_SUFFIX})

samples/reflection/CMakeLists.txt

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
include(CTest)
22

3-
#
4-
# This projects depends headers generated from reflection.fbs but these
5-
# are pre-generated in `include/flatcc/reflection` so we don't need to
6-
# build them here.
7-
#
8-
# What we do build is a binary schema `monster.bfbs` for the monster
9-
# sample, and the actual C source of this project.
10-
#
3+
# Pre-generated headers from reflection.fbs are already present in include/flatcc/reflection
114

125
set(INC_DIR "${PROJECT_SOURCE_DIR}/include")
136
set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
147
set(FBS_DIR "${PROJECT_SOURCE_DIR}/samples/monster")
158

16-
include_directories("${GEN_DIR}" "${INC_DIR}")
9+
# Expected binary schema file
10+
set(GEN_SCHEMA "${GEN_DIR}/monster.bfbs")
1711

18-
add_custom_target(gen_monster_bfbs ALL)
19-
add_custom_command (
20-
TARGET gen_monster_bfbs
12+
add_custom_command(
13+
OUTPUT ${GEN_SCHEMA}
2114
COMMAND ${CMAKE_COMMAND} -E make_directory "${GEN_DIR}"
2215
COMMAND flatcc_cli --schema -o "${GEN_DIR}" "${FBS_DIR}/monster.fbs"
23-
DEPENDS flatcc_cli "${FBS_DIR}/monster.fbs"
16+
DEPENDS
17+
flatcc_cli
18+
"${FBS_DIR}/monster.fbs"
19+
COMMENT "Generating FlatCC binary schema for monster.fbs"
20+
VERBATIM
2421
)
22+
23+
add_custom_target(gen_monster_bfbs ALL
24+
DEPENDS ${GEN_SCHEMA}
25+
)
26+
2527
add_executable(bfbs2json bfbs2json.c)
26-
add_dependencies(bfbs2json gen_monster_bfbs)
28+
29+
target_include_directories(bfbs2json PRIVATE "${GEN_DIR}" "${INC_DIR}")
2730
target_link_libraries(bfbs2json flatccrt)
31+
add_dependencies(bfbs2json gen_monster_bfbs)
2832

2933
if (FLATCC_TEST)
30-
add_test(bfbs2json bfbs2json${CMAKE_EXECUTABLE_SUFFIX} ${GEN_DIR}/monster.bfbs)
34+
add_test(bfbs2json bfbs2json${CMAKE_EXECUTABLE_SUFFIX} ${GEN_SCHEMA})
3135
endif()

test/doublevec_test/CMakeLists.txt

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,35 @@ set(INC_DIR "${PROJECT_SOURCE_DIR}/include")
44
set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
55
set(FBS_DIR "${PROJECT_SOURCE_DIR}/test/doublevec_test")
66

7-
include_directories("${GEN_DIR}" "${INC_DIR}")
7+
# Use a reliably generated output file as the trigger
8+
set(GEN_HDR "${GEN_DIR}/doublevec_test_reader.h")
89

9-
add_custom_target(gen_doublevec_test ALL)
10-
add_custom_command (
11-
TARGET gen_doublevec_test
12-
COMMAND cmake -E make_directory "${GEN_DIR}"
10+
# Custom command to generate headers
11+
add_custom_command(
12+
OUTPUT ${GEN_HDR}
13+
COMMAND ${CMAKE_COMMAND} -E make_directory "${GEN_DIR}"
1314
COMMAND flatcc_cli -a -o "${GEN_DIR}" "${FBS_DIR}/doublevec_test.fbs"
14-
DEPENDS flatcc_cli "${FBS_DIR}/header.fbs"
15+
DEPENDS
16+
flatcc_cli
17+
"${FBS_DIR}/doublevec_test.fbs"
18+
COMMENT "Generating FlatCC output for doublevec_test.fbs"
19+
VERBATIM
1520
)
21+
22+
# Target representing schema generation
23+
add_custom_target(gen_doublevec_test ALL
24+
DEPENDS ${GEN_HDR}
25+
)
26+
27+
# Test executable
1628
add_executable(doublevec_test doublevec_test.c)
17-
add_dependencies(doublevec_test gen_doublevec_test)
29+
30+
# Include paths
31+
target_include_directories(doublevec_test PRIVATE "${GEN_DIR}" "${INC_DIR}")
32+
33+
# Link + build order
1834
target_link_libraries(doublevec_test flatccrt)
35+
add_dependencies(doublevec_test gen_doublevec_test)
1936

37+
# Register the test
2038
add_test(doublevec_test doublevec_test${CMAKE_EXECUTABLE_SUFFIX})

test/emit_test/CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@ include(CTest)
33
set(INC_DIR "${PROJECT_SOURCE_DIR}/include")
44
set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
55
set(FBS_DIR "${PROJECT_SOURCE_DIR}/test/emit_test")
6+
set(FBS "${FBS_DIR}/emit_test.fbs")
67

78
include_directories("${GEN_DIR}" "${INC_DIR}")
89

9-
add_custom_target(gen_emit_test ALL)
10-
add_custom_command (
11-
TARGET gen_emit_test
10+
# Generate headers for emit_test.fbs
11+
add_custom_command(
12+
OUTPUT "${GEN_DIR}/emit_test_builder.h"
1213
COMMAND ${CMAKE_COMMAND} -E make_directory "${GEN_DIR}"
13-
COMMAND flatcc_cli -a -o "${GEN_DIR}" "${FBS_DIR}/emit_test.fbs"
14+
COMMAND flatcc_cli -a -o "${GEN_DIR}" "${FBS}"
1415
DEPENDS flatcc_cli "${FBS}"
16+
COMMENT "Generating code from emit_test.fbs"
1517
)
18+
19+
add_custom_target(gen_emit_test ALL
20+
DEPENDS "${GEN_DIR}/emit_test_builder.h"
21+
)
22+
23+
# Build and link the test
1624
add_executable(emit_test emit_test.c)
1725
add_dependencies(emit_test gen_emit_test)
1826
target_link_libraries(emit_test flatccrt)
1927

28+
# Register test with CTest
2029
add_test(emit_test emit_test${CMAKE_EXECUTABLE_SUFFIX})

test/flatc_compat/CMakeLists.txt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,32 @@ include(CTest)
33
set(INC_DIR "${PROJECT_SOURCE_DIR}/include")
44
set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
55
set(FBS_DIR "${PROJECT_SOURCE_DIR}/test/monster_test")
6+
set(MON_DATA "${CMAKE_CURRENT_BINARY_DIR}/monsterdata_test.mon")
7+
set(GEN_HDR "${GEN_DIR}/monster_test_reader.h")
68

79
include_directories("${GEN_DIR}" "${INC_DIR}")
810

9-
add_custom_target(gen_flatc_compat ALL)
10-
add_custom_command (
11-
TARGET gen_flatc_compat
11+
add_custom_command(
12+
OUTPUT ${GEN_HDR} ${MON_DATA}
1213
COMMAND ${CMAKE_COMMAND} -E make_directory "${GEN_DIR}"
13-
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/monsterdata_test.mon" ${CMAKE_CURRENT_BINARY_DIR}
14+
COMMAND ${CMAKE_COMMAND} -E copy
15+
"${CMAKE_CURRENT_SOURCE_DIR}/monsterdata_test.mon"
16+
"${MON_DATA}"
1417
COMMAND flatcc_cli -a -o "${GEN_DIR}" "${FBS_DIR}/monster_test.fbs"
15-
DEPENDS flatcc_cli "${FBS_DIR}/monster_test.fbs" "${FBS_DIR}/include_test1.fbs" "${FBS_DIR}/include_test2.fbs"
18+
DEPENDS
19+
flatcc_cli
20+
"${FBS_DIR}/monster_test.fbs"
21+
"${FBS_DIR}/include_test1.fbs"
22+
"${FBS_DIR}/include_test2.fbs"
23+
"${CMAKE_CURRENT_SOURCE_DIR}/monsterdata_test.mon"
24+
COMMENT "Generating headers and copying binary data for flatc compatibility test"
25+
VERBATIM
1626
)
27+
28+
add_custom_target(gen_flatc_compat ALL
29+
DEPENDS ${GEN_HDR} ${MON_DATA}
30+
)
31+
1732
add_executable(flatc_compat flatc_compat.c)
1833
add_dependencies(flatc_compat gen_flatc_compat)
1934
target_link_libraries(flatc_compat flatccrt)

0 commit comments

Comments
 (0)