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