]> git.mxchange.org Git - flightgear.git/blob - CMakeModules/FindSvnClient.cmake
Fix for old PUI versions
[flightgear.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 ${ADDITIONAL_LIBRARY_PATHS}
33     )
34
35         list(APPEND ${libs} ${${compLibName}})
36 endmacro()
37
38 find_program(HAVE_APR_CONFIG apr-1-config)
39 if(HAVE_APR_CONFIG) 
40         
41     execute_process(COMMAND apr-1-config --cppflags --includes
42         OUTPUT_VARIABLE APR_CFLAGS
43         OUTPUT_STRIP_TRAILING_WHITESPACE)
44         
45     execute_process(COMMAND apr-1-config --link-ld
46         OUTPUT_VARIABLE RAW_APR_LIBS
47         OUTPUT_STRIP_TRAILING_WHITESPACE)
48     
49 # clean up some vars, or other CMake pieces complain
50         string(STRIP "${RAW_APR_LIBS}" APR_LIBS)
51
52 else(HAVE_APR_CONFIG)
53     message(STATUS "apr-1-config not found, implement manual search for APR")
54 endif(HAVE_APR_CONFIG)
55
56 if(HAVE_APR_CONFIG OR MSVC)
57         find_path(LIBSVN_INCLUDE_DIR svn_client.h
58       NO_DEFAULT_PATH
59           HINTS
60           $ENV{LIBSVN_DIR} ${CMAKE_INSTALL_PREFIX} ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include
61           PATH_SUFFIXES include/subversion-1
62           PATHS ${ADDITIONAL_LIBRARY_PATHS}
63         )
64         
65         set(LIBSVN_LIBRARIES "")
66         if (MSVC)
67                 find_static_component("apr-1" LIBSVN_LIBRARIES)
68         else (MSVC)
69                 list(APPEND LIBSVN_LIBRARIES ${APR_LIBS})
70         endif (MSVC)
71         find_static_component("svn_client-1" LIBSVN_LIBRARIES)
72         find_static_component("svn_subr-1" LIBSVN_LIBRARIES)
73         find_static_component("svn_ra-1" LIBSVN_LIBRARIES)
74
75         include(FindPackageHandleStandardArgs)
76         FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSVN DEFAULT_MSG LIBSVN_LIBRARIES LIBSVN_INCLUDE_DIR)
77         if(NOT LIBSVN_FOUND)
78                 set(LIBSVN_LIBRARIES "")
79         endif(NOT LIBSVN_FOUND)
80 endif(HAVE_APR_CONFIG OR MSVC)