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

build: add options in cmake to skip some building parts #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

neverchanje
Copy link

@neverchanje neverchanje commented Jul 23, 2020

Hi, we included s2geometry as one of the dependencies for our project. To reduce the building time (and complexity) of s2geometry, we want to make some building parts optional and skippable. So in this PR, I add several CMake options, including:

  1. BUILD_TESTING for unit tests.
  2. BULID_PYTHON for Python interfaces.

This PR is tested on my platform:

cmake .. -DBUILD_PYTHON=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DGTEST_ROOT=/home/wutao1/git/googletest/googletest
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The following features have been disabled:

 * GFLAGS, allows changing command line flags.
 * GLOG, provides logging configurability.
 * SHARED_LIBS, builds shared libraries instead of static.

-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.0.2n")  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
GTEST_ROOT: /home/wutao1/git/googletest/googletest
-- Found PythonInterp: /usr/bin/python (found version "2.7.17") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wutao1/git/s2geometry/build

@neverchanje
Copy link
Author

Hi, this PR has passed all the Travis tests. Could anyone please have a look?

endif()

if (BUILD_EXAMPLES)
add_subdirectory("doc/examples" examples)
endif()

if (${SWIG_FOUND} AND ${PYTHONLIBS_FOUND})
if (${BUILD_PYTHON} AND ${SWIG_FOUND} AND ${PYTHONLIBS_FOUND})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you thing about doing something like:

if (BUILD_PYTHON) {
  if (!SWIG_FOUND) informative error
  if (!PYTHON_LIBS_FOUND) informative error
  add_subdirectory()
}

?


option(BUILD_PYTHON "Build Python interfaces" ON)
if (BUILD_PYTHON)
find_package(SWIG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these could all be required now, if BUILD_PYTHON is set.

@jmr jmr added the python label Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants