Skip to content
Permalink
Browse files

Attempt to get pcre2 linking

  • Loading branch information...
creationix committed Jul 29, 2015
1 parent 97ebaf1 commit 03dbeb33283c201a1d40a8a4c2d394384fa36e37
Showing with 58 additions and 4 deletions.
  1. +7 −3 CMakeLists.txt
  2. +1 −1 Makefile
  3. +23 −0 deps/lrexlib.cmake
  4. +19 −0 deps/pcre2.cmake
  5. +5 −0 src/luvi.c
  6. +3 −0 src/luvi.h
@@ -35,6 +35,8 @@ option(WithSharedLibluv "Shared or Static libluv" OFF)
option(WithOpenSSL "Include OpenSSL" OFF)
option(WithOpenSSLASM "Enable Assembly Optimizations" OFF)
option(WithSharedOpenSSL "Shared or Static OpenSSL" ON)
option(WithPCRE2 "Include PCRE2" OFF)
option(WithSharedPCRE2 "Shared or Static PCRE2" OFF)
option(WithZLIB "Include ZLIB" OFF)
option(WithSharedZLIB "Shared or Static ZLIB" ON)
option(WithPackageSH "Build shell-installable package." OFF)
@@ -74,12 +76,14 @@ endif (WithSharedLibluv)

if (WithOpenSSL)
include(deps/openssl.cmake)
add_definitions( -DWITH_OPENSSL )
endif (WithOpenSSL)

if (WithPCRE2)
include (deps/pcre2.cmake)
endif (WithPCRE2)

if (WithZLIB)
include(deps/zlib.cmake)
add_definitions( -DWITH_ZLIB )
endif (WithZLIB)

add_definitions( -DLUVI_VERSION="${LUVI_VERSION}" )
@@ -96,7 +100,7 @@ if(UNIX)
endif()

luajit_add_executable(luvi
${winsvc}
${extra_sources}
src/main.c
src/lua/init.lua
)
@@ -57,7 +57,7 @@ build:

# Configure the build with minimal dependencies
tiny: deps/luv/CMakeLists.txt
cmake $(CMAKE_FLAGS) $(CPACK_FLAGS)
cmake $(CMAKE_FLAGS) $(CPACK_FLAGS) -DWithPCRE2=ON

# Configure the build with openssl statically included
regular: deps/luv/CMakeLists.txt
@@ -0,0 +1,23 @@
set(LREXLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/lrexlib)

include_directories(
${LREXLIB_DIR}/src
)

add_definitions(
-DVERSION="2.8.0"
)

add_library(lrexlib
${LREXLIB_DIR}/src/common.c
${LREXLIB_DIR}/src/pcre/lpcre.c
${LREXLIB_DIR}/src/pcre/lpcre_f.c
)

if (WithSharedPCRE2)
target_link_libraries(lrexlib pcre2)
else (WithSharedPCRE2)
target_link_libraries(lrexlib pcre2posix)
endif (WithSharedPCRE2)

set(EXTRA_LIBS ${EXTRA_LIBS} lrexlib)
@@ -0,0 +1,19 @@

if (WithSharedPCRE2)
find_package(PCRE2 REQUIRED)
message("PCRE2 include dir: ${PCRE2_INCLUDE_DIR}")
message("PCRE2 libraries: ${PCRE2_LIBRARIES}")
include_directories(${PCRE2_INCLUDE_DIR})
link_directories(${PCRE2_ROOT_DIR}/lib)
list(APPEND LIB_LIST ${PCRE2_LIBRARIES})
else (WithSharedPCRE2)
set (PCRE2_BUILD_PCRE2GREP OFF)
set (PCRE2_BUILD_TESTS OFF)
set (PCRE2_MATCH_LIMIT 150000)
add_subdirectory(deps/pcre2)
message("Enabling Static PCRE2")
list(APPEND LIB_LIST pcre2posix)
endif (WithSharedPCRE2)

add_definitions(-DWITH_PCRE2)
include(deps/lrexlib.cmake)
@@ -33,6 +33,11 @@ LUALIB_API int luaopen_luvi(lua_State *L) {
lua_pushstring(L, buffer);
lua_setfield(L, -2, "ssl");
#endif
#ifdef WITH_PCRE2
pcre2_config(PCRE2_CONFIG_VERSION, buffer);
lua_pushstring(L, buffer);
lua_setfield(L, -2, "pcre2");
#endif
#ifdef WITH_ZLIB
lua_pushstring(L, zlibVersion());
lua_setfield(L, -2, "zlib");
@@ -36,6 +36,9 @@
#ifdef WITH_OPENSSL
#include "openssl.h"
#endif
#ifdef WITH_PCRE2
#include "pcre2.h"
#endif
#ifdef WITH_ZLIB
#include "zlib.h"
LUALIB_API int luaopen_zlib(lua_State * const L);

0 comments on commit 03dbeb3

Please sign in to comment.
You can’t perform that action at this time.