compilation support

This commit is contained in:
Vitor Santos Costa 2016-08-01 06:54:28 -05:00
parent bff0440b64
commit 81c00f9736
14 changed files with 359 additions and 48 deletions

View File

@ -33,9 +33,9 @@ include(Prelims NO_POLICY_SCOPE)
include(Sources NO_POLICY_SCOPE)
include(Model NO_POLICY_SCOPE)
include_directories ( utf8proc packages/myddas packages/myddas/sqlite3 packages/myddas/sqlite3/Android/jni/sqlite/nativehelper packages/myddas/sqlite3/Android/jni/sqlite/ )
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
if (MYSQL_FOUND)
@ -75,6 +75,11 @@ else ()
endif ()
if (WIN32)
list (APPEND YLIBS $<TARGET_OBJECTS:Yap++>)
endif()
add_library( # Sets the name of the library.
libYap
@ -84,21 +89,19 @@ add_library( # Sets the name of the library.
${ENGINE_SOURCES}
${C_INTERFACE_SOURCES}
${STATIC_SOURCES}
${HEADERS}
${WINDLLS}
${YLIBS}
${ALL_SOURCES}
${YLIBS}
${WINDLLS}
)
include(libYap)
include(libYap NO_POLICY_SCOPE)
if (USE_GMP)
target_link_libraries(libYap ${READLINE_LIBRARIES})
endif (USE_GMP)
if (USE_READLINE)
target_link_libraries(libYap libGMP)
target_link_libraries(libYap ${READLINE_LIBRARIES})
endif (USE_READLINE)
if (ANDROID)
target_link_libraries(libYap m android log)
@ -108,5 +111,6 @@ set_target_properties(libYap
PROPERTIES OUTPUT_NAME Yap
)
include(Config)
MY_include(Packages)
include(Config NO_POLICY_SCOPE)
MY_include(Packages NO_POLICY_SCOPE)

View File

@ -10,16 +10,19 @@ set (CXX_SOURCES
list(APPEND LIBYAP_SOURCES ${CXX_SOURCES} PARENT_SCOPE)
add_external (Yap++ ${CXX_SOURCES} )
if (ANDROID)
if (ANDROID OR WIN32)
add_component (Yap++ ${CXX_SOURCES} )
else()
add_external (Yap++ ${CXX_SOURCES} )
MY_target_link_libraries(Yap++ ${CMAKE_DL_LIBS} libYap)
endif()
MY_install(TARGETS Yap++
LIBRARY DESTINATION ${libdir}
ARCHIVE DESTINATION ${libdir}
)
endif()
include_directories (H include ${CMAKE_BINARY_DIR} ${GMP_INCLUDE_DIR})

View File

@ -84,3 +84,10 @@ ELSE(READLINE_FOUND)
MESSAGE(SYSTEM_ERROR_FATAL "Could not find readline -- please give some paths to CMake")
ENDIF(READLINE_FIND_REQUIRED)
ENDIF(READLINE_FOUND)
find_package_handle_standard_args(Readline READLINE_INCLUDE_DIR READLINE_LIBRARIES READLINE_readline_LIBRARY READLINE_ncurses_LIBRARY)
MARK_AS_ADVANCED(
READLINE_FOUND
)

View File

@ -106,3 +106,6 @@ set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:L
endif (WITH_CALL_TRACER)
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS UTF8PROC=1)

View File

@ -75,11 +75,9 @@ if (GMP_FOUND)
# GMP_INCLUDE_DIRS - include search path
# GMP_LIBRARIES - libraries to link with
# GMP_LIBRARY_ #add_executable(test ${SOURCES})
add_library(libGMP SHARED IMPORTED GLOBAL)
set_target_properties(libGMP PROPERTIES IMPORTED_LOCATION ${GMP_LIBRARIES})
#config.h needs this (TODO: change in code latter)
include_directories( ${GMP_INCLUDE_DIRS} )
target_link_libraries(libYap libGMP)
target_link_libraries(libYap ${GMP_LIBRARIES} )
endif (GMP_FOUND)
include( Threads )
@ -94,15 +92,19 @@ list(APPEND YAP_SYSTEM_OPTIONS "thread support")
#utf-8 is not an option
# we use the nice UTF-8 package
#available at the Julia project
include_directories ( utf8proc )
MY_ADD_SUBDIRECTORY ( utf8proc )
MY_ADD_SUBDIRECTORY ( os )
MY_ADD_SUBDIRECTORY ( OPTYap )
MY_ADD_SUBDIRECTORY ( packages/myddas )
MY_ADD_SUBDIRECTORY ( utf8proc )
MY_ADD_SUBDIRECTORY ( library/dialect/swi/fli )
MY_ADD_SUBDIRECTORY ( CXX )
if (READLINE_LIBS)
target_link_libraries(libYap ${READLINE_LIBS} )
endif (READLINE_LIBS)
#bootstrap and saved state
add_subDIRECTORY ( pl )

View File

@ -67,9 +67,13 @@ include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckVariableExists)
option (READLINE "GNU readline console" ON)
option (WITH_READLINE "GNU readline console" ON)
if (READLINE)
if (WIN32)
set (WITH_READLINE OFF)
endif (WIN32)
if (WITH_READLINE)
macro_optional_find_package (Readline ON)
macro_log_feature (READLINE_FOUND "libreadline"
"Readline line editing library"
@ -84,10 +88,8 @@ include(CheckVariableExists)
# also defined, but not for general use are
# READLINE_readline_LIBRARY, where to find the READLINE library.
# READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined]
include_directories (BEFORE ${READLINE_INCLUDE_DIR})
set_property( TARGET libYap APPEND PROPERTY LINK_LIBRARIES ${READLINE_LIBRARIES} )
list( APPEND CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES} )
list( APPEND CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES} )
check_include_files( "stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H )
check_include_files( "stdio.h;readline/history.h" HAVE_READLINE_HISTORY_H )
if (HAVE_READLINE_READLINE_H)
@ -113,9 +115,7 @@ list( APPEND CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES} )
endif()
endif (READLINE_FOUND)
set( READLINE_LIBS ${READLINE_LIBRARIES} PARENT_SCOPE)
endif (READLINE)
endif (WITH_READLINE)

