diff --git a/.gitignore b/.gitignore index 59c6c914..3ea88b23 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,6 @@ cmake_install.cmake rules.ninja # Build products -src/librealm-object-store.* +src/librealm-object-store.dylib +src/librealm-object-store-static.a tests/tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 286e6ff0..e476b64c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ include(RealmCore) set(REALM_CORE_VERSION "0.100.1" CACHE STRING "") use_realm_core(${REALM_CORE_VERSION}) -include_directories(${REALM_CORE_INCLUDE_DIR} src external/pegtl) +set(PEGTL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/pegtl) add_subdirectory(src) add_subdirectory(tests) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8f849049..3574147e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,5 +55,20 @@ else() impl/generic/external_commit_helper.hpp) endif() -add_library(realm-object-store SHARED ${SOURCES} ${HEADERS}) -target_link_libraries(realm-object-store realm ${CF_LIBRARY}) +set(INCLUDE_DIRS ${REALM_CORE_INCLUDE_DIR} ${PEGTL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + +# An object library to group together the compilation of the source files. +add_library(realm-object-store-objects OBJECT ${SOURCES} ${HEADERS}) +add_dependencies(realm-object-store-objects realm) +set_target_properties(realm-object-store-objects PROPERTIES POSITION_INDEPENDENT_CODE 1) +target_include_directories(realm-object-store-objects PUBLIC ${INCLUDE_DIRS}) + +# A static library, aggregating the prebuilt object files. +add_library(realm-object-store-static STATIC $) +target_include_directories(realm-object-store-static PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(realm-object-store-static PUBLIC realm ${CF_LIBRARY}) + +# A dynamic library, linking together the prebuilt object files. +add_library(realm-object-store SHARED $) +target_include_directories(realm-object-store PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(realm-object-store PRIVATE realm ${CF_LIBRARY})