Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine CMake Configuration Variables #283

Merged
merged 3 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/conda/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions .github/conda/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
10 changes: 4 additions & 6 deletions .github/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand All @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/ppa-wip/bionic/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/ppa-wip/focal/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
118 changes: 76 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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})
Expand All @@ -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})
Expand Down Expand Up @@ -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)
Expand Down
Loading