Make sure add_subdirectory and find_package behave identically

Add a BUILD_INTERFACE and a pybind11::pybind11 alias for the interface
library to match the installed target.

Add new cmake tests for add_subdirectory and consolidates the
.cpp and .py files needed for the cmake build tests:

Before:
tests
|-- test_installed_module
|   |-- CMakeLists.txt
|   |-- main.cpp
|   \-- test.py
\-- test_installed_target
    |-- CMakeLists.txt
    |-- main.cpp
    \-- test.py

After:
tests
\-- test_cmake_build
    |-- installed_module/CMakeLists.txt
    |-- installed_target/CMakeLists.txt
    |-- subdirectory_module/CMakeLists.txt
    |-- subdirectory_target/CMakeLists.txt
    |-- main.cpp
    \-- test.py
This commit is contained in:
Dean Moldovan
2016-12-14 01:43:39 +01:00
committed by Wenzel Jakob
parent 003a9eba59
commit b0f3885c95
16 changed files with 130 additions and 107 deletions

View File

@@ -85,6 +85,11 @@ function(pybind11_add_module target_name)
# import time.
target_link_libraries(${target_name} PRIVATE "-undefined dynamic_lookup")
if(${lib_type} STREQUAL "SHARED")
# Suppress CMake >= 3.0 warning for shared libraries
set_target_properties(${target_name} PROPERTIES MACOSX_RPATH ON)
endif()
endif()
select_cxx_standard()