View File

@ -35,6 +35,7 @@ set_property(GLOBAL
COMPILE_DEFINITIONS
-DUSE_MYDDAS=1)
include_directories(. sqlite3)
add_subdirectory(sqlite3)
MY_add_subdirectory(mysql)

View File

@ -23,8 +23,16 @@
set_property(GLOBAL
APPEND PROPERTY COMPILE_DEFINITIONS -DMYDDAS_MYSQL=1)
add_library(Yapmysql SHARED ${MYSQL_SOURCES})
target_link_libraries(Yapmysql ${MYSQL_LIBRARIES} libYap)
if (WIN32)
add_library(Yapmysql OBJECT ${MYSQL_SOURCES})
else()
add_library(Yapmysql SHARED ${MYSQL_SOURCES})
target_link_libraries(Yapmysql ${MYSQL_LIBRARIES} libYap)
install(TARGETS Yapmysql
LIBRARY DESTINATION ${dlls}
ARCHIVE DESTINATION ${dlls}
)
endif()
include_directories(${MYSQL_INCLUDE_DIR} ..)
set_target_properties(Yapmysql PROPERTIES
POSITION_INDEPENDENT_CODE ON
@ -37,11 +45,7 @@
-DMYDDAS_MYSQL=1)
install(TARGETS Yapmysql
LIBRARY DESTINATION ${dlls}
ARCHIVE DESTINATION ${dlls}
)
else ()
add_definitions(-DMYDDAS_MYSQL=0)
endif (MYSQL_FOUND)

View File

