OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-matrix commits / b5d739e

Start porting the CMakefiles
b5d739eca0b481252a314b1ec9c97de8e0101a01
by Linas Vepštas <linasvepstas@gmail.com> · 2025-01-21T17:18:18.000Z

Changed files (4) +238 -65

CMakeLists.txt +230 -0
……@@ -0,0 +1,230 @@
1#
2# Master AtomSpace Matrix 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 3.0.2, so may as well ask for that.
13CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2)
14IF (COMMAND CMAKE_POLICY)
15 # These must be explicitly set, as otherwise warnings are printed.
16 CMAKE_POLICY(SET CMP0003 NEW)
17 CMAKE_POLICY(SET CMP0037 NEW)
18 CMAKE_POLICY(SET CMP0045 NEW)
19ENDIF (COMMAND CMAKE_POLICY)
20
21PROJECT(matrix)
22
23# ----------------------------------------------------------
24# User-modifiable options. Feel free to change these!
25#
26# Uncomment to be in Release mode [default].
27# SET(CMAKE_BUILD_TYPE Release)
28
29# Uncomment to build in debug mode.
30# SET(CMAKE_BUILD_TYPE Debug)
31
32# Uncomment to be in coverage testing mode.
33# SET(CMAKE_BUILD_TYPE Coverage)
34
35# Uncomment to build in profile mode.
36# SET(CMAKE_BUILD_TYPE Profile)
37
38# Uncomment to build in release mode with debug information.
39# SET(CMAKE_BUILD_TYPE RelWithDebInfo)
40
41# default build type
42IF (CMAKE_BUILD_TYPE STREQUAL "")
43 SET(CMAKE_BUILD_TYPE Release)
44ENDIF (CMAKE_BUILD_TYPE STREQUAL "")
45
46MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
47
48ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
49 -DPROJECT_BINARY_DIR="${CMAKE_BINARY_DIR}")
50
51# ===============================================================
52# Check for existance of various required, optional packages.
53# Listed in alphabetical order, more or less.
54# CogUtil must come first, because it supplies various FindXXX macros.
55
56# Add the 'lib' dir to cmake's module search path
57list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/lib/")
58
59# Cogutil
60FIND_PACKAGE(CogUtil 2.0.1 CONFIG REQUIRED)
61IF (COGUTIL_FOUND)
62 MESSAGE(STATUS "CogUtil version ${COGUTIL_VERSION} found.")
63 ADD_DEFINITIONS(-DHAVE_COGUTIL)
64 SET(HAVE_COGUTIL 1)
65ELSE (COGUTIL_FOUND)
66 MESSAGE(FATAL_ERROR "CogUtil missing: it is needed!")
67ENDIF (COGUTIL_FOUND)
68
69# add the 'cmake' directory from cogutil to search path
70list(APPEND CMAKE_MODULE_PATH ${COGUTIL_DATA_DIR}/cmake)
71
72include(OpenCogGccOptions)
73include(OpenCogLibOptions)
74include(OpenCogInstallOptions)
75include(Summary)
76
77# ===================================================================
78# Check for existance of various required, optional packages.
79
80# AtomSpace
81FIND_PACKAGE(AtomSpace 5.0.3 CONFIG REQUIRED)
82IF (ATOMSPACE_FOUND)
83 MESSAGE(STATUS "AtomSpace found.")
84 ADD_DEFINITIONS(-DHAVE_ATOMSPACE)
85 SET(HAVE_ATOMSPACE 1)
86ELSE (ATOMSPACE_FOUND)
87 MESSAGE(FATAL_ERROR "AtomSpace missing: it is needed!")
88ENDIF (ATOMSPACE_FOUND)
89
90# ----------------------------------------------------------
91# Needed for unit tests
92
93FIND_PACKAGE(Cxxtest)
94IF (NOT CXXTEST_FOUND)
95 MESSAGE(STATUS "CxxTest missing: needed for unit tests.")
96ENDIF (NOT CXXTEST_FOUND)
97
98# ----------------------------------------------------------
99# Is guile installed?
100
101include(OpenCogFindGuile)
102
103# ===================================================================
104# Include configuration.
105
106# Set default include paths.
107INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}
108 ${COGUTIL_INCLUDE_DIR} ${ATOMSPACE_INCLUDE_DIR})
109
110INCLUDE(OpenCogMacros)
111INCLUDE(OpenCogGuile)
112
113# ==========================================================
114# Decide what to build, based on the packages found.
115
116ADD_SUBDIRECTORY(cmake)
117ADD_SUBDIRECTORY(opencog)
118
119IF (CXXTEST_FOUND)
120 ADD_CUSTOM_TARGET(tests)
121 ADD_SUBDIRECTORY(tests EXCLUDE_FROM_ALL)
122 IF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
123 # doing coverage stuff while running tests if this is the Coverage build
124 ADD_CUSTOM_TARGET(check
125 # TODO lcov should be found by cmake first
126 # TODO set it up so that we can pick to run coverage per test, or
127 # combined across all tests (the latter is MUCH faster). Use a define?
128 # There is coverage specific stuff in AddCxxTest.cmake now...
129 WORKING_DIRECTORY tests
130 COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure $(ARGS)
131
132 # This script combines the coverage analysis of each test,
133 # then creates html in tests/lcov
134 # Note: this should now be run separately...
135 #COMMAND ${PROJECT_SOURCE_DIR}/scripts/combine_lcov.sh
136 COMMENT "Running tests with coverage..."
137 )
138 ELSE (CMAKE_BUILD_TYPE STREQUAL "Coverage")
139 # Coverage is disabled; test normally
140 ADD_CUSTOM_TARGET(check
141 DEPENDS tests
142 WORKING_DIRECTORY tests
143 COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure $(ARGS)
144 COMMENT "Running tests..."
145 )
146 ENDIF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
147
148 ADD_CUSTOM_TARGET(test_mono
149 DEPENDS tests
150 WORKING_DIRECTORY tests/persist/monospace
151 COMMAND ${CMAKE_CTEST_COMMAND} $(ARGS)
152 COMMENT "Running Monospace tests..."
153 )
154
155 ADD_CUSTOM_TARGET(test_multi
156 DEPENDS tests
157 WORKING_DIRECTORY tests/persist/matrix
158 COMMAND ${CMAKE_CTEST_COMMAND} $(ARGS)
159 COMMENT "Running Multispace tests..."
160 )
161
162ENDIF (CXXTEST_FOUND)
163
164ADD_CUSTOM_TARGET(cscope
165 COMMAND find opencog examples tests -name '*.cc' -o -name '*.h' -o -name '*.cxxtest' -o -name '*.scm' > ${CMAKE_SOURCE_DIR}/cscope.files
166 COMMAND cscope -b
167 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
168 COMMENT "Generating CScope database"
169)
170
171# ===================================================================
172# Packaging
173# XXX FIXME. Packging below is stale/wrong/broken.
174## Architecture the package is for.
175## TODO: Will give error on non debian distros, fix it.
176EXECUTE_PROCESS(COMMAND dpkg --print-architecture
177 OUTPUT_VARIABLE PACKAGE_ARCHITECTURE
178 OUTPUT_STRIP_TRAILING_WHITESPACE)
179STRING(TIMESTAMP UTC_DATE %Y%m%d UTC)
180# If 'sudo make install' is run before 'make package', then install_manifest.txt
181# will be owned by root. Creating the file during configuration stage ensures
182# that it is owned by the builder thus avoiding 'Permission denied' error when
183# packaging.
184FILE(WRITE "${PROJECT_BINARY_DIR}/install_manifest.txt")
185## It doesn't have a header-file declaring the version similar to cogutil and
186## atomspace.
187# SEMANTIC_VERSION is set in `lib/AtomSpaceMatrixConfig.cmake.in`
188# SET(SEMANTIC_VERSION 1.3.0)
189
190## Cpack configuration
191SET(CPACK_GENERATOR "DEB")
192SET(CPACK_PACKAGE_CONTACT "opencog@googlegroups.com")
193SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
194SET(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages")
195SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The AtomSpace Matrix Toolset")
196SET(CPACK_PACKAGE_NAME "atomspace-matrix-dev")
197SET(CPACK_PACKAGE_VENDOR "opencog.org")
198SET(CPACK_PACKAGE_VERSION "${SEMANTIC_VERSION}-${UTC_DATE}")
199SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
200SET(CPACK_PACKAGE_FILE_NAME
201 "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${PACKAGE_ARCHITECTURE}")
202SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
203
204## Debian specific configurations
205SET(DEPENDENCY_LIST
206 "guile-3.0-dev (>= 3.0.0)"
207 "libstdc++6 (>= 7.0)"
208 "libcogutil-dev (>= 2.0.2)"
209 "atomspace-dev (>= 5.0.3)"
210)
211
212STRING(REPLACE ";" ", " MAIN_DEPENDENCIES "${DEPENDENCY_LIST}")
213SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${MAIN_DEPENDENCIES}")
214SET(CPACK_DEBIAN_PACKAGE_SECTION "libdevel")
215SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://opencog.org")
216INCLUDE(CPack)
217
218# ===================================================================
219# Documentation.
220FIND_PACKAGE(Doxygen)
221# ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
222
223# ===================================================================
224# Show a summary of what we found, what we will do.
225
226SUMMARY_ADD("Matrix" "AtomSpace Sparse Matrix Tools" HAVE_ATOMSPACE)
227SUMMARY_ADD("Doxygen" "Code documentation" DOXYGEN_FOUND)
228SUMMARY_ADD("Unit tests" "Unit tests" CXXTEST_FOUND)
229
230SUMMARY_SHOW()
README.md +2 -2
……@@ -1,6 +1,6 @@
11
2Graph Sparse Vector Library
3===========================
2Graph Sparse Vector/Matrix Library
3==================================
44[![CircleCI](https://circleci.com/gh/opencog/matrix.svg?style=svg)](https://circleci.com/gh/opencog/matrix)
55
66See: [Presentation slides of key ideas](opencog/matrix/docs/AtomSpace.pdf).
opencog/CMakeLists.txt +5 -35
……@@ -2,41 +2,11 @@
22# The atom_types.h file is written to the build directory
33INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
44
5DECLARE_GUILE_CONFIG_TARGET(SCM_CONFIG "opencog as-config" "ATOMSPACE_TEST")
5DECLARE_GUILE_CONFIG_TARGET(SCM_CONFIG "opencog matrix-config" "ATOMSPACE_TEST")
66
7# The build order used here is loosely in terms of
8# dependencies: the later parts depend on, or may
9# someday depend on the earlier parts.
10#
11ADD_SUBDIRECTORY (atoms)
12ADD_SUBDIRECTORY (atomspace)
13ADD_SUBDIRECTORY (eval)
14ADD_SUBDIRECTORY (query)
15ADD_SUBDIRECTORY (persist)
7ADD_SUBDIRECTORY (matrix)
168
17# Guile/scheme API bindings and utilities
18IF (HAVE_GUILE)
19 ADD_SUBDIRECTORY (guile)
20 ADD_SUBDIRECTORY (scm)
21 ADD_SUBDIRECTORY (matrix)
22ENDIF (HAVE_GUILE)
9WRITE_GUILE_CONFIG(${GUILE_BIN_DIR}/opencog/matrix-config.scm SCM_CONFIG TRUE)
2310
24# Python3 API bindings.
25IF (HAVE_CYTHON)
26 ADD_SUBDIRECTORY (cython)
27ENDIF (HAVE_CYTHON)
28
29# Haskell bindings.
30IF (HAVE_STACK)
31 ADD_SUBDIRECTORY (haskell)
32ENDIF (HAVE_STACK)
33
34# OCaml bindings.
35IF (HAVE_OCAML)
36 ADD_SUBDIRECTORY (ocaml)
37ENDIF (HAVE_OCAML)
38
39WRITE_GUILE_CONFIG(${GUILE_BIN_DIR}/opencog/as-config.scm SCM_CONFIG TRUE)
40
41WRITE_GUILE_CONFIG(${GUILE_BIN_DIR}/opencog/as-config-installable.scm SCM_CONFIG FALSE)
42INSTALL(FILES ${GUILE_BIN_DIR}/opencog/as-config-installable.scm DESTINATION ${GUILE_SITE_DIR}/opencog RENAME as-config.scm)
11WRITE_GUILE_CONFIG(${GUILE_BIN_DIR}/opencog/matrix-config-installable.scm SCM_CONFIG FALSE)
12INSTALL(FILES ${GUILE_BIN_DIR}/opencog/matrix-config-installable.scm DESTINATION ${GUILE_SITE_DIR}/opencog RENAME matrix-config.scm)
tests/CMakeLists.txt +1 -28
……@@ -8,38 +8,11 @@ ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
88# file is specific to the test (this variable is used by ADD_CXXTEST)
99SET(GUILE_LOAD_PATH "${PROJECT_BINARY_DIR}/opencog/scm")
1010
11# The atom_types.h file is written to the build directory
12INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
13
1411# Perform tests in component-dependency order, as much as possible.
1512# For example, since most things depends on the atomspace,
1613# its is tested first.
1714IF (CXXTEST_FOUND)
1815
19 ADD_SUBDIRECTORY (atomspace)
20 ADD_SUBDIRECTORY (atoms)
21
22 # Persistence is for saving/restoring atomspace to disk.
23 ADD_SUBDIRECTORY (persist)
24
25 # guile provides scheme bindings for the atomspace.
26 ADD_SUBDIRECTORY (scm)
27
28 IF(HAVE_SQL_STORAGE)
29 ADD_SUBDIRECTORY (matrix)
30 ENDIF(HAVE_SQL_STORAGE)
31
32 # Many of the query tests require a working guile, so run
33 # these only after guile has been tested.
34 ADD_SUBDIRECTORY (query)
35
36 IF (HAVE_CYTHON AND HAVE_NOSETESTS)
37 MESSAGE(STATUS "Found cython and nosetests, enabling python unit tests")
38 ADD_SUBDIRECTORY (cython)
39 ENDIF (HAVE_CYTHON AND HAVE_NOSETESTS)
40
41 IF (HAVE_STACK)
42 ADD_SUBDIRECTORY (haskell)
43 ENDIF (HAVE_STACK)
16 ADD_SUBDIRECTORY (matrix)
4417
4518ENDIF (CXXTEST_FOUND)