#
# Master AtomSpace CogServer client 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
#
# cogutils already requires 3.12, so may as well ask for that.
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
IF (COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0037 NEW)
ENDIF (COMMAND CMAKE_POLICY)
# Python venv seems to need this.
IF(CMAKE_VERSION VERSION_GREATER 3.31)
CMAKE_POLICY(SET CMP0177 NEW)
ENDIF(CMAKE_VERSION VERSION_GREATER 3.31)
PROJECT(cog-storage VERSION 1.2.0)
# ----------------------------------------------------------
# User-modifiable options. Feel free to change these!
#
# 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}")
# ===============================================================
# Check for existance of various required, optional packages.
# Listed in alphabetical order, more or less.
# CogUtil must come first, because it supplies various FindXXX macros.
# Cogutil
FIND_PACKAGE(CogUtil 2.2.1 CONFIG REQUIRED)
IF (NOT COGUTIL_FOUND)
MESSAGE(FATAL_ERROR "CogUtil missing: it is needed!")
ENDIF ()
include(${COGUTIL_DATA_DIR}/cmake/OpenCogGccOptions.cmake)
include(${COGUTIL_DATA_DIR}/cmake/OpenCogLibOptions.cmake)
include(${COGUTIL_DATA_DIR}/cmake/OpenCogInstallOptions.cmake)
include(${COGUTIL_DATA_DIR}/cmake/Summary.cmake)
# ===================================================================
# Check for existance of various required, optional packages.
# AtomSpace
FIND_PACKAGE(AtomSpace 5.2.0 CONFIG REQUIRED)
IF (NOT ATOMSPACE_FOUND)
MESSAGE(FATAL_ERROR "AtomSpace missing: it is needed!")
ENDIF ()
FIND_PACKAGE(AtomSpaceStorage 4.3 CONFIG REQUIRED)
IF (NOT ATOMSPACE_STORAGE_FOUND)
MESSAGE(FATAL_ERROR "AtomSpace Storage missing: it is needed!")
ENDIF ()
# CogServer - needed for unit tests
FIND_PACKAGE(CogServer 3.4 CONFIG)
IF (COGSERVER_FOUND)
SET(HAVE_COGSERVER 1)
ELSE (COGSERVER_FOUND)
MESSAGE(STATUS "CogServer missing: needed for unit tests.")
ENDIF (COGSERVER_FOUND)
# ----------------------------------------------------------
# Guile Python and Cython
include(OpenCogFindGuile)
# include(OpenCogFindPython)
# ===================================================================
# Include configuration.
# Set default include paths.
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}
${COGUTIL_INCLUDE_DIR} ${ATOMSPACE_INCLUDE_DIR})
INCLUDE(OpenCogMacros)
INCLUDE(OpenCogGuile)
# INCLUDE(OpenCogCython)
# ==========================================================
# Decide what to build, based on the packages found.
ADD_SUBDIRECTORY(opencog)
# ----------------------------------------------------------
# Unit tests
INCLUDE(OpenCogTestOptions)
OPENCOG_SETUP_TESTING()
OPENCOG_ADD_TEST_TARGET(test_storage tests/persist/cog-storage "Running CogStorage tests...")
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
# This is broken, more or less.
## Architecture the package is for.
## TODO: Will give error on non debian distros, fix it.
EXECUTE_PROCESS(COMMAND dpkg --print-architecture
OUTPUT_VARIABLE PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(TIMESTAMP UTC_DATE %Y%m%d UTC)
# If 'sudo make install' is run before 'make package', then install_manifest.txt
# will be owned by root. Creating the file during configuration stage ensures
# that it is owned by the builder thus avoiding 'Permission denied' error when
# packaging.
FILE(WRITE "${PROJECT_BINARY_DIR}/install_manifest.txt")
## Cpack configuration
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_CONTACT "opencog@googlegroups.com")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The AtomSpace Cogserver Client")
SET(CPACK_PACKAGE_NAME "atomspace-cog-dev")
SET(CPACK_PACKAGE_VENDOR "opencog.org")
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}-${UTC_DATE}")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${PACKAGE_ARCHITECTURE}")
SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
SET(CPACK_PACKAGE_EXECUTABLES "atomspace-cog" "The AtomSpace Cogserver Client")
## Debian specific configurations
SET(DEPENDENCY_LIST
"guile-3.0-dev (>= 3.0.0)"
"libstdc++6 (>= 4.7)"
"libcogutil-dev (>= 2.2.1)"
"atomspace-dev (>= 5.2.0)"
)
STRING(REPLACE ";" ", " MAIN_DEPENDENCIES "${DEPENDENCY_LIST}")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${MAIN_DEPENDENCIES}")
SET(CPACK_DEBIAN_PACKAGE_SECTION "libdevel")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://opencog.org")
INCLUDE(CPack)
# ===================================================================
# documentation
FIND_PACKAGE(Doxygen)
# ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
# ===================================================================
# Show a summary of what we found, what we will do.
SUMMARY_ADD("CogStorage" "Network Distributed AtomSpace" 1)
SUMMARY_ADD("Doxygen" "Code documentation" DOXYGEN_FOUND)
SUMMARY_ADD("Unit tests" "Unit tests" CXXTEST_FOUND AND HAVE_COGSERVER)
SUMMARY_SHOW()