Skip to content

Commit

Permalink
Adds support for MacOS Universal binaries.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jake-at-work committed Dec 14, 2020
1 parent 50a441c commit 541c9aa
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 34 deletions.
25 changes: 20 additions & 5 deletions dependencies/ACE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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++ )
Expand All @@ -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 )
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
18 changes: 11 additions & 7 deletions dependencies/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )


Expand All @@ -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=<INSTALL_DIR>/$<CONFIG>
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DGTEST_ROOT=$<TARGET_PROPERTY:GTest::gtest,INTERFACE_INCLUDE_DIRECTORIES>/..
-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 )
Expand Down
53 changes: 32 additions & 21 deletions dependencies/boost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=<INSTALL_DIR>/$<CONFIG>
--with-system
Expand All @@ -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 )

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions dependencies/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ ExternalProject_Add( ${PROJECT_NAME}-extern
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=$<CONFIG>
-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 )
Expand Down
4 changes: 4 additions & 0 deletions dependencies/sqlite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ ExternalProject_Add( ${EXTERN}
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
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 )
Expand Down
10 changes: 9 additions & 1 deletion dependencies/xerces-c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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=$<CONFIG>
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-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 )
Expand Down

0 comments on commit 541c9aa

Please sign in to comment.