forked from opencog/atomspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
602 lines (528 loc) · 20.9 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
#
# Master Opencog CMake file.
#
# General organization:
# -- check for different compilers, OS'es
# -- search for various required & optional libraries/tools
# -- decide what to build based on above results.
# -- configure various config files.
# -- print pretty summary
#
include(lib/Summary.cmake)
# Need to have cmake-2.8.8 in order to be able to check the compiler
# version.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
IF (COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0005 OLD)
ENDIF (COMMAND CMAKE_POLICY)
PROJECT(atomspace)
# To supress Cygwin warning "CMake no longer defines WIN32 on Cygwin!"
# Remove when CMake >= 2.8.4 is required to build the project
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
# uncomment to be in Release mode [default]
# SET(CMAKE_BUILD_TYPE Release)
# uncomment to build in debug mode
# SET(CMAKE_BUILD_TYPE Debug)
# uncomment to be in coverage testing mode
# SET(CMAKE_BUILD_TYPE Coverage)
# uncomment to build in profile mode
# SET(CMAKE_BUILD_TYPE Profile)
# uncomment to build in release mode with debug information
# SET(CMAKE_BUILD_TYPE RelWithDebInfo)
# default build type
IF (CMAKE_BUILD_TYPE STREQUAL "")
SET(CMAKE_BUILD_TYPE Release)
ENDIF (CMAKE_BUILD_TYPE STREQUAL "")
MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR=\\"${CMAKE_SOURCE_DIR}\\"
-DPROJECT_BINARY_DIR=\\"${CMAKE_BINARY_DIR}\\")
# add the 'lib' dir to cmake's module search path
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/lib/")
# ===============================================================
# Detect different compilers and OS'es, tweak flags as necessary.
IF (CMAKE_COMPILER_IS_GNUCXX)
# gcc before version 4.8 does not support the c++11 definition
# of thread_local.
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.0)
MESSAGE(FATAL_ERROR "GCC version must be at least 4.8.0!")
ENDIF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.0)
IF (APPLE)
SET(CMAKE_C_FLAGS "-Wall -Wno-long-long -Wno-conversion")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_C_FLAGS_PROFILE "-O0 -pg")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -g0")
# Vital to do this otherwise unresolved symbols everywhere:
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-flat_namespace,-undefined,dynamic_lookup")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-flat_namespace,-undefined,dynamic_lookup")
ELSE (APPLE)
SET(CMAKE_C_FLAGS "-Wall -fPIC")
# SET(CMAKE_C_FLAGS "-Wl,--copy-dt-needed-entries")
SET(CMAKE_C_FLAGS_DEBUG "-ggdb3 -fstack-protector")
SET(CMAKE_C_FLAGS_PROFILE "-O2 -g3 -fstack-protector -pg")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -g -fstack-protector")
ENDIF (APPLE)
# 1) -Wno-variadic-macros is to avoid warnings regarding using
# variadic in macro OC_ASSERT (the warning warns that this is only
# available from C99, lol!)
#
# 2) -fopenmp for multithreading support
#
# 3) -std=gnu++0x for C++0x and GNU extensions support
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wno-variadic-macros -fopenmp -std=gnu++0x")
SET(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
SET(CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
# Options for generating gcov code coverage output
SET(CMAKE_C_FLAGS_COVERAGE "-O0 -g -fprofile-arcs -ftest-coverage -fno-inline")
SET(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -fno-default-inline")
# Might be needed for some combinations of ln and gcc
IF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
LINK_LIBRARIES(gcov)
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
ENDIF (CMAKE_COMPILER_IS_GNUCXX)
# Do the windows build
IF (WIN32)
ADD_DEFINITIONS(-DWIN32)
IF (CYGWIN)
ADD_DEFINITIONS(-DCYGWIN)
# SET(WIN32 1)
ENDIF (CYGWIN)
# It is "not unix" when the code is compiled under windows but not
# under cygwin
IF (NOT UNIX)
ADD_DEFINITIONS(-DWIN32_NOT_UNIX)
FIND_PACKAGE(PThreads REQUIRED)
FIND_PACKAGE(STLPort REQUIRED)
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include/win32" ${PTHREADS_INCLUDE_DIR} ${STLPORT_INCLUDE_DIR})
LINK_LIBRARIES(${PTHREADS_LIBRARY} ${STLPORT_LIBRARIES})
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
ELSE (NOT UNIX)
LINK_LIBRARIES(pthread)
IF (CYGWIN)
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl")
ELSE (CYGWIN)
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-new-dtags")
ENDIF (CYGWIN)
ENDIF (NOT UNIX)
ENDIF (WIN32)
# ===================================================================
# Check for existance of various required, optional packages.
# Check for boost. We need dynamic-linked, threaded libs by default.
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREADED ON)
# Required boost packages
# hypertable requires boost iostreams
# boost-1.49 no longer has a libboost_iostreams
# 1.46 is minimum for required filesystem support
# program_options needed by some combo utilities
FIND_PACKAGE(Boost 1.46 COMPONENTS date_time filesystem program_options regex serialization system thread REQUIRED)
IF(Boost_FOUND)
SET(Boost_FOUND_SAVE 1)
# Boost.Signals2 requires this in signal_type.hpp
SET(BOOST_PARAMETER_MAX_ARITY 7)
ADD_DEFINITIONS(-DBOOST_PARAMETER_MAX_ARITY=${BOOST_PARAMETER_MAX_ARITY})
ELSE(Boost_FOUND)
MESSAGE(FATAL_ERROR "Boost 1.46 or newer is needed to build OpenCog!")
ENDIF(Boost_FOUND)
# Opencog won't compile with Boost 1.51, some kind of conflict with
# hash functions, see github bugs 1 and 36
IF(105100 EQUAL ${Boost_VERSION})
MESSAGE(FATAL_ERROR "Boost version 1.51 will not work with OpenCog. Please use a different version.")
ENDIF(105100 EQUAL ${Boost_VERSION})
MESSAGE(STATUS "Boost version ${Boost_VERSION} found.")
# Optional boost packages; can build without these.
FIND_PACKAGE(Boost 1.46 COMPONENTS python program_options QUIET)
FIND_PACKAGE(Boost 1.46 COMPONENTS math_c99 QUIET)
# Arghhh. Except cmake is treating above as required, not optional. #$%**&
IF(Boost_FOUND_SAVE)
SET(Boost_FOUND 1)
ENDIF(Boost_FOUND_SAVE)
# Cogutils
FIND_PACKAGE(CogUtil)
IF (COGUTIL_FOUND)
MESSAGE(STATUS "CogUtil found.")
ADD_DEFINITIONS(-DHAVE_COGUTIL)
SET(HAVE_COGUTIL 1)
ELSE (COGUTIL_FOUND)
MESSAGE(FATAL_ERROR "CogUtil missing: it is needed for everything!")
ENDIF (COGUTIL_FOUND)
FIND_PACKAGE(Cxxtest)
IF (CXXTEST_FOUND)
MESSAGE(STATUS "CxxTest found.")
ELSE (CXXTEST_FOUND)
MESSAGE(STATUS "CxxTest missing: needed for unit tests.")
ENDIF (CXXTEST_FOUND)
FIND_PACKAGE(LibGearman)
ADD_DEFINITIONS(-DHAVE_GEARMAN)
IF(GEARMAN_FOUND)
SET(HAVE_GEARMAN 1)
SET(GEARMAN_DIR_MESSAGE "Gearman found.")
ELSE (GEARMAN_FOUND)
SET(HAVE_GEARMAN 0)
SET(GEARMAN_DIR_MESSAGE "Gearman not found.")
ENDIF(GEARMAN_FOUND)
MESSAGE(STATUS "${GEARMAN_DIR_MESSAGE}")
# Gnu Scientific Library
FIND_PACKAGE(GSL)
IF (GSL_FOUND)
MESSAGE(STATUS "GSL found.")
ADD_DEFINITIONS(-DHAVE_GSL)
SET(HAVE_GSL 1)
ELSE (GSL_FOUND)
MESSAGE(STATUS "GSL missing: needed for the AtomSpace.")
ENDIF (GSL_FOUND)
# This is required for Guile
FIND_LIBRARY(GMP_LIBRARY gmp)
FIND_PATH(GMP_INCLUDE_DIR gmp.h)
# Gnu Guile scheme interpreter
# Version 2.0.9 is needed for mrs io ports, compilation, etc.
FIND_PACKAGE(Guile 2.0.9)
IF (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR)
ADD_DEFINITIONS(-DHAVE_GUILE)
SET(HAVE_GUILE 1)
INCLUDE_DIRECTORIES(${GUILE_INCLUDE_DIR})
ELSE (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR)
SET(GUILE_DIR_MESSAGE "Guile was not found; the scheme shell will not be built.\nTo over-ride, make sure GUILE_LIBRARIES and GUILE_INCLUDE_DIRS are set.")
MESSAGE(STATUS "${GUILE_DIR_MESSAGE}")
ENDIF (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR)
# Hypertable library, for atomspace persistence
FIND_PACKAGE(HyperTable)
IF (HYPERTABLE_FOUND)
ADD_DEFINITIONS(-DHAVE_HYPERTABLE)
SET(HAVE_HYPERTABLE 1)
MESSAGE(STATUS "Hypertable was found.")
# Don't bother looking for SIGAR unlesss hyperable was found.
FIND_PACKAGE(SIGAR)
IF (SIGAR_FOUND)
ELSE (SIGAR_FOUND)
MESSAGE(WARNING "SIGAR was not found! It is needed for Hypertable support.")
ENDIF (SIGAR_FOUND)
ELSE (HYPERTABLE_FOUND)
# The FindHypertable.cmake file already prints a message.
# MESSAGE(STATUS "Hypertable was not found; hypertable support will not be built.\n To over-ride, make sure HYPERTABLE_LIBRARIES and HYPERTABLE_INCLUDE_DIRS\n are set.")
MESSAGE(STATUS "Hypertable not found; the experimental distributed persistence DB needs it.")
ENDIF (HYPERTABLE_FOUND)
# At this time, there is no reason to build with memcached for
# FIND_PACKAGE(LibMemCached)
# Google Protobuf library
# The protocol buffer compiler is a separately installable package, and
# it is also needed for building embodiment PAI. So check for that, too.
FIND_PACKAGE(Protobuf)
IF (PROTOBUF_FOUND
AND PROTOBUF_LIBRARY
AND PROTOBUF_INCLUDE_DIR
AND PROTOBUF_PROTOC_EXECUTABLE)
ADD_DEFINITIONS(-DHAVE_PROTOBUF)
SET(HAVE_PROTOBUF 1)
SET(PROTOBUF_DIR_MESSAGE "Protobuf was found.")
ELSE (PROTOBUF_FOUND
AND PROTOBUF_LIBRARY
AND PROTOBUF_INCLUDE_DIR
AND PROTOBUF_PROTOC_EXECUTABLE)
# If we are here, then we are missing either the libraries, or the
# compiler. React appropriately.
IF (PROTOBUF_PROTOC_EXECUTABLE)
SET(PROTOBUF_DIR_MESSAGE "Protobuf was not found; the new message decoding functions would not work.\n To over-ride, make sure PROTOBUF_LIBRARIES and PROTOBUF_INCLUDE_DIRS are set.")
ELSE (PROTOBUF_PROTOC_EXECUTABLE)
SET(PROTOBUF_DIR_MESSAGE "Protobuf compiler was not found; embodiment PAI can't be built without it.\n To over-ride, make sure PROTOBUF_PROTOC_EXECUTABLE is set.")
ENDIF (PROTOBUF_PROTOC_EXECUTABLE)
ENDIF (PROTOBUF_FOUND
AND PROTOBUF_LIBRARY
AND PROTOBUF_INCLUDE_DIR
AND PROTOBUF_PROTOC_EXECUTABLE)
MESSAGE(STATUS "${PROTOBUF_DIR_MESSAGE}")
# Python needed for PLN !???
FIND_PACKAGE(PythonInterp)
FIND_PACKAGE(PythonLibs 2.7)
IF(PYTHONLIBS_FOUND)
MESSAGE(STATUS "Python libs found.")
ELSE(PYTHONLIBS_FOUND)
MESSAGE(STATUS "Python libs NOT found.")
ENDIF(PYTHONLIBS_FOUND)
# Python bindings using Cython
# Cython is used to generate bindings
FIND_PACKAGE(Cython 0.19.0)
IF (CYTHON_FOUND AND PYTHONLIBS_FOUND)
# find python destination dir for python bindings
ADD_DEFINITIONS(-DHAVE_CYTHON)
SET(HAVE_CYTHON 1)
EXECUTE_PROCESS(
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *;print(get_python_lib())"
OUTPUT_VARIABLE PYTHON_DEST
)
# replace new line at end
STRING(REPLACE "\n" "" PYTHON_DEST "${PYTHON_DEST}")
IF ("${PYTHON_DEST}" STREQUAL "")
MESSAGE(FATAL_ERROR "Python destination dir not found")
ELSE ("${PYTHON_DEST}" STREQUAL "")
MESSAGE(STATUS "Python destination dir found: ${PYTHON_DEST}" )
ENDIF ("${PYTHON_DEST}" STREQUAL "")
ELSE (CYTHON_FOUND AND PYTHONLIBS_FOUND)
IF(NOT CYTHON_FOUND)
MESSAGE(STATUS "Cython executable not found.")
ENDIF(NOT CYTHON_FOUND)
ENDIF (CYTHON_FOUND AND PYTHONLIBS_FOUND)
# Nosetests will find and automatically run python tests.
FIND_PROGRAM(NOSETESTS_EXECUTABLE nosetests)
IF (NOSETESTS_EXECUTABLE AND CYTHON_FOUND AND PYTHONLIBS_FOUND)
SET(HAVE_NOSETESTS 1)
ENDIF (NOSETESTS_EXECUTABLE AND CYTHON_FOUND AND PYTHONLIBS_FOUND)
# Glasgow Haskell compiler
FIND_PACKAGE(Stack)
IF (STACK_FOUND)
ADD_DEFINITIONS(-DHAVE_STACK)
SET(HAVE_STACK 1)
ENDIF (STACK_FOUND)
FIND_PACKAGE(UnixODBC QUIET)
IF (UnixODBC_FOUND)
ADD_DEFINITIONS(-DHAVE_SQL_STORAGE)
SET(HAVE_SQL_STORAGE 1)
SET(ODBC_FOUND 1)
SET(ODBC_INCLUDE_DIRS ${UnixODBC_INCLUDE_DIRS})
SET(ODBC_LIBRARIES ${UnixODBC_LIBRARIES})
SET(ODBC_DIR_MESSAGE "UnixODBC was found.")
ELSE (UnixODBC_FOUND)
SET(ODBC_FOUND 0)
SET(ODBC_DIR_MESSAGE "UnixODBC was not found; persistence subsystem will not be built.\nTo over-ride, make sure UnixODBC_LIBRARIES and UnixODBC_INCLUDE_DIRS are set.")
ENDIF (UnixODBC_FOUND)
MESSAGE(STATUS "${ODBC_DIR_MESSAGE}")
# Optional, currently needed only to hush up DRD in util/Logger.cc
FIND_PACKAGE(VALGRIND)
IF (VALGRIND_FOUND)
MESSAGE(STATUS "VALGRIND was found.")
IF (VALGRIND_INCLUDE_DIR)
MESSAGE(STATUS "VALGRIND devel headers found.")
ADD_DEFINITIONS(-DHAVE_VALGRIND)
ELSE (VALGRIND_INCLUDE_DIR)
MESSAGE(STATUS "VALGRIND devel headers NOT FOUND: needed for thread debugging.")
ENDIF (VALGRIND_INCLUDE_DIR)
ELSE (VALGRIND_FOUND)
MESSAGE(STATUS "VALGRIND missing: needed for thread debugging.")
ENDIF (VALGRIND_FOUND)
# ZeroMQ
FIND_PACKAGE(ZMQ 3.2.4)
IF (ZMQPP_FOUND AND ZMQ_LIBRARY)
ADD_DEFINITIONS(-DHAVE_ZMQLIB)
SET(HAVE_ZMQLIB 1)
SET(ZMQ_DIR_MESSAGE "ZeroMQ was found.")
ELSE (ZMQPP_FOUND AND ZMQ_LIBRARY)
SET(ZMQ_DIR_MESSAGE "ZeroMQ library or its C++ header file was not found; \nTo over-ride, make sure that the environment variable ZMQ_LIBRARY is set.\nInstallation instructions: http://zeromq.org/intro:get-the-software")
ENDIF (ZMQPP_FOUND AND ZMQ_LIBRARY)
MESSAGE(STATUS "${ZMQ_DIR_MESSAGE}")
# ==========================================================
# Decide what to build, based on the packages found.
IF(GSL_FOUND AND HAVE_COGUTIL)
SET(HAVE_ATOMSPACE 1)
ENDIF(GSL_FOUND AND HAVE_COGUTIL)
IF(HAVE_ATOMSPACE AND ODBC_FOUND) # SQL persistance
SET(HAVE_PERSIST 1)
ENDIF(HAVE_ATOMSPACE AND ODBC_FOUND)
# Both protobuf and also zmq are needed to build ZMQ API.
IF(HAVE_PROTOBUF AND HAVE_ZMQLIB)
SET(HAVE_ZMQ 1)
ENDIF(HAVE_PROTOBUF AND HAVE_ZMQLIB)
# At this time, there is no reason to build with memcached for
# any "normal" use, so just stub it out.
# IF (LIBMEMCACHED_FOUND)
# ADD_DEFINITIONS(-DHAVE_LIBMEMCACHED)
# ENDIF (LIBMEMCACHED_FOUND)
# ===================================================================
# global includes
# set confdir and datadir
IF (NOT DEFINED CONFDIR)
SET (CONFDIR "${CMAKE_INSTALL_PREFIX}/etc")
ENDIF (NOT DEFINED CONFDIR)
IF (NOT DEFINED DATADIR)
SET (DATADIR "${CMAKE_INSTALL_PREFIX}/share/opencog")
ENDIF (NOT DEFINED DATADIR)
ADD_DEFINITIONS(-DCONFDIR=\\"${CONFDIR}\\")
ADD_DEFINITIONS(-DDATADIR=\\"${DATADIR}\\")
# (re?)define MAN_INSTALL_DIR
SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
# include custom opencog cmake macros
INCLUDE("${CMAKE_SOURCE_DIR}/lib/OpenCogMacros.cmake")
# small hack to handle unixes that use "/usr/lib64" instead of "/usr/lib" as the
# default lib path on 64 bit archs
IF (NOT DEFINED LIB_DIR_SUFFIX)
EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -print-search-dirs OUTPUT_VARIABLE PRINT_SEARCH_DIRS_OUTPUT)
STRING(REGEX MATCH "\r?\nlibraries:.*\r?\n" COMPILER_LIB_SEARCH_DIRS ${PRINT_SEARCH_DIRS_OUTPUT})
IF (NOT ${COMPILER_LIB_SEARCH_DIRS} STREQUAL "")
STRING(REGEX MATCH "/lib64/:|/lib64:|/lib64\n" HAS_LIB64 ${COMPILER_LIB_SEARCH_DIRS})
IF (NOT ${HAS_LIB64} STREQUAL "")
SET(LIB_DIR_SUFFIX "64")
ENDIF (NOT ${HAS_LIB64} STREQUAL "")
ENDIF (NOT ${COMPILER_LIB_SEARCH_DIRS} STREQUAL "")
ENDIF (NOT DEFINED LIB_DIR_SUFFIX)
# set default include paths
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR} ${Boost_INCLUDE_DIRS} ${COGUTIL_INCLUDE_DIR})
# rpath handling
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/opencog")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(opencog)
IF (CXXTEST_FOUND)
ADD_CUSTOM_TARGET(tests)
ADD_SUBDIRECTORY(tests EXCLUDE_FROM_ALL)
IF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
# doing coverage stuff while running tests if this is the Coverage build
ADD_CUSTOM_TARGET(test
# TODO lcov should be found by cmake first
# TODO set it up so that we can pick to run coverage per test, or
# combined across all tests (the latter is MUCH faster). Use a define?
# There is coverage specific stuff in AddCxxTest.cmake now...
# -
# Depends on cogserver because RESTFulTest needs it
# and cmake has no way to add non-test dependencies to tests
DEPENDS tests cogserver
WORKING_DIRECTORY tests
COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process $(ARGS)
# This script combines the coverage analysis of each test,
# then creates html in tests/lcov
# Note: this should now be run separately...
#COMMAND ${PROJECT_SOURCE_DIR}/scripts/combine_lcov.sh
COMMENT "Running tests with coverage..."
)
ELSE (CMAKE_BUILD_TYPE STREQUAL "Coverage")
# If this is a build with coverage enabled then test normally
ADD_CUSTOM_TARGET(test
DEPENDS tests
WORKING_DIRECTORY tests
COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process $(ARGS)
COMMENT "Running tests..."
)
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
ADD_CUSTOM_TARGET(test_python
DEPENDS PythonModuleUTest PyEvalUTest PythonEvalUTest CogServerUTest
PythonUtilitiesUTest
bindlink_cython atomspace_cython
scheme_wrapper logger_cython utilities_cython
WORKING_DIRECTORY tests/cython
COMMAND ${CMAKE_CTEST_COMMAND} $(ARGS)
COMMENT "Running Python and Cython tests..."
)
ADD_CUSTOM_TARGET(test_query
DEPENDS tests/query
# ../reasoning/RuleEngine/RuleUTest
# ../reasoning/RuleEngine/ForwardChainerUTest
# ../nlp/sureal/SuRealUTest
# ../nlp/microplanning/MicroplanningUTest
WORKING_DIRECTORY tests/query
COMMAND ${CMAKE_CTEST_COMMAND} $(ARGS)
COMMENT "Running pattern matcher tests..."
)
ENDIF (CXXTEST_FOUND)
ADD_SUBDIRECTORY(examples EXCLUDE_FROM_ALL)
IF (NOT WIN32)
ADD_CUSTOM_TARGET (examples
# using CMAKE_BUILD_TOOL results in teh cryptic error message
# warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
# This is because make doesn't know how to pass jobserver args to
# the submake. So, instead, just use $(MAKE) (with round parens)
# -- that will do the right thing.
# COMMAND ${CMAKE_BUILD_TOOL}
COMMAND $(MAKE)
WORKING_DIRECTORY examples
COMMENT "Building examples"
)
ENDIF (NOT WIN32)
ADD_CUSTOM_TARGET(cscope
COMMAND find opencog examples tests -name '*.cc' -o -name '*.h' -o -name '*.cxxtest' -o -name '*.scm' > ${CMAKE_SOURCE_DIR}/cscope.files
COMMAND cscope -b
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating CScope database"
)
# packaging
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Open Cognition Framework")
SET(CPACK_PACKAGE_NAME "opencog")
SET(CPACK_PACKAGE_VENDOR "opencog.org")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
SET(CPACK_PACKAGE_VERSION_MINOR "1")
SET(CPACK_PACKAGE_VERSION_PATCH "4")
SET(CPACK_BINARY_STGZ "OFF")
SET(CPACK_BINARY_TBZ2 "OFF")
SET(CPACK_BINARY_TGZ "OFF")
SET(CPACK_BINARY_TZ "OFF")
SET(CPACK_SOURCE_STGZ "OFF")
SET(CPACK_SOURCE_TBZ2 "ON")
SET(CPACK_SOURCE_TGZ "OFF")
SET(CPACK_SOURCE_TZ "OFF")
SET(CPACK_GENERATOR "TBZ2")
SET(CPACK_SOURCE_GENERATOR "TBZ2")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}")
SET(CPACK_SOURCE_IGNORE_FILES
"~$"
".a$"
".so$"
".log$"
".tar.z$"
".tar.gz$"
".tar.bz2$"
"/Makefile$"
"/CMakeFiles/"
"/CMakeCache.txt$"
"/DartTestfile.txt$"
"/cmake_install.cmake$"
"/Testfile.cmake$"
"/CTestTestfile.cmake$"
"/CTestTestfile.cmake$"
"UTest$"
"UTest.cpp$"
"/_CPack_Packages/"
"/CPackConfig.cmake$"
"/CPackSourceConfig.cmake$"
"/sniff$"
"/install_manifest.txt$"
"${CPACK_PACKAGE_FILE_NAME}"
"^${PROJECT_SOURCE_DIR}/debian/"
"^${PROJECT_SOURCE_DIR}/.*spec$"
"^${PROJECT_SOURCE_DIR}/vendor/"
"^${PROJECT_SOURCE_DIR}/.bzr/"
"^${PROJECT_SOURCE_DIR}/.bzrignore$"
"^${PROJECT_SOURCE_DIR}/.git/"
"^${PROJECT_BINARY_DIR}/opencog/server/cogserver$"
"^${PROJECT_BINARY_DIR}/examples/server/derivedserver$"
"^${PROJECT_BINARY_DIR}/examples/hopfield/hopfield$"
)
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
IF (WIN32)
# Its "not unix" is cygwin is being used.
IF (NOT UNIX)
# There is a bug in NSI that does not handle full unix paths
# properly. Make sure there is at least one set of four (4)
# backslashes.
SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}\\\\lib\\\\opencog.ico")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\cogserver.exe")
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} The Open Cognition Framework")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.opencog.org")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.opencog.org")
SET(CPACK_NSIS_CONTACT "[email protected]")
SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(NOT UNIX)
SET(CPACK_STRIP_FILES "bin/cogserver")
SET(CPACK_SOURCE_STRIP_FILES "")
ENDIF(NOT UNIX)
ENDIF(WIN32)
SET(CPACK_PACKAGE_EXECUTABLES "cogserver" "The Open Cognition Framework")
INCLUDE(CPack)
# documentation
FIND_PACKAGE(Doxygen)
ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
# Show a summary of what we got
SUMMARY_ADD("AtomSpace" "A weighted and typed hypergraph database" HAVE_ATOMSPACE)
SUMMARY_ADD("Doxygen" "Code documentation" DOXYGEN_FOUND)
SUMMARY_ADD("Gearman" "Distributed processing capability" HAVE_GEARMAN)
SUMMARY_ADD("Haskell bindings" "Haskell bindings" HAVE_STACK)
SUMMARY_ADD("Hypertable" "HyperTable for scalable persistance (experimental)" HAVE_HYPERTABLE)
SUMMARY_ADD("Python bindings" "Python (cython) bindings" HAVE_CYTHON)
SUMMARY_ADD("Python tests" "Python bindings nose tests" HAVE_NOSETESTS)
SUMMARY_ADD("Scheme bindings" "Scheme bindings and shell" HAVE_GUILE)
SUMMARY_ADD("SQL persistance" "Save/Restore of AtomSpace to database" HAVE_PERSIST)
SUMMARY_ADD("ZeroMQ persistence" "Save/Restore of AtomSpace to ZeroMQ server" HAVE_ZMQ)
SUMMARY_ADD("Unit tests" "Unit tests" CXXTEST_FOUND)
SUMMARY_SHOW()