1 # Find Subversion client libraries, and dependencies
2 # including APR (Apache Portable Runtime)
4 include (CheckFunctionExists)
5 include (CheckIncludeFile)
6 include (CheckLibraryExists)
8 macro(find_static_component comp libs)
9 # account for alternative Windows svn distribution naming
11 set(compLib "lib${comp}")
13 set(compLib "${comp}")
16 string(TOUPPER "${comp}" compLibBase)
17 set( compLibName ${compLibBase}_LIBRARY )
19 # NO_DEFAULT_PATH is important on Mac - we need to ensure subversion
20 # libraires in dist/ or Macports are picked over the Apple version
21 # in /usr, since that's what we will ship.
22 FIND_LIBRARY(${compLibName}
25 HINTS $ENV{LIBSVN_DIR} ${CMAKE_INSTALL_PREFIX} ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib
26 PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
33 list(APPEND ${libs} ${${compLibName}})
36 find_program(HAVE_APR_CONFIG apr-1-config)
39 execute_process(COMMAND apr-1-config --cppflags --includes
40 OUTPUT_VARIABLE APR_CFLAGS
41 OUTPUT_STRIP_TRAILING_WHITESPACE)
43 execute_process(COMMAND apr-1-config --link-ld
44 OUTPUT_VARIABLE RAW_APR_LIBS
45 OUTPUT_STRIP_TRAILING_WHITESPACE)
47 # clean up some vars, or other CMake pieces complain
48 string(STRIP "${RAW_APR_LIBS}" APR_LIBS)
51 message(STATUS "apr-1-config not found, implement manual search for APR")
52 endif(HAVE_APR_CONFIG)
54 if(HAVE_APR_CONFIG OR MSVC)
55 find_path(LIBSVN_INCLUDE_DIR svn_client.h
58 $ENV{LIBSVN_DIR} ${CMAKE_INSTALL_PREFIX} ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include
59 PATH_SUFFIXES include/subversion-1
66 set(LIBSVN_LIBRARIES "")
68 find_static_component("apr-1" LIBSVN_LIBRARIES)
70 list(APPEND LIBSVN_LIBRARIES ${APR_LIBS})
72 find_static_component("svn_client-1" LIBSVN_LIBRARIES)
73 find_static_component("svn_subr-1" LIBSVN_LIBRARIES)
74 find_static_component("svn_ra-1" LIBSVN_LIBRARIES)
76 include(FindPackageHandleStandardArgs)
77 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSVN DEFAULT_MSG LIBSVN_LIBRARIES LIBSVN_INCLUDE_DIR)
79 set(LIBSVN_LIBRARIES "")
80 endif(NOT LIBSVN_FOUND)
81 endif(HAVE_APR_CONFIG OR MSVC)