@ -20,7 +20,6 @@ function(cpp_compile output filename)
get_filename_component(base ${filename} NAME_WE)
set(base_abs ${CMAKE_CURRENT_BINARY_DIR}/${base})
set(outfile ${base_abs}.yap)
message(${outfile})
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
IF (MSVC)
add_custom_command(
@ -39,8 +38,6 @@ endfunction()
function(cpp_driver output dbms filename)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/myddas_${dbms}.yap)
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
message(${outfile})
IF (MSVC)
add_custom_command(
OUTPUT ${outfile}

View File

@ -0,0 +1,226 @@
%/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: myddas_mysql.yap *
* Last rev: *
* mods: *
* comments: MySQL Predicates *
* *
*************************************************************************/
#ifdef MYDDAS_SQLITE3
:- module(myddas_sqlite3,[
sqlite3_result_set/1,
sqlite3_datalog_describe/1,
sqlite3_datalog_describe/2,
sqlite3_describe/3,
sqlite3_describe/2,
sqlite3_datalog_show_tables/1,
sqlite3_datalog_show_tables/0,
sqlite3_show_tables/2,
sqlite3_show_tables/1,
sqlite3_show_database/2,
sqlite3_show_databases/2,
sqlite3_show_databases/1,
sqlite3_change_database/2,
sqlite3_call_procedure/4,
sqlite3_call_procedure/3,
c_sqlite3_change_database/2,
c_sqlite3_connect/4,
c_sqlite3_disconnect/1,
c_sqlite3_get_attributes_types/3,
c_sqlite3_get_database/2,
c_sqlite3_get_fields_properties/3,
c_sqlite3_get_next_result_set/3,
c_sqlite3_query/5,
c_sqlite3_number_of_fields/3,
c_sqlite3_row/3
]).
:- use_module(myddas,[
db_sql/3
]).
:- use_module(myddas_errors,[
'$error_checks'/1
]).
:- use_module(myddas_util_predicates,[
'$get_value'/2,
'$make_atom'/2,
'$make_atom_args'/2,
'$make_a_list'/2,
'$write_or_not'/1
]).
:- load_foreign_files( ['Yapsqlite3'], [], init_sqlite3).
%--------------------------------------------------------
% Public Predicates
%--------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_result_set/1
%
%
sqlite3_result_set(X):-
var(X),!,
get_value(sqlite3_result_set,X).
sqlite3_result_set(use_result):-
set_value(sqlite3_result_set,use_result).
sqlite3_result_set(store_result):-
set_value(sqlite3_result_set,store_result).
%default value
:- sqlite3_result_set(use_result).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_describe/2
%
%
sqlite3_datalog_describe(Relation):-
sqlite3_datalog_describe(myddas,Relation).
sqlite3_datalog_describe(Connection,Relation) :-
'$error_checks'(sqlite3_datalog_describe(Relation,Connection)),
'$get_value'(Connection,Conn),
'$make_atom'(['DESCRIBE ',Relation],SQL),
sqlite3_result_set(Mode),
c_sqlite3_query(SQL,ResultSet,Conn,Mode,_),
c_sqlite3_table_write(ResultSet).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_describe/3
% sqlite3_describe/2
% gives the results of the DESCRIBE statement
% by backtracking
sqlite3_describe(Relation,TableInfo) :-
sqlite3_describe(myddas,Relation,TableInfo).
sqlite3_describe(Connection,Relation,tableinfo(A1,A2,A3,A4,A5,A6)) :-
'$error_checks'(sqlite3_describe(Relation,Connection,_)),
'$get_value'(Connection,Conn),
'$make_atom'(['DESCRIBE ',Relation],SQL),
sqlite3_result_set(Mode),
'$write_or_not'(SQL),
c_sqlite3_query(SQL,ResultSet,Conn,Mode,_),
!,
c_sqlite3_row(ResultSet,6,[A1,A2,A3,A4,A5,A6]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_datalog_show_tables/1
%
%
sqlite3_datalog_show_tables:-
sqlite3_datalog_show_tables(myddas).
sqlite3_datalog_show_tables(Connection) :-
'$error_checks'(sqlite3_show_tables(Connection)),
'$get_value'(Connection,Conn),
sqlite3_result_set(Mode),
'$write_or_not'('.tables'),
c_sqlite3_query('.tables',ResultSet,Conn,Mode,_),
c_sqlite3_table_write(ResultSet).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_show_tables/2
% sqlite3_show_tables/1
% gives the results of the SHOW TABLES statement
% by backtracking
sqlite3_show_tables(Table) :-
sqlite3_show_tables(myddas,Table).
sqlite3_show_tables(Connection,table(Table)) :-
'$error_checks'(sqlite3_show_tables(Connection)),
'$get_value'(Connection,Conn),
sqlite3_result_set(Mode),
'$write_or_not'('.tables'),
c_sqlite3_query('.tables',ResultSet,Conn,Mode,_),
!,c_sqlite3_row(ResultSet,1,[Table]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_show_database/2
%
%
sqlite3_show_database(Connection,Database) :-
'$error_checks'(sqlite3_show_database(Connection,Database)),
'$get_value'(Connection,Con),
c_sqlite3_get_database(Con,Database).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_show_databases/2
%
%
sqlite3_show_databases(Connection,database(Databases)) :-
%'$error_checks'(sqlite3_show_databases(Connection,Database)),
'$get_value'(Connection,Conn),
sqlite3_result_set(Mode),
'$write_or_not'('SHOW DATABASES'),
c_sqlite3_query('SHOW DATABASES',ResultSet,Conn,Mode,_),
!,c_sqlite3_row(ResultSet,1,[Databases]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_show_databases/1
% TODO Error Checks
%
sqlite3_show_databases(Connection) :-
'$error_checks'(sqlite3_show_databases(Connection)),
'$get_value'(Connection,Conn),
sqlite3_result_set(Mode),
'$write_or_not'('SHOW DATABASES'),
c_sqlite3_query('SHOW DATABASES',ResultSet,Conn,Mode,_),
c_sqlite3_table_write(ResultSet).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_change_database/2
%
%
sqlite3_change_database(Connection,Database) :-
'$error_checks'(sqlite3_change_database(Connection,Database)),
'$get_value'(Connection,Con),
'$make_atom'(['USE ',Database],SQL),
'$write_or_not'(SQL),
c_sqlite3_change_database(Con,Database).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sqlite3_call_procedure/4
% sqlite3_call_procedure/3
% sqlite3_call_procedure(+,+,+,?)
% Only support in MySQL 5.0 an above
% Called procedure must return results via MySQL result set
sqlite3_call_procedure(Procedure,Args,Result) :-
sqlite3_call_procedure(myddas,Procedure,Args,Result).
sqlite3_call_procedure(Connection,Procedure,Args,LA) :-
'$error_checks'(sqlite3_call_procedure(Connection,Procedure,Args,LA)),
'$make_atom_args'(Args,ArgsSQL),
'$make_atom'(['CALL ',Procedure,'(',ArgsSQL,')'],SQL),
sqlite3_sql(Connection,SQL,LA).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif /* MYDDAS_SQLITE3 */

View File

@ -22,13 +22,14 @@ set (SQLITE3_FOUND ON CACHE PRIVATE "")
" * Sqlite3 Data-Base (http://www.sqlite3ql.org) is distributed with
MYDDAS" )
include_directories ( .. . Android/jni/sqlite Android/jni/sqlite/nativehelper)
list (APPEND MYDDAS_FLAGS -DMYDDAS_SQLITE3=1)
list (APPEND MYDDAS_FLAGS -DMYDDAS_SQLITE3=1)
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
-DMYDDAS_SQLITE3=1)
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Android/jni/sqlite ${CMAKE_CURRENT_SOURCE_DIR}/Android/jni/sqlite/nativehelper)
if (ANDROID)
add_external (Yapsqlite3 ${YAPSQLITE3_SOURCES} ${YAPSQLITE3_ANDROID_SOURCES})
else()

63
packages/swig/new Normal file
View File

@ -0,0 +1,63 @@
# This is a CMake example for Python
INCLUDE(${SWIG_USE_FILE})
if (PYTHONLIBS_FOUND)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/CXX)
SET(CMAKE_SWIG_FLAGS "")
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTIES SWIG_FLAGS "-includeall")
SET( CMAKE_SWIG_OUTDIR "${PROJECT_BINARY_DIR}/yap" )
SWIG_ADD_MODULE(py python ../yap.i )
SWIG_LINK_LIBRARIES (py Yap++ )
add_dependencies(py Yap++ )
configure_file ("setup.py.cmake"
"yap/setup.py" )
add_custom_target ( PyYAP ALL
COMMAND ${PYTHON_EXECUTABLE} setup.py install
WORKING_DIRECTORY "yap"
DEPENDS python Yap++)
if ( DOCUMENTATION AND DOXYGEN_FOUND )
set(CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
# Run doxygen to only generate the xml
add_custom_command ( OUTPUT ${CMAKE_BINARY_DIR}/doc/xml/ftdi_8c.xml
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/doc
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile.xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS ${c_headers};${c_sources};${cpp_sources};${cpp_headers}
)
# generate .i from doxygen .xml
add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
${CMAKE_BINARY_DIR}/doc/xml/ftdi_8c.xml
${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i
DEPENDS ${CMAKE_BINARY_DIR}/doc/xml/ftdi_8c.xml
)
add_custom_target ( doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i )
add_dependencies( ${SWIG_MODULE_ftdi1_REAL_NAME} doc_i )
endif ()
# add_subdirectory ( examples )
else ()
message(STATUS "Not building python bindings")
endif(PYTHONLIBS_FOUND)

View File

@ -4,6 +4,7 @@ set ( UTF8PROC_SOURCES
utf8proc.c )
add_component(utf8proc ${UTF8PROC_SOURCES} )
#set_source_files_properties(${all_c_files} PROPERTIES LANGUAGE CXX)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
@ -24,12 +25,11 @@ add_definitions (
-DUTF8PROC_EXPORTS
)
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=c99 -pedantic -Wall")
endif ()
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" )
#if (NOT MSVC)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=c99 -pedantic -Wall")
#endif ()
##SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" )
#SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" )
set( CMAKE_REQUIRED_INCLUDES . ${CMAKE_REQUIRED_INCLUDES} )

View File

@ -112,13 +112,13 @@ typedef bool utf8proc_bool;
#endif
#include <limits.h>
#ifdef _WIN32
#if defined( _WIN32 ) && 0
# ifdef UTF8PROC_EXPORTS
# define UTF8PROC_DLLEXPORT __declspec(dllexport)
# else
# define UTF8PROC_DLLEXPORT __declspec(dllimport)
# endif
#elif __GNUC__ >= 4
#elif __GNUC__ >= 4 && 0
# define UTF8PROC_DLLEXPORT __attribute__ ((visibility("default")))
#else
# define UTF8PROC_DLLEXPORT