Skip to content

Commit bd4aa95

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

File tree

7 files changed

+10
-7
lines changed

7 files changed

+10
-7
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ 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
1515
add_compile_options(-Wall -Wextra -Wpedantic -pedantic-errors -Wunused)

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
set(MODULE_NAME xml.lite)
22

33
if(ENABLE_XML)
4-
if (UNIX)
4+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
55
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-as-null-pointer-constant")
66
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
77
endif()

0 commit comments

Comments
 (0)