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