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/packages/myddas/CMakeLists.txt

122 lines
4.0 KiB
CMake
Raw Normal View History

2015-04-21 23:12:18 +01:00
SET( CMAKE_FIND_FRAMEWORK LAST)
SET( CMAKE_FIND_APPBUNDLE LAST)
2014-12-14 12:05:43 +00:00
set( MYDDAS_SOURCES
myddas_mysql.c
myddas_odbc.c
2015-02-17 20:26:46 +00:00
myddas_postgres.c
myddas_sqlite3.c
2014-12-14 12:05:43 +00:00
myddas_util.c
myddas_initialization.c
myddas_shared.c
myddas_statistics.c
myddas_top_level.c
myddas_wkb2prolog.c )
set( MYDDAS_PROLOG
pl/myddas.ypp
pl/myddas_assert_predicates.ypp
pl/myddas_mysql.ypp
2015-02-17 20:26:46 +00:00
pl/myddas_sqlite3.ypp
pl/myddas_postgres.ypp
2014-12-14 12:05:43 +00:00
pl/myddas_top_level.ypp
pl/myddas_errors.ypp
pl/myddas_prolog2sql.ypp
2015-01-26 04:02:46 +00:00
pl/myddas_util_predicates.ypp
2014-12-14 12:05:43 +00:00
pl/myddas_prolog2sql_optimizer.ypp )
function(cpp_compile filename)
get_filename_component(base ${filename} NAME_WE)
set(base_abs ${CMAKE_CURRENT_BINARY_DIR}/${base})
set(output ${base_abs}.yap)
add_custom_command(
OUTPUT ${output}
COMMAND ${CMAKE_C_COMPILER} -E ${CMAKE_C_FLAGS} -P -E -w -o ${CMAKE_CURRENT_BINARY_DIR} ${filename})
set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
endfunction()
foreach(file ${MYDDAS_PROLOG})
cpp_compile(GENERATED_SOURCES ${file})
endforeach()
source_group("" FILES ${MYDDAS_PROLOG})
source_group(generated FILES ${GENERATED_SOURCES})
macro_optional_find_package(ODBC ON)
macro_optional_find_package(MySQL ON)
2015-01-26 04:02:46 +00:00
macro_optional_find_package(Sqlite3 ON)
2015-02-17 20:26:46 +00:00
macro_optional_find_package(PostgreSQL ON)
2014-12-14 12:05:43 +00:00
2015-02-03 02:37:25 +00:00
macro_log_feature (ODBC_FOUND "ODBC"
"Use ODBC Data-Base Interface "
"http://www.unixodbc.org" FALSE)
macro_log_feature (MYSQL_FOUND "MySQL"
"Use MYSQL Data-Base Interface "
"http://www.mysql.org" FALSE)
2015-02-17 20:26:46 +00:00
macro_log_feature (SQLITE3_FOUND "SQLite3"
"SQL Light Data-Base "
"http://www.sqlite3.org" FALSE)
2015-02-03 02:37:25 +00:00
2015-02-17 20:26:46 +00:00
macro_log_feature (PostgreSQL_FOUND "PostgreSQL"
"PostgreSQL Data-Base "
"http://www.postgresql.org" FALSE)
if (ODBC_FOUND OR MYSQL_FOUND OR SQLITE3_FOUND OR PostgreSQL_FOUND)
add_definitions (-DUSE_MYDDAS=1)
2014-12-14 12:05:43 +00:00
add_library (myddas SHARED ${MYDDAS_SOURCES})
2015-01-26 04:02:46 +00:00
target_link_libraries(myddas libYap)
2014-12-14 12:05:43 +00:00
if (ODBC_FOUND)
2015-01-26 04:02:46 +00:00
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h
# ODBC_LIBRARIES, the libraries to link against to use ODBC
# ODBC_FOUND. If false, you cannot build anything that requires MySQL.
2015-02-03 02:37:25 +00:00
add_definitions (-DMYDDAS_ODBC=1)
2015-01-26 04:02:46 +00:00
target_link_libraries(myddas ${ODBC_LIBRARIES})
include_directories (${ODBC_INCLUDE_DIRECTORIES})
2014-12-14 12:05:43 +00:00
endif (ODBC_FOUND)
2015-01-26 04:02:46 +00:00
if (SQLITE3_FOUND)
2015-02-17 20:26:46 +00:00
# SQLITE3_FOUND - system has Sqlite3
# SQLITE3_INCLUDE_DIRS - the Sqlite3 include directory
# SQLITE3_LIBRARIES - Link these to use Sqlite3
# SQLITE3_DEFINITIONS - Compiler switches required for using Sqlite3
2015-04-21 23:12:18 +01:00
check_function_exists( sqlite3_table_column_metadata HAVE_SQLITE3_TABLE_COLUMN_METADATA )
if (HAVE_SQLITE3_TABLE_COLUMN_METADATA:INTERNAL=1)
add_definitions (-DMYDDAS_SQLITE3=1)
target_link_libraries(myddas ${SQLITE3_LIBRARIES})
include_directories (${SQLITE3_INCLUDE_DIRS})
endif()
2015-01-26 04:02:46 +00:00
endif (SQLITE3_FOUND)
if (MYSQL_FOUND)
2014-12-14 12:05:43 +00:00
# MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
# MYSQL_LIBRARIES - List of libraries when using MySQL.
# MYSQL_FOUND - True if MySQL found.
2015-02-03 02:37:25 +00:00
add_definitions (-DMYDDAS_MYSQL=1)
2015-01-26 04:02:46 +00:00
target_link_libraries(myddas ${MYSQL_LIBRARIES})
2014-12-14 12:05:43 +00:00
include_directories (${MYSQL_INCLUDE_DIR})
endif (MYSQL_FOUND)
2015-02-17 20:26:46 +00:00
if (PostgreSQL_FOUND)
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
add_definitions (-DMYDDAS_POSTGRES=1)
target_link_libraries(myddas ${PostgreSQL_LIBRARIES})
include_directories (${MYSQL_INCLUDE_DIRS})
endif (PostgreSQL_FOUND)
2014-12-14 12:05:43 +00:00
add_custom_target (plmyddas ALL DEPENDS ${GENERATED_SOURCES} ) # WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
2015-04-20 01:21:19 +01:00
endif (ODBC_FOUND OR MYSQL_FOUND OR SQLITE3_FOUND OR PostgreSQL_FOUND)
cmake_dependent_option (WITH_MYDDAS_Stats
"enable the MYDDAS library statistics support" OFF
WITH_MYDDAS OFF)
#TODO:
cmake_dependent_option (WITH_MYDDAS_top_level
"enable the MYDDAS top-level support to MySQL" OFF
'WITH_MYDDAS AND MYSQL_FOUND' OFF)
#TODO: