Fixed PCRE2 beng built when CMake is configured

The bundled PCRE2 library will be built as a separate target and configuring
CMake no longer builds it. Instead, it will only be built when it is out of date.
This requires all targets to declare that they depend on the pcre2 target in
order for it to be built.
This commit is contained in:
Markus Makela
2015-11-14 06:49:19 +02:00
parent f9c99761d6
commit b22d40b06b
7 changed files with 22 additions and 4 deletions

View File

@ -42,6 +42,7 @@ find_package(Git)
find_package(CURL)
# Build PCRE2
# Read BuildPCRE2 for details about how to add pcre2 as a dependency to a target
include(cmake/BuildPCRE2.cmake)
# You can find the variables set by this in the FindCURL.cmake file

View File

@ -1,16 +1,22 @@
# Build the PCRE2 library from source
#
# This will add a 'pcre2' target to CMake which will generate the libpcre2-8.so
# dynamic library and the pcre2.h header. If your target requires PCRE2 you
# need to add a dependeny on the 'pcre2' target by adding add_dependencies(<target> pcre2)
# to the CMakeLists.txt
set(PCRE_ROOT_DIR ${CMAKE_SOURCE_DIR}/pcre2/)
set(PCRE_BUILD_DIR ${CMAKE_BINARY_DIR}/pcre2/)
set(PCRE2_LIBRARIES ${CMAKE_BINARY_DIR}/pcre2/libpcre2-8.so CACHE STRING "PCRE2 dynamic libraries" FORCE)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PCRE_BUILD_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PCRE_ROOT_DIR} ${PCRE_BUILD_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} ${PCRE_BUILD_DIR}
add_custom_target(pcre2 COMMAND ${CMAKE_COMMAND} ${PCRE_BUILD_DIR}
-DBUILD_SHARED_LIBS=Y
-DPCRE2_BUILD_PCRE2GREP=N
-DPCRE2_BUILD_TESTS=N
COMMAND make
WORKING_DIRECTORY ${PCRE_BUILD_DIR})
execute_process(COMMAND make WORKING_DIRECTORY ${PCRE_BUILD_DIR})
set(PCRE2_LIBRARIES ${CMAKE_BINARY_DIR}/pcre2/libpcre2-8.so CACHE STRING "PCRE2 dynamic libraries" FORCE)
include_directories(${CMAKE_BINARY_DIR}/pcre2/)
install(PROGRAMS ${PCRE2_LIBRARIES} DESTINATION ${MAXSCALE_LIBDIR})

View File

@ -6,6 +6,7 @@ if(BUILD_TESTS OR BUILD_TOOLS)
target_link_libraries(fullcore ${TCMALLOC_LIBRARIES})
endif()
target_link_libraries(fullcore ${CURL_LIBRARIES} utils log_manager pthread ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ssl aio rt crypt dl crypto inih z m stdc++)
add_dependencies(fullcore pcre2)
endif()
add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c
@ -13,6 +14,7 @@ add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c
poll.c config.c users.c hashtable.c dbusers.c thread.c gwbitmask.c
monitor.c adminusers.c secrets.c filter.c modutil.c hint.c
housekeeper.c memlog.c resultset.c gwdirs.c externcmd.c random_jkiss.c maxscale_pcre2.c)
add_dependencies(maxscale pcre2)
if(WITH_JEMALLOC)
target_link_libraries(maxscale ${JEMALLOC_LIBRARIES})

View File

@ -8,6 +8,7 @@ endif()
add_library(regexfilter SHARED regexfilter.c)
target_link_libraries(regexfilter log_manager ${PCRE2_LIBRARIES})
add_dependencies(regexfilter pcre2)
install(TARGETS regexfilter DESTINATION ${MAXSCALE_LIBDIR})
add_library(testfilter SHARED testfilter.c)

View File

@ -1,16 +1,21 @@
add_library(mysqlmon SHARED mysql_mon.c monitor_common.c)
target_link_libraries(mysqlmon log_manager)
add_dependencies(mysqlmon pcre2)
install(TARGETS mysqlmon DESTINATION ${MAXSCALE_LIBDIR})
add_library(galeramon SHARED galeramon.c monitor_common.c)
target_link_libraries(galeramon log_manager)
add_dependencies(galeramon pcre2)
install(TARGETS galeramon DESTINATION ${MAXSCALE_LIBDIR})
add_library(ndbclustermon SHARED ndbclustermon.c monitor_common.c)
target_link_libraries(ndbclustermon log_manager)
add_dependencies(ndbclustermon pcre2)
install(TARGETS ndbclustermon DESTINATION ${MAXSCALE_LIBDIR})
if(BUILD_MMMON)
add_library(mmmon SHARED mmmon.c monitor_common.c)
target_link_libraries(mmmon log_manager)
add_dependencies(mmmon pcre2)
install(TARGETS mmmon DESTINATION ${MAXSCALE_LIBDIR})
endif()

View File

@ -1,9 +1,11 @@
add_library(schemarouter SHARED schemarouter.c sharding_common.c)
target_link_libraries(schemarouter log_manager query_classifier)
add_dependencies(schemarouter pcre2)
install(TARGETS schemarouter DESTINATION ${MAXSCALE_LIBDIR})
add_library(shardrouter SHARED shardrouter.c svcconn.c sharding_common.c)
target_link_libraries(shardrouter log_manager query_classifier)
add_dependencies(shardrouter pcre2)
install(TARGETS shardrouter DESTINATION ${MAXSCALE_LIBDIR})
if(BUILD_TESTS)

View File

@ -1,2 +1,3 @@
add_library(utils skygw_utils.cc ../server/core/atomic.c)
target_link_libraries(utils stdc++ ${PCRE2_LIBRARIES})
add_dependencies(utils pcre2)