Skip to content

Commit 2a50bad

Browse files
author
Vaughn
committed
Make compatible with more compilers
1 parent ed4d7b6 commit 2a50bad

File tree

7 files changed

+25
-32
lines changed

7 files changed

+25
-32
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (${CMAKE_PROJECT_NAME} STREQUAL coda-oss)
2525
if (MSVC)
2626
add_compile_options(/WX) # warnings as errors
2727
add_compile_options(/MP) # multi-processor compile
28-
elseif (UNIX)
28+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
2929
add_compile_options(-Werror) # warnings as errors
3030
add_compile_options(-Wno-error=c++20-compat)
3131
endif()

modules/c++/CMakeLists.txt

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,25 @@ if (MSVC)
99
# > extremely noisy and low-value warnings. In general, the STL does not attempt to be `/Wall` clean.
1010
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # add_compile_options(/W4)
1111

12-
elseif (UNIX)
12+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
1313
# https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
1414
#add_compile_options(-Werror) # Make all warnings into errors
15-
add_compile_options(-Wall -Wextra -Wpedantic -pedantic-errors -Wunused)
16-
17-
add_compile_options(-Wzero-as-null-pointer-constant)
18-
#add_compile_options(-Wsuggest-final-types -Wsuggest-final-methods)
19-
add_compile_options(-Wsuggest-override)
20-
add_compile_options(-Woverloaded-virtual)
21-
#add_compile_options(-Warray-bounds)
22-
add_compile_options(-Wduplicated-branches -Wduplicated-cond)
23-
add_compile_options(-Wtrampolines)
24-
add_compile_options(-Wshadow)
25-
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
26-
#add_compile_options(-Wfloat-equal)
27-
#add_compile_options(-Wconversion)
28-
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++")
29-
30-
add_compile_options(-Wno-double-promotion) # implicit conversion of `float` to `double` is fine
31-
32-
add_compile_options(-Wno-array-bounds) # TODO: fix the code!
33-
add_compile_options(-Wno-maybe-uninitialized) # TODO: fix the code!
34-
35-
# Need a newer compiler than GCC 9
36-
#add_compile_options(-Wnrvo)
15+
add_compile_options(-Wall -Wextra -Wpedantic -pedantic-errors -Wunused
16+
-Wzero-as-null-pointer-constant
17+
-Wsuggest-final-types -Wsuggest-final-methods
18+
-Wsuggest-override
19+
-Woverloaded-virtual
20+
-Warray-bounds
21+
-Wduplicated-branches -Wduplicated-cond
22+
-Wtrampolines
23+
-Wshadow
24+
-Wold-style-cast
25+
-Wfloat-equal
26+
-Wconversion
27+
-Weffc++
28+
# Need a newer compiler than GCC 9
29+
#-Wnrvo
30+
)
3731
endif()
3832

3933
# add an interface library for unittests

modules/c++/sys/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
set(MODULE_NAME sys)
22

3+
include(CheckSourceCompiles)
4+
check_source_compiles(CXX [[ int main() { __builtin_cpu_init(); return 0; } ]] HAVE_BUILTIN_CPU_INIT)
35
coda_generate_module_config_header(${MODULE_NAME})
46

57
coda_add_module(

modules/c++/sys/include/sys/Dbg.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* (C) Copyright 2004 - 2014, MDA Information Systems LLC
66
* (C) Copyright 2021, Maxar Technologies, Inc.
7+
* (C) Copyright 2025-26 ARKA Group, L.P. All rights reserved
78
*
89
* sys-c++ is free software; you can redistribute it and/or modify
910
* it under the terms of the GNU Lesser General Public License as published by
@@ -71,8 +72,6 @@
7172
//#error "NDEBUG should be #define'd with __OPTIMIZE__"
7273
#endif
7374
#define CODA_OSS_DEBUG 0 // i.e., release
74-
#else
75-
#error "Can't #define CODA_OSS_DEBUG for __GNUC__."
7675
#endif
7776
#endif // __GNUC__
7877

modules/c++/sys/include/sys/sys_config.h.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef _@tgt_munged_name@_CONFIG_H_
22
#define _@tgt_munged_name@_CONFIG_H_
33

4+
#cmakedefine01 HAVE_BUILTIN_CPU_INIT
45
#cmakedefine HAVE_PTHREAD_H @HAVE_PTHREAD_H@
56
#cmakedefine HAVE_EXECINFO_H @HAVE_EXECINFO_H@
67
#cmakedefine HAVE_CLOCK_GETTIME @HAVE_CLOCK_GETTIME@

modules/c++/sys/source/OSUnix.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ void sys::OSUnix::getAvailableCPUs(std::vector<int>& physicalCPUs,
426426

427427
sys::SIMDInstructionSet sys::OSUnix::getSIMDInstructionSet() const
428428
{
429-
#if defined(__x86_64__) || defined(__i386__)
429+
// NOTE: This function relies on compiler instrinsics at runtime
430+
#if (defined(__x86_64__) || defined(__i386__)) && HAVE_BUILTIN_CPU_INIT
430431
// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/X86-Built-in-Functions.html
431432
__builtin_cpu_init();
432433

@@ -444,7 +445,7 @@ sys::SIMDInstructionSet sys::OSUnix::getSIMDInstructionSet() const
444445
}
445446
#endif
446447

447-
throw std::runtime_error("SSE2 support is required.");
448+
throw std::runtime_error("SIMD support is required.");
448449
}
449450

450451
void sys::OSUnix::createSymlink(const std::string& origPathname,

modules/c++/xml.lite/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
set(MODULE_NAME xml.lite)
22

33
if(ENABLE_XML)
4-
if (UNIX)
5-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-as-null-pointer-constant")
6-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
7-
endif()
84

95
if(CONAN_PACKAGE_NAME)
106
# import targets from xerces-c conan package

0 commit comments

Comments
 (0)