This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/CMakeLists.txt

909 lines
23 KiB
CMake
Raw Normal View History

2017-10-17 00:13:09 +01:00
2016-07-31 10:56:54 +01:00
# value of 3.4.0 or lower.
2017-06-13 13:34:17 +01:00
cmake_minimum_required(VERSION 3.4)
2014-12-14 12:05:43 +00:00
# Sets the version of CMake required to build the native
# library. You should either keep the default value or pass a
2016-07-31 10:56:54 +01:00
# value of 3.4.0 or lower.
2017-05-02 07:42:21 +01:00
include(CMakeToolsHelpers OPTIONAL)
2015-08-08 15:11:29 +01:00
2017-07-30 22:24:00 +01:00
include(FeatureSummary)
2017-10-17 00:13:09 +01:00
include(GNUInstallDirs)
2017-05-08 18:51:29 +01:00
2017-12-05 15:14:57 +00:00
project(YAP)
2017-06-12 18:02:37 +01:00
set(YAP_APP_DIR "${CMAKE_SOURCE_DIR}/../..")
2017-10-17 00:13:09 +01:00
cmake_policy(VERSION 3.4)
2016-11-11 07:23:34 +00:00
2017-11-11 22:48:09 +00:00
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/cmake")
2016-05-30 11:23:36 +01:00
2017-12-10 01:22:45 +00:00
set(ANACONDA $ENV{CONDA_BUILD} CACHE BOOL "Anaconda Environment")
message(STATUS "ANACONDA found: ${ANACONDA}")
2017-11-10 23:08:35 +00:00
2016-07-31 10:56:54 +01:00
include(CheckIncludeFiles)
2015-06-19 01:30:13 +01:00
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckTypeSize)
2016-07-31 10:56:54 +01:00
include(CMakeDependentOption)
include(MacroOptionalAddSubdirectory)
include(MacroOptionalFindPackage)
2017-07-30 22:24:00 +01:00
include(FeatureSummary)
2016-07-31 10:56:54 +01:00
include(FindPackageHandleStandardArgs)
2017-10-17 00:13:09 +01:00
# Optional Components
#
include(CheckIncludeFileCXX)
include(CheckFunctionExists)
include(CheckFunctionExists)
include(CheckPrototypeExists)
include(CheckVariableExists)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
include(GetGitRevisionDescription)
2016-12-10 07:06:16 +00:00
2016-07-31 10:56:54 +01:00
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.z
# You can define libraries, and CMake builds it for you.
2016-07-31 10:56:54 +01:00
# Gradle automatically packages shared libraries with your APK.
2015-06-19 01:30:13 +01:00
2016-11-11 07:23:34 +00:00
#cross-compilation support
# Search packages for host system instead of packages for target system
# in case of cross compilation define these macro by toolchain file
2017-11-11 22:48:09 +00:00
if (NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
endmacro()
endif ()
if (NOT COMMAND find_host_program)
macro(find_host_program)
find_program(${ARGN})
endmacro()
endif ()
2015-06-19 01:30:13 +01:00
2017-11-08 09:29:01 +00:00
if (POLICY CMP0003)
2017-11-11 22:48:09 +00:00
cmake_policy(SET CMP0003 NEW)
endif ()
2017-11-08 09:29:01 +00:00
if (POLICY CMP0068)
2017-11-11 22:48:09 +00:00
cmake_policy(SET CMP0068 NEW)
endif ()
2017-11-08 09:29:01 +00:00
2017-11-10 23:08:35 +00:00
option(BUILD_SHARED_LIBS "Build shared library" ON)
2017-11-08 09:29:01 +00:00
2017-11-11 22:48:09 +00:00
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
2017-10-11 02:24:15 +01:00
#begining stuff for top CMakeLists
2016-06-02 11:52:22 +01:00
2017-11-11 22:48:09 +00:00
include(MacroLogFeature)
2016-05-30 11:23:36 +01:00
2017-10-11 02:24:15 +01:00
if (POLICY CMP0042)
2017-11-11 22:48:09 +00:00
cmake_policy(SET CMP0042 NEW)
endif ()
2017-10-11 02:24:15 +01:00
function(add_to_group list output)
2017-11-11 22:48:09 +00:00
set(tmp ${${output}})
foreach (path ${${list}})
get_source_file_property(path ${path} LOCATION)
list(APPEND tmp ${path})
endforeach ()
set(${output} ${tmp} CACHE INTERNAL "prolog library files")
endfunction(add_to_group list output)
2017-10-11 02:24:15 +01:00
function(add_to_libgroup el list)
2017-11-11 22:48:09 +00:00
# add_custom_command( TARGET ${el} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${el}> ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py
# DEPENDS ${el} )
list(APPEND ${list} ${${el}})
set(${list} ${${list}} CACHE INTERNAL "prolog dll files")
endfunction(add_to_libgroup el list)
2017-10-11 02:24:15 +01:00
function(add_to_corelibgroup el list)
2017-11-11 22:48:09 +00:00
# add_custom_command( TARGET ${el} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${el}> $<TARGET_SONAME_FILE:${el}> $<TARGET_LINKER_FILE:${el}> ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py
# DEPENDS ${el} )
list(APPEND ${list} ${${el}})
set(${list} ${${list}} CACHE INTERNAL "prolog dll files")
endfunction(add_to_corelibgroup el list)
2017-10-11 02:24:15 +01:00
if (ANDROID_OLD)
2017-11-11 22:48:09 +00:00
macro(MY_add_custom_target)
endmacro()
else ()
macro(MY_add_custom_target)
add_custom_target(${ARGN})
endmacro()
endif ()
2017-10-11 02:24:15 +01:00
if (WIN32)
2017-11-11 22:48:09 +00:00
macro(add_component arg1)
add_library(${arg1} OBJECT ${ARGN})
endmacro()
else ()
macro(add_component arg1)
add_library(${arg1} OBJECT ${ARGN})
endmacro()
endif ()
macro(add_lib arg1)
add_library(${arg1} SHARED ${ARGN})
add_to_libgroup(${arg1} YAP_DLLS)
2017-10-11 02:24:15 +01:00
endmacro()
2017-11-11 22:48:09 +00:00
macro(add_corelib arg1)
add_library(${arg1} SHARED ${ARGN})
add_to_corelibgroup(${arg1} YAP_DLLS)
2017-10-11 02:24:15 +01:00
endmacro()
if (ANDROID_OLD)
2017-11-11 22:48:09 +00:00
macro(MY_add_dependencies)
endmacro()
else ()
macro(MY_add_dependencies)
add_dependencies(${ARGN})
endmacro()
endif ()
2017-10-11 02:24:15 +01:00
if (ANDROID_OLD)
2017-11-11 22:48:09 +00:00
macro(MY_add_library)
endmacro()
else ()
macro(MY_add_library)
add_library(${ARGN})
endmacro()
endif ()
2017-10-11 02:24:15 +01:00
if (ANDROID)
2017-11-11 22:48:09 +00:00
macro(MY_add_subdirectory)
endmacro()
else ()
macro(MY_add_subdirectory)
add_subdirectory(${ARGN})
endmacro()
endif ()
2017-10-11 02:24:15 +01:00
if (ANDROID_OLD)
2017-11-11 22:48:09 +00:00
macro(MY_include)
endmacro()
else ()
macro(MY_include)
include(${ARGN})
endmacro()
endif ()
2017-10-11 02:24:15 +01:00
if (ANDROID)
2017-11-11 22:48:09 +00:00
macro(MY_install)
endmacro()
else ()
macro(MY_install)
install(${ARGN})
endmacro()
endif ()
2017-10-11 02:24:15 +01:00
if (ANDROID_OLD)
2017-11-11 22:48:09 +00:00
macro(MY_set_target_properties)
endmacro()
else ()
macro(MY_set_target_properties)
set_target_properties(${ARGN})
endmacro()
endif ()
2017-10-11 02:24:15 +01:00
if (ANDROID_OLD)
2017-11-11 22:48:09 +00:00
macro(MY_target_link_libraries)
endmacro()
else ()
macro(MY_target_link_libraries)
target_link_libraries(${ARGN})
endmacro()
endif ()
2017-10-11 02:24:15 +01:00
# where we have most scripts
# set path to additional CMake modules
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(disallow)
disallow_intree_builds()
# set(CMAKE_BUILD_TYPE Debug)
2017-11-08 09:29:01 +00:00
if ($ENV{CONDA_BUILD}x STREQUAL "1x" )
2017-11-11 22:48:09 +00:00
set(CMAKE_LIBRARY_ARCHITECTURE $ENV{PREFIX})
set(CMAKE_PREFIX_PATH $ENV{PREFIX})
2017-11-11 22:48:09 +00:00
set( R_COMMAND "$ENV{R}")
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CONDA_BUILD=1)
list (APPEND CMAKE_REQUIRED_INCLUDES
${PREFIX}/include
${SYS_PREFIX}/include
)
2017-11-15 12:18:19 +00:00
set(YAP_IS_MOVABLE 1)
2017-10-17 00:13:09 +01:00
endif()
ADD_CUSTOM_TARGET(run_install COMMAND ${CMAKE_MAKE_PROGRAM} install)
2017-11-11 22:48:09 +00:00
if (APPLE)
2018-02-10 14:12:29 +00:00
set(MACOSX_RPATH ON)
if (NOT $ENV{CONDA_BUILD}x STREQUAL "1x")
2017-11-11 22:48:09 +00:00
set(PATH $ENV{PATH})
2018-02-10 14:12:29 +00:00
option(WITH_BREW "brew" ON)
if (WITH_MACPORTS)
# Add MacPorts
# Detect if the "port" command is valid on this system; if so, return full path
EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
IF (${DETECT_MACPORTS} EQUAL 0)
# "/opt/local/bin/port" doesn't have libs, so we get the parent directory
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
# "/opt/local/bin" doesn't have libs, so we get the parent directory
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
# "/opt/local" is where MacPorts lives, add `/lib` suffix and link
LINK_DIRECTORIES(${LINK DIRECTORIES} ${MACPORTS_PREFIX}/lib)
MESSAGE("WINNING!: ${MACPORTS_PREFIX}/lib")
ENDIF()
ENDIF()
option(WITH_BREW "brew" ON)
if (WITH_BREW)
EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_BREW OUTPUT_VARIABLE BREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
IF (${DETECT_BREW} EQUAL 0)
# "/opt/local" is where MacPorts lives, add `/lib` suffix and link
LINK_DIRECTORIES( ${BREW_PREFIX}/lib)
MESSAGE("BREW!: ${BREW_PREFIX}/lib")
ENDIF()
2017-11-11 22:48:09 +00:00
list(INSERT CMAKE_PREFIX_PATH pos
2018-02-10 14:12:29 +00:00
${BREW_PREFIX}/opt/gmp
${BREW_PREFIX}/opt/libxml2
${BREW_PREFIX}/opt/openmpi
${BREW_PREFIX}/opt/openssl
${BREW_PREFIX}/opt/postgresql
${BREW_PREFIX}/opt/python3
${BREW_PREFIX}/opt/readline
${BREW_PREFIX}/opt/swig
2017-11-11 22:48:09 +00:00
)
2018-02-10 14:12:29 +00:00
endif ()
endif()
2017-11-11 22:48:09 +00:00
endif ()
2017-12-11 17:22:24 +00:00
2017-11-11 22:48:09 +00:00
set(prefix ${CMAKE_INSTALL_PREFIX}) #BINDIR})
set(bindir ${CMAKE_INSTALL_PREFIX}/bin) #BINDIR})
set(includedir ${CMAKE_INSTALL_PREFIX}/include) #INCLUDEDIR})
set(libdir ${CMAKE_INSTALL_PREFIX}/lib) #LIBDIR})
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/libexec) #LIBEXECDIR})
set(datarootdir ${CMAKE_INSTALL_PREFIX}/share) #DATAROOTDIR})
2017-11-18 10:55:22 +00:00
if (ANDROID)
set(datarootdir ${YAP_APP_DIR}/src/generated/assets)
endif ()
2017-11-11 22:48:09 +00:00
set(datadir ${CMAKE_INSTALL_PREFIX}/share) #DATADIR})
set(mandir ${CMAKE_INSTALL_PREFIX}/share/man) #MANDIR})
set(docdir ${CMAKE_INSTALL_PREFIX}/share/docs) #MANDIR})
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
set(libpl ${datarootdir}/Yap)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
set(dlls ${libdir}/Yap)
2017-10-11 02:24:15 +01:00
set(YAP_ROOTDIR ${prefix})
# erootdir -> rootdir
# libdir defined above
2017-12-05 15:14:57 +00:00
set(YAP_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
set(YAP_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR}/Yap)
set(YAP_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
set(YAP_DLLDIR ${CMAKE_INSTALL_FULL_LIBDIR}/Yap)
set(YAP_PLDIR ${CMAKE_INSTALL_FULL_DATADIR}/Yap)
set(YAP_INSTALL_DLLDIR ${CMAKE_INSTALL_LIBDIR}/Yap)
set(YAP_INSTALL_PLDIR ${CMAKE_INSTALL_DATADIR}/Yap)
set(libpl ${YAP_INSTALL_PLDIR})
2017-10-11 02:24:15 +01:00
#
#
2017-12-05 15:14:57 +00:00
# include( Sources )
2017-10-11 02:24:15 +01:00
#
2017-12-05 15:14:57 +00:00
# include( Model )
2017-10-11 02:24:15 +01:00
2017-12-05 15:14:57 +00:00
include(cudd )
include(java )
2017-11-11 22:48:09 +00:00
set(pl_library "" CACHE INTERNAL "prolog library files")
set(pl_os_library "" CACHE INTERNAL "prolog os files")
set(pl_boot_library "" CACHE INTERNAL "prolog boot files")
2017-10-11 02:24:15 +01:00
2016-05-30 11:23:36 +01:00
2017-11-11 22:48:09 +00:00
find_package(GMP)
2017-10-17 00:13:09 +01:00
# GMP_FOUND - true if GMP/MPIR was found
# GMP_INCLUDE_DIRS - include search path
# GMP_LIBRARIES - libraries to link with
# GMP_LIBRARY_ #add_executable(test ${SOURCES})
2017-10-11 02:24:15 +01:00
2017-10-17 00:13:09 +01:00
list(APPEND YAP_SYSTEM_OPTIONS big_numbers)
2017-10-11 02:24:15 +01:00
if (GMP_FOUND)
#config.h needs this (TODO: change in code latter)
include_directories(${GMP_INCLUDE_DIRS})
endif (GMP_FOUND)
2018-02-10 14:12:29 +00:00
option(WITH_READLINE "use readline or libedit" ON)
if (WITH_READLINE)
2017-11-11 22:48:09 +00:00
include(FindReadline)
2017-10-11 02:24:15 +01:00
2017-10-17 00:13:09 +01:00
List(APPEND YAP_SYSTEM_OPTIONS readline)
2017-10-12 12:08:32 +01:00
# include subdirectories configuration
## after we have all functionality in
#
# ADD_SUBDIRECTORY(console/terminal)
if (READLINE_FOUND)
include_directories(${READLINE_INCLUDE_DIR})
# required for configure
list(APPEND CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES})
list(APPEND CMAKE_REQUIRED_INCLUDES ${READLINE_INCLUDE_DIR})
endif ()
2018-02-10 14:12:29 +00:00
endif()
2017-10-11 02:24:15 +01:00
#MPI STUFF
# library/mpi/mpi.c library/mpi/mpe.c
# library/lammpi/yap_mpi.c library/lammpi/hash.c library/lammpi/prologterms2c.c
# )
#WIN STUFF
# SET(PLCONS_SOURCES
# console/LGPL/pl-nt.c
# console/LGPL/pl-ntcon.c
# console/LGPL/pl-ntconsole.c
# console/LGPL/pl-ntmain.c
# )
set(YAP_FOUND ON)
set(YAP_MAJOR_VERSION 6)
set(YAP_MINOR_VERSION 3)
set(YAP_PATCH_VERSION 5)
set(YAP_FULL_VERSION
2017-11-11 22:48:09 +00:00
${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION}.${YAP_PATCH_VERSION})
2017-10-11 02:24:15 +01:00
set(YAP_FVERSION
2017-11-11 22:48:09 +00:00
${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION}.${YAP_PATCH_VERSION})
2017-10-11 02:24:15 +01:00
set(YAP_NUMERIC_VERSION
2017-11-11 22:48:09 +00:00
${YAP_MAJOR_VERSION}*10000+${YAP_MINOR_VERSION}*100+${YAP_PATCH_VERSION})
2017-10-11 02:24:15 +01:00
set(MYDDAS_VERSION MYDDAS-0.9.1)
2017-11-11 22:48:09 +00:00
site_name(YAP_SITE)
2017-10-11 02:24:15 +01:00
if (WIN32)
2017-11-11 22:48:09 +00:00
set(YAP_ARCH $ENV{PROCESSOR_ARCHITECTURE})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "MS_WIN64=1")
set(YAP_SYSTEM_OPTIONS "windows " ${YAP_SYSTEM_OPTIONS})
endif ()
2017-10-11 02:24:15 +01:00
if (UNIX)
2017-11-11 22:48:09 +00:00
find_program(UNAME uname)
execute_process(
COMMAND ${UNAME} -m
OUTPUT_VARIABLE YAP_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
set(YAP_SYSTEM_OPTIONS "unix " ${YAP_SYSTEM_OPTIONS})
endif ()
2017-10-11 02:24:15 +01:00
#
2017-11-11 22:48:09 +00:00
set(MIN_STACKSPACE 1024*SIZEOF_INT_P)
set(MIN_HEAPSPACE 32*1024*SIZEOF_INT_P)
set(MIN_TRAILSPACE 512*SIZEOF_INT_P)
set(DEF_STACKSPACE 0)
set(DEF_HEAPSPACE 0)
set(DEF_TRAILSPACE 0)
2017-10-11 02:24:15 +01:00
# option (RATIONAL_TREES "support infinite rational trees" ON)
# dd_definitions (-D)
## don't touch these opts
2017-11-11 22:48:09 +00:00
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS DEPTH_LIMIT=1;COROUTINING=1;RATIONAL_TREES=1)
2017-10-11 02:24:15 +01:00
# inform we are compiling YAP
2017-11-11 22:48:09 +00:00
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE")
2017-10-11 02:24:15 +01:00
# Compilation model
# target_compile_definitions(libYap PUBLIC _XOPEN_SOURCE=700 )
#add_definitions( -Wall -Wstrict-prototypes -Wmissing-prototypes)
# Model Specific
2017-11-11 22:48:09 +00:00
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUG=1>)
2017-10-11 02:24:15 +01:00
#ensure cells are properly aligned in code
2017-11-11 22:48:09 +00:00
set(ALIGN_LONGS 1)
2017-10-11 02:24:15 +01:00
#ensure best access to slots in environments
2017-11-11 22:48:09 +00:00
set(MSHIFTOFFS 1)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
set(C_COMPILER CMAKE_C_COMPILER_ID)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
if (${C_COMPILER} MATCHES "GNU")
set(HAVE_GCC 1)
endif ()
2017-10-11 02:24:15 +01:00
# compatible compilers
2017-11-11 22:48:09 +00:00
if (${C_COMPILER} MATCHES "Clang")
set(HAVE_GCC 1)
endif ()
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
if (${C_COMPILER} MATCHES "Intel")
set(HAVE_GCC 1)
endif ()
2017-10-11 02:24:15 +01:00
2017-12-11 03:36:21 +00:00
# rpath stuff, hopefully it works
# use, i.e. don't skip the full RPATH for the build tree
2018-01-05 16:57:38 +00:00
#SET(CMAKE_SKIP_BUILD_RPATH TRUE)
2017-12-11 03:36:21 +00:00
# when building, don't use the install RPATH already
2018-01-05 16:57:38 +00:00
## (but later on when installing)
#SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
#
## SET(CMAKE_INSTALL_FULL_RPATH ${CMAKE_TOP_BINARY_DIR})
#
## add the automatically determined parts of the RPATH
## which point to directories outside the build tree to the install RPATH
#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FAlSE)
#
#
## the RPATH to be used when installing, but only if it's not a system directory
#LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir}" isSystemDir)
# IF("${isSystemDir}" STREQUAL "-1")
# SET(CMAKE_INSTALL_RPATH ${libdir})
#ENDIF("${isSystemDir}" STREQUAL "-1")
#
2017-12-11 03:36:21 +00:00
IF(NOT WIN32 AND NOT APPLE)
LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../lib/Yap)
LIST(APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../lib)
LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../../../lib)
2018-01-05 16:57:38 +00:00
ELSE()
LIST(APPEND CMAKE_INSTALL_RPATH @loader_path/../lib/Yap)
LIST(APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
LIST(APPEND CMAKE_INSTALL_RPATH @loader_path/../lib)
LIST(APPEND CMAKE_INSTALL_RPATH @loader_path/../../../lib)
2017-12-11 03:36:21 +00:00
ENDIF()
2017-10-11 02:24:15 +01:00
# Model Specific
if (HAVE_GCC)
2017-11-11 22:48:09 +00:00
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -Wall)
if (${C_COMPILER} MATCHES "GNU")
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$<CONFIG:Release>:-O3;-fomit-frame-poinkter;-fstrict-aliasing;-freorder-blocks;-fsched-interblock>)
else ()
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS $<$<CONFIG:Release>:-O3;-fstrict-aliasing;-freorder-blocks;-fsched-interblock>)
endif ()
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -fexceptions)
endif ()
2017-10-11 02:24:15 +01:00
# set_property( DIRECTORY APPEND_STRING PROPERTY -fsanitize=memory;-fsanitize-memory-track-origins=2)
if (HAVE_GCC)
2017-11-11 22:48:09 +00:00
# replace instructions codes by the address of their code
option(WITH_THREADED_CODE "threaded code" ON)
if (WITH_THREADED_CODE)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS THREADED_CODE=1)
endif (WITH_THREADED_CODE)
2017-10-11 02:24:15 +01:00
endif (HAVE_GCC)
#
#option (YAP_SWI_IO ON)
2017-11-11 22:48:09 +00:00
OPTION(WITH_CALL_TRACER
"support for procedure-call tracing" ON)
2017-10-11 02:24:15 +01:00
#TODO:
if (WITH_CALL_TRACER)
2017-11-11 22:48:09 +00:00
list(APPEND YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:LOW_LEVEL_TRACER=1>)
2017-10-11 02:24:15 +01:00
endif (WITH_CALL_TRACER)
2017-11-11 22:48:09 +00:00
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS UTF8PROC=1)
2017-06-13 13:34:17 +01:00
2017-11-11 22:48:09 +00:00
include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src)
2016-11-11 15:53:09 +00:00
2017-10-17 00:13:09 +01:00
2018-02-15 00:02:44 +00:00
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
2016-11-11 15:53:09 +00:00
if (ANDROID)
2017-11-11 22:48:09 +00:00
include_directories(
packages/myddas/sqlite3/src/Android/jni/sqlite
packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper
2017-06-13 13:34:17 +01:00
)
2016-11-11 15:53:09 +00:00
2018-02-15 00:02:44 +00:00
else()
2016-05-30 11:23:36 +01:00
2016-07-31 10:56:54 +01:00
if (MYSQL_FOUND)
2017-11-11 22:48:09 +00:00
add_definitions(= -DMYDDAS_MYSQL=1)
endif ()
2015-06-19 01:30:13 +01:00
2016-07-31 10:56:54 +01:00
if (ODBC_FOUND)
2017-11-11 22:48:09 +00:00
add_definitions(= -DMYDDAS_ODBC=1)
endif ()
2016-07-31 10:56:54 +01:00
if (MYSQL_POSTGRES)
2017-11-11 22:48:09 +00:00
add_definitions(= -DMYDDAS_POSTGRES=1)
endif ()
2018-02-15 00:02:44 +00:00
endif()
2017-06-13 13:34:17 +01:00
2017-11-11 22:48:09 +00:00
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
2017-11-21 15:44:43 +00:00
IF (WITH_SWIG)
2017-11-11 22:48:09 +00:00
find_host_package(SWIG)
# macro_log_feature (SWIG_FOUND "Swig"
# "Use SWIG Interface Generator "
# "http://www.swig.org" ON)
2017-11-27 13:36:19 +00:00
ENDIF (WITH_SWIG)
2016-12-16 17:22:50 +00:00
2017-10-17 00:13:09 +01:00
2017-11-11 22:48:09 +00:00
option(WITH_PYTHON
"Allow Python->YAP and YAP->Python" ON)
2017-06-13 13:34:17 +01:00
IF (WITH_PYTHON)
2017-12-05 15:14:57 +00:00
include(python )
2017-06-13 13:34:17 +01:00
ENDIF (WITH_PYTHON)
2017-11-11 22:48:09 +00:00
List(APPEND YLIBS $<TARGET_OBJECTS:libOPTYap>)
List(APPEND YLIBS $<TARGET_OBJECTS:libYAPOs>)
List(APPEND YLIBS $<TARGET_OBJECTS:utf8proc>)
List(APPEND YLIBS $<TARGET_OBJECTS:myddas>)
List(APPEND YLIBS $<TARGET_OBJECTS:libswi>)
2018-01-18 14:47:27 +00:00
if (WIN32 OR ANDROID)
2017-11-11 22:48:09 +00:00
List(APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3>)
List(APPEND YLIBS $<TARGET_OBJECTS:YAP++>)
2018-02-14 00:13:13 +00:00
if (WIN32 AND WITH_PYTHON)
2017-11-11 22:48:09 +00:00
List(APPEND YLIBS $<TARGET_OBJECTS:Py4YAP>)
endif ()
endif ()
2017-06-13 13:34:17 +01:00
2017-11-11 22:48:09 +00:00
include(Sources)
2016-12-03 16:38:07 +00:00
2017-10-11 02:24:15 +01:00
add_corelib( # Sets the name of the library.
2017-11-11 22:48:09 +00:00
libYap
2016-07-31 10:56:54 +01:00
2017-11-11 22:48:09 +00:00
# Sets the library as a shared library.
SHARED
2017-11-11 22:48:09 +00:00
${ENGINE_SOURCES}
${C_INTERFACE_SOURCES}
//${STATIC_SOURCES}
# cmake object libraries
${YLIBS}
)
2016-04-08 09:13:45 +01:00
2017-10-17 00:13:09 +01:00
if (GMP_FOUND)
2017-11-11 22:48:09 +00:00
target_link_libraries(libYap ${GMP_LIBRARIES})
2017-10-17 00:13:09 +01:00
endif (GMP_FOUND)
2017-10-11 02:24:15 +01:00
2017-10-17 00:13:09 +01:00
if (READLINE_FOUND)
2017-11-11 22:48:09 +00:00
target_link_libraries(libYap ${READLINE_LIBRARIES})
# required for configure
2017-11-11 22:48:09 +00:00
endif ()
2017-10-11 02:24:15 +01:00
if (WIN32)
target_link_libraries(libYap ${WINDLLS})
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES)
target_link_libraries(libYap ${PYTHON_LIBRARIES})
endif ()
endif (WIN32)
target_link_libraries(libYap m)
2017-10-11 02:24:15 +01:00
set(YAP_STARTUP startup.yss)
2017-12-05 15:14:57 +00:00
set(YAP_BOOTFILE boot.yap )
2017-10-11 02:24:15 +01:00
## define system
2017-10-17 00:13:09 +01:00
# Optional libraries that affect compilation
#
2017-10-11 02:24:15 +01:00
set(CMAKE_TOP_BINARY_DIR ${CMAKE_BINARY_DIR})
set(YAP_PL_SRCDIR ${CMAKE_SOURCE_DIR}/pl)
set(YAP_YAPLIB libYap${CMAKE_SHARED_LIBRARY_SUFFIX})
string(TIMESTAMP YAP_TIMESTAMP)
2017-11-11 22:48:09 +00:00
string(SUBSTRING ${CMAKE_SHARED_LIBRARY_SUFFIX} 1 -1 SO_EXT)
2017-10-11 02:24:15 +01:00
set_property(DIRECTORY PROPERTY CXX_STANDARD 11)
2017-11-11 22:48:09 +00:00
include_directories(H
H/generated
include os OPTYap utf8proc JIT/HPP)
include_directories(BEFORE ${CMAKE_BINARY_DIR} ${CMAKE_TOP_BINARY_DIR})
2017-10-11 02:24:15 +01:00
if (ANDROID)
2017-11-11 22:48:09 +00:00
include_directories(CXX ${CMAKE_SOURCE_DIR}/../generated/src/jni)
endif ()
include(Threads)
2017-10-11 02:24:15 +01:00
#
# include OS and I/o stuff
#
# convenience libraries
# OPTYap exports important flags
#
list(APPEND YAP_SYSTEM_OPTIONS "thread support")
2017-10-17 00:13:09 +01:00
set_target_properties(libYap
2017-11-11 22:48:09 +00:00
PROPERTIES OUTPUT_NAME Yap
)
2017-10-17 00:13:09 +01:00
MY_set_target_properties(libYap
2017-11-11 22:48:09 +00:00
PROPERTIES VERSION ${YAP_FULL_VERSION}
SOVERSION ${YAP_MAJOR_VERSION}.${YAP_MINOR_VERSION}
)
2017-10-17 00:13:09 +01:00
2017-11-10 23:08:35 +00:00
2017-10-11 02:24:15 +01:00
#utf-8 is not an option
# we use the nice UTF-8 package
#available at the Julia project
2017-11-11 22:48:09 +00:00
ADD_SUBDIRECTORY(OPTYap)
ADD_SUBDIRECTORY(os)
ADD_SUBDIRECTORY(packages/myddas)
ADD_SUBDIRECTORY(utf8proc)
ADD_SUBDIRECTORY(library/dialect/swi/fli)
ADD_SUBDIRECTORY(CXX)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(H)
2017-10-11 02:24:15 +01:00
#bootstrap and saved state
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(pl)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
ADD_SUBDIRECTORY(library)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
ADD_SUBDIRECTORY(swi/library "swiLibrary")
2016-07-31 10:56:54 +01:00
set_target_properties(libYap
2017-11-11 22:48:09 +00:00
PROPERTIES OUTPUT_NAME Yap
)
2016-08-01 12:54:28 +01:00
2017-11-10 23:08:35 +00:00
# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py)
2017-10-27 23:06:23 +01:00
2017-06-13 13:34:17 +01:00
if (PYTHONLIBS_FOUND AND SWIG_FOUND)
2017-11-11 22:48:09 +00:00
add_subdirectory(packages/python/swig)
2017-06-13 13:34:17 +01:00
2017-11-11 22:48:09 +00:00
include(FindPythonModule)
2017-06-13 13:34:17 +01:00
2017-11-11 22:48:09 +00:00
find_python_module(jupyter)
2017-06-13 13:34:17 +01:00
2017-11-11 22:48:09 +00:00
if (PY_JUPYTER)
add_subdirectory(packages/python/yap_kernel)
ENDIF ()
endif ()
2017-06-13 13:34:17 +01:00
2017-07-25 01:10:44 +01:00
2017-11-21 15:44:43 +00:00
IF ( ANDROID)
add_subDIRECTORY(packages/swig )
target_link_libraries(libYap android log)
2017-11-11 22:48:09 +00:00
ENDIF ()
2017-07-25 01:10:44 +01:00
2017-10-11 02:24:15 +01:00
message(STATUS "Building YAP packages version ${YAP_VERSION}")
if (NOT WIN32)
2017-11-11 22:48:09 +00:00
set(BUILD_SHARED_LIBS ON)
endif ()
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
option(WITH_JIT
"just in Time Clause Compilation" OFF)
2017-10-11 02:24:15 +01:00
if (WITH_JIT)
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(JIT)
2017-10-11 02:24:15 +01:00
endif (WITH_JIT)
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/raptor)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/xml)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
OPTION(WITH_CLPBN " Enable the CLPBN and PFL probabilistic languages" ON)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
OPTION(WITH_CPLINT " Enable the cplint probabilistic language" ON)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
OPTION(WITH_HORUS " Enable the CLPBN and PFL probabilistic languages" ON)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
OPTION(WITH_DOCS " Enable documentation, requires doxygen-yap" ON)
2017-10-11 02:24:15 +01:00
IF (WITH_CLPBN)
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/CLPBN)
ENDIF (WITH_CLPBN)
2017-10-11 02:24:15 +01:00
IF (WITH_CPLINT)
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/cplint)
ENDIF (WITH_CPLINT)
2017-10-17 00:13:09 +01:00
# please install doxygen for prolog first
# git clone http://www.github.com/vscosta/doxygen-yap
# cd doxygen-yap
# mkdir -p build
# cd build
# make; sudo make install
2017-11-11 22:48:09 +00:00
option(WITH_DOCS
"generate YAP docs" OFF)
2017-10-17 00:13:09 +01:00
IF (WITH_DOCS)
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(docs)
2017-10-17 00:13:09 +01:00
ENDIF (WITH_DOCS)
2017-10-11 02:24:15 +01:00
# add_subDIRECTORY (packages/cuda)
2017-11-11 22:48:09 +00:00
option(WITH_GECODE
"interface gecode constraint solver" ON)
2017-10-11 02:24:15 +01:00
if (WITH_GECODE)
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/gecode)
endif ()
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/real)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/jpl)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/bdd)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/ProbLog)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/swi-minisat2)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_subDIRECTORY(packages/clpqr)
2017-10-11 02:24:15 +01:00
#todo: use cmake target builds
# option (USE_MAXPERFORMANCE
# "try using the best flags for specific architecture" OFF)
# option (USE_MAXMEMORY
# "try using the best flags for using the memory to the most" ON)
#TODO: check MAXMEMORY
#TODO: use cmake target builds
# option (USE_DEBUGYAP
# "enable C-debugging for YAP" OFF)
#TODO: use cmake arch/compiler
# option (USE_CYGWIN
# "use cygwin library in WIN32" OFF)
2017-11-11 22:48:09 +00:00
option(WITH_PRISM
"use PRISM system in YAP" ON)
2017-10-11 02:24:15 +01:00
#TODO:
2017-11-11 22:48:09 +00:00
option(WITH_YAP_DLL
"compile YAP as a DLL" ON)
2017-10-11 02:24:15 +01:00
#TODO:
2017-11-11 22:48:09 +00:00
option(WITH_YAP_STATIC
"compile YAP statically" OFF)
2017-10-11 02:24:15 +01:00
#TODO:
option(WITH_YAP_CONDOR
2017-11-11 22:48:09 +00:00
"allow YAP to be used from condor" OFF)
2017-10-11 02:24:15 +01:00
if (WITH_YAP_CONDOR)
2017-11-11 22:48:09 +00:00
# use default allocator
set(YAP_STATIC ON)
set(YAP_DLL OFF)
endif ()
2017-10-11 02:24:15 +01:00
#TODO: detect arch before allow this option
# OPTION(WIN64
# "compile YAP for win64" OFF)
# option (APRIL
# "compile Yap to support April ILP system" OFF)
# option (DLCOMPAT
# "use dlcompat library for dynamic loading on Mac OS X" OFF)
# SHARED PACKAGES with SWI
# swi packages have both Makefile.in which we will use and
# Makefile.mak, we will use the later to identify this packages
# while we keep both autotools amd cmake working side by side
# Search for available packages which all have a Makefile.mak
#file (GLOB PACKAGES packages/*/Makefile.mak)
# needed by this packages
2017-11-11 22:48:09 +00:00
if (WIN32)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
if (MSVC)
set(MSVC_RUNTIME "dynamic")
ENDIF (MSVC)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
target_link_libraries(libYap wsock32 ws2_32 Shlwapi)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
endif (WIN32)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
add_executable(yap-bin ${CONSOLE_SOURCES})
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
set_target_properties(yap-bin PROPERTIES OUTPUT_NAME yap)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
target_link_libraries(yap-bin libYap)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
install(TARGETS libYap yap-bin
2017-12-05 15:14:57 +00:00
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
2017-11-11 22:48:09 +00:00
)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation" ON
"NOT WITH_YAPOR_THOR" OFF)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON
"NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF)
2017-10-11 02:24:15 +01:00
2017-11-21 15:44:43 +00:00
if (NOT ANDROID)
2017-10-17 00:13:09 +01:00
add_subDIRECTORY(library/lammpi)
2017-10-11 02:24:15 +01:00
2017-10-17 00:13:09 +01:00
if (MPI_C_FOUND)
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
CMAKE_DEPENDENT_OPTION(WITH_MPI ON "Interface to OpenMPI/MPICH"
"MPI_C_FOUND" OFF)
macro_optional_add_subDIRECTORY(library/mpi)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS} ")
include_directories(${MPI_C_INCLUDE_PATH})
target_link_libraries(yap-bin ${MPI_C_LIBRARIES})
if (MPI_C_COMPILE_FLAGS)
set_target_properties(yap-bin PROPERTIES
COMPILE_FLAGS "${MPI_C_COMPILE_FLAGS}")
endif (MPI_C_COMPILE_FLAGS)
if (MPI_C_LINK_FLAGS)
set_target_properties(yap-bin PROPERTIES
LINK_FLAGS "${MPI_C_LINK_FLAGS}")
endif ()
2017-10-17 00:13:09 +01:00
endif (MPI_C_FOUND)
2017-10-11 02:24:15 +01:00
2017-11-21 15:44:43 +00:00
endif(NOT ANDROID)
2017-10-11 02:24:15 +01:00
## add_subDIRECTORY(utils)
#
2017-12-10 01:22:45 +00:00
install(FILES ${INCLUDE_HEADERS} ${CONFIGURATION_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Yap )
2017-12-05 15:14:57 +00:00
2017-10-11 02:24:15 +01:00
macro_display_feature_log()
2017-11-11 22:48:09 +00:00
if (POLICY CMP0058)
cmake_policy(SET CMP0058 NEW)
endif (POLICY CMP0058)
2017-10-11 02:24:15 +01:00
2017-12-05 15:14:57 +00:00
include(Config )
2017-07-30 22:24:00 +01:00
2017-10-11 02:24:15 +01:00
2017-07-30 22:24:00 +01:00
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES
2017-11-11 22:48:09 +00:00
INCLUDE_QUIET_PACKAGES
)
2017-12-05 15:14:57 +00:00