Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bill Hoffman
autopybind11
Commits
14d11de4
Commit
14d11de4
authored
May 05, 2020
by
Joe Snyder
Browse files
Remove GENERATE_WRAPPING option
parent
225d64de
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.rst
View file @
14d11de4
...
...
@@ -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 -D
GENERATE_WRAPPING
=ON .... <path/to>/wrapper_generator
$ cmake -D
DEFINE_TEST_PARAM
=ON .... <path/to>/wrapper_generator
The ``generator.py`` script will be run as a part of the ``Configure`` step in
of CMake.
...
...
example/CMakeLists.txt
View file @
14d11de4
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\r
from 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\r
from 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
}
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment