From dc692a3835c4a11dd135c78d62c2f2acad33614f Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 11:07:00 +0800 Subject: [PATCH] disable dylib by default --- CMakeLists.txt | 3 ++- include/pocketpy/export.h | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb67898d..dc977c06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}/include) aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src POCKETPY_SRC) option(PK_USE_BOX2D "Use Box2D" OFF) +option(PK_USE_DYLIB "Use dylib" OFF) if(PK_USE_BOX2D) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/3rd/box2d) @@ -65,7 +66,7 @@ else() target_link_libraries(${PROJECT_EXE_NAME} ${CMAKE_DL_LIBS}) endif() -if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") +if(PK_USE_DYLIB) target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS}) endif() diff --git a/include/pocketpy/export.h b/include/pocketpy/export.h index 829f0815..10922fc9 100644 --- a/include/pocketpy/export.h +++ b/include/pocketpy/export.h @@ -102,20 +102,32 @@ typedef struct tagBITMAPINFOHEADER { #define PK_SUPPORT_DYLIB 4 #elif TARGET_OS_MAC #define PK_SYS_PLATFORM "darwin" - #include - #define PK_SUPPORT_DYLIB 2 + #ifdef PK_USE_DYLIB + #include + #define PK_SUPPORT_DYLIB 2 + #else + #define PK_SUPPORT_DYLIB 0 + #endif #else # error "Unknown Apple platform" #endif #define PK_EXPORT __attribute__((visibility("default"))) #elif __ANDROID__ - #include - #define PK_SUPPORT_DYLIB 3 + #ifdef PK_USE_DYLIB + #include + #define PK_SUPPORT_DYLIB 3 + #else + #define PK_SUPPORT_DYLIB 0 + #endif #define PK_EXPORT __attribute__((visibility("default"))) #define PK_SYS_PLATFORM "android" #elif __linux__ - #include - #define PK_SUPPORT_DYLIB 2 + #ifdef PK_USE_DYLIB + #include + #define PK_SUPPORT_DYLIB 2 + #else + #define PK_SUPPORT_DYLIB 0 + #endif #define PK_EXPORT __attribute__((visibility("default"))) #define PK_SYS_PLATFORM "linux" #else