diff --git a/.github/conda/bld.bat b/.github/conda/bld.bat index 957be95f7..51003ae07 100644 --- a/.github/conda/bld.bat +++ b/.github/conda/bld.bat @@ -4,10 +4,9 @@ cmake -G "%CMAKE_GENERATOR%" -H. -Bbuild ^ -DCMAKE_CXX_COMPILER="%CXX%" ^ -DCMAKE_C_COMPILER="%CC%" ^ -DPython_ROOT_DIR="%PREFIX%" ^ - -DPYTHON_EXECUTABLE="%PYTHON%" ^ - -DCLINGO_REQUIRE_PYTHON=ON ^ + -DPython_EXECUTABLE="%PYTHON%" ^ + -DCLINGO_BUILD_WITH_PYTHON=ON ^ -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^ - -DPYCLINGO_USER_INSTALL=OFF ^ -DCLINGO_BUILD_WITH_LUA=OFF ^ -DCLINGO_MANAGE_RPATH=OFF diff --git a/.github/conda/build.sh b/.github/conda/build.sh index b5b7e1781..3e70836c8 100644 --- a/.github/conda/build.sh +++ b/.github/conda/build.sh @@ -14,9 +14,8 @@ cmake .. \ -DCMAKE_C_COMPILER="${CC}" \ -DPython_ROOT_DIR="${PREFIX}" \ -DPython_EXECUTABLE="${PYTHON}" \ - -DCLINGO_REQUIRE_PYTHON=ON \ + -DCLINGO_BUILD_WITH_PYTHON=ON \ -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ - -DPYCLINGO_USER_INSTALL=OFF \ -DCLINGO_BUILD_WITH_LUA=OFF \ -DCLINGO_MANAGE_RPATH=OFF \ -DPYCLINGO_INSTALL_DIR="${SP_DIR}" \ diff --git a/.github/deploy.yml b/.github/deploy.yml index b080b0646..351c95f78 100644 --- a/.github/deploy.yml +++ b/.github/deploy.yml @@ -112,9 +112,8 @@ conda: -DCMAKE_C_COMPILER="${CC}" \ -DPython_ROOT_DIR="${PREFIX}" \ -DPython_EXECUTABLE="${PYTHON}" \ - -DCLINGO_REQUIRE_PYTHON=ON \ + -DCLINGO_BUILD_WITH_PYTHON=ON \ -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ - -DPYCLINGO_USER_INSTALL=OFF \ -DCLINGO_BUILD_WITH_LUA=OFF \ -DCLINGO_MANAGE_RPATH=OFF \ -DPYCLINGO_INSTALL_DIR="${SP_DIR}" \ @@ -131,10 +130,9 @@ conda: -DCMAKE_CXX_COMPILER="%CXX%" ^ -DCMAKE_C_COMPILER="%CC%" ^ -DPython_ROOT_DIR="%PREFIX%" ^ - -DPYTHON_EXECUTABLE="%PYTHON%" ^ - -DCLINGO_REQUIRE_PYTHON=ON ^ + -DPython_EXECUTABLE="%PYTHON%" ^ + -DCLINGO_BUILD_WITH_PYTHON=ON ^ -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^ - -DPYCLINGO_USER_INSTALL=OFF ^ -DCLINGO_BUILD_WITH_LUA=OFF ^ -DCLINGO_MANAGE_RPATH=OFF @@ -253,4 +251,4 @@ ppa: dh $@ --with python3 override_dh_auto_configure: - dh_auto_configure -- -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) -DCLINGO_BUILD_REVISION=$(CLINGO_BUILD_REVISION) -DCLINGO_REQUIRE_LUA=On -DCLINGO_REQUIRE_PYTHON=On -DPYCLINGO_USER_INSTALL=Off -DCLINGO_MANAGE_RPATH=Off -DPYCLINGO_INSTALL_DIR=/usr/lib/python3/dist-packages + dh_auto_configure -- -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) -DCLINGO_BUILD_REVISION=$(CLINGO_BUILD_REVISION) -DCLINGO_BUILD_WITH_LUA=On -DCLINGO_BUILD_WITH_PYTHON=On -DCLINGO_MANAGE_RPATH=Off -DPYCLINGO_INSTALL_DIR=/usr/lib/python3/dist-packages diff --git a/.github/ppa-wip/bionic/debian/rules b/.github/ppa-wip/bionic/debian/rules index 89e7dc754..d3048dbb7 100755 --- a/.github/ppa-wip/bionic/debian/rules +++ b/.github/ppa-wip/bionic/debian/rules @@ -6,4 +6,4 @@ export CLINGO_BUILD_REVISION = dh $@ --with python3 override_dh_auto_configure: - dh_auto_configure -- -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) -DCLINGO_BUILD_REVISION=$(CLINGO_BUILD_REVISION) -DCLINGO_REQUIRE_LUA=On -DCLINGO_REQUIRE_PYTHON=On -DPYCLINGO_USER_INSTALL=Off -DCLINGO_MANAGE_RPATH=Off -DPYCLINGO_INSTALL_DIR=/usr/lib/python3/dist-packages + dh_auto_configure -- -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) -DCLINGO_BUILD_REVISION=$(CLINGO_BUILD_REVISION) -DCLINGO_BUILD_WITH_LUA=On -DCLINGO_BUILD_WITH_PYTHON=On -DCLINGO_MANAGE_RPATH=Off -DPYCLINGO_INSTALL_DIR=/usr/lib/python3/dist-packages diff --git a/.github/ppa-wip/focal/debian/rules b/.github/ppa-wip/focal/debian/rules index 89e7dc754..d3048dbb7 100755 --- a/.github/ppa-wip/focal/debian/rules +++ b/.github/ppa-wip/focal/debian/rules @@ -6,4 +6,4 @@ export CLINGO_BUILD_REVISION = dh $@ --with python3 override_dh_auto_configure: - dh_auto_configure -- -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) -DCLINGO_BUILD_REVISION=$(CLINGO_BUILD_REVISION) -DCLINGO_REQUIRE_LUA=On -DCLINGO_REQUIRE_PYTHON=On -DPYCLINGO_USER_INSTALL=Off -DCLINGO_MANAGE_RPATH=Off -DPYCLINGO_INSTALL_DIR=/usr/lib/python3/dist-packages + dh_auto_configure -- -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) -DCLINGO_BUILD_REVISION=$(CLINGO_BUILD_REVISION) -DCLINGO_BUILD_WITH_LUA=On -DCLINGO_BUILD_WITH_PYTHON=On -DCLINGO_MANAGE_RPATH=Off -DPYCLINGO_INSTALL_DIR=/usr/lib/python3/dist-packages diff --git a/.travis.yml b/.travis.yml index 33ca16621..552b38e15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,11 +26,11 @@ script: - mkdir build && cd build && cmake - -DCMAKE_VERBOSE_MAKEFILE=True - -DCLINGO_BUILD_TESTS=True - -DCLASP_BUILD_TESTS=True - -DLIB_POTASSCO_BUILD_TESTS=True - -DCLINGO_BUILD_EXAMPLES=True + -DCMAKE_VERBOSE_MAKEFILE=On + -DCLINGO_BUILD_TESTS=On + -DCLASP_BUILD_TESTS=On + -DLIB_POTASSCO_BUILD_TESTS=On + -DCLINGO_BUILD_EXAMPLES=On .. && make -j3 && make test CTEST_OUTPUT_ON_FAILURE=True diff --git a/CMakeLists.txt b/CMakeLists.txt index 202c14f2c..52f0c520c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,39 +24,83 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -option(CLINGO_BUILD_WEB "enable web target" OFF) -option(CLINGO_BUILD_STATIC "do not build shared libraries" OFF) -option(CLINGO_BUILD_WITH_PYTHON "enable python support" ON) -option(CLINGO_BUILD_WITH_LUA "enable lua support" ON) -option(CLINGO_BUILD_TESTS "build tests" OFF) -option(CLINGO_BUILD_EXAMPLES "build examples" OFF) -option(CLINGO_BUILD_APPS "build applications" ON) -option(CLINGO_MANAGE_RPATH "set rpath if not installed into system directory" ON) - -CMAKE_DEPENDENT_OPTION(CLINGO_REQUIRE_PYTHON "fail if python support not found" OFF "CLINGO_BUILD_WITH_PYTHON" OFF) -CMAKE_DEPENDENT_OPTION(CLINGO_REQUIRE_LUA "fail if lua support not found" OFF "CLINGO_BUILD_WITH_LUA" OFF) -CMAKE_DEPENDENT_OPTION(CLINGO_BUILD_SHARED "build clingo library shared" ON "NOT CLINGO_BUILD_STATIC" OFF) -CMAKE_DEPENDENT_OPTION(CLINGO_BUILD_SHARED_INTERFACE "share symbols in dependents" OFF "CLINGO_BUILD_SHARED" OFF) - -option(CLINGO_INSTALL_LIB "install the clingo library" ${CLINGO_BUILD_SHARED}) -option(PYCLINGO_FORCE_OLD_MODULE "force use of the old find_python module" OFF) -option(PYCLINGO_USER_INSTALL "install the python module in the user's site directory" ON) -option(PYCLINGO_DYNAMIC_LOOKUP "do not link to python library and pass linker option `-undefined link_dynamic`" ${APPLE}) -CMAKE_DEPENDENT_OPTION(PYCLINGO_USE_INSTALL_PREFIX "install the python module under the install prefix" OFF "NOT PYCLINGO_USER_INSTALL" OFF) - -set(CLINGO_CLINGOPATH "" CACHE STRING "global search directories for clingo's include statement") -set(CLINGO_USE_LIB OFF CACHE BOOL "advanced option to build python and lua modules against an existing libclingo") -set(CLINGO_BUILD_REVISION "" CACHE STRING "revision string to add to version information") -set(CLINGO_PYTHON_VERSION "" CACHE STRING "set this to find a specific python version") -set(CLINGO_LUA_VERSION "" CACHE STRING "set this to find a specific lua version") +# build targets +option(CLINGO_BUILD_WEB +"Enable the web target. This option is meant to be used with emscripten to \ +compile a library exporting just one function to run clingo." +OFF) +option(CLINGO_BUILD_TESTS +"Enable unit and system tests." +OFF) +option(CLINGO_BUILD_EXAMPLES +"Build clingo C and C++ examples." +OFF) +option(CLINGO_BUILD_APPS +"Build applications including gringo, clingo, reify, clasp, and lpconvert." +ON) +set(CLINGO_CLINGOPATH "" CACHE STRING +"Set inbuilt global search directories for clingo's include statement.") +set(CLINGO_BUILD_REVISION "" CACHE STRING +"revision string to add to version information") + +# build fine-tuning +option(CLINGO_MANAGE_RPATH +"Set RPATH if not installed into system directory on *NIX systems." +ON) +option(CLINGO_BUILD_STATIC +"Do not build any shared libraries and do not compile position independent \ +code." +OFF) +CMAKE_DEPENDENT_OPTION(CLINGO_BUILD_SHARED +"Build clingo library shared." +ON "NOT CLINGO_BUILD_STATIC" OFF) +set(CLINGO_USE_LIB OFF CACHE BOOL +"Advanced option to build Python and Lua modules against an existing \ +libclingo.") + +# Python configuration +set(CLINGO_BUILD_WITH_PYTHON "auto" CACHE STRING +"Whether to enable Python support. Can be set to \"ON\" (to enable Python \ +support), \"OFF\" (to disable Python support), \"auto\" (to enable Python \ +support if available), or \"pip\" (advanced configuration to build a Python \ +module exporting clingo symbols).") +set(CLINGO_PYTHON_VERSION "3.6" CACHE STRING +"Set this to find a specific Python version. This can for example be set with \ +`-DCLINGO_PYTHON_VERSION:LIST=\"3.6;EXACT\"` to require a specific version." ) +set(PYCLINGO_INSTALL "prefix" CACHE STRING +"Configure where to install the Python module. Can be set to \"user\" (to \ +install in the user prefix), \"system\" (to install in the system \ +\"prefix\"), or \"prefix\" (to install into the installation prefix).") +set(PYCLINGO_INSTALL_DIR "" CACHE STRING +"Advanced variable to manually configure where to install the Python module.") +set(PYCLINGO_SUFFIX CACHE STRING +"Advanced variable to manually configure the suffix of the Python module.") +option(PYCLINGO_DYNAMIC_LOOKUP +"Pass linker option `-undefined link_dynamic`." +${APPLE}) + +# Lua configuration +set(CLINGO_BUILD_WITH_LUA "auto" CACHE STRING +"Whether to enable Lua support. Can be set to 'ON' (to enable Lua support), \ +'OFF' (to disable Lua support), or 'auto' (to enable Python support if \ +available).") +set(CLINGO_LUA_VERSION "5.0" CACHE STRING +"Set this to find a specific Lua version. This can for example be set with \ +`-DCLINGO_LUA_VERSION:LIST=\"5.3;EXACT\"` to require a specific version." ) +set(LUACLINGO_INSTALL_DIR "" CACHE STRING +"Advanced variable to manually configure where to install the Lua module.") +set(LUACLINGO_SUFFIX CACHE STRING +"Advanced variable to manually configure the suffix of the Lua module.") mark_as_advanced(CLINGO_BUILD_WEB) mark_as_advanced(CLINGO_BUILD_STATIC) mark_as_advanced(CLINGO_BUILD_SHARED) -mark_as_advanced(CLINGO_BUILD_SHARED_INTERFACE) mark_as_advanced(CLINGO_USE_LIB) -mark_as_advanced(CLINGO_BUILD_REVISION) -mark_as_advanced(PYCLINGO_FORCE_OLD_MODULE) +mark_as_advanced(PYCLINGO_INSTALL_DIR) +mark_as_advanced(PYCLINGO_SUFFIX) +mark_as_advanced(PYCLINGO_DYNAMIC_LOOKUP) +mark_as_advanced(LUACLINGO_INSTALL_DIR) +mark_as_advanced(LUACLINGO_SUFFIX) # workaround to set custom ar and ranlib if (CLINGO_CMAKE_AR) @@ -102,15 +146,11 @@ if (NOT CMAKE_IMPORT_LIBRARY_PREFIX) set(CMAKE_IMPORT_LIBRARY_PREFIX import_) endif() -if (NOT CLINGO_PYTHON_VERSION) - set(CLINGO_PYTHON_VERSION "3.6") -endif() - # NOTE: searching for the interpreter first increases the chance # that searching for the python libraries finds the matching libraries for the default python interpreter # python is also used to run the tests -if(NOT PYCLINGO_FORCE_OLD_MODULE AND (CMAKE_VERSION VERSION_GREATER "3.15.0" OR CMAKE_VERSION VERSION_EQUAL "3.15.0")) +if(NOT CLINGO_BUILD_WITH_PYTHON STREQUAL "pip" AND (CMAKE_VERSION VERSION_GREATER "3.15.0" OR CMAKE_VERSION VERSION_EQUAL "3.15.0")) if(DEFINED PYTHON_EXECUTABLE AND NOT DEFINED Python_EXECUTABLE) set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") endif() @@ -126,7 +166,7 @@ if(NOT PYCLINGO_FORCE_OLD_MODULE AND (CMAKE_VERSION VERSION_GREATER "3.15.0" OR set(_args Interpreter) if (CLINGO_BUILD_WITH_PYTHON) set(_args ${_args} Development) - if (CLINGO_REQUIRE_PYTHON) + if (NOT CLINGO_BUILD_WITH_PYTHON STREQUAL "auto") set(_args ${_args} REQUIRED) endif() endif() @@ -136,7 +176,7 @@ else() set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") set(Python_VERSION_MAJOR "${PYTHON_VERSION_MAJOR}") if (CLINGO_BUILD_WITH_PYTHON) - if (CLINGO_REQUIRE_PYTHON) + if (NOT CLINGO_BUILD_WITH_PYTHON STREQUAL "auto") find_package(PythonLibs ${CLINGO_PYTHON_VERSION} REQUIRED) else() find_package(PythonLibs ${CLINGO_PYTHON_VERSION}) @@ -160,7 +200,7 @@ if (Python_Development_FOUND AND Python_VERSION_MAJOR LESS 3) message(FATAL_ERROR "Clingo does not support Python 2.") endif() if (CLINGO_BUILD_WITH_LUA) - if (CLINGO_REQUIRE_LUA) + if (NOT CLINGO_BUILD_WITH_LUA STREQUAL "auto") find_package(Lua ${CLINGO_LUA_VERSION} REQUIRED) else() find_package(Lua ${CLINGO_LUA_VERSION}) @@ -196,13 +236,7 @@ if (CLINGO_USE_LIB) set_property(TARGET libclingo PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CLINGO_SOURCE_DIR}/libclingo") set_property(TARGET libclingo PROPERTY INTERFACE_LINK_LIBRARIES "clingo") else() - if (NOT CLINGO_BUILD_SHARED_INTERFACE) - list(APPEND clingo_library_targets libclingo) - endif() set(clingo_library_targets libgringo libpotassco libclasp libreify) - if (NOT CLINGO_BUILD_SHARED) - set(CLASP_INSTALL_LIB ${CLINGO_INSTALL_LIB} CACHE BOOL "") - endif() set(CLASP_USE_LOCAL_LIB_POTASSCO ON CACHE BOOL "" FORCE) add_subdirectory(clasp) add_subdirectory(libreify) diff --git a/INSTALL.md b/INSTALL.md index e64d4611d..d5ba93753 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,15 +18,15 @@ This document is about installing clingo from source. We also provide precompiled packages for various package managers: . -- a c++14 conforming compiler - - *at least* [gcc](https://gcc.gnu.org/) version 4.9 - - [clang](http://clang.llvm.org/) version 3.1 (using either libstdc++ +- a C++14 conforming compiler + - *at least* [GCC](https://gcc.gnu.org/) version 4.9 + - [Clang](http://clang.llvm.org/) version 3.1 (using either libstdc++ provided by gcc 4.9 or libc++) - - *at least* msvc++ 14.0 ([Visual Studio](https://www.visualstudio.com/) 2015 + - *at least* MSVC 14.0 ([Visual Studio](https://www.visualstudio.com/) 2015 Update 3) - other compilers might work - the [cmake](https://www.cmake.org/) build system - - at least version 3.3 is recommended + - at least version 3.18 is recommended - at least version 3.1 is *required* ## Development Dependencies @@ -39,16 +39,16 @@ branch. Releases already include the necessary generated files. - version 3.0 produces harmless warnings (to stay backwards-compatible) - the [re2c](https://re2c.org/) lexer generator - - *at least* version 0.13 - - version 0.13.5 is used for development + - *at least* version 0.13 is required ## Optional Dependencies -- the [Python](https://www.python.org/) script language - - at least version 3.6 +- the [Python](https://www.python.org/) script language and the + [CFFI](cffi.readthedocs.io/) package + - *at least* Python version 3.6 + - at least CFFI 1.14 is required (earlier versions have not been tested) - the [Lua](https://www.lua.org/) script language - - version 5.1 is used for development - - version 5.2 and 5.3 should work + - *at least* Lua 5.1 is required # Build, Install, and Test @@ -82,7 +82,7 @@ Cmake's `-L` option can be used to get an overview over the variables that can be set for building gringo/clingo. To get gringo/clingo specific options, run cmake -H -B -DCMAKE_BUILD_TYPE=Release -LH - + or, to also print important cmake specific configuration variables cmake -H -B -DCMAKE_BUILD_TYPE=Release -LAH @@ -106,6 +106,11 @@ In the following, the most important options to control the build are listed. - Variable `CMAKE_BUILD_TYPE` should be set to `Release`. - Variable `CMAKE_INSTALL_PREFIX` controls where to install clingo. +- Option `CLINGO_MANAGE_RPATH` controls how to find libraries on platforms + where this is supported, like Linux, macOS, or BSD but not Windows. This + option should be enabled if clingo is installed in a non-default location, + like the users home directory; otherwise it has no effect. + (Default: `ON`) - Option `CLINGO_BUILD_APPS` controls whether to build the applications gringo, clingo, and reify. (Default: `ON`) @@ -115,59 +120,59 @@ In the following, the most important options to control the build are listed. - Option `CLINGO_BUILD_TESTS` controls whether to build the clingo tests and enable the test target running unit as well as acceptance tests. (Default: `OFF`) -- Option `CLINGO_MANAGE_RPATH` controls how to find libraries on platforms - where this is supported, like Linux, macOS, or BSD but not Windows. This - option should be enabled if clingo is installed in a non-default location, - like the users home directory; otherwise it has no effect. - (Default: `ON`) ### Python Support With the default configuration, Python support will be auto-detected if the Python development packages are installed. -- Option `CLINGO_BUILD_WITH_PYTHON` can be used to enable or disable Python - support. - (Default: `ON`) -- If option `CLINGO_REQUIRE_PYTHON` is enabled, configuration will fail if no - Python support is detected; otherwise, Python support will simply be disabled - if not detected. - (Default: `OFF`) -- The variable `CLINGO_PYTHON_VERSION` can be used to select a specific python - version. For example, passing `-DCLINGO_PYTHON_VERSION:LIST="3.6;EXACT"` to - cmake requires python version 3.6 to be available. Starting with cmake 3.15, - variable `Python_ROOT` can be used to specify where to search for a python - installation (the documentation of cmake's `FindPython` module has further - information). -- If option `PYCLINGO_USER_INSTALL` is enabled, the clingo Python module is - installed in the users home directory; otherwise it is installed in the - system's Python library directory. - (Default: `ON`) +- Varibale `CLINGO_BUILD_WITH_PYTHON` can be set to `ON` to enable Python + support, `OFF` to disable Python support, `auto` to enable Python support if + available, or `pip` for advanced configuration to build a Python module + exporting clingo symbols. + (Default: `auto`) +- Variable `CLINGO_PYTHON_VERSION` can be used to select a specific Python + version. For example, passing `-DCLINGO_PYTHON_VERSION:LIST="3.8;EXACT"` to + cmake requires Python version 3.8 to be available and not just a compatbile + Python version. Starting with cmake 3.15, variable `Python_ROOT` can be used + to specify where to search for a Python installation (the documentation of + cmake's `FindPython` module has further information). + (Default: `3.6`) +- Variable `PYCLINGO_INSTALL` controls where to install the Python module. It + can be set to `user` to install in the user prefix, `system` to install in + the system prefix, or `prefix` to install into the installation prefix. + (Default: `prefix`) +- Variable `PYCLINGO_SUFFIX` can be used to customize which suffix to use for + the Python module. + (Default: automatically detected) - Variable `PYCLINGO_INSTALL_DIR` can be used to customize where to install the - python module. + Python module. (Default: automatically detected) -Note that it can happen that the found Python interpreter does not match the -found Python libraries if the development headers for the interpreter are not -installed. Make sure to install them before running cmake (or remove or adjust -the `CMakeCache.txt` file). +With cmake versions before 3.15, it can happen that the found Python +interpreter does not match the found Python libraries if the development +headers for the interpreter are not installed. Make sure to install them before +running cmake (or remove or adjust the `CMakeCache.txt` file). ### Lua Support With the default configuration, Lua support will be auto-detected if the Lua development packages are installed. -- Option `CLINGO_BUILD_WITH_LUA` can be used to enable or disable Lua support. - (Default: `ON`) -- If option `CLINGO_REQUIRE_LUA` is enabled, configuration will fail if no Lua - support is detected; otherwise, Lua support will simply be disabled if not - detected. (Default: `OFF`) -- The variable `CLINGO_LUA_VERSION` can be used to select a specific Lua - version. For example, passing `-DCLINGO_LUA_VERSION:LIST="5.2;EXACT"` to only - find Lua 5.2. -- If variable `LUACLINGO_INSTALL_DIR` is set, the clingo lua module will be - installed there. - (Default: not set) +- Varibale `CLINGO_BUILD_WITH_LUA` can be set to `ON` to enable Lua support, + `OFF` to disable Lua support, `auto` to enable Lua support if available. + (Default: `auto`) +- Variable `CLINGO_LUA_VERSION` can be used to select a specific Lua + version. For example, passing `-DCLINGO_LUA_VERSION:LIST="5.3;EXACT"` to + cmake requires Lua version 5.3 to be available and not just a compatbile + Lua version. + (Default: `5.0`) +- Variable `LUACLINGO_SUFFIX` can be used to customize which suffix to use for + the Lua module. + (Default: automatically detected) +- Variable `LUACLINGO_INSTALL_DIR` can be used to customize where to install + the Lua module. + (Default: automatically detected) ## Compilation to JavaScript @@ -206,7 +211,7 @@ If a dependency is missing or a software version too old, then there are typically community repositories that provide the necessary packages. To list a few: - the [ToolChain](https://wiki.ubuntu.com/ToolChain) repository for Ubuntu - 14.04 and earlier (later versions should include all required packages) + versions before 18.04. - the [Developer Toolset](https://wiki.centos.org/SpecialInterestGroup/SCLo/CollectionsList) for CentOS @@ -222,8 +227,7 @@ systems. ;) clingo can be compiled using the [Mingw-w64](https://mingw-w64.sourceforge.net/) compiler, the Cygwin project, -or Visual Studio 2015 Update 3. For development, -[bison](http://cs.uni-potsdam.de/~kaminski/win_flex_bison-latest.zip) from the -[Win flex-bison](https://sourceforge.net/projects/winflexbison/) project and a -self compiled [re2c](http://cs.uni-potsdam.de/~kaminski/re2c.exe) executable -can be used. +or Visual Studio 2015 Update 3. For development, The [re2c](https://re2c.org/) +and [winflexbison](https://github.com/lexxmark/winflexbison) (providing +[bison](https://www.gnu.org/software/bison/) for Windows) packages can be +installed using the [chocolatey](https://chocolatey.org/) package manager, too. diff --git a/app/pyclingo/CMakeLists.txt b/app/pyclingo/CMakeLists.txt index 453a9557f..db35586a6 100644 --- a/app/pyclingo/CMakeLists.txt +++ b/app/pyclingo/CMakeLists.txt @@ -7,17 +7,17 @@ set(source ${source-group}) # ]]] -if (NOT PYCLINGO_INSTALL_DIR AND Python_EXECUTABLE) - if (PYCLINGO_USER_INSTALL) - execute_process(COMMAND ${Python_EXECUTABLE} -m site --user-site OUTPUT_VARIABLE PYCLINGO_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) - elseif(PYCLINGO_USE_INSTALL_PREFIX) +if (PYCLINGO_INSTALL_DIR STREQUAL "" AND Python_EXECUTABLE) + if (PYCLINGO_INSTALL STREQUAL "user") + execute_process(COMMAND ${Python_EXECUTABLE} ${CLINGO_SOURCE_DIR}/cmake/python-site.py site OUTPUT_VARIABLE PYCLINGO_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + elseif(PYCLINGO_INSTALL STREQUAL "prefix") execute_process(COMMAND ${Python_EXECUTABLE} ${CLINGO_SOURCE_DIR}/cmake/python-site.py prefix "${CMAKE_INSTALL_PREFIX}" OUTPUT_VARIABLE PYCLINGO_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) else() execute_process(COMMAND ${Python_EXECUTABLE} ${CLINGO_SOURCE_DIR}/cmake/python-site.py prefix OUTPUT_VARIABLE PYCLINGO_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) endif() endif() -if (NOT PYCLINGO_SUFFIX) +if (PYCLINGO_SUFFIX STREQUAL "") if (Python_EXECUTABLE) execute_process(COMMAND ${Python_EXECUTABLE} ${CLINGO_SOURCE_DIR}/cmake/python-site.py suffix OUTPUT_VARIABLE PYCLINGO_SUFFIX OUTPUT_STRIP_TRAILING_WHITESPACE) else() @@ -31,17 +31,14 @@ if (NOT PYCLINGO_SUFFIX) endif() endif() -if (CLINGO_BUILD_SHARED_INTERFACE) - add_library(pyclingo SHARED ${source}) -else() - add_library(pyclingo MODULE ${source}) -endif() +add_library(pyclingo MODULE ${source}) target_link_libraries(pyclingo PRIVATE libclingo Python::Module) # NOTE: It would be really nice to enable the limited API for the pip packages # to avoid having to build Python-specific wheels. Unfortunately, this fails to # build on conda on Windows then. Since supporting conda is important, it is # disabled for now but should be investigated further, later. target_compile_definitions(pyclingo PRIVATE _CFFI_NO_LIMITED_API) +# NOTE: This seems to be necessary on MacOS. I do not understand why. if (PYCLINGO_DYNAMIC_LOOKUP) set_property(TARGET pyclingo PROPERTY LINK_FLAGS "-undefined dynamic_lookup") endif() @@ -66,7 +63,7 @@ if (PYCLINGO_INSTALL_DIR) RUNTIME DESTINATION ${_PYCLINGO_INSTALL_DIR}/clingo LIBRARY DESTINATION ${_PYCLINGO_INSTALL_DIR}/clingo ARCHIVE DESTINATION ${_PYCLINGO_INSTALL_DIR}/clingo) - if (NOT PYCLINGO_FORCE_OLD_MODULE) + if (CLINGO_BUILD_WITH_PYTHON STREQUAL "pip") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/INSTALLER "pip\n") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/METADATA "Metadata-Version: 1.1\nName: clingo\nVersion: ${CLINGO_VERSION}\n") install(FILES diff --git a/libclingo/CMakeLists.txt b/libclingo/CMakeLists.txt index 2ee98bd61..a067868e7 100644 --- a/libclingo/CMakeLists.txt +++ b/libclingo/CMakeLists.txt @@ -44,7 +44,7 @@ list(APPEND source "${CLASP_SOURCE_DIR}/app/clasp_app.cpp") set(clingo_public_scope_ PUBLIC) set(clingo_private_scope_ PRIVATE) if (CLINGO_BUILD_SHARED) - if (CLINGO_BUILD_SHARED_INTERFACE) + if (CLINGO_BUILD_WITH_PYTHON STREQUAL "pip") set(clingo_lib_type INTERFACE) set(clingo_public_scope_ INTERFACE) set(clingo_private_scope_ INTERFACE) @@ -70,7 +70,7 @@ if (NOT CLINGO_BUILD_SHARED) target_compile_definitions(libclingo PUBLIC CLINGO_NO_VISIBILITY) endif() -if (CLINGO_INSTALL_LIB AND NOT CLINGO_BUILD_SHARED_INTERFACE) +if (CLINGO_BUILD_SHARED AND NOT CLINGO_BUILD_WITH_PYTHON STREQUAL "pip") set(clingo_targets libclingo) if (CLINGO_BUILD_SHARED) set_target_properties(libclingo PROPERTIES SOVERSION 4 VERSION 4.0) @@ -110,7 +110,7 @@ endif() if (CLINGO_BUILD_REVISION) target_compile_definitions(libclingo PRIVATE CLINGO_BUILD_REVISION=${CLINGO_BUILD_REVISION}) endif() -if (NOT CLINGO_BUILD_SHARED_INTERFACE) +if (NOT CLINGO_BUILD_WITH_PYTHON STREQUAL "pip") set_target_properties(libclingo PROPERTIES OUTPUT_NAME clingo FOLDER lib) diff --git a/setup.py b/setup.py index e11481b58..b0e30f16e 100644 --- a/setup.py +++ b/setup.py @@ -26,17 +26,10 @@ license = 'MIT', url = 'https://github.com/potassco/clingo', install_requires=[ 'cffi' ], - cmake_args=[ '-DCLINGO_INSTALL_LIB=OFF', - '-DCLINGO_MANAGE_RPATH=OFF', + cmake_args=[ '-DCLINGO_MANAGE_RPATH=OFF', '-DCLINGO_BUILD_APPS=OFF', - '-DCLINGO_BUILD_STATIC=OFF', - '-DCLINGO_BUILD_SHARED=ON', - '-DCLINGO_BUILD_SHARED_INTERFACE=ON', - '-DCLINGO_REQUIRE_PYTHON=ON', + '-DCLINGO_BUILD_WITH_PYTHON=pip', '-DCLINGO_BUILD_WITH_LUA=OFF', - '-DPYCLINGO_USER_INSTALL=OFF', - '-DPYCLINGO_USE_INSTALL_PREFIX=ON', - '-DPYCLINGO_FORCE_OLD_MODULE=ON', '-DPYCLINGO_INSTALL_DIR=libpyclingo' ], packages=[ 'clingo' ], package_data={ 'clingo': [ 'py.typed', 'import__clingo.lib', 'clingo.h', 'clingo.hh' ] },