Skip to content

Commit

Permalink
Merge pull request #10346 from NREL/10345-SushWarnings
Browse files Browse the repository at this point in the history
#10345 - Sush warnings in third_party directory on modern compilers/OSes
  • Loading branch information
Myoldmopar authored Dec 22, 2023
2 parents b1555b2 + cc6b54f commit 8f96c94
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 40 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ add_library(project_fp_options INTERFACE)

add_library(project_warnings INTERFACE)

add_library(turn_off_warnings INTERFACE)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
target_link_libraries(project_options INTERFACE Threads::Threads)
Expand Down
8 changes: 8 additions & 0 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ if(MSVC AND NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) # Visual C++ (VS
target_compile_options(project_options INTERFACE $<$<CONFIG:Debug>:/RTCsu>) # Runtime checks
target_compile_options(project_fp_options INTERFACE $<$<CONFIG:Debug>:/fp:strict>) # Floating point model
target_compile_options(project_options INTERFACE $<$<CONFIG:Debug>:/DMSVC_DEBUG>) # Triggers code in main.cc to catch floating point NaNs

target_compile_options(turn_off_warnings INTERFACE /W0)

elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") # g++/Clang

# TODO: after we fix all test, enable this by default on Debug builds
Expand Down Expand Up @@ -139,6 +142,8 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O
target_compile_options(project_options INTERFACE $<$<CONFIG:Release>:-fno-stack-protector>)
# ADD_CXX_RELEASE_DEFINITIONS("-Ofast") # -Ofast (or -ffast-math) needed to auto-vectorize floating point loops

target_compile_options(turn_off_warnings INTERFACE -w)

