Commit 14d11de4 authored by Joe Snyder's avatar Joe Snyder
Browse files

Remove GENERATE_WRAPPING option

parent 225d64de
......@@ -81,13 +81,10 @@ There are two CMake options which can be altered by the user.
+ | CXX flags: changes +
+ | a function signature +
+------------------------+--------------------------+
+ GENERATE_WRAPPING | Adds PyBind11 library +
+ | for wrapped code +
+------------------------+--------------------------+
These options can be set either CMake GUIs or on the command line::
$ cmake -DGENERATE_WRAPPING=ON .... <path/to>/wrapper_generator
$ cmake -DDEFINE_TEST_PARAM=ON .... <path/to>/wrapper_generator
The ``generator.py`` script will be run as a part of the ``Configure`` step in
of CMake.
......
add_library(wrapper_example SHARED ${CMAKE_BINARY_DIR}/wrapper.cpp test.hpp test_2.hpp)
target_include_directories(wrapper_example PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
option(GENERATE_WRAPPING "Generate PyBind11 wrapping with Python?" OFF)
if (GENERATE_WRAPPING)
add_subdirectory(pybind11)
find_package (Python COMPONENTS Interpreter Development)
include_directories(${Python_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
find_program(CastXML_EXECUTABLE NAMES castxml)
option(DEFINE_TEST_PARAM "Adds a define parameter to swap definitions of the 'summer' function" OFF)
if (DEFINE_TEST_PARAM)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-DTESTFLAG")
endif()
add_subdirectory(pybind11)
find_package (Python COMPONENTS Interpreter Development)
include_directories(${Python_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
find_program(CastXML_EXECUTABLE NAMES castxml)
option(DEFINE_TEST_PARAM "Adds a define parameter to swap definitions of the 'summer' function" OFF)
if (DEFINE_TEST_PARAM)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-DTESTFLAG")
endif()
message(\"${CMAKE_CXX_FLAGS}\")
execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/generator.py "-s" ${CMAKE_CURRENT_SOURCE_DIR}
"-g" ${CastXML_EXECUTABLE}
"-cf" \"${CMAKE_CXX_FLAGS}\"
"-o" ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT_VARIABLE generator_return)
execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/generator.py "-s" ${CMAKE_CURRENT_SOURCE_DIR}
"-g" ${CastXML_EXECUTABLE}
"-cf" \"${CMAKE_CXX_FLAGS}\"
"-o" ${CMAKE_CURRENT_BINARY_DIR}
-n
OUTPUT_VARIABLE generator_return OUTPUT_STRIP_TRAILING_WHITESPACE)
add_library(wrapper_example SHARED ${CMAKE_BINARY_DIR}/wrapper.cpp test.hpp test_2.hpp)
target_include_directories(wrapper_example PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
message(\"${CMAKE_CXX_FLAGS}\")
execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/generator.py "-s" ${CMAKE_CURRENT_SOURCE_DIR}
"-g" ${CastXML_EXECUTABLE}
"-cf" \"${CMAKE_CXX_FLAGS}\"
"-o" ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT_VARIABLE generator_return)
execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/generator.py "-s" ${CMAKE_CURRENT_SOURCE_DIR}
"-g" ${CastXML_EXECUTABLE}
"-cf" \"${CMAKE_CXX_FLAGS}\"
"-o" ${CMAKE_CURRENT_BINARY_DIR}
-n
OUTPUT_VARIABLE generator_return OUTPUT_STRIP_TRAILING_WHITESPACE)
message(${generator_return})
foreach(file ${generator_return})
message(${file})
get_filename_component(tgt_helper_name ${file} NAME_WE)
pybind11_add_module(${tgt_helper_name} ${file})
file(GENERATE OUTPUT "${tgt_helper_name}.py" CONTENT "
message(${generator_return})
foreach(file ${generator_return})
message(${file})
get_filename_component(tgt_helper_name ${file} NAME_WE)
pybind11_add_module(${tgt_helper_name} ${file})
file(GENERATE OUTPUT "${tgt_helper_name}.py" CONTENT "
def __bootstrap__():
global __bootstrap__, __loader__, __file__
import sys, pkg_resources, imp
__file__ = pkg_resources.resource_filename(__name__,'$<TARGET_FILE_NAME:${tgt_helper_name}>')
__loader__ = None; del __bootstrap__, __loader__
imp.load_dynamic(__name__,__file__)
global __bootstrap__, __loader__, __file__
import sys, pkg_resources, imp
__file__ = pkg_resources.resource_filename(__name__,'$<TARGET_FILE_NAME:${tgt_helper_name}>')
__loader__ = None; del __bootstrap__, __loader__
imp.load_dynamic(__name__,__file__)
__bootstrap__()"
)
set(py_command "from example import ${tgt_helper_name}")
if(${tgt_helper_name} STREQUAL "test_py")
set(py_command "from example import test_base_py\n\rfrom example import ${tgt_helper_name}")
endif()
add_test(NAME test_import_${tgt_helper_name} COMMAND ${Python_EXECUTABLE} -c ${py_command} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endforeach()
add_test(NAME WG_Linter COMMAND pycodestyle ${CMAKE_SOURCE_DIR}/generator.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
\ No newline at end of file
)
set(py_command "from example import ${tgt_helper_name}")
if(${tgt_helper_name} STREQUAL "test_py")
set(py_command "from example import test_base_py\n\rfrom example import ${tgt_helper_name}")
endif()
add_test(NAME test_import_${tgt_helper_name} COMMAND ${Python_EXECUTABLE} -c ${py_command} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endforeach()
add_test(NAME WG_Linter COMMAND pycodestyle ${CMAKE_SOURCE_DIR}/generator.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
Supports Markdown
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