From 541c9aa0b8ff6713eb9aa43e15f5706559e52e45 Mon Sep 17 00:00:00 2001 From: Jacob Barrett Date: Mon, 23 Nov 2020 08:10:14 -0800 Subject: [PATCH] Adds support for MacOS Universal binaries. Specify CMAKE_OSX_ARCHITECTURES with multiple target architectures. * Updates ACE to 6.5.12 * Updates Boost to 1.75.0 * Updates Benchmark to 1.5.2 --- dependencies/ACE/CMakeLists.txt | 25 ++++++++++--- dependencies/benchmark/CMakeLists.txt | 18 +++++---- dependencies/boost/CMakeLists.txt | 53 ++++++++++++++++----------- dependencies/gtest/CMakeLists.txt | 4 ++ dependencies/sqlite/CMakeLists.txt | 4 ++ dependencies/xerces-c/CMakeLists.txt | 10 ++++- 6 files changed, 80 insertions(+), 34 deletions(-) diff --git a/dependencies/ACE/CMakeLists.txt b/dependencies/ACE/CMakeLists.txt index 096471d0de..08b4518ae1 100644 --- a/dependencies/ACE/CMakeLists.txt +++ b/dependencies/ACE/CMakeLists.txt @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -project( ACE VERSION 6.5.9 LANGUAGES NONE ) +project( ACE VERSION 6.5.12 LANGUAGES NONE ) -set( SHA256 85382427bf2c87eca215a6d963ad6b427a8d5b696ac96367e67bb952b3d2885c ) +set( SHA256 de96c68a6262d6b9ba76b5057c02c7e6964c070b1328a63bf70259e9530a7996 ) if ("SunOS" STREQUAL ${CMAKE_SYSTEM_NAME}) set( ACE_PLATFORM sunos5_sunc++ ) @@ -29,9 +29,15 @@ elseif ("Linux" STREQUAL ${CMAKE_SYSTEM_NAME} ) set( ACE_CONFIG linux ) ## TODO fix visibility problem with g++ set( _MAKE_ARGS ${_MAKE_ARGS} no_hidden_visibility=1 ) -elseif ("Darwin" STREQUAL ${CMAKE_SYSTEM_NAME} ) - set( ACE_PLATFORM macosx ) - set( ACE_CONFIG macosx ) +elseif ("Darwin" STREQUAL ${CMAKE_SYSTEM_NAME}) + set(ACE_PLATFORM macosx) + set(ACE_CONFIG macosx) + foreach(arch ${CMAKE_OSX_ARCHITECTURES}) + string(APPEND CMAKE_CXX_FLAGS " -arch ${arch}") + string(APPEND CMAKE_STATIC_LINKER_FLAGS " -arch ${arch}") + endforeach() + string(APPEND CMAKE_CXX_FLAGS " ${CMAKE_CXX_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") + string(APPEND CMAKE_CXX_FLAGS " ${CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}") elseif ("Windows" STREQUAL ${CMAKE_SYSTEM_NAME} ) set( ACE_PLATFORM win32-msvc ) set( ACE_CONFIG win32 ) @@ -152,6 +158,7 @@ ExternalProject_Add_Step( ${EXTERN} platform COMMAND echo "CC = ${CMAKE_C_COMPILER}" >> ${SOURCE_DIR}/include/makeinclude/platform_macros.GNU COMMAND echo "CXX = ${CMAKE_CXX_COMPILER}" >> ${SOURCE_DIR}/include/makeinclude/platform_macros.GNU COMMAND echo "CCFLAGS += ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_OPTIONS_PIC}" >> ${SOURCE_DIR}/include/makeinclude/platform_macros.GNU + COMMAND echo "LDFLAGS += ${CMAKE_STATIC_LINKER_FLAGS}" >> ${SOURCE_DIR}/include/makeinclude/platform_macros.GNU COMMAND echo "include ${SOURCE_DIR}/include/makeinclude/platform_${ACE_PLATFORM}.GNU" >> ${SOURCE_DIR}/include/makeinclude/platform_macros.GNU ) endif() @@ -202,5 +209,13 @@ target_link_libraries(ACE_ACE_SSL INTERFACE OpenSSL::Crypto ) +list(LENGTH CMAKE_OSX_ARCHITECTURES len) +if (len GREATER 1) + target_link_options(ACE_ACE_SSL INTERFACE + -undefined dynamic_lookup # remove after OpenSSL goes universal + ) +endif() +unset(len) + add_library(ACE::ACE ALIAS ACE_ACE) add_library(ACE::ACE_SSL ALIAS ACE_ACE_SSL) diff --git a/dependencies/benchmark/CMakeLists.txt b/dependencies/benchmark/CMakeLists.txt index 63ec1d7772..317bc381cf 100644 --- a/dependencies/benchmark/CMakeLists.txt +++ b/dependencies/benchmark/CMakeLists.txt @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -project( benchmark VERSION 1.5.0 LANGUAGES NONE ) +project( benchmark VERSION 1.5.2 LANGUAGES NONE ) -set( SHA256 2d22dd3758afee43842bb504af1a8385cccb3ee1f164824e4837c1c1b04d92a0 ) +set( SHA256 21e6e096c9a9a88076b46bd38c33660f565fa050ca427125f64c4a8bf60f336b ) set( DEPENDS GTest::gtest ) @@ -26,17 +26,21 @@ endif() set( EXTERN ${PROJECT_NAME}-extern ) include(ExternalProject) ExternalProject_Add( ${EXTERN} - URL "https://github.com/google/benchmark/archive/v${PROJECT_VERSION}.zip" - URL_HASH SHA256=${SHA256} - UPDATE_COMMAND "" - CMAKE_ARGS + URL "https://github.com/google/benchmark/archive/v${PROJECT_VERSION}.zip" + URL_HASH SHA256=${SHA256} + UPDATE_COMMAND "" + CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} -DCMAKE_INSTALL_PREFIX=/$ -DCMAKE_BUILD_TYPE=$ -DGTEST_ROOT=$/.. -DBENCHMARK_ENABLE_TESTING=OFF - DEPENDS ${DEPENDS} + CMAKE_CACHE_ARGS + -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} + DEPENDS ${DEPENDS} ) ExternalProject_Get_Property( ${EXTERN} SOURCE_DIR ) diff --git a/dependencies/boost/CMakeLists.txt b/dependencies/boost/CMakeLists.txt index b69c6032b5..e0e1bb9436 100644 --- a/dependencies/boost/CMakeLists.txt +++ b/dependencies/boost/CMakeLists.txt @@ -13,11 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -project( boost VERSION 1.73.0 LANGUAGES NONE ) +project( boost VERSION 1.75.0 LANGUAGES NONE ) -set( SHA256 9995e192e68528793755692917f9eb6422f3052a53c5e13ba278a228af6c7acf ) +set( SHA256 aeb26f80e80945e82ee93e5939baebdca47b9dee80a07d3144be1e1a6a66dd6a ) -set(_B2_FLAGS +if (WIN32) + set(BOOTSTRAP_COMMAND .\\bootstrap.bat) + set(B2_COMMAND .\\b2) +else() + set(BOOTSTRAP_COMMAND ./bootstrap.sh) + set(B2_COMMAND ./b2) +endif() +set(B2_FLAGS -d0 --prefix=/$ --with-system @@ -31,30 +38,34 @@ set(_B2_FLAGS ) include(ProcessorCount) -ProcessorCount(_NPROCS) -if (${_NPROCS}) - set ( _B2_FLAGS ${_B2_FLAGS} -j${_NPROCS} ) +ProcessorCount(NPROCS) +if (${NPROCS}) + list(APPEND B2_FLAGS -j${NPROCS}) endif() -if (${WIN32}) - set ( _BOOTSTRAP_COMMAND .\\bootstrap.bat ) - set ( _B2_COMMAND .\\b2 ) - set ( _B2_FLAGS ${_B2_FLAGS} toolset=msvc-14.1 ) -else() - set ( _BOOTSTRAP_COMMAND ./bootstrap.sh ) - set ( _B2_COMMAND ./b2 ) - set ( _B2_FLAGS ${_B2_FLAGS} "cxxflags=${CMAKE_CXX_FLAGS} ${CMAKE_CXX11_STANDARD_COMPILE_OPTION} ${CMAKE_CXX_COMPILE_OPTIONS_PIC}" ) +if ("Darwin" STREQUAL ${CMAKE_SYSTEM_NAME}) + # disabled until combined supports arm list(APPEND B2_FLAGS architecture=combined) + # manually set arch until combine supports arm + foreach(arch ${CMAKE_OSX_ARCHITECTURES}) + string(APPEND CMAKE_CXX_FLAGS " -arch ${arch}") + string(APPEND CMAKE_STATIC_LINKER_FLAGS " -arch ${arch}") + endforeach() + string(APPEND CMAKE_CXX_FLAGS " ${CMAKE_CXX_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") + string(APPEND CMAKE_CXX_FLAGS " ${CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}") endif() if ("SunOS" STREQUAL ${CMAKE_SYSTEM_NAME}) - set ( _BOOTSTRAP_COMMAND ${_BOOTSTRAP_COMMAND} --with-toolset=sun ) - set ( _B2_FLAGS ${_B2_FLAGS} define=BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) + list(APPEND BOOTSTRAP_FLAGS --with-toolset=sun) + list(APPEND B2_FLAGS define=BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) elseif ("Windows" STREQUAL ${CMAKE_SYSTEM_NAME}) - set ( CMAKE_STATIC_LIBRARY_PREFIX lib ) + set(CMAKE_STATIC_LIBRARY_PREFIX lib) + list(APPEND B2_FLAGS toolset=msvc-14.1) elseif ("Clang" STREQUAL ${CMAKE_CXX_COMPILER_ID}) - set ( _BOOTSTRAP_COMMAND ${_BOOTSTRAP_COMMAND} --with-toolset=clang ) + list(APPEND BOOTSTRAP_FLAGS --with-toolset=clang) endif() +list(APPEND B2_FLAGS "cxxflags=${CMAKE_CXX_FLAGS} ${CMAKE_CXX11_STANDARD_COMPILE_OPTION} ${CMAKE_CXX_COMPILE_OPTIONS_PIC}") + string(REPLACE "." "_" _VERSION_UNDERSCORE ${PROJECT_VERSION}) set( EXTERN ${PROJECT_NAME}-extern ) @@ -65,9 +76,9 @@ ExternalProject_Add( ${EXTERN} URL_HASH SHA256=${SHA256} UPDATE_COMMAND "" BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND ${_BOOTSTRAP_COMMAND} - BUILD_COMMAND ${_B2_COMMAND} ${_B2_FLAGS} - INSTALL_COMMAND ${_B2_COMMAND} ${_B2_FLAGS} install + CONFIGURE_COMMAND ${BOOTSTRAP_COMMAND} ${BOOTSTRAP_FLAGS} + BUILD_COMMAND ${B2_COMMAND} ${B2_FLAGS} + INSTALL_COMMAND ${B2_COMMAND} ${B2_FLAGS} install PREFIX . DOWNLOAD_DIR . SOURCE_DIR ./src diff --git a/dependencies/gtest/CMakeLists.txt b/dependencies/gtest/CMakeLists.txt index 4cca1e772a..65e6678fa4 100644 --- a/dependencies/gtest/CMakeLists.txt +++ b/dependencies/gtest/CMakeLists.txt @@ -27,6 +27,10 @@ ExternalProject_Add( ${PROJECT_NAME}-extern -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=$ -Dgtest_force_shared_crt:BOOL=ON + CMAKE_CACHE_ARGS + -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} ) ExternalProject_Get_Property( ${PROJECT_NAME}-extern INSTALL_DIR ) diff --git a/dependencies/sqlite/CMakeLists.txt b/dependencies/sqlite/CMakeLists.txt index add55e8cac..1dea2ea6df 100644 --- a/dependencies/sqlite/CMakeLists.txt +++ b/dependencies/sqlite/CMakeLists.txt @@ -27,6 +27,10 @@ ExternalProject_Add( ${EXTERN} CMAKE_ARGS -DCMAKE_BUILD_TYPE=$ -DCMAKE_INSTALL_PREFIX= + CMAKE_CACHE_ARGS + -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} ) ExternalProject_Get_Property( ${EXTERN} SOURCE_DIR ) diff --git a/dependencies/xerces-c/CMakeLists.txt b/dependencies/xerces-c/CMakeLists.txt index 68eebfa013..449bf5bcaf 100644 --- a/dependencies/xerces-c/CMakeLists.txt +++ b/dependencies/xerces-c/CMakeLists.txt @@ -25,6 +25,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(Xerces_TRANSCODER "-Dtranscoder=iconv") endif() +# Xerces-C++ is very warningful +string(APPEND CMAKE_C_FLAGS " -w") +string(APPEND CMAKE_CXX_FLAGS " -w") + ExternalProject_Add( ${PROJECT_NAME}-extern URL "http://archive.apache.org/dist/xerces/c/3/sources/xerces-c-${PROJECT_VERSION}.tar.gz" URL_HASH SHA256=${SHA256} @@ -33,12 +37,16 @@ ExternalProject_Add( ${PROJECT_NAME}-extern -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_BUILD_TYPE=$ -DCMAKE_INSTALL_PREFIX= -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dnetwork:BOOL=OFF ${Xerces_TRANSCODER} + CMAKE_CACHE_ARGS + -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET} ) ExternalProject_Get_Property( ${PROJECT_NAME}-extern INSTALL_DIR )