Skip to content

Conversation

@nrhinehart
Copy link

Using set(PYBIND11_PYTHON_VERSION in a parent project was failing because it is overwritten in pybind11/CMakeLists.txt. This PR fixes overriding the variable if it is already defined, and defaults to the original initialization if it was undefined.

Tested by successfully compiling my project with pybind11 bindings and running its test (failed when finding wrong python version) in addition to running pybind11 tests. I think this is related to functionality included in PR #207

@dean0x7d
Copy link
Member

dean0x7d commented Jun 12, 2016

CMake already does this for CACHE variables: only the first set(... CACHE) is registered and everything else is ignored. The parent project just needs to use a cached variable instead of a regular one:

set(PYBIND11_PYTHON_VERSION <value> CACHE STRING "")
add_subdirectory(pybind11)

Alternatively, this can be done on the command line when CMake is first invoked:

cmake -DPYBIND11_PYTHON_VERSION=<value> <source_dir>

All command line -D variables are automatically added to the cache.

@wjakob
Copy link
Member

wjakob commented Jun 12, 2016

Agreed, there is no issue with pybind11 here.

@wjakob wjakob closed this Jun 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants