Skip to content

Commit 58fece1

Browse files
committed
feat: Allow static linking without Emscripten
1 parent 3a5e436 commit 58fece1

7 files changed

Lines changed: 17 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ if (LODESTONE_DOCS_TARGET STREQUAL "ON")
1313
set(LODESTONE_AT_ESCAPE "@")
1414
endif()
1515

16+
if (NOT DEFINED BUILD_SHARED_LIBS)
17+
option(BUILD_SHARED_LIBS "Build libraries as shared" ON)
18+
endif()
19+
20+
if(BUILD_SHARED_LIBS)
21+
add_compile_definitions(LODESTONE_BUILD_SHARED_LIBS=1)
22+
else()
23+
add_compile_definitions(LODESTONE_BUILD_SHARED_LIBS=0)
24+
endif()
25+
1626
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/linting.cmake)
1727
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/doxygen.cmake)
1828

projects/Converters/Minecraft/Console/include/Lodestone.Minecraft.Console/LodestoneLce.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace lodestone::minecraft::console {
3636
lodestone::common::util::Semver getVersion() const override;
3737
};
3838

39-
#ifndef __EMSCRIPTEN__
39+
#ifndef LODESTONE_BUILD_SHARED_LIBS
4040
extern "C" {
4141
core::LodestoneExtension *lodestoneInit();
4242
}

projects/Converters/Minecraft/Console/src/LodestoneLce.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace lodestone::minecraft::console {
2828
return VERSION;
2929
}
3030

31-
#ifndef __EMSCRIPTEN__
31+
#ifndef LODESTONE_BUILD_SHARED_LIBS
3232
core::LodestoneExtension *lodestoneInit() {
3333
return LodestoneLCE::getInstance();
3434
}

projects/Converters/Minecraft/Java/include/Lodestone.Minecraft.Java/LodestoneJava.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace lodestone::minecraft::java {
3939
lodestone::conversion::block::version::VersionedBlockIO m_blockIo;
4040
};
4141

42-
#ifndef __EMSCRIPTEN__
42+
#ifndef LODESTONE_BUILD_SHARED_LIBS
4343
extern "C" {
4444
core::LodestoneExtension *lodestoneInit();
4545
}

projects/Converters/Minecraft/Java/src/LodestoneJava.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ namespace lodestone::minecraft::java {
782782

783783
lodestone::common::util::Semver LodestoneJava::getVersion() const { return VERSION; }
784784

785-
#ifndef __EMSCRIPTEN__
785+
#ifndef LODESTONE_BUILD_SHARED_LIBS
786786
core::LodestoneExtension *lodestoneInit() {
787787
return LodestoneJava::getInstance();
788788
}

projects/Libraries/Core/include/Lodestone.Core/loader/ExtensionLoader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace lodestone::core::loader {
2121
class ExtensionLoader {
2222
public:
23-
#ifndef __EMSCRIPTEN__
23+
#ifndef LODESTONE_BUILD_SHARED_LIBS
2424
using LodestoneInit = lodestone::core::LodestoneExtension *(*)(void);
2525
#endif
2626
static constexpr const char *ENTRYPOINT = "lodestoneInit";
@@ -30,7 +30,7 @@ namespace lodestone::core::loader {
3030
explicit ExtensionLoader(core::Lodestone *core);
3131

3232
virtual void load() = 0;
33-
#ifndef __EMSCRIPTEN__
33+
#ifndef LODESTONE_BUILD_SHARED_LIBS
3434
virtual void loadExtension(LodestoneInit entrypoint);
3535
#endif
3636

projects/Libraries/Core/src/loader/ExtensionLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace lodestone::core::loader {
1414
ExtensionLoader::ExtensionLoader(core::Lodestone* core) : m_core(core) {}
1515

16-
#ifndef __EMSCRIPTEN__
16+
#ifndef LODESTONE_BUILD_SHARED_LIBS
1717
void ExtensionLoader::loadExtension(const LodestoneInit entrypoint) {
1818
core::LodestoneExtension *ext = entrypoint();
1919

0 commit comments

Comments
 (0)