Timeout merge 2:
[opensync.git] / CMakeLists.txt
blobfc67c10f575ef8417abfbe5c8a87405c9d7a8a15
1 PROJECT( libopensync C )
3 SET( OPENSYNC_VERSION_MAJOR "0" )
4 SET( OPENSYNC_VERSION_MINOR "39" )
6 # The most recent interface number that this library implements.
7 #UPDATE: If any interface have been added, removed or changed since
8 #UPDATE: the last update increment CURRENT.
9 SET( OPENSYNC_LIBVERSION_CURRENT 1 )
11 # The implementation number of the CURRENT interface.
12 # UPDATE: Increment only if the library code has changed at all, since
13 # UPDATE: last release.
14 # UPDATE: Set REVISION to 0 if any interface have been added, removed or
15 # UPDATE: changed since the last update.
16 SET( OPENSYNC_LIBVERSION_REVISION 0 )
18 # The difference between the newest and the oldest interfaces.
19 # UPDATE: If any interface have been added since the last public
20 # UPDATE: release, then increment.
21 # UPDATE: If any interface have been removed since the last release
22 # UPDATE: reset to 0.
23 SET( OPENSYNC_LIBVERSION_AGE 0 )
26 # The range of implemention CURRENT - AGE is the SOVERSION
27 MATH( EXPR OPENSYNC_LIBVERSION_SOVERSION "${OPENSYNC_LIBVERSION_CURRENT} - ${OPENSYNC_LIBVERSION_AGE}" )
29 SET( OPENSYNC_LIBVERSION_VERSION "${OPENSYNC_LIBVERSION_SOVERSION}.${OPENSYNC_LIBVERSION_REVISION}.${OPENSYNC_LIBVERSION_AGE}" )
31 IF ( $ENV{OPENSYNC_RELEASE} )
32         SET( OPENSYNC_VERSION "${OPENSYNC_VERSION_MAJOR}.${OPENSYNC_VERSION_MINOR}" )   
33 ELSE ( $ENV{OPENSYNC_RELEASE} )
35         IF (DEFINED OPENSYNC_SCM_REVISION )
36                 SET( OPENSYNC_VERSION "${OPENSYNC_VERSION_MAJOR}.${OPENSYNC_VERSION_MINOR}-${OPENSYNC_SCM_REVISION}" )  
37         ELSE (DEFINED OPENSYNC_SCM_REVISION )
38                 SET( OPENSYNC_VERSION "${OPENSYNC_VERSION_MAJOR}.${OPENSYNC_VERSION_MINOR}-snapshot" )  
39         ENDIF (DEFINED OPENSYNC_SCM_REVISION )
40 ENDIF ( $ENV{OPENSYNC_RELEASE} )
42 SET( OPENSYNC_PLUGINVERSION ${OPENSYNC_LIBVERSION_SOVERSION} )
44 ################################################        
46 SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/modules )
48 CMAKE_MINIMUM_REQUIRED( VERSION 2.4.4 )
50 IF(COMMAND cmake_policy)
51         cmake_policy(SET CMP0003 NEW)
52 ENDIF(COMMAND cmake_policy)
54 INCLUDE( Documentation )
55 INCLUDE( OpenSyncDefaults )
56 INCLUDE( OpenSyncPackaging )
58 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/opensync" ${CMAKE_CURRENT_SOURCE_DIR} )
60 ###############################################
62 FIND_PACKAGE( GLIB2 REQUIRED )
63 FIND_PACKAGE( GTHREAD2 REQUIRED )
64 FIND_PACKAGE( GMODULE2 REQUIRED )
65 FIND_PACKAGE( Sqlite3 REQUIRED )
66 FIND_PACKAGE( LibXml2 REQUIRED )
67 FIND_PACKAGE( LibXslt REQUIRED )
68 FIND_PACKAGE( LibExslt REQUIRED )
69 FIND_PACKAGE( SWIG )    
70 FIND_PACKAGE( PythonLibs )
71 FIND_PACKAGE( Check )
73 # test configuration
75 OPTION( OPENSYNC_UNITTESTS "enable testing" OFF )
76 IF ( CHECK_FOUND )
77         SET( OPENSYNC_UNITTESTS ON )
78 ELSE ( CHECK_FOUND )
79         SET( OPENSYNC_UNITTESTS OFF )
80 ENDIF ( CHECK_FOUND )
82 # sub directories
84 ADD_SUBDIRECTORY( opensync )
85 ADD_SUBDIRECTORY( tools )
86 ADD_SUBDIRECTORY( misc )
87 ADD_SUBDIRECTORY( cmake )
89 #ADD_SUBDIRECTORY( docs/example-plugin/src/ ) 
91 OPTION( ENABLE_WRAPPER "enable wrapper" OFF )
92 IF ( SWIG_FOUND )
93         ADD_SUBDIRECTORY( wrapper )
94         SET( ENABLE_WRAPPER ON )
95 ELSE ( SWIG_FOUND )
96         SET( ENABLE_WRAPPER OFF )
97 ENDIF ( SWIG_FOUND )
99 IF ( OPENSYNC_UNITTESTS )
100         INCLUDE( Testing )
101         ADD_SUBDIRECTORY( tests )
102 ENDIF ( OPENSYNC_UNITTESTS )
104 IF ( CMAKE_SYSTEM_NAME MATCHES SunOS )
105         SET( HAVE_SOLARIS 1 )
106 ENDIF (CMAKE_SYSTEM_NAME MATCHES SunOS )
108 ############################################## 
109 MARK_AS_ADVANCED ( CLEAR BUILD_DOCUMENTATION )
111 IF ( BUILD_DOCUMENTATION )
112         IF ( DOXYGEN_DOT_EXECUTABLE )
113                 SET( HAVE_DOT "YES" )
114         ENDIF ( DOXYGEN_DOT_EXECUTABLE )
115         CONFIGURE_FILE( "Doxyfile.in" "Doxyfile" )
116         CONFIGURE_FILE( "misc/doxygen.css" "misc/doxygen.css" )
117         ADD_CUSTOM_TARGET( DoxygenDoc ${DOXYGEN_EXECUTABLE} )
118 ENDIF ( BUILD_DOCUMENTATION )
120 # Check if system has flock(..) function
121 INCLUDE( CheckFunctionExists )
122 SET( CMAKE_REQUIRED_INCLUDES "" )
123 SET( CMAKE_REQUIRED_LIBRARIES "" )
124 SET( CMAKE_REQUIRED_FLAGS "" )
125 SET( CMAKE_REQUIRED_DEFINITIONS "" )
126 CHECK_FUNCTION_EXISTS( flock HAVE_FLOCK )
128 IF ( APPLE ) 
129         SET( OPENSYNC_PREVENT_CLIENT_SHUTDOWN "1" )
130 ENDIF ( APPLE )
132 # add uninstall target
133 CONFIGURE_FILE( "${CMAKE_SOURCE_DIR}/cmake/modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
135 ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
137 CONFIGURE_FILE( "config.h.cmake" "config.h" )
138 CONFIGURE_FILE( "libopensync.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libopensync.pc" )
140 ########## INSTALL ##############################
141         
142 INSTALL( FILES "${CMAKE_CURRENT_BINARY_DIR}/libopensync.pc" DESTINATION ${LIBDATA_INSTALL_DIR}/pkgconfig/ )     
144 ### CPack ########################################
146 OPENSYNC_PACKAGE( ${PROJECT_NAME} ${OPENSYNC_VERSION} )
148 ######## configuration status output ###############
149 INCLUDE( ShowStatus )
150 MESSAGE( STATUS "==================================================" )
151 SHOW_STATUS( OPENSYNC_UNITTESTS "enable testing\t\t" )
152 SHOW_STATUS( ENABLE_WRAPPER "build wrapper\t\t" )
153 SHOW_STATUS( BUILD_DOCUMENTATION "build documentation\t\t" )