NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
501 stars 191 forks source link

Build is broken on Apple Clang 15 due to boost 1.79 #4978

Closed jmarrec closed 1 year ago

jmarrec commented 1 year ago

Issue overview

My M1 updated Xcode while I was working. Could compile fine, then 30 minutes later I couldn't anymore.

This is due to the removal of the std::unary_function from the stdlib. https://github.com/boostorg/container_hash/blob/355603c0c2a56013d7e44f3a0952004f4f280b39/include/boost/container_hash/hash.hpp#L132

std::unary_function was deprecated in C++11 and removed in C++17, so this is just Apple Clang finally complying with the standard. https://en.cppreference.com/w/cpp/utility/functional/unary_function

This was fixed in boost 1.81 by this commit: https://github.com/boostorg/container_hash/commit/4e11c855cb4c7813c75ff5a34f3d9e4fe7d800a0

Current Behavior

/Users/julien/.conan/data/boost/1.79.0/_/_/package/1d4cf74eec610dd689c30a2588eba75912388924/include/boost/container_hash/hash.hpp:132:33: error: no template named 'unary_function' in namespace 'std'; did you mean '__unary_function'?
        struct hash_base : std::unary_function<T, std::size_t> {};
                           ~~~~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/unary_function.h:46:1: note: '__unary_function' declared here
using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;

Expected Behavior

Steps to Reproduce

Compile with Apple Clang 15

Possible Solution

image

Details

Environment

Some additional details about your environment for this issue (if relevant):

jmarrec commented 1 year ago

BOOST_NO_CXX98_FUNCTION_BASE doesn't work.

jmarrec commented 1 year ago

Updating to Boost 1.83, lots of deprecated errors due to filesystem.

jmarrec commented 1 year ago

Ok, either of these works:

add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
  if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0))
    add_definitions(-DBOOST_NO_CXX98_FUNCTION_BASE)
    add_definitions(-D_HAS_AUTO_PTR_ETC=0)
  endif()