From bef0a6ea6e06e5c5e6eb2172e1d94796e82c1140 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Wed, 1 Jun 2016 12:19:07 -0700 Subject: [PATCH 1/2] Build core as a static library when building it as a dependency. --- CMake/RealmCore.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMake/RealmCore.cmake b/CMake/RealmCore.cmake index d4d02e9a..f1ccfc12 100644 --- a/CMake/RealmCore.cmake +++ b/CMake/RealmCore.cmake @@ -68,8 +68,8 @@ function(download_realm_core core_version) endfunction() macro(define_built_realm_core_target core_directory) - set(core_library_debug ${core_directory}/src/realm/librealm-dbg${CMAKE_SHARED_LIBRARY_SUFFIX}) - set(core_library_release ${core_directory}/src/realm/librealm${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(core_library_debug ${core_directory}/src/realm/librealm-dbg.a) + set(core_library_release ${core_directory}/src/realm/librealm.a) set(core_libraries ${core_library_debug} ${core_library_release}) ExternalProject_Add_Step(realm-core ensure-libraries @@ -78,7 +78,7 @@ macro(define_built_realm_core_target core_directory) DEPENDEES build ) - add_library(realm SHARED IMPORTED) + add_library(realm STATIC IMPORTED) add_dependencies(realm realm-core) set_property(TARGET realm PROPERTY IMPORTED_LOCATION_DEBUG ${core_library_debug}) @@ -97,7 +97,7 @@ function(clone_and_build_realm_core branch) PREFIX ${core_prefix_directory} BUILD_IN_SOURCE 1 CONFIGURE_COMMAND "" - BUILD_COMMAND export ${MAKEFLAGS} && ${MAKE_EQUAL_MAKE} sh build.sh build + BUILD_COMMAND export ${MAKEFLAGS} && make -C src/realm librealm.a librealm-dbg.a INSTALL_COMMAND "" ${USES_TERMINAL_BUILD} ) @@ -115,7 +115,7 @@ function(build_existing_realm_core core_directory) BUILD_IN_SOURCE 1 BUILD_ALWAYS 1 CONFIGURE_COMMAND "" - BUILD_COMMAND export ${MAKEFLAGS} && ${MAKE_EQUAL_MAKE} sh build.sh build + BUILD_COMMAND export ${MAKEFLAGS} && make -C src/realm librealm.a librealm-dbg.a INSTALL_COMMAND "" ${USES_TERMINAL_BUILD} ) From 332813f7f3f594137a2a40ca1450a2c97edad7f4 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Wed, 1 Jun 2016 12:20:17 -0700 Subject: [PATCH 2/2] Avoid dumping all environment variables when building core without ASan enabled. --- CMake/RealmCore.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMake/RealmCore.cmake b/CMake/RealmCore.cmake index f1ccfc12..87b7e566 100644 --- a/CMake/RealmCore.cmake +++ b/CMake/RealmCore.cmake @@ -5,7 +5,9 @@ if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") endif() if(SANITIZE_ADDRESS) - set(MAKEFLAGS "MAKEFLAGS=EXTRA_CFLAGS=-fsanitize=address EXTRA_LDFLAGS=-fsanitize=address") + set(EXPORT_MAKEFLAGS export MAKEFLAGS='EXTRA_CFLAGS=-fsanitize=address EXTRA_LDFLAGS=-fsanitize=address') +else() + set(EXPORT_MAKEFLAGS true) endif() if (${CMAKE_VERSION} VERSION_GREATER "3.4.0") @@ -97,7 +99,7 @@ function(clone_and_build_realm_core branch) PREFIX ${core_prefix_directory} BUILD_IN_SOURCE 1 CONFIGURE_COMMAND "" - BUILD_COMMAND export ${MAKEFLAGS} && make -C src/realm librealm.a librealm-dbg.a + BUILD_COMMAND ${EXPORT_MAKEFLAGS} && make -C src/realm librealm.a librealm-dbg.a INSTALL_COMMAND "" ${USES_TERMINAL_BUILD} ) @@ -115,7 +117,7 @@ function(build_existing_realm_core core_directory) BUILD_IN_SOURCE 1 BUILD_ALWAYS 1 CONFIGURE_COMMAND "" - BUILD_COMMAND export ${MAKEFLAGS} && make -C src/realm librealm.a librealm-dbg.a + BUILD_COMMAND ${EXPORT_MAKEFLAGS} && make -C src/realm librealm.a librealm-dbg.a INSTALL_COMMAND "" ${USES_TERMINAL_BUILD} )