Skip to content

Commit

Permalink
cmake: add option ONLY_PROGRAM as a shortcut to disable lib/python/de…
Browse files Browse the repository at this point in the history
…v files
  • Loading branch information
wojdyr committed Sep 29, 2024
1 parent 9cd4e27 commit 5623c6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ option(USE_NLOPT "Experimental, for testing only, don't use it" OFF)
# uncomment to show compilation times for each compilation unit
#set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "\"${CMAKE_COMMAND}\" -E time")

if ((DEFINED ENV{FC} AND NOT "$ENV{FC}" STREQUAL "") OR CMAKE_Fortran_COMPILER)
set(USE_FORTRAN ON CACHE BOOL "Build Fortran bindings" FORCE)
endif()

if (DEFINED Python_EXECUTABLE)
set(USE_PYTHON ON CACHE BOOL "Build Python bindings" FORCE)
if (ONLY_PROGRAM)
set(USE_PYTHON OFF CACHE BOOL "" FORCE) # it's set to ON in pyproject.toml
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(INSTALL_DEV_FILES OFF CACHE BOOL "" FORCE)
else()
if ((DEFINED ENV{FC} AND NOT "$ENV{FC}" STREQUAL "") OR CMAKE_Fortran_COMPILER)
set(USE_FORTRAN ON CACHE BOOL "Build Fortran bindings" FORCE)
endif()
if (DEFINED Python_EXECUTABLE AND NOT DEFINED SKBUILD)
set(USE_PYTHON ON CACHE BOOL "Build Python bindings" FORCE)
endif()
endif()

if (NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN)
Expand Down
6 changes: 6 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ installed (on Ubuntu: `sudo apt install git cmake make g++`), then::
cmake .
make

Alternatively, you can use `pip install git+https://...`, which installs
both Python module and the program. If you are not using the Python module,
you can use pip to build only the program::

pip install git+https://github.com/project-gemmi/gemmi.git --config-settings=cmake.args=-DONLY_PROGRAM=ON

Testing
-------

Expand Down

0 comments on commit 5623c6d

Please sign in to comment.