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 # On other platforms we do need default paths though, i.e. since Linux
23 # distros may use architecture-specific directories (like
24 # /usr/lib/x86_64-linux-gnu) which we cannot hardcode/guess here.
25 FIND_LIBRARY(${compLibName}
30 HINTS $ENV{LIBSVN_DIR} ${CMAKE_INSTALL_PREFIX} ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib
31 PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
32 PATHS ${ADDITIONAL_LIBRARY_PATHS}
35 list(APPEND ${libs} ${${compLibName}})
38 find_program(HAVE_APR_CONFIG apr-1-config)
41 execute_process(COMMAND apr-1-config --cppflags --includes
42 OUTPUT_VARIABLE APR_CFLAGS
43 OUTPUT_STRIP_TRAILING_WHITESPACE)
45 execute_process(COMMAND apr-1-config --link-ld
46 OUTPUT_VARIABLE RAW_APR_LIBS
47 OUTPUT_STRIP_TRAILING_WHITESPACE)
49 # clean up some vars, or other CMake pieces complain
50 string(STRIP "${RAW_APR_LIBS}" APR_LIBS)
53 message(STATUS "apr-1-config not found, implement manual search for APR")
54 endif(HAVE_APR_CONFIG)
56 if(HAVE_APR_CONFIG OR MSVC)
57 find_path(LIBSVN_INCLUDE_DIR svn_client.h
60 $ENV{LIBSVN_DIR} ${CMAKE_INSTALL_PREFIX} ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include
61 PATH_SUFFIXES include/subversion-1
68 set(LIBSVN_LIBRARIES "")
70 find_static_component("apr-1" LIBSVN_LIBRARIES)
72 list(APPEND LIBSVN_LIBRARIES ${APR_LIBS})
74 find_static_component("svn_client-1" LIBSVN_LIBRARIES)
75 find_static_component("svn_subr-1" LIBSVN_LIBRARIES)
76 find_static_component("svn_ra-1" LIBSVN_LIBRARIES)
78 include(FindPackageHandleStandardArgs)
79 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSVN DEFAULT_MSG LIBSVN_LIBRARIES LIBSVN_INCLUDE_DIR)
81 set(LIBSVN_LIBRARIES "")
82 endif(NOT LIBSVN_FOUND)
83 endif(HAVE_APR_CONFIG OR MSVC)