]> git.mxchange.org Git - simgear.git/blob - CMakeModules/FindSvnClient.cmake
Sound Manager: support subsystem reinit,
[simgear.git] / CMakeModules / FindSvnClient.cmake
1 # Find Subversion client libraries, and dependencies
2 # including APR (Apache Portable Runtime)
3
4 include (CheckFunctionExists)
5 include (CheckIncludeFile)
6 include (CheckLibraryExists)
7
8 macro(find_static_component comp libs)
9     # account for alternative Windows svn distribution naming
10     if(MSVC)
11       set(compLib "lib${comp}")
12     else(MSVC)
13       set(compLib "${comp}")
14     endif(MSVC)
15     
16     string(TOUPPER "${comp}" compLibBase)
17     set( compLibName ${compLibBase}_LIBRARY )
18
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}
26 if(APPLE)
27       NO_DEFAULT_PATH
28 endif(APPLE)
29       NAMES ${compLib}
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
33       /opt/local
34       /usr/local
35       /usr
36     )
37
38         list(APPEND ${libs} ${${compLibName}})
39 endmacro()
40
41 find_program(HAVE_APR_CONFIG apr-1-config)
42 if(HAVE_APR_CONFIG) 
43         
44     execute_process(COMMAND apr-1-config --cppflags --includes
45         OUTPUT_VARIABLE APR_CFLAGS
46         OUTPUT_STRIP_TRAILING_WHITESPACE)
47         
48     execute_process(COMMAND apr-1-config --link-ld
49         OUTPUT_VARIABLE RAW_APR_LIBS
50         OUTPUT_STRIP_TRAILING_WHITESPACE)
51     
52 # clean up some vars, or other CMake pieces complain
53         string(STRIP "${RAW_APR_LIBS}" APR_LIBS)
54
55 else(HAVE_APR_CONFIG)
56     message(STATUS "apr-1-config not found, implement manual search for APR")
57 endif(HAVE_APR_CONFIG)
58
59 if(HAVE_APR_CONFIG OR MSVC)
60         find_path(LIBSVN_INCLUDE_DIR svn_client.h
61       NO_DEFAULT_PATH
62           HINTS
63           $ENV{LIBSVN_DIR} ${CMAKE_INSTALL_PREFIX} ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include
64           PATH_SUFFIXES include/subversion-1
65           PATHS
66       /opt/local
67           /usr/local
68           /usr
69         )
70         
71         set(LIBSVN_LIBRARIES "")
72         if (MSVC)
73                 find_static_component("apr-1" LIBSVN_LIBRARIES)
74         else (MSVC)
75                 list(APPEND LIBSVN_LIBRARIES ${APR_LIBS})
76         endif (MSVC)
77         find_static_component("svn_client-1" LIBSVN_LIBRARIES)
78         find_static_component("svn_subr-1" LIBSVN_LIBRARIES)
79         find_static_component("svn_ra-1" LIBSVN_LIBRARIES)
80
81         include(FindPackageHandleStandardArgs)
82         FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSVN DEFAULT_MSG LIBSVN_LIBRARIES LIBSVN_INCLUDE_DIR)
83         if(NOT LIBSVN_FOUND)
84                 set(LIBSVN_LIBRARIES "")
85         endif(NOT LIBSVN_FOUND)
86 endif(HAVE_APR_CONFIG OR MSVC)