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
2017-02-20 15:28:46 +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-11-11 22:48:09 +00:00
project ( YAP )
2016-08-03 00:30:02 +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-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-11-11 22:48:09 +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
2017-02-20 15:28:46 +00:00
# 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
2017-02-20 15:28:46 +00:00
# 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 )
2016-11-23 23:23:59 +00:00
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
2017-11-11 22:48:09 +00:00
if ( ANACONDA )
set ( CMAKE_LIBRARY_ARCHITECTURE $ENV{ PREFIX } )
set ( CMAKE_PREFIX_PATH $ENV{ PREFIX } $ENV{ SYS_PREFIX } )
set ( PATH $ENV{ PREFIX } /bin $ENV{ SYS_PREFIX } /bin ${ PATH } )
set ( PYTHON_EXECUTABLE "$ENV{PYTHON}" )
set ( R_COMMAND "$ENV{R}" )
# set(CMAKE_INCLUDE_PATH $ENV{SYS_PREFIX}/include ${CMAKE_INCLUDE_PATH} )
#set(CMAKE_LIBRARY_PATH $ENV{SYS_PREFIX}/lib $ENV{SYS_PREFIX}/lib ${CMAKE_LIBRARY_PATH})
# set(ENV{PATH} PATH $ENV{PREFIX}/bin $ENV{SYS_PREFIX}/bin $ENV{PATH})
# set(PATH $ENV{PATH} ${PATH})
#set( CMAKE_INSTALL_PREFIX $ENV{PREFIX} )
set ( PYTHON_LIBRARY $ENV{ PREFIX } /lib/libpython $ENV{ PY_VER } m $ENV{ SHLIB_EXT } )
set ( PYTHON_INCLUDE_DIR $ENV{ PREFIX } /include/python $ENV{ PY_VER } m )
2017-10-17 00:13:09 +01:00
endif ( )
2017-11-11 22:48:09 +00:00
if ( APPLE )
set ( MACOSX_RPATH ON )
if ( NOT ANACONDA )
set ( PATH $ENV{ PATH } )
list ( FIND ${ PATH } pos /usr/local )
if ( pos EQUAL -1 )
set ( pos 0 )
endif ( )
list ( INSERT CMAKE_PREFIX_PATH pos
/ u s r / l o c a l / o p t / g m p
/ u s r / l o c a l / o p t / l i b x m l 2
/ u s r / l o c a l / o p t / o p e n m p i
/ u s r / l o c a l / o p t / o p e n s s l
/ u s r / l o c a l / o p t / p o s t g r e s q l
/ u s r / l o c a l / o p t / p y t h o n 3
/ u s r / l o c a l / o p t / r e a d l i n e
/ u s r / l o c a l / o p t / s w i g
)
endif ( )
endif ( )
if ( ANDROID )
set ( datarootdir /assets )
endif ( )
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})
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
# bindir defined above
# libdir defined above
2017-10-17 00:13:09 +01:00
set ( YAP_SHAREDIR ${ datarootdir } )
set ( YAP_BINDIR ${ bindir } )
set ( YAP_INCLUDEDIR ${ includedir } )
set ( YAP_ROOTDIR ${ prefix } )
set ( YAP_LIBDIR ${ dlls } )
2017-10-11 02:24:15 +01:00
#
#
# include( Sources NO_POLICY_SCOPE )
#
# include( Model NO_POLICY_SCOPE )
2017-11-11 22:48:09 +00:00
include ( cudd NO-POLICY-SCOPE )
include ( java NO-POLICY-SCOPE )
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
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)
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
$ { Y A P _ M A J O R _ V E R S I O N } . $ { Y A P _ M I N O R _ V E R S I O N } . $ { Y A P _ P A T C H _ V E R S I O N } )
2017-10-11 02:24:15 +01:00
set ( YAP_FVERSION
2017-11-11 22:48:09 +00:00
$ { Y A P _ M A J O R _ V E R S I O N } . $ { Y A P _ M I N O R _ V E R S I O N } . $ { Y A P _ P A T C H _ V E R S I O N } )
2017-10-11 02:24:15 +01:00
set ( YAP_NUMERIC_VERSION
2017-11-11 22:48:09 +00:00
$ { Y A P _ M A J O R _ V E R S I O N } * 1 0 0 0 0 + $ { Y A P _ M I N O R _ V E R S I O N } * 1 0 0 + $ { Y A P _ P A T C H _ V E R S I O N } )
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 (
C O M M A N D $ { U N A M E } - m
O U T P U T _ V A R I A B L E Y A P _ A R C H O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
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
# 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
" s u p p o r t f o r p r o c e d u r e - c a l l t r a c i n g " O N )
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
2016-11-11 15:53:09 +00:00
if ( ANDROID )
2017-11-11 22:48:09 +00:00
include_directories (
p a c k a g e s / m y d d a s / s q l i t e 3 / s r c / A n d r o i d / j n i / s q l i t e
p a c k a g e s / m y d d a s / s q l i t e 3 / s r c / A n d r o i d / j n i / s q l i t e / n a t i v e h e l p e r
2017-06-13 13:34:17 +01:00
)
endif ( ANDROID )
2016-11-11 15:53:09 +00:00
2017-11-11 22:48:09 +00:00
set_property ( SOURCE ${ LIBYAP_SOURCES } APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
2017-02-20 15:28:46 +00:00
2016-07-31 10:56:54 +01:00
add_definitions ( -DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1 )
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 ( )
2014-12-04 07:59:30 +00:00
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 ( )
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 )
2014-12-04 07:59:30 +00:00
2017-07-25 01:10:44 +01:00
IF ( WITH_SWIG OR ANDROID )
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-07-25 01:10:44 +01:00
ENDIF ( WITH_SWIG OR ANDROID )
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
" A l l o w P y t h o n - > Y A P a n d Y A P - > P y t h o n " O N )
2017-06-13 13:34:17 +01:00
IF ( WITH_PYTHON )
2017-11-11 22:48:09 +00:00
include ( python NO_POLICY_SCOPE )
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 > )
2017-10-17 00:13:09 +01:00
if ( WIN32 )
2017-11-11 22:48:09 +00:00
List ( APPEND YLIBS $< TARGET_OBJECTS:Yapsqlite3 > )
List ( APPEND YLIBS $< TARGET_OBJECTS:YAP++ > )
if ( WITH_PYTHON )
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
l i b Y a p
2016-07-31 10:56:54 +01:00
2017-11-11 22:48:09 +00:00
# Sets the library as a shared library.
S H A R E D
2017-02-20 15:28:46 +00:00
2017-11-11 22:48:09 +00:00
$ { E N G I N E _ S O U R C E S }
$ { C _ I N T E R F A C E _ S O U R C E S }
/ / $ { S T A T I C _ S O U R C E S }
# cmake object libraries
$ { Y L I B S }
)
2016-04-08 09:13:45 +01:00
2017-02-20 15:28:46 +00:00
if ( WIN32 )
2017-11-11 22:48:09 +00:00
target_link_libraries ( libYap ${ WINDLLS } )
if ( PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES )
target_link_libraries ( libYap ${ PYTHON_LIBRARIES } )
endif ( )
2017-02-20 15:28:46 +00:00
endif ( WIN32 )
2016-08-01 12:54:28 +01:00
2017-10-17 00:13:09 +01:00
if ( GMP_FOUND )
2017-11-11 22:48:09 +00:00
#config.h needs this (TODO: change in code latter)
include_directories ( ${ GMP_INCLUDE_DIRS } )
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
include_directories ( ${ READLINE_INCLUDE_DIR } )
target_link_libraries ( libYap ${ READLINE_LIBRARIES } )
# required for configure
list ( APPEND CMAKE_REQUIRED_LIBRARIES ${ READLINE_LIBRARIES } )
list ( APPEND CMAKE_REQUIRED_INCLUDES ${ READLINE_INCLUDE_DIR } )
endif ( )
2017-10-11 02:24:15 +01:00
set ( YAP_STARTUP startup.yss )
## 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 )
# rpath stuff, hopefully it works
2017-10-17 00:13:09 +01:00
# use, i.e. don't skip the full RPATH for the build tree
2017-11-08 09:29:01 +00:00
# SET(CMAKE_SKIP_BUILD_RPATH FALSE)
2017-10-11 02:24:15 +01:00
2017-11-10 23:08:35 +00:00
2017-10-11 02:24:15 +01:00
# when building, don't use the install RPATH already
# (but later on when installing)
2017-11-08 09:29:01 +00:00
# SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
2017-10-11 02:24:15 +01:00
2017-11-08 09:29:01 +00:00
# SET(CMAKE_INSTALL_RPATH ${CMAKE_CURRENT_BUILD_PATH})
2017-10-11 02:24:15 +01:00
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
2017-11-08 09:29:01 +00:00
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
2017-10-11 02:24:15 +01:00
2017-11-08 09:29:01 +00:00
# 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")
2017-11-10 23:08:35 +00:00
if ( ANACONDA )
2017-11-11 22:48:09 +00:00
SET ( CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
SET ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
SET ( CMAKE_INSTALL_RPATH ${ CMAKE_BINARY_DIR } )
else ( )
SET ( CMAKE_INSTALL_RPATH "${libdir}" )
endif ( )
2017-11-08 09:29:01 +00:00
# ENDIF("${isSystemDir}" STREQUAL "-1")
2017-10-11 02:24:15 +01:00
2017-11-11 22:48:09 +00:00
include_directories ( H
H / g e n e r a t e d
i n c l u d e o s O P T Y a p u t f 8 p r o c J I T / H P P )
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
P R O P E R T I E S O U T P U T _ N A M E Y a p
)
2017-10-17 00:13:09 +01:00
MY_set_target_properties ( libYap
2017-11-11 22:48:09 +00:00
P R O P E R T I E S V E R S I O N $ { Y A P _ F U L L _ V E R S I O N }
S O V E R S I O N $ { Y A P _ M A J O R _ V E R S I O N } . $ { Y A P _ M I N O R _ V E R S I O N }
)
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" )
2014-12-04 07:59:30 +00:00
2016-06-02 11:52:22 +01:00
if ( ANDROID )
2017-11-11 22:48:09 +00:00
target_link_libraries ( libYap android log )
2016-08-22 05:31:21 +01:00
2016-07-31 10:56:54 +01:00
endif ( )
2016-05-31 19:28:29 +01:00
2016-07-31 10:56:54 +01:00
set_target_properties ( libYap
2017-11-11 22:48:09 +00:00
P R O P E R T I E S O U T P U T _ N A M E Y a p
)
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
IF ( SWIG_FOUND OR ANDROID )
2017-11-11 22:48:09 +00:00
add_subDIRECTORY ( packages/swig NO_POLICY_SCOPE )
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
" j u s t i n T i m e C l a u s e C o m p i l a t i o n " O F F )
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
" g e n e r a t e Y A P d o c s " O F F )
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
" i n t e r f a c e g e c o d e c o n s t r a i n t s o l v e r " O N )
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
" u s e P R I S M s y s t e m i n Y A P " O N )
2017-10-11 02:24:15 +01:00
#TODO:
2017-11-11 22:48:09 +00:00
option ( WITH_YAP_DLL
" c o m p i l e Y A P a s a D L L " O N )
2017-10-11 02:24:15 +01:00
#TODO:
2017-11-11 22:48:09 +00:00
option ( WITH_YAP_STATIC
" c o m p i l e Y A P s t a t i c a l l y " O F F )
2017-10-11 02:24:15 +01:00
#TODO:
option ( WITH_YAP_CONDOR
2017-11-11 22:48:09 +00:00
" a l l o w Y A P t o b e u s e d f r o m c o n d o r " O F F )
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
R U N T I M E D E S T I N A T I O N $ { b i n d i r }
L I B R A R Y D E S T I N A T I O N $ { l i b d i r }
A R C H I V E D E S T I N A T I O N $ { l i b d i r }
)
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
" N O T W I T H _ Y A P O R _ T H O R " O F F )
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
" N O T W I T H _ Y A P O R _ T H O R ; N O T W I T H _ S Y S T E M _ M M A P " O F F )
2017-10-11 02:24:15 +01:00
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"
" M P I _ C _ F O U N D " O F F )
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
C O M P I L E _ F L A G S " $ { M P I _ C _ C O M P I L E _ F L A G S } " )
endif ( MPI_C_COMPILE_FLAGS )
if ( MPI_C_LINK_FLAGS )
set_target_properties ( yap-bin PROPERTIES
L I N K _ F L A G S " $ { M P I _ C _ L I N K _ F L A G S } " )
endif ( )
2017-10-17 00:13:09 +01:00
endif ( MPI_C_FOUND )
2017-10-11 02:24:15 +01:00
## add_subDIRECTORY(utils)
#
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-02-20 15:28:46 +00:00
include ( Config NO_POLICY_SCOPE )
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
I N C L U D E _ Q U I E T _ P A C K A G E S
)