-
Notifications
You must be signed in to change notification settings - Fork 53
/
CMakeLists.txt
680 lines (591 loc) · 21.8 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
#
# CMakeLists.txt for openwsman/
#
# 2.6 minimum because of CMP0005 (escaping defines)
# 2.8.12 minimum because CMake 3.19.7 says so
# 3.27 for new find python commands
cmake_minimum_required(VERSION 3.27)
PROJECT(openwsman)
include(CTest)
enable_testing()
#
# cmake2.6: backward compatibility to cmake 2.4
#
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0005 NEW)
if ( POLICY CMP0042 )
cmake_policy(SET CMP0042 NEW)
endif ( POLICY CMP0042 )
if ( POLICY CMP0046 )
cmake_policy(SET CMP0046 NEW)
endif ( POLICY CMP0046 )
if ( POLICY CMP0148 )
# new find python commands
cmake_policy(SET CMP0148 NEW)
endif ( POLICY CMP0148 )
endif(COMMAND cmake_policy)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
# SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
INCLUDE( ${CMAKE_SOURCE_DIR}/VERSION.cmake )
SET(VERSION "${OPENWSMAN_MAJOR}.${OPENWSMAN_MINOR}.${OPENWSMAN_PATCH}")
MESSAGE(STATUS "Version ${VERSION}")
SET(PACKAGE_VERSION \"${OPENWSMAN_MAJOR}.${OPENWSMAN_MINOR}\")
MESSAGE(STATUS "Package Version ${PACKAGE_VERSION}")
SET(OPENWSMAN_PLUGIN_API_VERSION \"${OPENWSMAN_PLUGIN_API_MAJOR}.${OPENWSMAN_PLUGIN_API_MINOR}\")
MESSAGE(STATUS "Plugin API Version ${OPENWSMAN_PLUGIN_API_VERSION}")
# Package architecture
IF ( NOT DEFINED PACKAGE_ARCHITECTURE )
EXECUTE_PROCESS(COMMAND "uname" "-m" OUTPUT_VARIABLE UNAME_M)
# strip trailing newline
STRING(REPLACE "\n" "" PACKAGE_ARCHITECTURE ${UNAME_M})
ENDIF ( NOT DEFINED PACKAGE_ARCHITECTURE )
MESSAGE(STATUS "Building for ${PACKAGE_ARCHITECTURE}" )
# pkg-config
find_package(PkgConfig)
# Library path (lib / lib64 )
IF ( DEFINED LIB )
SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}" )
ELSE ( DEFINED LIB )
IF (APPLE)
SET(LIB_SUFFIX "")
ELSE (APPLE)
IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
SET( LIB_SUFFIX "64" )
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
ENDIF (APPLE)
SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
ENDIF ( DEFINED LIB )
MESSAGE(STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}" )
SET( BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" )
SET( INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" )
IF( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
SET( SYSCONFDIR "/etc" )
ELSE( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
SET( SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc" )
ENDIF( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
SET( WSMANCONF_DIR "${SYSCONFDIR}/openwsman" )
MESSAGE(STATUS "Configuration will be installed in ${WSMANCONF_DIR}" )
SET( DEFAULT_CONFIG_FILE \"${WSMANCONF_DIR}/openwsman.conf\")
SET( DEFAULT_CLIENT_CONFIG_FILE \"${WSMANCONF_DIR}/openwsman_client.conf\")
SET( PACKAGE_SUBSCRIPTION_DIR /var/lib/openwsman/subscriptions )
SET( PACKAGE_PLUGIN_DIR ${LIB_INSTALL_DIR}/openwsman/plugins )
SET( PACKAGE_AUTH_DIR ${LIB_INSTALL_DIR}/openwsman/authenticators )
# Macro for error message when header files not present, but build option
# explicitly declared
MACRO(NO_HEADERS_WARNING_EXPL optionName pkgName)
MESSAGE(STATUS "************ WARNING *************")
MESSAGE(STATUS "Didn't find ${pkgName} headers... ")
MESSAGE(STATUS "${optionName} explicitly requested.")
MESSAGE(STATUS "Make sure ${pkgName} header files are available and run cmake again.")
MESSAGE(STATUS "************************************")
SET(HAVE_WARNINGS YES)
ENDMACRO(NO_HEADERS_WARNING_EXPL)
# Macro for error message when header files not present, but build option
# not explicitly declared
MACRO(NO_HEADERS_WARNING optionName pkgName)
SET(${optionName} NO)
SET(HAVE_WARNINGS YES)
MESSAGE(STATUS "************ WARNING *************")
MESSAGE(STATUS "Didn't find ${pkgName} headers... not building ${pkgName} bindings")
MESSAGE(STATUS "************************************")
ENDMACRO(NO_HEADERS_WARNING)
# For binding options, see if it is explicitly set on the command line,
# before defining the option with a default. Then if we don't find
# the headers: if it was explicitly set then fail, otherwise
# just give a warning message
SET( BUILD_PYTHON_EXPLICIT ${BUILD_PYTHON})
SET( BUILD_PYTHON3_EXPLICIT ${BUILD_PYTHON3})
SET( BUILD_RUBY_EXPLICIT ${BUILD_RUBY})
SET( BUILD_PERL_EXPLICIT ${BUILD_PERL})
SET( BUILD_JAVA_EXPLICIT ${BUILD_JAVA})
SET( BUILD_SWIG_PLUGIN_EXPLICIT ${BUILD_SWIG_PLUGIN})
# options
OPTION( BUILD_LIBCIM "Build CIM plugin" YES )
OPTION( BUILD_EXAMPLES "Build examples" YES )
OPTION( BUILD_BINDINGS "Build client bindings and swig server plugin" YES )
OPTION( BUILD_PYTHON3 "Build Python3 bindings" YES )
OPTION( BUILD_PYTHON "Build Python2 bindings" NO )
IF (BUILD_PYTHON3)
IF (BUILD_PYTHON)
MESSAGE(FATAL_ERROR "Can only build for Python2 or Python3, but not both")
ENDIF (BUILD_PYTHON)
ENDIF (BUILD_PYTHON3)
OPTION( BUILD_RUBY "Build Ruby bindings" YES )
IF( BUILD_RUBY )
OPTION( BUILD_RUBY_GEM "Build Ruby GEM" YES )
ENDIF( BUILD_RUBY )
OPTION( BUILD_PERL "Build Perl bindings" YES )
OPTION( BUILD_JAVA "Build Java bindings" YES )
OPTION( BUILD_CSHARP "Build C# bindings" YES)
OPTION( BUILD_CUNIT_TESTS "Build serialization tests" NO )
OPTION( DISABLE_PLUGINS "Do not build plugins" NO )
OPTION( BUILD_SWIG_PLUGIN "Build SWIG plugin" YES )
OPTION( DISABLE_SERVER "Do not build server component" NO )
OPTION( ENABLE_EVENTING_SUPPORT "WS-Eventing wanted" YES )
OPTION( WSMAN_DEBUG_VERBOSE "Verbose debug logging" NO )
OPTION( ENABLE_IPV6 "Enable IPv6 support" YES )
OPTION( BUILD_TESTS "Build tests" YES )
IF(APPLE)
OPTION( BUILD_SHARED_LIBS "Build shared libraries" NO )
ELSE(APPLE)
OPTION( BUILD_SHARED_LIBS "Build shared libraries" YES )
ENDIF(APPLE)
IF (UNIX)
add_definitions(-fPIC)
ENDIF (UNIX)
IF (ENABLE_EVENTING_SUPPORT)
SET(ENABLE_EVENTING_SUPPORT 1)
find_package(OpenSSL REQUIRED)
ELSE (ENABLE_EVENTING_SUPPORT)
SET(ENABLE_EVENTING_SUPPORT 0)
ENDIF (ENABLE_EVENTING_SUPPORT)
IF(WSMAN_DEBUG_VERBOSE)
SET(WSMAN_DEBUG_VERBOSE 1)
ELSE(WSMAN_DEBUG_VERBOSE)
SET(WSMAN_DEBUG_VERBOSE 0)
ENDIF(WSMAN_DEBUG_VERBOSE)
OPTION( USE_PAM "Use PAM authentication" YES )
IF( USE_PAM )
FIND_LIBRARY( HAVE_LIBPAM "pam" )
IF(HAVE_LIBPAM)
SET( HAVE_PAM 1 )
MESSAGE(STATUS "building PAM authentication" )
ELSE(HAVE_LIBPAM)
MESSAGE(WARNING " libpam not found, disabling PAM authentication" )
SET( HAVE_PAM 1 )
ENDIF(HAVE_LIBPAM)
ELSE( USE_PAM )
SET( HAVE_PAM 0 )
MESSAGE(STATUS "Disabling PAM authentication" )
ENDIF( USE_PAM )
find_package(OpenSSL)
IF(OPENSSL_FOUND)
SET(HAVE_SSL 1)
SET(USE_OPENSSL 1)
ENDIF(OPENSSL_FOUND)
IF( BUILD_RUBY )
find_package(Ruby)
IF(RUBY_FOUND)
MESSAGE(STATUS "Ruby: ${RUBY_EXECUTABLE}" )
MESSAGE(STATUS "Ruby Library: ${RUBY_LIBRARY}" )
MESSAGE(STATUS "Ruby Include: ${RUBY_INCLUDE_PATH}" )
MESSAGE(STATUS "Ruby Site Arch: ${RUBY_SITEARCH_DIR}" )
MESSAGE(STATUS "Building Ruby bindings" )
ELSE(RUBY_FOUND)
MESSAGE(WARNING "Ruby not found" )
SET(BUILD_RUBY NO)
ENDIF(RUBY_FOUND)
IF(NOT RUBY_INCLUDE_PATH)
IF(BUILD_RUBY_EXPLICIT)
NO_HEADERS_WARNING_EXPL(BUILD_RUBY Ruby)
ELSE(BUILD_RUBY_EXPLICIT)
NO_HEADERS_WARNING(BUILD_RUBY Ruby)
ENDIF(BUILD_RUBY_EXPLICIT)
ENDIF(NOT RUBY_INCLUDE_PATH )
ENDIF( BUILD_RUBY )
IF( BUILD_PERL )
find_package(PerlLibs)
IF(PERL_EXECUTABLE)
MESSAGE(STATUS "Building Perl bindings" )
ELSE(PERL_EXECUTABLE)
MESSAGE(WARNING "Perl not found" )
SET(BUILD_PERL NO)
ENDIF(PERL_EXECUTABLE)
ENDIF( BUILD_PERL )
IF( BUILD_JAVA )
find_package(Java)
IF(JAVA_COMPILE)
find_package(JNI)
IF(JNI_INCLUDE_DIRS)
MESSAGE(STATUS "Building Java bindings" )
ELSE(JNI_INCLUDE_DIRS)
MESSAGE(WARNING " Java jni.h not found" )
SET( BUILD_JAVA "NO" )
ENDIF(JNI_INCLUDE_DIRS)
ELSE(JAVA_COMPILE)
MESSAGE(ERROR " Java compiler not found" )
SET( BUILD_JAVA "NO" )
ENDIF(JAVA_COMPILE)
ENDIF( BUILD_JAVA )
# swig
IF( BUILD_BINDINGS )
FIND_PACKAGE(SWIG)
IF( NOT SWIG_EXECUTABLE)
FIND_PROGRAM(SWIG_EXECUTABLE
NAMES swig
PATHS ${SWIG_DIR} ${SWIG_DIR}/.. ${SWIG_DIR}/../../bin /usr/bin /usr/local/bin ${CMAKE_INSTALL_PREFIX}/bin
)
SET(SWIG_VERSION "(unknown version)")
ELSE ( NOT SWIG_EXECUTABLE)
# FIND_PACKAGE(SWIG) succeeded, now check the version
# swig 2.0.4 and lower is known to be broken
IF (SWIG_VERSION)
IF(${SWIG_VERSION} VERSION_LESS "2.0.5")
MESSAGE( FATAL_ERROR "Found SWIG version ${SWIG_VERSION}, please upgrade SWIG to 2.0.5 or later" )
ENDIF(${SWIG_VERSION} VERSION_LESS "2.0.5")
ENDIF (SWIG_VERSION)
ENDIF( NOT SWIG_EXECUTABLE)
ENDIF( BUILD_BINDINGS )
IF ( NOT SWIG_EXECUTABLE )
MESSAGE( STATUS "SWIG not found, skipping bindings and swig server plugin." )
SET(BUILD_BINDINGS FALSE)
IF (BUILD_SWIG_PLUGIN_EXPLICIT)
MESSAGE( FATAL "Cannot build SWIG server plugin" )
ENDIF (BUILD_SWIG_PLUGIN_EXPLICIT)
SET( BUILD_SWIG_PLUGIN NO )
IF( BUILD_PYTHON3_EXPLICIT OR BUILD_PYTHON_EXPLICIT OR BUILD_RUBY_EXPLICIT OR BUILD_PERL_EXPLICIT OR BUILD_JAVA_EXPLICIT)
MESSAGE( ERROR "Cannot build client bindings" )
ENDIF( BUILD_PYTHON3_EXPLICIT OR BUILD_PYTHON_EXPLICIT OR BUILD_RUBY_EXPLICIT OR BUILD_PERL_EXPLICIT OR BUILD_JAVA_EXPLICIT)
ELSE ( NOT SWIG_EXECUTABLE )
MESSAGE( STATUS "SWIG ${SWIG_VERSION} found at ${SWIG_EXECUTABLE}" )
ENDIF ( NOT SWIG_EXECUTABLE )
# curl
IF(UNIX)
find_package(CURL)
IF ( NOT CURL_FOUND)
MESSAGE( FATAL_ERROR " curl not found" )
ELSE ( NOT CURL_FOUND)
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
IF(CURL_VERSION_STRING)
STRING(COMPARE LESS ${CURL_VERSION_STRING} "7.12.0" result)
IF(result LESS 0)
MESSAGE( FATAL_ERROR " curl version ${CURL_VERSION_STRING} is too low, need 7.12.0 or greater" )
ENDIF(result LESS 0)
ENDIF(CURL_VERSION_STRING)
ENDIF( NOT CURL_FOUND)
ENDIF(UNIX)
# xml2
find_package(LibXml2)
IF ( NOT LIBXML2_FOUND)
MESSAGE( FATAL_ERROR " libxml2 not found" )
ELSE ( NOT LIBXML2_FOUND)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
ENDIF( NOT LIBXML2_FOUND)
# pthreads
IF(UNIX)
find_package(Threads)
IF( NOT CMAKE_USE_PTHREADS_INIT )
MESSAGE( FATAL_ERROR " openwsman needs pthread" )
ELSE( NOT CMAKE_USE_PTHREADS_INIT )
SET(USE_PTHREAD TRUE)
ENDIF( NOT CMAKE_USE_PTHREADS_INIT )
ENDIF(UNIX)
# dl
FIND_LIBRARY( HAVE_LIBDL "dl" )
IF(HAVE_LIBDL)
SET(DL_LIBRARIES ${HAVE_LIBDL})
SET(HAVE_LIBDL 1)
ELSE(HAVE_LIBDL)
SET(HAVE_LIBDL 0)
ENDIF(HAVE_LIBDL)
# m
FIND_LIBRARY( HAVE_LIBM "m" )
IF(HAVE_LIBM)
SET(M_LIBRARIES ${HAVE_LIBM})
SET(HAVE_LIBM 1)
ELSE(HAVE_LIBM)
SET(HAVE_LIBM 0)
ENDIF(HAVE_LIBM)
# crypt
FIND_LIBRARY( HAVE_LIBCRYPT "crypt" )
IF(HAVE_LIBCRYPT)
SET(CRYPT_LIBRARIES ${HAVE_LIBCRYPT})
SET(HAVE_LIBCRYPT 1)
ELSE(HAVE_LIBCRYPT)
SET(HAVE_LIBCRYPT 0)
ENDIF(HAVE_LIBCRYPT)
# nsl
FIND_LIBRARY( HAVE_LIBNSL "nsl" )
IF(HAVE_LIBNSL)
SET(HAVE_LIBNSL 1)
ELSE(HAVE_LIBNSL)
SET(HAVE_LIBNSL 0)
ENDIF(HAVE_LIBNSL)
# socket
FIND_LIBRARY( HAVE_LIBSOCKET "socket" )
IF(HAVE_LIBSOCKET)
SET(HAVE_LIBSOCKET 1)
ELSE(HAVE_LIBSOCKET)
SET(HAVE_LIBSOCKET 0)
ENDIF(HAVE_LIBSOCKET)
# cmpisfcc
IF(BUILD_LIBCIM)
FIND_LIBRARY( SFCC_LIBRARIES "cmpisfcc" REQUIRED )
ENDIF(BUILD_LIBCIM)
# Various include files
INCLUDE(CheckIncludeFile)
INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS( "alloca" HAVE_ALLOCA )
IF (NOT HAVE_ALLOCA)
SET(HAVE_ALLOCA 0)
SET(C_ALLOCA 0)
CHECK_INCLUDE_FILE( "alloca.h" HAVE_ALLOCA_H )
ELSE (NOT HAVE_ALLOCA)
SET(HAVE_ALLOCA 1)
SET(C_ALLOCA 1)
SET(HAVE_ALLOCA_H 0)
ENDIF (NOT HAVE_ALLOCA)
#
# The wsman_config file checks include file existance via "#if",
# requiring a 0/1 argument
# However CHECK_INCLUDE_FILE , returns ""/"1" resulting in
# an empty argument to "#if" in the 'false' case
# The code below ensures that "HAVE_xxx" is set to "0" or "1"
#
SET (FILES_TO_TEST "alloca.h" "crypt.h" "ctype.h" "dirent.h" "dlfcn.h" "ifaddrs.h" "inttypes.h" "memory.h" "netinet/in.h" "net/if_dl.h" "net/if.h" "pam/pam_appl.h" "pam/pam_misc.h" "pthread.h" "security/pam_appl.h" "security/pam_misc.h" "stdarg.h" "stdint.h" "stdlib.h" "strings.h" "string.h" "sys/ioctl.h" "sys/resource.h" "sys/select.h" "sys/sendfile.h" "sys/signal.h" "sys/socket.h" "sys/sockio.h" "sys/stat.h" "sys/types.h" "unistd.h" "vararg.h" )
FOREACH( FILE ${FILES_TO_TEST})
STRING(REGEX REPLACE "\\." "_" FILEDOT ${FILE})
STRING(REGEX REPLACE "/" "_" FILESLASH ${FILEDOT})
STRING(TOUPPER ${FILESLASH} UPNAME)
# MESSAGE(STATUS "Looking for ${FILE} as ${UPNAME}")
SET(HAVENAME "HAVE_${UPNAME}")
CHECK_INCLUDE_FILE( "${FILE}" HAVE_${FILE}_FILE )
IF(HAVE_${FILE}_FILE)
SET(${HAVENAME} 1)
ELSE(HAVE_${FILE}_FILE)
SET(${HAVENAME} 0)
ENDIF(HAVE_${FILE}_FILE)
ENDFOREACH( FILE ${FILES_TO_TEST})
IF(BUILD_CUNIT_TESTS)
CHECK_INCLUDE_FILE( "CUnit/Basic.h" HAVE_CUNIT_BASIC_H )
IF(HAVE_CUNIT_BASIC_H)
ELSE(HAVE_CUNIT_BASIC_H)
MESSAGE(FATAL_ERROR "Can't find CUnit/Basic.h - missing cunit-devel package ?")
ENDIF(HAVE_CUNIT_BASIC_H)
ENDIF(BUILD_CUNIT_TESTS)
#/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
CHECK_INCLUDE_FILE( "sys/time.h" TIME_WITH_SYS_TIME )
IF(NOT TIME_WITH_SYS_TIME)
SET(TIME_WITH_SYS_TIME 0)
ENDIF(NOT TIME_WITH_SYS_TIME)
#/* Define ssize_t to int' if <sys/types.h> does not define. */
SET(SSIZE_T_MISSING 0)
# library functions
CHECK_FUNCTION_EXISTS("getifaddrs" HAVE_GETIFADDRS)
#SIOCGIFHWADDR
#SIOCGARP
SET( CRAY_STACKSEG_END 0 )
#
# The wsman_config file checks functions existance via "#if",
# requiring a 0/1 argument
# CHECK_FUNCTION_EXISTS however, returns ""/"1" resulting in
# an empty argument to "#if" in the 'false' case
# The code below ensures that "HAVE_xxx" is set to "0" or "1"
#
SET (FUNCS_TO_TEST "bcopy" "crypt" "daemon" "fnmatch" "getaddrinfo" "getnameinfo" "getpid" "gettimeofday" "gmtime_r" "inet_aton" "inet_ntop" "inet_pton" "sleep" "srandom" "ssl" "strsep" "strtok_r" "syslog" "timegm" "memmove" "unlink" "va_copy" )
FOREACH( FUNC ${FUNCS_TO_TEST})
STRING(TOUPPER ${FUNC} UPNAME)
SET(HAVENAME "HAVE_${UPNAME}")
CHECK_FUNCTION_EXISTS( "${FUNC}" HAVE_FUNC )
IF(HAVE_FUNC)
SET(${HAVENAME} 1)
ELSE(HAVE_FUNC)
SET(${HAVENAME} 0)
ENDIF(HAVE_FUNC)
ENDFOREACH( FUNC ${FUNCS_TO_TEST})
# types
INCLUDE(CheckTypeSize)
SET( CMAKE_REQUIRED_IUNCLUDE "/usr/include/netinet" )
#
# The wsman_config file checks type existance via "#if",
# requiring a 0/1 argument
# CHECK_TYPE_SIZE however, returns ""/"1" resulting in
# an empty argument to "#if" in the 'false' case
# The code below ensures that "HAVE_xxx" is set to "0" or "1"
#
SET (TYPES_TO_TEST "in_addr_t" "in_port_t" "sa_family_t" "int" "long" "long long" "short")
FOREACH( TYPE ${TYPES_TO_TEST})
STRING(TOUPPER ${TYPE} UPNAME)
STRING(REGEX REPLACE " " "_" UPNAME ${UPNAME})
SET(HAVENAME "HAVE_${UPNAME}")
CHECK_TYPE_SIZE( "${TYPE}" HAVE_TYPE )
MESSAGE(STATUS "Check type ${TYPE} as ${HAVENAME}")
IF(HAVE_TYPE)
SET(${HAVENAME} 1)
ELSE(HAVE_TYPE)
SET(${HAVENAME} 0)
ENDIF(HAVE_TYPE)
ENDFOREACH( TYPE ${TYPES_TO_TEST})
INCLUDE(CheckStructHasMember)
# Check if struct sockaddr contains sa_len
CHECK_STRUCT_HAS_MEMBER("struct sockaddr" sa_len sys/socket.h HAVE_SA_LEN)
IF(HAVE_SA_LEN)
SET(HAVE_SA_LEN 1)
ELSE(HAVE_SA_LEN)
SET(HAVE_SA_LEN 0)
ENDIF(HAVE_SA_LEN)
IF (ENABLE_IPV6)
IF(NOT WIN32)
# Check if struct sockaddr_in6 contains sin6
CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_addr netinet/in.h HAVE_IPV6)
IF (HAVE_IPV6)
SET(ENABLE_IPV6 1)
ELSE (HAVE_IPV6)
MESSAGE( SEND_ERROR " IPv6 not supported by system, disabling" )
SET(ENABLE_IPV6 0)
ENDIF (HAVE_IPV6)
ENDIF(NOT WIN32)
ELSE (ENABLE_IPV6)
SET(ENABLE_IPV6 0)
ENDIF (ENABLE_IPV6)
#
#/* Define to 1 if you have the ANSI C header files. */
# STDC_HEADERS
SET(STDC_HEADERS 1)
####################################################################
# CONFIGURATION #
####################################################################
ADD_DEFINITIONS( -DHAVE_CONFIG_H )
SET(PACKAGE "openwsman")
SET(PACKAGE_BUGREPORT "\"www.openwsman.org\"")
SET(PACKAGE_NAME "\"${PACKAGE}\"")
SET(PACKAGE_STRING "\"WS-Management for all\"")
SET("prefix" ${CMAKE_INSTALL_PREFIX})
SET("includedir" ${CMAKE_INSTALL_PREFIX}/include)
SET("libdir" ${LIB_INSTALL_DIR})
# Library names !
SET(WSMAN_PKG wsman)
SET(WSMAN_SERVER_PKG wsman_server)
SET(WSMAN_CLIENT_PKG wsman_client)
SET(WSMAN_CLIENTPP_PKG wsman_clientpp)
IF(UNIX)
SET(WSMAN_CLIENT_TRANSPORT_PKG wsman_curl_client_transport)
ELSE(UNIX)
SET(WSMAN_CLIENT_TRANSPORT_PKG wsman_win_client_transport)
ENDIF(UNIX)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/wsman_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/wsman_config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openwsman.pc.in ${CMAKE_CURRENT_BINARY_DIR}/openwsman.pc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openwsman++.pc.in ${CMAKE_CURRENT_BINARY_DIR}/openwsman++.pc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openwsman-server.pc.in ${CMAKE_CURRENT_BINARY_DIR}/openwsman-server.pc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package/openwsman.spec.in ${CMAKE_CURRENT_BINARY_DIR}/package/openwsman.spec @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package/openwsman.service.in ${CMAKE_CURRENT_BINARY_DIR}/package/openwsman.service)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/openwsman.pc
${CMAKE_CURRENT_BINARY_DIR}/openwsman++.pc
${CMAKE_CURRENT_BINARY_DIR}/openwsman-server.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
OPTION(MSVC_STATIC_RUNTIME "Use multi-threaded statically-linked runtime library" NO)
IF(MSVC_STATIC_RUNTIME)
add_compile_options(/MT$<$<CONFIG:Debug>:d>)
ENDIF(MSVC_STATIC_RUNTIME)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(doc)
add_subdirectory(etc)
IF(BUILD_BINDINGS)
add_subdirectory(bindings)
ENDIF(BUILD_BINDINGS)
IF ( BUILD_TESTS )
add_subdirectory(tests)
ENDIF ( BUILD_TESTS )
IF ( BUILD_EXAMPLES )
add_subdirectory(examples)
ENDIF ( BUILD_EXAMPLES )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include )
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS /sdl /W3")
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS /sdl /W3")
else (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Woverloaded-virtual -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wunused -Werror" )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wunused -Werror" )
SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3" )
SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3" )
endif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
####################################################################
# PACKAGING #
####################################################################
SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Web Services for Management")
SET(CPACK_PACKAGE_VENDOR "openwsman.org")
SET(CPACK_PACKAGE_VERSION_MAJOR ${OPENWSMAN_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${OPENWSMAN_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${OPENWSMAN_PATCH})
SET(CPACK_GENERATOR "TBZ2")
SET(CPACK_SOURCE_GENERATOR "TBZ2")
SET(CPACK_PACKAGE_DIRECTORY "package")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
MESSAGE(STATUS "Package file ${CPACK_SOURCE_PACKAGE_FILE_NAME}")
# The following components are regex's to match anywhere (unless anchored)
# in absolute path + filename to find files or directories to be excluded
# from source tarball.
SET (CPACK_SOURCE_IGNORE_FILES
#git files
"/.git"
"\\\\.gitignore$"
#svn files
"\\\\.svn/"
"\\\\.cvsignore$"
# temporary files
"\\\\.swp$"
# backup files
"~$"
# eclipse files
"\\\\.cdtproject$"
"\\\\.cproject$"
"\\\\.project$"
"\\\\.settings/"
# others
"\\\\.#"
"/#"
"/build/"
"/_build/"
"/\\\\.git/"
# used before
"/CVS/"
"/\\\\.libs/"
"/\\\\.deps/"
"\\\\.o$"
"\\\\.lo$"
"\\\\.la$"
"Makefile\\\\.in$"
"Makefile$"
# autotool
"/m4/"
"autom4te.cache"
"config.log"
"./config.h"
"configure$"
"config.status"
"depcomp"
"config.guess"
"install.sh"
"libtool"
# generated
"\\\\.bz2$"
"\\\\.class$"
"/bindings/ruby/rdoc/"
)
INCLUDE(CPack)
####################################################################
SET( DOC_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
FORCE
)
IF(HAVE_WARNINGS)
MESSAGE(STATUS " ************ NOTE: ************")
MESSAGE(STATUS " Warnings occurred during cmake configuration... Please see output")
MESSAGE(STATUS " *******************************")
ENDIF(HAVE_WARNINGS)
####################################################################
# RPM SPEC #
####################################################################
SET( AUTOBUILD_COMMAND
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
COMMAND ${CMAKE_MAKE_PROGRAM} package_source
COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/openwsman-redhat-initscript.patch" "${CMAKE_BINARY_DIR}/package"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/openwsman.pam" "${CMAKE_BINARY_DIR}/package"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/openwsman.pam.rh" "${CMAKE_BINARY_DIR}/package"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/openwsman.rpmlintrc" "${CMAKE_BINARY_DIR}/package"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/openwsman.SuSEfirewall2" "${CMAKE_BINARY_DIR}/package"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/openwsman.firewalld" "${CMAKE_BINARY_DIR}/package"
)
ADD_CUSTOM_TARGET( srcpackage_local
${AUTOBUILD_COMMAND}
)
ADD_CUSTOM_TARGET( srcpackage
${AUTOBUILD_COMMAND}
)