Skip to content

Commit 451a94f

Browse files
authored
Merge pull request nasa#462 from jphickey/jph-fix-24-basic-warnings
Fix nasa#24, Add compiler option examples
2 parents 15ed1cd + c5625fc commit 451a94f

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ read_targetconfig()
9797
# The custom script may override functions such as the
9898
# cfe_exec_do_install() and cfe_app_do_install() functions for this
9999
if (IS_CFS_ARCH_BUILD)
100-
include("${MISSION_DEFS}/arch_build.cmake" OPTIONAL)
101-
include("${MISSION_DEFS}/arch_build_${TARGETSYSTEM}.cmake" OPTIONAL)
100+
include("${MISSION_DEFS}/arch_build_custom.cmake" OPTIONAL)
101+
include("${MISSION_DEFS}/arch_build_custom_${TARGETSYSTEM}.cmake" OPTIONAL)
102102
elseif (IS_CFS_MISSION_BUILD)
103-
include("${MISSION_DEFS}/mission_build.cmake" OPTIONAL)
103+
include("${MISSION_DEFS}/mission_build_custom.cmake" OPTIONAL)
104104
endif (IS_CFS_ARCH_BUILD)
105105

106106
# Call the prepare function defined by the sub-script
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Example arch_build_custom.cmake
3+
# -------------------------------
4+
#
5+
# This file will be automatically included in the arch-specific build scope
6+
#
7+
# Definitions and options specified here will be used when cross-compiling
8+
# _all_ FSW code for _all_ targets defined in targets.cmake.
9+
#
10+
# Avoid machine-specific code generation options in this file (e.g. -f,-m options); such
11+
# options should be localized to the toolchain file such that they will only be
12+
# included on the machines where they apply.
13+
#
14+
# CAUTION: In heterogeneous environments where different cross compilers are
15+
# used for different CPUs, particularly if from different vendors, it is likely
16+
# that compile options will need to be different as well.
17+
#
18+
# In general, options in this file can only be used in cases where all CPUs use a
19+
# compiler from the same vendor and/or are all GCC based such that they accept similar
20+
# command line options.
21+
#
22+
# This file can alternatively be named as "arch_build_custom_${TARGETSYSTEM}.cmake"
23+
# where ${TARGETSYSTEM} represents the system type, matching the toolchain.
24+
#
25+
# These example options assume a GCC-style toolchain is used for cross compilation,
26+
# and uses the same warning options that are applied at the mission level.
27+
#
28+
add_compile_options(
29+
-std=c99 # Target the C99 standard (without gcc extensions)
30+
-pedantic # Issue all the warnings demanded by strict ISO C
31+
-Wall # Warn about most questionable operations
32+
-Wstrict-prototypes # Warn about missing prototypes
33+
-Wwrite-strings # Warn if not treating string literals as "const"
34+
-Wpointer-arith # Warn about suspicious pointer operations
35+
-Wcast-align # Warn about casts that increase alignment requirements
36+
-Werror # Treat warnings as errors (code should be clean)
37+
)
38+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# Example mission_build_custom.cmake
3+
# ----------------------------------
4+
#
5+
# This file will be automatically included in the top level ("mission") build scope
6+
#
7+
# Definitions and options specified here will be used when building local tools and
8+
# other code that runs on the development host, but do _NOT_ apply to flight software
9+
# (embedded) code or anything built for the target machine.
10+
#
11+
# These options assume a GCC toolchain but a similar set should be applicable to clang.
12+
#
13+
add_compile_options(
14+
-std=c99 # Target the C99 standard (without gcc extensions)
15+
-pedantic # Issue all the warnings demanded by strict ISO C
16+
-Wall # Warn about most questionable operations
17+
-Wstrict-prototypes # Warn about missing prototypes
18+
-Wwrite-strings # Warn if not treating string literals as "const"
19+
-Wpointer-arith # Warn about suspicious pointer operations
20+
-Wcast-align # Warn about casts that increase alignment requirements
21+
-Werror # Treat warnings as errors (code should be clean)
22+
)
23+
24+
# The _XOPEN_SOURCE directive is required for glibc to enable conformance with the
25+
# the X/Open standard version 6, which includes POSIX.1c as well as SUSv2/UNIX98 extensions.
26+
add_definitions(
27+
-D_XOPEN_SOURCE=600
28+
)

0 commit comments

Comments
 (0)