Changeset: a453b13d2b41 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a453b13d2b41
Modified Files:
CMakeLists.txt
CMakeReadme.txt
clients/mapiclient/CMakeLists.txt
clients/mapilib/CMakeLists.txt
clients/odbc/driver/CMakeLists.txt
clients/odbc/samples/CMakeLists.txt
clients/odbc/setup/CMakeLists.txt
common/stream/CMakeLists.txt
gdk/CMakeLists.txt
sql/backends/monet5/vaults/bam/CMakeLists.txt
testing/CMakeLists.txt
testing/Mtest.py.in
Branch: cmake-fun
Log Message:
Major cleanup. Use default cmake methods to find libraries.
diffs (truncated from 751 to 300 lines):
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -331,196 +331,88 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "Inte
endif()
endif()
-set(PYTHON2 "AUTO" CACHE PATH "python2 is installed in DIR")
-set(PYTHON3 "AUTO" CACHE PATH "python3 is installed in DIR")
-message(STATUS "Checking major version of Python interpreter")
-find_program(PYTHON_INTERPRETER python)
-if(PYTHON_INTERPRETER)
- exec_program("${PYTHON_INTERPRETER}" ARGS "-V" OUTPUT_VARIABLE
PY_OUPUT_RES RETURN_VALUE PY_RETURN_CODE)
- string(REGEX REPLACE "Python *\([0-9]+\)\\.[0-9]+\\.[0-9]+" "\\1"
MAJOR_PYTHON "${PY_OUPUT_RES}")
- if(PY_RETURN_CODE EQUAL 0 AND PY_OUPUT_RES)
- if("${MAJOR_PYTHON}" EQUAL "2") # Python 2 has precedence
- set(HAVE_PYTHON2 YES)
- set(PY2_OUPUT_RES "${PY_OUPUT_RES}")
- elseif("${MAJOR_PYTHON}" EQUAL "3")
- set(HAVE_PYTHON3 YES)
- set(PY3_OUPUT_RES "${PY_OUPUT_RES}")
- else()
- message(FATAL_ERROR "Only python versions 2 and 3 are
supported by MonetDB")
- endif()
- if(HAVE_PYTHON2 OR HAVE_PYTHON3)
- set(HAVE_PYTHON YES)
- message(STATUS "Major Python interpreter:
${MAJOR_PYTHON}")
- endif()
- endif()
-else()
- message(STATUS "A python interpreter was not found")
-endif()
-
-if(NOT ${PYTHON2} STREQUAL "NO")
- if(${PYTHON2} STREQUAL "AUTO")
- if(MAJOR_PYTHON EQUAL 2)
- set(PYTHON2_INTERPRETER "${PYTHON_INTERPRETER}")
- else()
- find_program(PYTHON2_INTERPRETER python2)
- endif()
- else()
- set(PYTHON2_INTERPRETER "${PYTHON2}/python2")
- endif()
+set(PY2_INCLUDE_DIR "")
+set(PY2_LIBRARIES "")
+set(PY3_INCLUDE_DIR "")
+set(PY3_LIBRARIES "")
+set(ENABLE_PY2INTEGRATION "AUTO" CACHE STRING "Enable support for Python 2
integration into MonetDB (default=AUTO)") # Check with HAVE_LIBPY
+set(ENABLE_PY3INTEGRATION "AUTO" CACHE STRING "enable support for Python 3
integration into MonetDB (default=AUTO)") # Check with HAVE_LIBPY3
- if(NOT CMAKE_CROSSCOMPILING)
- exec_program("${PYTHON2_INTERPRETER}" ARGS "-V" OUTPUT_VARIABLE
PY2_CUSTOM_OUPUT_RES RETURN_VALUE PY2_RETURN_CODE)
- if(PY2_RETURN_CODE EQUAL 0 AND PY2_CUSTOM_OUPUT_RES)
- string(FIND "${PY2_CUSTOM_OUPUT_RES}" "Python 2"
HAS_PYTHON2)
- if(HAS_PYTHON2 EQUAL -1)
- if(${PYTHON2} STREQUAL "YES")
- message(FATAL_ERROR "Python 2
executable not found")
- else()
- message(STATUS "Python 2 executable not
found")
- endif()
- else()
- set(HAVE_PYTHON2 YES)
- set(PY2_OUPUT_RES ${PY2_CUSTOM_OUPUT_RES})
- endif()
- endif()
- if(NOT HAVE_PYTHON2)
- if(${PYTHON2} STREQUAL "YES")
- message(FATAL_ERROR "Python 2 executable not
found")
- else()
- message(STATUS "Python 2 executable not found")
- endif()
- endif()
+include(FindPython2)
+include(FindPython3)
+find_package(Python2 COMPONENTS Interpreter Development)
+find_package(Python3 COMPONENTS Interpreter Development)
+if(Python2_FOUND)
+ if(Python2_VERSION_MINOR LESS 6)
+ message(WARNING "Python 2 executable is too old (<2.6)")
+ else()
+ set(HAVE_PYTHON2 YES)
+ set(PY2_INCLUDE_DIR "${Python2_INCLUDE_DIRS}")
+ set(PY2_LIBRARIES "${Python2_LIBRARIES}")
+ set(PYTHON2 "${Python2_EXECUTABLE}")
endif()
-
- if(HAVE_PYTHON2)
- string(REGEX REPLACE "Python *[0-9]+\\.\([0-9]+\)\\.[0-9]+"
"\\1" PY2_VERSION "${PY2_OUPUT_RES}")
- if(PY2_VERSION LESS 6)
- set(HAVE_PYTHON2 NO)
- if(${PYTHON2} STREQUAL "YES")
- message(FATAL_ERROR "Python 2 executable is too
old (<2.6)")
- else()
- message(WARNING "Python 2 executable is too old
(<2.6)")
- endif()
- endif()
+endif()
+if(Python3_FOUND)
+ if(Python3_VERSION_MINOR LESS 5)
+ message(WARNING "Python 3 executable is too old (<3.5)")
+ else()
+ set(HAVE_PYTHON3 YES)
+ set(PY3_INCLUDE_DIR "${Python3_INCLUDE_DIRS}")
+ set(PY3_LIBRARIES "${Python3_LIBRARIES}")
+ set(PYTHON3 "${Python3_EXECUTABLE}")
endif()
-
- set(PYTHON2_LIBDIR "AUTO" CACHE PATH "Path for Python 2 library
directory (where Python 2 modules should be installed)")
- if(HAVE_PYTHON2 AND ${PYTHON2_LIBDIR} STREQUAL "YES" OR
${PYTHON2_LIBDIR} STREQUAL "AUTO")
- if(CMAKE_CROSSCOMPILING)
- if(${PYTHON2} STREQUAL "YES")
- message(FATAL_ERROR "Must specify
PYTHON2_LIBDIR when cross compiling")
- else()
- message(WARNING "Must specify PYTHON2_LIBDIR
when cross compiling")
- endif()
- endif()
- if(APPLE AND CMAKE_SYSTEM_VERSION VERSION_EQUAL 9 AND
PY2_VERSION VERSION_EQUAL 2.5)
- exec_program("${PYTHON2_INTERPRETER}" ARGS "-c \"import
distutils.sysconfig; print
distutils.sysconfig.get_python_lib(1,1,'${LIBDIR}')\"" OUTPUT_VARIABLE
PYTHON2_LIBDIR RETURN_VALUE PYTHON2_LIBDIR_CODE) # TODO Escape this
- if(PYTHON2_LIBDIR)
- set(PYTHON2_LIBDIR
"${PYTHON2_LIBDIR}/site-packages") # Runs on a POSIX platform, so it's safe to
do
- endif()
- else()
- exec_program("${PYTHON2_INTERPRETER}" ARGS "-c \"import
distutils.sysconfig; print
distutils.sysconfig.get_python_lib(1,0,'${LIBDIR}')\"" OUTPUT_VARIABLE
PYTHON2_LIBDIR RETURN_VALUE PYTHON2_LIBDIR_CODE) # TODO Escape this
- endif()
-
+endif()
+if(HAVE_PYTHON2 OR HAVE_PYTHON2)
+ set(HAVE_PYTHON YES)
+ if(HAVE_PYTHON2) # Prioritize python 2 over python 3
+ exec_program("${PYTHON2}" ARGS "-c \"import
distutils.sysconfig;
print(distutils.sysconfig.get_python_lib(1,0,'${LIBDIR}'))\"" OUTPUT_VARIABLE
PYTHON2_LIBDIR RETURN_VALUE PYTHON2_LIBDIR_CODE)
if(PYTHON2_LIBDIR AND PYTHON2_LIBDIR_CODE EQUAL 0)
string(LENGTH "${LIBDIR}" LIBDIR_LENGTH)
string(LENGTH "${PYTHON2_LIBDIR}"
PYTHON2_LIBDIR_PREFIX_LENGTH)
math(EXPR LEN1 "${LIBDIR_LENGTH}+1") # add the /
separator
- string(SUBSTRING "${PYTHON2_LIBDIR}" ${LEN1} -1
PYTHON2_LIBDIR) # remove the prefix
- elseif(${PYTHON2} STREQUAL "YES")
- message(FATAL_ERROR "Could not find PYTHON2_LIBDIR")
+ string(SUBSTRING "${PYTHON2_LIBDIR}" ${LEN1} -1
PYTHON_LIBDIR) # remove the prefix
else()
- message(STATUS "Could not find PYTHON2_LIBDIR")
- endif()
- endif()
-else()
- set(HAVE_PYTHON2 NO)
-endif()
-
-if(NOT ${PYTHON3} STREQUAL "NO")
- if(${PYTHON3} STREQUAL "AUTO")
- if(MAJOR_PYTHON EQUAL 3)
- set(PYTHON3_INTERPRETER "${PYTHON_INTERPRETER}")
- else()
- find_program(PYTHON3_INTERPRETER python3)
+ message(FATAL_ERROR "Could not find PYTHON2_LIBDIR")
endif()
else()
- set(PYTHON3_INTERPRETER "${PYTHON3}/python3")
- endif()
-
- if(NOT CMAKE_CROSSCOMPILING)
- exec_program("${PYTHON3_INTERPRETER}" ARGS "-V" OUTPUT_VARIABLE
PY3_CUSTOM_OUPUT_RES RETURN_VALUE PY3_RETURN_CODE)
- if(PY3_RETURN_CODE EQUAL 0 AND PY3_CUSTOM_OUPUT_RES)
- string(FIND "${PY3_CUSTOM_OUPUT_RES}" "Python 3"
HAS_PYTHON3)
- if(HAS_PYTHON3 EQUAL -1)
- if(${PYTHON3} STREQUAL "YES")
- message(FATAL_ERROR "Python 3
executable not found")
- else()
- message(STATUS "Python 3 executable not
found")
- endif()
- else()
- set(HAVE_PYTHON3 YES)
- set(PY3_OUPUT_RES ${PY3_CUSTOM_OUPUT_RES})
- endif()
- endif()
- if(NOT HAVE_PYTHON3)
- if(${PYTHON3} STREQUAL "YES")
- message(FATAL_ERROR "Python 3 executable not
found")
- else()
- message(STATUS "Python 3 executable not found")
- endif()
- endif()
- endif()
-
- if(HAVE_PYTHON3)
- string(REGEX REPLACE "Python *[0-9]+\\.\([0-9]+\)\\.[0-9]+"
"\\1" PY3_VERSION "${PY3_OUPUT_RES}")
- if(PY3_VERSION LESS 5)
- set(HAVE_PYTHON3 NO)
- if(${PYTHON3} STREQUAL "YES")
- message(FATAL_ERROR "Python 3 executable is too
old (<3.5)")
- else()
- message(WARNING "Python 3 executable is too old
(<3.5)")
- endif()
- endif()
- endif()
-
- set(PYTHON3_LIBDIR "AUTO" CACHE PATH "Path for Python 3 library
directory (where Python 3 modules should be installed)")
- if(HAVE_PYTHON3 AND ${PYTHON3_LIBDIR} STREQUAL "YES" OR
${PYTHON3_LIBDIR} STREQUAL "AUTO")
- if(CMAKE_CROSSCOMPILING)
- if(${PYTHON3} STREQUAL "YES")
- message(FATAL_ERROR "Must specify
PYTHON3_LIBDIR when cross compiling")
- else()
- message(WARNING "Must specify PYTHON3_LIBDIR
when cross compiling")
- endif()
- endif()
- exec_program("${PYTHON3_INTERPRETER}" ARGS "-c \"import
distutils.sysconfig;
print(distutils.sysconfig.get_python_lib(1,0,'${LIBDIR}'))\"" OUTPUT_VARIABLE
PYTHON3_LIBDIR RETURN_VALUE PYTHON3_LIBDIR_CODE)
-
+ exec_program("${PYTHON3}" ARGS "-c \"import
distutils.sysconfig;
print(distutils.sysconfig.get_python_lib(1,0,'${LIBDIR}'))\"" OUTPUT_VARIABLE
PYTHON3_LIBDIR RETURN_VALUE PYTHON3_LIBDIR_CODE)
if(PYTHON3_LIBDIR AND PYTHON3_LIBDIR_CODE EQUAL 0)
string(LENGTH "${LIBDIR}" LIBDIR_LENGTH)
string(LENGTH "${PYTHON3_LIBDIR}"
PYTHON3_LIBDIR_PREFIX_LENGTH)
math(EXPR LEN1 "${LIBDIR_LENGTH}+1") # add the /
separator
- string(SUBSTRING "${PYTHON3_LIBDIR}" ${LEN1} -1
PYTHON3_LIBDIR) # remove the prefix
- elseif(${PYTHON3} STREQUAL "YES")
+ string(SUBSTRING "${PYTHON3_LIBDIR}" ${LEN1} -1
PYTHON_LIBDIR) # remove the prefix
+ else()
message(FATAL_ERROR "Could not find PYTHON3_LIBDIR")
- else()
- message(STATUS "Could not find PYTHON3_LIBDIR")
endif()
endif()
else()
- set(HAVE_PYTHON3 NO)
+ message(FATAL_ERROR "A valid python 2 or python 3 interpreter is
required to compile MonetDB")
endif()
-if(HAVE_PYTHON2 AND "${PYTHON2_LIBDIR_CODE}" STREQUAL "0")
- set(PYTHON_LIBDIR ${PYTHON2_LIBDIR})
-elseif(HAVE_PYTHON3 AND "${PYTHON3_LIBDIR_CODE}" STREQUAL "0")
- set(PYTHON_LIBDIR ${PYTHON3_LIBDIR})
+function(MT_testPythonIntegration HAVE_LIBPY PY_MAJOR_VERSION
INTEGRATION_ENABLED INTERPRETER_PATH)
+ message(STATUS "Checking for numpy version")
+ exec_program("${INTERPRETER_PATH}" ARGS "-c \"import numpy;
print(int(numpy.__version__.split('.').__getitem__(1)) >= 7)\"" OUTPUT_VARIABLE
NUMPY_OUTPUT RETURN_VALUE NUMPY_RETURN_CODE)
+ if(NUMPY_RETURN_CODE EQUAL 0 AND "${NUMPY_OUTPUT}" STREQUAL "True")
+ set(${HAVE_LIBPY} YES PARENT_SCOPE)
+ message(STATUS "numpy version >= 1.7.0 for Python
${PY_MAJOR_VERSION} found")
+ elseif("${INTEGRATION_ENABLED}" STREQUAL "YES")
+ message(FATAL_ERROR "numpy version >= 1.7.0 required for Python
${PY_MAJOR_VERSION} integration support")
+ else()
+ message(STATUS "numpy version >= 1.7.0 required for Python
${PY_MAJOR_VERSION} integration support")
+ endif()
+endfunction()
+if(HAVE_PYTHON2 AND NOT ${ENABLE_PY2INTEGRATION} STREQUAL "NO")
+ MT_testPythonIntegration(HAVE_LIBPY 2 ${ENABLE_PY2INTEGRATION}
${Python2_EXECUTABLE})
+endif()
+if(HAVE_PYTHON3 AND NOT ${ENABLE_PY3INTEGRATION} STREQUAL "NO")
+ MT_testPythonIntegration(HAVE_LIBPY3 3 ${ENABLE_PY3INTEGRATION}
${Python3_EXECUTABLE})
endif()
set(ENABLE_TESTING "AUTO" CACHE STRING "Enable support for testing
(default=AUTO)")
-if(NOT ENABLE_TESTING STREQUAL "NO" AND NOT HAVE_PYTHON2 AND NOT HAVE_PYTHON3)
+if(NOT "${ENABLE_TESTING}" STREQUAL "NO" AND NOT HAVE_PYTHON2 AND NOT
HAVE_PYTHON3)
set(ENABLE_TESTING "NO")
endif()
-if(NOT ${ENABLE_TESTING} STREQUAL "NO")
+if(NOT "${ENABLE_TESTING}" STREQUAL "NO")
set(HAVE_TESTING ON)
endif()
@@ -672,28 +564,11 @@ if(PSAPI_LIBRARY)
endif()
# Thread libraries
-set(THREAD_INCLUDE_DIR "")
-set(THREAD_LIBRARY_DIR "")
-if(NOT WIN32)
- set(WITH_THREAD "AUTO" CACHE PATH "Thread library is installed in DIR")
-endif()
+set(THREADS_PREFER_PTHREAD_FLAG ON) # We do prefer pthreads
+find_package(Threads REQUIRED)
+set(THREAD_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
cmake_push_check_state()
-if(NOT WIN32 AND NOT "${WITH_THREAD}" STREQUAL "AUTO")
- set(THREAD_INCLUDE_DIR "${WITH_THREAD}/include")
- set(THREAD_LIBRARY_DIR "${WITH_THREAD}/lib")
- set(THREAD_LIBRARIES "pthread")
- set(CMAKE_REQUIRED_INCLUDES
"${CMAKE_REQUIRED_INCLUDES};${THREAD_INCLUDE_DIR}") # Set back again in the end!
- set(CMAKE_REQUIRED_LINK_OPTIONS
"${CMAKE_REQUIRED_LINK_OPTIONS};${THREAD_LIBRARY_DIR}") # Set back again in the
end!
- check_symbol_exists("pthread_create" "pthread.h" HAVE_PTHREAD_CREATE)
- if(NOT HAVE_PTHREAD_CREATE)
- message(FATAL_ERROR "MonetDB requires a pthread library on UNIX
systems")
- endif()
-else()
- set(THREADS_PREFER_PTHREAD_FLAG ON) # We do prefer pthreads
- find_package(Threads REQUIRED)
- set(THREAD_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
- set(CMAKE_REQUIRED_LIBRARIES
"${CMAKE_REQUIRED_LIBRARIES};${THREAD_LIBRARIES}")
-endif()
+set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};${THREAD_LIBRARIES}")
check_include_file("pthread.h" HAVE_PTHREAD_H)
check_include_file("semaphore.h" HAVE_SEMAPHORE_H)
check_symbol_exists("pthread_kill" "signal.h" HAVE_PTHREAD_KILL)
@@ -701,19 +576,10 @@ check_symbol_exists("pthread_sigmask" "s
cmake_pop_check_state()
# Readline libs
-set(READLINE_INCLUDE_DIR "")
set(READLINE_LIBRARIES "")
-set(READLINE_LIBRARY_DIR "")
-set(WITH_READLINE "AUTO" CACHE PATH "Readline library is installed in DIR") #
Check with HAVE_LIBREADLINE
+set(WITH_READLINE "AUTO" CACHE PATH "Include readline support (default=AUTO)")
# Check with HAVE_LIBREADLINE
if(NOT ${WITH_READLINE} STREQUAL "NO")
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list