Skip to content

Commit

Permalink
cmake: introduce BUILD_LINK_LUA_LIBRARIES option
Browse files Browse the repository at this point in the history
close #302, `cmake -DBUILD_LINK_LUA_LIBRARIES=ON`
  • Loading branch information
zhaozg committed Apr 5, 2024
1 parent b30f689 commit ab12f5f
Show file tree
Hide file tree
Showing 5 changed files with 277 additions and 300 deletions.
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
option(BUILD_SHARED_LUA_OPENSSL "Shared or Static lua-openssl" ON)
option(BUILD_LINK_LUA_LIBRARIES "Link Lua libraries during build-time" OFF)
if(WIN32)
set(BUILD_LINK_LUA_LIBRARIES ON)
endif()

include(GNUInstallDirs)

Expand Down Expand Up @@ -87,14 +91,15 @@ target_link_libraries(lua-openssl PUBLIC
Threads::Threads
)

if(WIN32)
target_link_libraries(lua-openssl PUBLIC
${LUA_LIBRARIES}
)
endif()

if(APPLE)
target_link_options(lua-openssl PUBLIC -bundle -undefined dynamic_lookup)
if(BUILD_LINK_LUA_LIBRARIES)
target_link_libraries(lua-openssl PUBLIC ${LUA_LIBRARIES})
if(UNIX)
target_link_options(lua-openssl PUBLIC -Wl,--no-undefined)
endif()
else()
if(APPLE)
target_link_options(lua-openssl PUBLIC -bundle -undefined dynamic_lookup)
endif()
endif()

target_compile_options(lua-openssl PRIVATE -DLUA_LIB)
Expand Down
15 changes: 3 additions & 12 deletions src/asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,9 @@ static int openssl_get_object(lua_State*L)
int class = 0;
int ret;

if (start > l)
{
lua_pushnil(L);
openssl_pushargerror(L, 2, "out of range");
return 2;
}
if (start>stop)
{
lua_pushnil(L);
openssl_pushargerror(L, 3, "before of start");
return 2;
}
luaL_argcheck(L, start > 0 && start < l, 2, "start out of length of asn1 string");
luaL_argcheck(L, stop > start, 3, "stop must be greater than start");
luaL_argcheck(L, stop <= l, 3, "stop out of length of asn1 string");

p = (const unsigned char *)asn1s + start - 1;
ret = ASN1_get_object(&p, &len, &tag, &class, stop - start + 1);
Expand Down
Loading

0 comments on commit ab12f5f

Please sign in to comment.