elseif(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")

# Disabled Warnings: Enable some of these as more serious warnings are addressed
Expand Down Expand Up @@ -192,6 +197,8 @@ elseif(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
target_compile_options(project_fp_options INTERFACE $<$<CONFIG:Debug>:/Qfp-stack-check>)
target_compile_options(project_options INTERFACE $<$<CONFIG:Debug>:/traceback>) # Enables traceback on error

target_compile_options(turn_off_warnings INTERFACE /w)

elseif(UNIX AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")

# Disabled Warnings: Enable some of these as more serious warnings are addressed
Expand Down Expand Up @@ -237,6 +244,7 @@ elseif(UNIX AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
target_compile_options(project_fp_options INTERFACE $<$<CONFIG:Debug>:-fp-stack-check>) # Check the floating point stack after every function call
target_compile_options(project_options INTERFACE $<$<CONFIG:Debug>:-traceback>) # Enables traceback on error

target_compile_options(turn_off_warnings INTERFACE -w)
endif() # COMPILER TYPE

# Add Color Output if Using Ninja:
Expand Down
27 changes: 23 additions & 4 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ target_compile_definitions(
)
target_include_directories(
nlohmann_json
INTERFACE
SYSTEM INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/nlohmann>
)
set_source_files_properties(
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/nlohmann>/json.hpp
TARGET_DIRECTORY nlohmann_json
PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations
)

# To avoid modifying every third_party library
# we link the project_options in here for every library in this
Expand Down Expand Up @@ -67,12 +72,15 @@ elseif(MSVC) # VisualStudio
endif()
target_compile_features(ssc PRIVATE cxx_std_11)

# C++17 flag is intentionally after ssd
# C++17 flag is intentionally after ssc
set(CMAKE_CXX_STANDARD 17)

#Note: the Tarcog files are improperly initializing their virtual base classes, and this 4589 warning
# on MSVC is legitimate, but silencing the warning because it's a third-party library

# Shush every warning for any lib added after it?
# link_libraries(turn_off_warnings)

if(NOT MSVC)
add_compile_options(-Wno-pedantic -Wno-unused-parameter -Wno-unknown-pragmas)
else()
Expand All @@ -93,7 +101,7 @@ set(RE2_BUILD_TESTING
# CACHE BOOL "" FORCE)
#endif()

# We don't want to enable the global warnings for any of the third party projects
# We don't want to enable the global project_warnings for any of the third party projects
link_libraries(project_options)
add_subdirectory(SQLite)
set_target_properties(sqlite PROPERTIES FOLDER ThirdParty/SQLite)
Expand Down Expand Up @@ -123,21 +131,32 @@ endif()

add_subdirectory(ObjexxFCL)
set_target_properties(objexx PROPERTIES FOLDER ThirdParty/ObjexxFCL)

add_subdirectory(BCVTB)
set_target_properties(bcvtb PROPERTIES FOLDER ThirdParty/BCVTB)

add_subdirectory(Expat)
set_target_properties(epexpat PROPERTIES FOLDER ThirdParty/Expat)

add_subdirectory(FMI)
set_target_properties(epfmiimport PROPERTIES FOLDER ThirdParty/FMI)
target_link_libraries(epfmiimport turn_off_warnings)

add_subdirectory(zlib)
set_target_properties(miniziplib PROPERTIES FOLDER ThirdParty/zlib)
target_link_libraries(miniziplib PRIVATE turn_off_warnings)

add_subdirectory(DElight)
set_target_properties(DElight PROPERTIES FOLDER ThirdParty/DElight)
target_link_libraries(DElight PRIVATE turn_off_warnings)

add_subdirectory(re2)
set_target_properties(re2 PROPERTIES FOLDER ThirdParty/re2)

add_subdirectory(fmt-8.0.1)
target_compile_definitions(fmt PRIVATE FMT_USE_FULL_CACHE_DRAGONBOX=1)
set_target_properties(fmt PROPERTIES FOLDER ThirdParty/fmt)

add_subdirectory(cpgfunctionEP)
set_target_properties(cpgfunctionEP PROPERTIES FOLDER ThirdParty/cpgfunctionEP)

Expand All @@ -152,7 +171,7 @@ set(KIVA_3D OFF CACHE BOOL "" FORCE)
set(KIVA_GROUND_PLOT ${BUILD_GROUND_PLOT} CACHE BOOL "" FORCE)
set(KIVA_COVERAGE OFF CACHE BOOL "" FORCE)

add_subdirectory("kiva")
add_subdirectory(kiva)
set_target_properties(libkiva PROPERTIES FOLDER ThirdParty/Kiva)

if(NOT APPLE)
Expand Down
2 changes: 1 addition & 1 deletion third_party/DElight/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12...3.5 ) # bumped max support to 3.5 to hush a cmake deprecation warning

PROJECT(DElight)

Expand Down
2 changes: 1 addition & 1 deletion third_party/Windows-CalcEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required( VERSION 2.8.12 )
cmake_minimum_required( VERSION 2.8.12...3.5) # bumped max support to 3.5 to hush a cmake deprecation warning

set( target_name Windows-CalcEngine )

Expand Down
4 changes: 2 additions & 2 deletions third_party/eigen/Eigen/src/SparseCore/TriangularSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef EIGEN_SPARSETRIANGULARSOLVER_H
#define EIGEN_SPARSETRIANGULARSOLVER_H

namespace Eigen {
namespace Eigen {

namespace internal {

Expand Down Expand Up @@ -270,7 +270,7 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
}


Index count = 0;
[[maybe_unused]] Index count = 0;
// FIXME compute a reference value to filter zeros
for (typename AmbiVector<Scalar,StorageIndex>::Iterator it(tempVector/*,1e-12*/); it; ++it)
{
Expand Down
2 changes: 1 addition & 1 deletion third_party/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Note: CMake support is community-based. The maintainers do not use CMake
# internally.

cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 2.8.12...3.5) # bumped max support to 3.5 to hush a cmake deprecation warning

if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
Expand Down
2 changes: 1 addition & 1 deletion third_party/gtest/googlemock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ else()
cmake_policy(SET CMP0048 NEW)
project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
endif()
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 2.8.12...3.5) # bumped max support to 3.5 to hush a cmake deprecation warning

if (COMMAND set_up_hermetic_build)
set_up_hermetic_build()
Expand Down
2 changes: 1 addition & 1 deletion third_party/gtest/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ else()
cmake_policy(SET CMP0048 NEW)
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
endif()
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 2.8.12...3.5) # bumped max support to 3.5 to hush a cmake deprecation warning

if (POLICY CMP0063) # Visibility
cmake_policy(SET CMP0063 NEW)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ struct segments_intersection_points
Ratio const& rb_from_wrt_a, Ratio const& rb_to_wrt_a)
{
return_type result;
unsigned int index = 0, count_a = 0, count_b = 0;
unsigned int index = 0;
[[maybe_unused]] unsigned int count_a = 0;
[[maybe_unused]] unsigned int count_b = 0;
Ratio on_a[2];

// The conditions "index < 2" are necessary for non-robust handling,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,33 +190,37 @@
# endif

// BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_trivially_constructible)
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)

# if BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_trivially_constructible)
# define BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) (__is_constructible(T, T&&) && __is_trivially_constructible(T, T&&))
# elif BOOST_MOVE_HAS_TRAIT(has_trivial_move_constructor)
# define BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) __has_trivial_move_constructor(T)
# endif

// BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && BOOST_MOVE_HAS_TRAIT(is_assignable) && BOOST_MOVE_HAS_TRAIT(is_trivially_assignable)
# if BOOST_MOVE_HAS_TRAIT(is_assignable) && BOOST_MOVE_HAS_TRAIT(is_trivially_assignable)
# define BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN(T) (__is_assignable(T, T&&) && __is_trivially_assignable(T, T&&))
# elif BOOST_MOVE_HAS_TRAIT(has_trivial_move_assign)
# define BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN(T) __has_trivial_move_assign(T)
# endif

// BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_nothrow_constructible)
# if BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_nothrow_constructible)
# define BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR(T) (__is_constructible(T, T&&) && __is_nothrow_constructible(T, T&&))
# elif BOOST_MOVE_HAS_TRAIT(has_nothrow_move_constructor)
# define BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR(T) __has_nothrow_move_constructor(T)
# endif

// BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && BOOST_MOVE_HAS_TRAIT(is_assignable) && BOOST_MOVE_HAS_TRAIT(is_nothrow_assignable)
# if BOOST_MOVE_HAS_TRAIT(is_assignable) && BOOST_MOVE_HAS_TRAIT(is_nothrow_assignable)
# define BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN(T) (__is_assignable(T, T&&) && __is_nothrow_assignable(T, T&&))
# elif BOOST_MOVE_HAS_TRAIT(has_nothrow_move_assign)
# define BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN(T) __has_nothrow_move_assign(T)
# endif

# endif //BOOST_NO_CXX11_RVALUE_REFERENCES

// BOOST_MOVE_ALIGNMENT_OF
# define BOOST_MOVE_ALIGNMENT_OF(T) __alignof(T)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#if defined(__MSL_CPP__) && (__MSL_CPP__ >= 0x8000)
// Metrowerks compiler is acquiring intrinsic type traits support
// post version 8. We hook into the published interface to pick up
// user defined specializations as well as compiler intrinsics as
// user defined specializations as well as compiler intrinsics as
// and when they become available:
# include <msl_utility>
# define BOOST_IS_UNION(T) BOOST_STD_EXTENSION_NAMESPACE::is_union<T>::value
Expand Down Expand Up @@ -160,11 +160,11 @@
# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
#endif

#if defined(BOOST_CLANG) && defined(__has_feature) && !defined(__CUDACC__)
#if defined(BOOST_CLANG) && defined(__has_feature) && defined(__has_builtin) && (!(defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ < 11)) || defined(__CUDA__))
//
// Note that these intrinsics are disabled for the CUDA meta-compiler as it appears
// to not support them, even though the underlying clang compiler does so.
// This is a rubbish fix as it basically stops type traits from working correctly,
// This is a rubbish fix as it basically stops type traits from working correctly,
// but maybe the best we can do for now. See https://svn.boost.org/trac/boost/ticket/10694
//
//
Expand All @@ -183,25 +183,39 @@
# if (!defined(__GLIBCXX__) || (__GLIBCXX__ >= 20080306 && __GLIBCXX__ != 20080519)) && __has_feature(is_empty)
# define BOOST_IS_EMPTY(T) __is_empty(T)
# endif
# if __has_feature(has_trivial_constructor)
# if __has_builtin(__is_trivially_constructible)
# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) __is_trivially_constructible(T)
# elif __has_feature(has_trivial_constructor)
# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T)
# endif
# if __has_feature(has_trivial_copy)
# if __has_builtin(__is_trivially_copyable)
# define BOOST_HAS_TRIVIAL_COPY(T) (__is_trivially_copyable(T) && !is_reference<T>::value)
# elif __has_feature(has_trivial_copy)
# define BOOST_HAS_TRIVIAL_COPY(T) (__has_trivial_copy(T) && !is_reference<T>::value)
# endif
# if __has_feature(has_trivial_assign)
# if __has_builtin(__is_trivially_assignable)
# define BOOST_HAS_TRIVIAL_ASSIGN(T) (__is_trivially_assignable(T&, const T&) && !is_volatile<T>::value && is_assignable<T&, const T&>::value)
# elif __has_feature(has_trivial_assign)
# define BOOST_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T) && !is_volatile<T>::value && is_assignable<T&, const T&>::value)
# endif
# if __has_feature(has_trivial_destructor)
# if __has_builtin(__is_trivially_destructible)
# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__is_trivially_destructible(T) && is_destructible<T>::value)
# elif __has_feature(has_trivial_destructor)
# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T) && is_destructible<T>::value)
# endif
# if __has_feature(has_nothrow_constructor)
# if __has_builtin(__is_nothrow_constructible)
# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__is_nothrow_constructible(T) && is_default_constructible<T>::value)
# elif __has_feature(has_nothrow_constructor)
# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_constructor(T) && is_default_constructible<T>::value)
# endif
# if __has_feature(has_nothrow_copy)
# if __has_builtin(__is_nothrow_constructible)
# define BOOST_HAS_NOTHROW_COPY(T) (__is_nothrow_constructible(T, const T&) && !is_volatile<T>::value && !is_reference<T>::value && is_copy_constructible<T>::value)
# elif __has_feature(has_nothrow_copy)
# define BOOST_HAS_NOTHROW_COPY(T) (__has_nothrow_copy(T) && !is_volatile<T>::value && !is_reference<T>::value && is_copy_constructible<T>::value)
# endif
# if __has_feature(has_nothrow_assign)
# if __has_builtin(__is_nothrow_assignable)
# define BOOST_HAS_NOTHROW_ASSIGN(T) (__is_nothrow_assignable(T&, const T&) && !is_volatile<T>::value && is_assignable<T&, const T&>::value)
# elif __has_feature(has_nothrow_assign)
# define BOOST_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) && !is_volatile<T>::value && is_assignable<T&, const T&>::value)
# endif
# if __has_feature(has_virtual_destructor)
Expand Down Expand Up @@ -388,4 +402,3 @@
#endif // BOOST_TT_DISABLE_INTRINSICS

#endif // BOOST_TT_INTRINSICS_HPP_INCLUDED

2 changes: 1 addition & 1 deletion third_party/ssc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function(set_default_compile_options target)
else(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if (APPLE)
set(MAIN_CFLAGS "${MAIN_CFLAGS} -arch x86_64 -fno-common -DWX_PRECOMP -D__MACOSX__")
set(MAIN_CFLAGS "${MAIN_CFLAGS} -fno-common -DWX_PRECOMP -D__MACOSX__")
else()
set(MAIN_CFLAGS "${MAIN_CFLAGS} -D__UNIX__")
endif()
Expand Down
11 changes: 0 additions & 11 deletions third_party/ssc/linux_errors

This file was deleted.

7 changes: 6 additions & 1 deletion third_party/ssc/ssc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,12 @@ foreach( name ${DEPENDENCIES} )
endforeach()

if (UNIX)
target_link_libraries(ssc -lpthread -lm -ldl -lstdc++)
find_package(Threads REQUIRED)
target_link_libraries(ssc Threads::Threads ${CMAKE_DL_LIBS})
find_library(MATH_LIBRARY m)
if(MATH_LIBRARY)
target_link_libraries(ssc ${MATH_LIBRARY})
endif()
endif()


Expand Down

5 comments on commit 8f96c94

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - x86_64-MacOS-10.17-clang-14.0.0: OK (2760 of 2760 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2759 of 2759 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (2781 of 2781 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1972 of 1972 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (790 of 790 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.