Skip to content

Commit 0976d18

Browse files
committedMay 26, 2016
Merge pull request #49 from realm/mar/static-library
Build both dynamic and static libraries of the object store
2 parents 1d34e78 + f19bab7 commit 0976d18

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed
 

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ cmake_install.cmake
99
rules.ninja
1010

1111
# Build products
12-
src/librealm-object-store.*
12+
src/librealm-object-store.dylib
13+
src/librealm-object-store-static.a
1314
tests/tests

‎CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include(RealmCore)
1313
set(REALM_CORE_VERSION "0.100.1" CACHE STRING "")
1414
use_realm_core(${REALM_CORE_VERSION})
1515

16-
include_directories(${REALM_CORE_INCLUDE_DIR} src external/pegtl)
16+
set(PEGTL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/pegtl)
1717

1818
add_subdirectory(src)
1919
add_subdirectory(tests)

‎src/CMakeLists.txt

+17-2
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,20 @@ else()
5555
impl/generic/external_commit_helper.hpp)
5656
endif()
5757

58-
add_library(realm-object-store SHARED ${SOURCES} ${HEADERS})
59-
target_link_libraries(realm-object-store realm ${CF_LIBRARY})
58+
set(INCLUDE_DIRS ${REALM_CORE_INCLUDE_DIR} ${PEGTL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
59+
60+
# An object library to group together the compilation of the source files.
61+
add_library(realm-object-store-objects OBJECT ${SOURCES} ${HEADERS})
62+
add_dependencies(realm-object-store-objects realm)
63+
set_target_properties(realm-object-store-objects PROPERTIES POSITION_INDEPENDENT_CODE 1)
64+
target_include_directories(realm-object-store-objects PUBLIC ${INCLUDE_DIRS})
65+
66+
# A static library, aggregating the prebuilt object files.
67+
add_library(realm-object-store-static STATIC $<TARGET_OBJECTS:realm-object-store-objects>)
68+
target_include_directories(realm-object-store-static PUBLIC ${INCLUDE_DIRS})
69+
target_link_libraries(realm-object-store-static PUBLIC realm ${CF_LIBRARY})
70+
71+
# A dynamic library, linking together the prebuilt object files.
72+
add_library(realm-object-store SHARED $<TARGET_OBJECTS:realm-object-store-objects>)
73+
target_include_directories(realm-object-store PUBLIC ${INCLUDE_DIRS})
74+
target_link_libraries(realm-object-store PRIVATE realm ${CF_LIBRARY})

0 commit comments

Comments
 (0)