diff --git a/cmake/BuildPCRE2.cmake b/cmake/BuildPCRE2.cmake index 823053e56..50ae5bb66 100644 --- a/cmake/BuildPCRE2.cmake +++ b/cmake/BuildPCRE2.cmake @@ -1,23 +1,18 @@ # 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 +# This will add a 'pcre2' target to CMake which will generate the libpcre2-8.a +# static 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( pcre2) -# to the CMakeLists.txt +# to the CMakeLists.txt. You don't need to link against the pcre2 library +# because the static symbols will be in MaxScale. include(ExternalProject) -set(PCRE2_ROOT_DIR ${CMAKE_SOURCE_DIR}/pcre2/) -set(PCRE2_BUILD_DIR ${CMAKE_BINARY_DIR}/pcre2/) -set(PCRE2_LIBRARIES ${CMAKE_BINARY_DIR}/pcre2/libpcre2-8.so - ${CMAKE_BINARY_DIR}/pcre2/libpcre2-8.so.1.0.0 - CACHE STRING "PCRE2 dynamic libraries" FORCE) - -ExternalProject_Add(pcre2 SOURCE_DIR ${PCRE2_ROOT_DIR} - CMAKE_ARGS -DBUILD_SHARED_LIBS=Y -DPCRE2_BUILD_PCRE2GREP=N -DPCRE2_BUILD_TESTS=N - BINARY_DIR ${PCRE2_BUILD_DIR} +ExternalProject_Add(pcre2 SOURCE_DIR ${CMAKE_SOURCE_DIR}/pcre2/ + CMAKE_ARGS -DBUILD_SHARED_LIBS=N -DPCRE2_BUILD_PCRE2GREP=N -DPCRE2_BUILD_TESTS=N + BINARY_DIR ${CMAKE_BINARY_DIR}/pcre2/ BUILD_COMMAND make INSTALL_COMMAND "") include_directories(${CMAKE_BINARY_DIR}/pcre2/) -install(PROGRAMS ${PCRE2_LIBRARIES} DESTINATION ${MAXSCALE_LIBDIR}) +set(PCRE2_LIBRARIES ${CMAKE_BINARY_DIR}/pcre2/libpcre2-8.a CACHE INTERNAL "") diff --git a/query_classifier/test/canonical_tests/CMakeLists.txt b/query_classifier/test/canonical_tests/CMakeLists.txt index 925a3dd4f..a81aa3e88 100644 --- a/query_classifier/test/canonical_tests/CMakeLists.txt +++ b/query_classifier/test/canonical_tests/CMakeLists.txt @@ -8,7 +8,7 @@ else() endif() endif() add_executable(canonizer canonizer.c ${CMAKE_SOURCE_DIR}/server/core/random_jkiss.c) -target_link_libraries(canonizer pthread query_classifier z dl ssl aio crypt crypto rt m ${EMBEDDED_LIB} fullcore stdc++) +target_link_libraries(canonizer ${PCRE2_LIBRARIES} utils pthread query_classifier z dl ssl aio crypt crypto rt m ${EMBEDDED_LIB} fullcore stdc++) add_test(NAME Internal-TestCanonicalQuery COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh ${CMAKE_CURRENT_BINARY_DIR}/test.log ${CMAKE_CURRENT_SOURCE_DIR}/input.sql diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 53004c811..9f29ba741 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -5,7 +5,7 @@ if(BUILD_TESTS OR BUILD_TOOLS) elseif(WITH_TCMALLOC) target_link_libraries(fullcore ${TCMALLOC_LIBRARIES}) endif() - target_link_libraries(fullcore ${CURL_LIBRARIES} utils log_manager pthread ${LZMA_LINK_FLAGS} ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ssl aio rt crypt dl crypto inih z m stdc++) + target_link_libraries(fullcore ${CURL_LIBRARIES} utils ${PCRE2_LIBRARIES} log_manager pthread ${LZMA_LINK_FLAGS} ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ssl aio rt crypt dl crypto inih z m stdc++) add_dependencies(fullcore pcre2) endif() @@ -22,15 +22,15 @@ elseif(WITH_TCMALLOC) target_link_libraries(maxscale ${TCMALLOC_LIBRARIES}) endif() -target_link_libraries(maxscale ${LZMA_LINK_FLAGS} ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ${CURL_LIBRARIES} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++) +target_link_libraries(maxscale ${LZMA_LINK_FLAGS} ${PCRE2_LIBRARIES} ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ${CURL_LIBRARIES} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++) install(TARGETS maxscale DESTINATION ${MAXSCALE_BINDIR}) add_executable(maxkeys maxkeys.c spinlock.c secrets.c utils.c gwdirs.c random_jkiss.c ${CMAKE_SOURCE_DIR}/log_manager/log_manager.cc) -target_link_libraries(maxkeys utils pthread crypt crypto) +target_link_libraries(maxkeys utils pthread crypt crypto ${PCRE2_LIBRARIES}) install(TARGETS maxkeys DESTINATION ${MAXSCALE_BINDIR}) add_executable(maxpasswd maxpasswd.c spinlock.c secrets.c utils.c gwdirs.c random_jkiss.c ${CMAKE_SOURCE_DIR}/log_manager/log_manager.cc) -target_link_libraries(maxpasswd utils pthread crypt crypto) +target_link_libraries(maxpasswd utils pthread crypt crypto ${PCRE2_LIBRARIES}) install(TARGETS maxpasswd DESTINATION ${MAXSCALE_BINDIR}) if(BUILD_TESTS) diff --git a/server/modules/filter/CMakeLists.txt b/server/modules/filter/CMakeLists.txt index e59201f22..a30aecbff 100644 --- a/server/modules/filter/CMakeLists.txt +++ b/server/modules/filter/CMakeLists.txt @@ -11,7 +11,7 @@ if(BUILD_RABBITMQ) endif() add_library(regexfilter SHARED regexfilter.c) -target_link_libraries(regexfilter log_manager ${PCRE2_LIBRARIES}) +target_link_libraries(regexfilter log_manager) add_dependencies(regexfilter pcre2) set_target_properties(regexfilter PROPERTIES VERSION "1.1.0") install(TARGETS regexfilter DESTINATION ${MAXSCALE_LIBDIR}) diff --git a/server/modules/routing/binlog/CMakeLists.txt b/server/modules/routing/binlog/CMakeLists.txt index fad0ecb8e..2b282eadb 100644 --- a/server/modules/routing/binlog/CMakeLists.txt +++ b/server/modules/routing/binlog/CMakeLists.txt @@ -20,7 +20,7 @@ add_executable(maxbinlogcheck maxbinlogcheck.c blr_file.c blr_cache.c blr_master ${CMAKE_SOURCE_DIR}/log_manager/log_manager.cc ${CMAKE_SOURCE_DIR}/server/core/externcmd.c) -target_link_libraries(maxbinlogcheck utils ssl pthread ${LZMA_LINK_FLAGS} ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} aio rt crypt dl crypto inih z m stdc++ ${CURL_LIBRARIES}) +target_link_libraries(maxbinlogcheck utils ssl pthread ${LZMA_LINK_FLAGS} ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} aio rt crypt dl crypto inih z m stdc++ ${CURL_LIBRARIES} ${PCRE2_LIBRARIES}) install(TARGETS maxbinlogcheck DESTINATION bin) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 2b467f34e..8bba56eca 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,3 +1,3 @@ add_library(utils skygw_utils.cc ../server/core/atomic.c) -target_link_libraries(utils stdc++ ${PCRE2_LIBRARIES}) +target_link_libraries(utils stdc++) add_dependencies(utils pcre2)