Skip to content

Commit 5013417

Browse files
committed
Initial commit
0 parents  commit 5013417

File tree

3 files changed

+942
-0
lines changed

3 files changed

+942
-0
lines changed

CMakeLists.txt

+246
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
#
2+
# Master AtomSpace RocksDB Backend CMake file.
3+
#
4+
# General organization:
5+
# -- check for different compilers, OS'es
6+
# -- search for various required & optional libraries/tools
7+
# -- decide what to build based on above results.
8+
# -- configure various config files.
9+
# -- print pretty summary
10+
#
11+
12+
# cogutils already requires 2.8.12.2, so may as well ask for that.
13+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.2)
14+
IF (COMMAND CMAKE_POLICY)
15+
CMAKE_POLICY(SET CMP0003 NEW)
16+
ENDIF (COMMAND CMAKE_POLICY)
17+
18+
IF(CMAKE_VERSION VERSION_GREATER 3.0.2)
19+
CMAKE_POLICY(SET CMP0037 OLD)
20+
ENDIF(CMAKE_VERSION VERSION_GREATER 3.0.2)
21+
22+
PROJECT(atomspace-rocks)
23+
24+
# ----------------------------------------------------------
25+
# User-modifiable options. Feel free to change these!
26+
#
27+
# uncomment to be in Release mode [default]
28+
# SET(CMAKE_BUILD_TYPE Release)
29+
30+
# uncomment to build in debug mode
31+
# SET(CMAKE_BUILD_TYPE Debug)
32+
33+
# uncomment to be in coverage testing mode
34+
# SET(CMAKE_BUILD_TYPE Coverage)
35+
36+
# uncomment to build in profile mode
37+
# SET(CMAKE_BUILD_TYPE Profile)
38+
39+
# uncomment to build in release mode with debug information
40+
# SET(CMAKE_BUILD_TYPE RelWithDebInfo)
41+
42+
# default build type
43+
IF (CMAKE_BUILD_TYPE STREQUAL "")
44+
SET(CMAKE_BUILD_TYPE Release)
45+
ENDIF (CMAKE_BUILD_TYPE STREQUAL "")
46+
47+
MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
48+
49+
ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
50+
-DPROJECT_BINARY_DIR="${CMAKE_BINARY_DIR}")
51+
52+
# ===============================================================
53+
# Check for existance of various required, optional packages.
54+
# Listed in alphabetical order, more or less.
55+
# CogUtil must come first, because it supplies various FindXXX macros.
56+
57+
# Add the 'lib' dir to cmake's module search path
58+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/lib/")
59+
60+
# Cogutil
61+
FIND_PACKAGE(CogUtil 2.0.1 CONFIG REQUIRED)
62+
IF (COGUTIL_FOUND)
63+
MESSAGE(STATUS "CogUtil found.")
64+
ADD_DEFINITIONS(-DHAVE_COGUTIL)
65+
SET(HAVE_COGUTIL 1)
66+
ELSE (COGUTIL_FOUND)
67+
MESSAGE(FATAL_ERROR "CogUtil missing: it is needed!")
68+
ENDIF (COGUTIL_FOUND)
69+
70+
# add the 'cmake' directory from cogutil to search path
71+
list(APPEND CMAKE_MODULE_PATH ${COGUTIL_DATA_DIR}/cmake)
72+
73+
include(${COGUTIL_DATA_DIR}/cmake/OpenCogGccOptions.cmake)
74+
include(${COGUTIL_DATA_DIR}/cmake/OpenCogLibOptions.cmake)
75+
include(${COGUTIL_DATA_DIR}/cmake/OpenCogInstallOptions.cmake)
76+
include(${COGUTIL_DATA_DIR}/cmake/Summary.cmake)
77+
78+
# ===================================================================
79+
# Check for existance of various required, optional packages.
80+
81+
# AtomSpace
82+
FIND_PACKAGE(AtomSpace 5.0.3 CONFIG REQUIRED)
83+
IF (ATOMSPACE_FOUND)
84+
MESSAGE(STATUS "AtomSpace found.")
85+
ADD_DEFINITIONS(-DHAVE_ATOMSPACE)
86+
SET(HAVE_ATOMSPACE 1)
87+
ELSE (ATOMSPACE_FOUND)
88+
MESSAGE(FATAL_ERROR "AtomSpace missing: it is needed!")
89+
ENDIF (ATOMSPACE_FOUND)
90+
91+
# CogServer
92+
FIND_PACKAGE(CogServer 1.0.0 CONFIG)
93+
IF (COGSERVER_FOUND)
94+
MESSAGE(STATUS "CogServer found.")
95+
ADD_DEFINITIONS(-DHAVE_SERVER)
96+
SET(HAVE_SERVER 1)
97+
ELSE (COGSERVER_FOUND)
98+
MESSAGE(STATUS "CogServer was not found.")
99+
ENDIF (COGSERVER_FOUND)
100+
101+
# ----------------------------------------------------------
102+
# Needed for unit tests
103+
104+
FIND_PACKAGE(Cxxtest)
105+
IF (NOT CXXTEST_FOUND)
106+
MESSAGE(STATUS "CxxTest missing: needed for unit tests.")
107+
ENDIF (NOT CXXTEST_FOUND)
108+
109+
# ----------------------------------------------------------
110+
# Guile Python and Cython
111+
112+
include(OpenCogFindGuile)
113+
# include(OpenCogFindPython)
114+
115+
# ----------------------------------------------------------
116+
# Optional, currently needed only to hush up DRD in util/Logger.cc
117+
FIND_PACKAGE(VALGRIND)
118+
IF (VALGRIND_FOUND)
119+
MESSAGE(STATUS "VALGRIND was found.")
120+
IF (VALGRIND_INCLUDE_DIR)
121+
MESSAGE(STATUS "VALGRIND devel headers found.")
122+
ADD_DEFINITIONS(-DHAVE_VALGRIND)
123+
ELSE (VALGRIND_INCLUDE_DIR)
124+
MESSAGE(STATUS "VALGRIND devel headers NOT FOUND: needed for thread debugging.")
125+
ENDIF (VALGRIND_INCLUDE_DIR)
126+
ELSE (VALGRIND_FOUND)
127+
MESSAGE(STATUS "VALGRIND missing: needed for thread debugging.")
128+
ENDIF (VALGRIND_FOUND)
129+
130+
# ===================================================================
131+
# Include configuration.
132+
133+
# Set default include paths.
134+
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}
135+
${COGUTIL_INCLUDE_DIR} ${ATOMSPACE_INCLUDE_DIR})
136+
137+
# Macros that define how atom types get declared.
138+
IF (NOT DEFINED ATOMSPACE_DATA_DIR)
139+
SET (ATOMSPACE_DATA_DIR "${COGUTIL_DATA_DIR}")
140+
ENDIF (NOT DEFINED ATOMSPACE_DATA_DIR)
141+
142+
INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogMacros.cmake")
143+
INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogGuile.cmake")
144+
# INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogCython.cmake")
145+
146+
# ==========================================================
147+
# Decide what to build, based on the packages found.
148+
149+
ADD_SUBDIRECTORY(opencog)
150+
151+
IF (CXXTEST_FOUND)
152+
ADD_CUSTOM_TARGET(tests)
153+
ADD_SUBDIRECTORY(tests EXCLUDE_FROM_ALL)
154+
IF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
155+
# doing coverage stuff while running tests if this is the Coverage build
156+
ADD_CUSTOM_TARGET(test
157+
# TODO lcov should be found by cmake first
158+
# TODO set it up so that we can pick to run coverage per test, or
159+
# combined across all tests (the latter is MUCH faster). Use a define?
160+
# There is coverage specific stuff in AddCxxTest.cmake now...
161+
WORKING_DIRECTORY tests
162+
COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure $(ARGS)
163+
164+
# This script combines the coverage analysis of each test,
165+
# then creates html in tests/lcov
166+
# Note: this should now be run separately...
167+
#COMMAND ${PROJECT_SOURCE_DIR}/scripts/combine_lcov.sh
168+
COMMENT "Running tests with coverage..."
169+
)
170+
ELSE (CMAKE_BUILD_TYPE STREQUAL "Coverage")
171+
# If this is a build with coverage enabled then test normally
172+
ADD_CUSTOM_TARGET(test
173+
DEPENDS tests
174+
WORKING_DIRECTORY tests
175+
COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure $(ARGS)
176+
COMMENT "Running tests..."
177+
)
178+
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
179+
ENDIF (CXXTEST_FOUND)
180+
181+
ADD_CUSTOM_TARGET(cscope
182+
COMMAND find opencog examples tests -name '*.cc' -o -name '*.h' -o -name '*.cxxtest' -o -name '*.scm' > ${CMAKE_SOURCE_DIR}/cscope.files
183+
COMMAND cscope -b
184+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
185+
COMMENT "Generating CScope database"
186+
)
187+
188+
# ===================================================================
189+
# Packaging
190+
## Architecture the package is for.
191+
## TODO: Will give error on non debian distros, fix it.
192+
EXECUTE_PROCESS(COMMAND dpkg --print-architecture
193+
OUTPUT_VARIABLE PACKAGE_ARCHITECTURE
194+
OUTPUT_STRIP_TRAILING_WHITESPACE)
195+
STRING(TIMESTAMP UTC_DATE %Y%m%d UTC)
196+
# If 'sudo make install' is run before 'make package', then install_manifest.txt
197+
# will be owned by root. Creating the file during configuration stage ensures
198+
# that it is owned by the builder thus avoiding 'Permission denied' error when
199+
# packaging.
200+
FILE(WRITE "${PROJECT_BINARY_DIR}/install_manifest.txt")
201+
## It doesn't have a header-file declaring the version similar to cogutil and
202+
## atomspace.
203+
SET(SEMANTIC_VERSION 0.1.4)
204+
205+
## Cpack configuration
206+
SET(CPACK_GENERATOR "DEB")
207+
SET(CPACK_PACKAGE_CONTACT "opencog@googlegroups.com")
208+
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
209+
SET(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages")
210+
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The AtomSpace Cogserver Client")
211+
SET(CPACK_PACKAGE_NAME "atomspace-cog-dev")
212+
SET(CPACK_PACKAGE_VENDOR "opencog.org")
213+
SET(CPACK_PACKAGE_VERSION "${SEMANTIC_VERSION}-${UTC_DATE}")
214+
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
215+
SET(CPACK_PACKAGE_FILE_NAME
216+
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${PACKAGE_ARCHITECTURE}")
217+
SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
218+
SET(CPACK_PACKAGE_EXECUTABLES "cogserver" "The AtomSpace Cogserver Client")
219+
220+
## Debian specific configurations
221+
SET(DEPENDENCY_LIST
222+
"guile-2.2-dev (>= 2.2.2)"
223+
"libstdc++6 (>= 4.7)"
224+
"libcogutil-dev (>= 2.0.2)"
225+
"atomspace-dev (>= 5.0.3)"
226+
)
227+
228+
STRING(REPLACE ";" ", " MAIN_DEPENDENCIES "${DEPENDENCY_LIST}")
229+
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${MAIN_DEPENDENCIES}")
230+
SET(CPACK_DEBIAN_PACKAGE_SECTION "libdevel")
231+
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://opencog.org")
232+
INCLUDE(CPack)
233+
234+
# ===================================================================
235+
# documentation
236+
FIND_PACKAGE(Doxygen)
237+
# ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
238+
239+
# ===================================================================
240+
# Show a summary of what we found, what we will do.
241+
242+
SUMMARY_ADD("AtomSpace-Rocks" "AtomSpace RocksDB Backend" HAVE_ATOMSPACE)
243+
SUMMARY_ADD("Doxygen" "Code documentation" DOXYGEN_FOUND)
244+
SUMMARY_ADD("Unit tests" "Unit tests" CXXTEST_FOUND)
245+
246+
SUMMARY_SHOW()

0 commit comments

Comments
 (0)