Commit 860e816e authored by Tom Osika's avatar Tom Osika
Browse files

Merge branch 'dev/additional-rsp-includes' into 'master'

Initial additional rsp include functionality

See merge request autopybind11/autopybind11!100
parents 432a914f d75e88a5
......@@ -37,9 +37,10 @@ endmacro()
function(_autopybind11_get_compiler_flags)
set(generateSingleValueArgs INCLUDE_FLAGS DEFINE_FLAGS INDEX_FLAGS)
set(generateMultiValueArgs TARGETS )
set(generateMultiValueArgs TARGETS INCLUDE_DIRS)
cmake_parse_arguments(PYBIND_GET_FLAGS "" "${generateSingleValueArgs}" "${generateMultiValueArgs}" ${ARGN})
list(LENGTH PYBIND_GET_FLAGS_TARGETS num_targets)
list(LENGTH PYBIND_GET_FLAGS_INCLUDE_DIRS num_inc_dirs)
set(includes_list)
set(defines_list)
set(indexes_list)
......@@ -58,6 +59,13 @@ function(_autopybind11_get_compiler_flags)
set(${PYBIND_GET_FLAGS_DEFINE_FLAGS} "${defines_list}" PARENT_SCOPE)
set(${PYBIND_GET_FLAGS_INDEX_FLAGS} "${indexes_list}" PARENT_SCOPE)
endif()
if(${num_inc_dirs} GREATER 0)
foreach(dir ${PYBIND_GET_FLAGS_INCLUDE_DIRS})
list(APPEND includes_list ${dir})
endforeach()
set(${PYBIND_GET_FLAGS_INCLUDE_FLAGS} "${includes_list}" PARENT_SCOPE)
endif()
endfunction()
function(_autopybind11_get_sources)
......@@ -90,7 +98,7 @@ function(autopybind11_add_module)
message(FATAL_ERROR "autopybind11_fetch_build_pybind11 must be called first")
endif()
set(generateOneValueArgs YAML_INPUT CONFIG_INPUT DESTINATION NAMESPACE C_STD_FLAG GEN_ONLY)
set(generateMultiValueArgs LINK_LIBRARIES FILES)
set(generateMultiValueArgs LINK_LIBRARIES FILES INCLUDE_DIRS)
set(PYBIND_ADD_LIB_NAME ${ARGV0})
cmake_parse_arguments(PARSE_ARGV 1 PYBIND_ADD_LIB "" "${generateOneValueArgs}" "${generateMultiValueArgs}")
......@@ -116,6 +124,8 @@ function(autopybind11_add_module)
_autopybind11_get_compiler_flags(
TARGETS
${PYBIND_ADD_LIB_LINK_LIBRARIES}
INCLUDE_DIRS
${PYBIND_ADD_LIB_INCLUDE_DIRS}
INCLUDE_FLAGS includes
DEFINE_FLAGS defines
INDEX_FLAGS indexes)
......@@ -208,5 +218,6 @@ function(autopybind11_add_module)
${tgt_helper_name}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PYBIND_ADD_LIB_DESTINATION})
${PYBIND_ADD_LIB_DESTINATION}
${PYBIND_ADD_LIB_INCLUDE_DIRS})
endfunction()
......@@ -19,6 +19,11 @@ function(add_autopybind11_test name)
endfunction()
function(add_autopybind11_failing_test name)
add_autopybind11_test(${name})
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
endfunction(add_autopybind11_failing_test)
add_autopybind11_test(simple)
add_autopybind11_test(missing_classes)
add_autopybind11_test(complex_trampoline)
......@@ -37,4 +42,6 @@ add_autopybind11_test(deleted_constructor)
add_autopybind11_test(module_local)
add_autopybind11_test(blacklist)
add_autopybind11_test(custom_namespaces)
add_autopybind11_test(extra_includes)
add_autopybind11_failing_test(extra_includes/expect_failure)
add_subdirectory(code_generation_regression)
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt
cmake_minimum_required(VERSION 3.15)
project(extra_includes CXX)
find_package(AutoPyBind11)
autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
add_library(mylib INTERFACE)
target_include_directories(mylib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
set(EXTRA_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/extra_inc)
autopybind11_add_module(myModule
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES mylib
INCLUDE_DIRS ${EXTRA_INCLUDES}
)
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt
cmake_minimum_required(VERSION 3.15)
project(extra_includes CXX)
find_package(AutoPyBind11)
autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
get_filename_component(EXTRA_INC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
add_library(mylib INTERFACE)
target_include_directories(mylib INTERFACE ${EXTRA_INC_SOURCE_DIR})
autopybind11_add_module(myModule
YAML_INPUT ${EXTRA_INC_SOURCE_DIR}/wrapper_input.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES mylib
)
\ No newline at end of file
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt */
#include <string>
#include <iostream>
class printer
{
public:
printer() {};
printer(std::string message) : m_(message) {};
void print() {std::cout << m_ << std::endl;};
private:
std::string m_;
};
\ No newline at end of file
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt
import os
import sys
import unittest
# Make it so we search where we are running.
sys.path.append(os.getcwd())
import myModule as mm
class ExtraIncludeDirTests(unittest.TestCase):
def test_constructors(self):
mm.better_printer()
mm.better_printer("foo")
def test_method(self):
bp = mm.better_printer("AutoPyBind11")
bp.better_print()
if __name__ == "__main__":
testRunner = unittest.main(__name__, argv=["main"], exit=False)
if not testRunner.result.wasSuccessful():
sys.exit(1)
\ No newline at end of file
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt */
#include <notmylib.h>
class better_printer
{
public:
better_printer() : other_printer(printer()) {};
better_printer(std::string message) : other_printer(printer(message)) {};
void better_print() {std::cout << "Message: "; other_printer.print();};
private:
printer other_printer;
};
\ No newline at end of file
classes:
better_printer:
file: mylib.h
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment