cmake: add BUILDPYTHON3 flag

Use the same methodology as in mraa, by default build for python2, if requested
use python3 for everything

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll 2016-03-21 17:22:25 +00:00
parent 159d2eee07
commit aa30b59e44
2 changed files with 16 additions and 13 deletions

View File

@ -51,6 +51,7 @@ set (CMAKE_SWIG_FLAGS "")
option (BUILDDOC "Build all doc." OFF) option (BUILDDOC "Build all doc." OFF)
option (BUILDSWIG "Build swig modules." ON) option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON) option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDPYTHON3 "Use python3 for building/installing/testing" OFF)
option (BUILDSWIGNODE "Build swig node modules." ON) option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDEXAMPLES "Build C++ example binaries" OFF) option (BUILDEXAMPLES "Build C++ example binaries" OFF)
option (BUILDJAVAEXAMPLES "Build java example jars" OFF) option (BUILDJAVAEXAMPLES "Build java example jars" OFF)
@ -210,10 +211,18 @@ if(BUILDJAVAEXAMPLES)
add_subdirectory (examples/java) add_subdirectory (examples/java)
endif() endif()
if(BUILDTESTS) if (BUILDSWIGPYTHON OR BUILDTESTS)
find_package (PythonInterp REQUIRED) if (BUILDPYTHON3)
if (${PYTHONINTERP_FOUND}) set (PYTHONBUILD_VERSION 3)
enable_testing () else ()
add_subdirectory (tests) set (PYTHONBUILD_VERSION 2.7)
endif () endif ()
find_package (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
find_package (PythonLibs ${PYTHONBUILD_VERSION} REQUIRED)
include_directories(${PYTHON_INCLUDE_PATH})
endif ()
if (BUILDTESTS)
enable_testing ()
add_subdirectory (tests)
endif() endif()

View File

@ -140,13 +140,7 @@ macro(upm_doxygen)
endmacro() endmacro()
if (SWIG_FOUND) if (SWIG_FOUND)
if(BUILDSWIGPYTHON) if (BUILDSWIGNODE)
find_package (PythonLibs)
string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
list (GET PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
endif(BUILDSWIGPYTHON)
if(BUILDSWIGNODE)
if(NOT NODE_FOUND) if(NOT NODE_FOUND)
find_package(Node) find_package(Node)
endif() endif()