Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_backend_opencv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
aidge
aidge_backend_opencv
Commits
854ee756
Commit
854ee756
authored
11 months ago
by
Grégoire Kubler
Committed by
Maxence Naud
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
feat: homogeinized cmakelists w backend_cpu
parent
e6541e0b
No related branches found
No related tags found
1 merge request
!18
v0.1.3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+12
-1
12 additions, 1 deletion
CMakeLists.txt
cmake/PybindModuleCreation.cmake
+15
-22
15 additions, 22 deletions
cmake/PybindModuleCreation.cmake
with
27 additions
and
23 deletions
CMakeLists.txt
+
12
−
1
View file @
854ee756
...
@@ -62,8 +62,16 @@ target_include_directories(${module_name}
...
@@ -62,8 +62,16 @@ target_include_directories(${module_name}
# PYTHON BINDING
# PYTHON BINDING
if
(
PYBIND
)
if
(
PYBIND
)
# Handles Python + pybind11 headers dependencies
include
(
PybindModuleCreation
)
include
(
PybindModuleCreation
)
generate_python_binding
()
generate_python_binding
(
${
CMAKE_PROJECT_NAME
}
${
module_name
}
)
target_link_libraries
(
${
module_name
}
PUBLIC
pybind11::pybind11
PRIVATE
Python::Module
)
endif
()
endif
()
target_compile_features
(
${
module_name
}
PRIVATE cxx_std_14
)
target_compile_features
(
${
module_name
}
PRIVATE cxx_std_14
)
...
@@ -133,6 +141,9 @@ export(EXPORT ${project}-targets
...
@@ -133,6 +141,9 @@ export(EXPORT ${project}-targets
##############################################
##############################################
## Add test
## Add test
if
(
TEST
)
if
(
TEST
)
if
(
PYBIND
)
message
(
FATAL_ERROR
"PYBIND and TEST are both enabled. But cannot compile with catch_2.
\n
Choose between pybind and Catch2 for compilation."
)
endif
()
enable_testing
()
enable_testing
()
add_subdirectory
(
unit_tests
)
add_subdirectory
(
unit_tests
)
endif
()
endif
()
This diff is collapsed.
Click to expand it.
cmake/PybindModuleCreation.cmake
+
15
−
22
View file @
854ee756
macro
(
generate_python_binding
)
function
(
generate_python_binding
pybind_module_name target_to_bind
)
add_definitions
(
-DPYBIND
)
add_definitions
(
-DPYBIND
)
Include
(
FetchContent
)
Include
(
FetchContent
)
# Use the New FindPython mode, recommanded. Requires CMake 3.15+
find_package
(
Python 3.7.0
COMPONENTS Interpreter Development.Module
REQUIRED
)
set
(
PYBIND11_FINDPYTHON ON
)
set
(
PYBIND_VERSION v2.10.4
)
set
(
PYBIND_VERSION v2.10.4
)
set
(
PYBIND11_FINDPYTHON ON
)
message
(
STATUS
"Retrieving pybind
${
PYBIND_VERSION
}
from git"
)
message
(
STATUS
"Retrieving pybind
${
PYBIND_VERSION
}
from git"
)
FetchContent_Declare
(
FetchContent_Declare
(
PyBind11
PyBind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG
${
PYBIND_VERSION
}
# or a later release
GIT_TAG
${
PYBIND_VERSION
}
# or a later release
)
)
# Use the New FindPython mode, recommanded. Requires CMake 3.15+
find_package
(
Python COMPONENTS Interpreter Development.Module
)
FetchContent_MakeAvailable
(
PyBind11
)
FetchContent_MakeAvailable
(
PyBind11
)
message
(
STATUS
"Creating binding for module
${
p
roject
}
"
)
message
(
STATUS
"Creating binding for module
${
p
ybind_module_name
}
"
)
file
(
GLOB_RECURSE pybind_src_files
"python_binding/*.cpp"
)
file
(
GLOB_RECURSE pybind_src_files
"python_binding/*.cpp"
)
pybind11_add_module
(
${
project
}
MODULE
${
pybind_src_files
}
"NO_EXTRAS"
)
# NO EXTRA required for pip install
pybind11_add_module
(
${
pybind_module_name
}
MODULE
${
pybind_src_files
}
"NO_EXTRAS"
)
# NO EXTRA recquired for pip install
target_include_directories
(
${
project
}
PUBLIC
"python_binding"
${
pybind11_INCLUDE_DIRECTORIES
}
)
target_include_directories
(
${
pybind_module_name
}
PUBLIC
"python_binding"
)
# Handles Python + pybind11 headers dependencies
target_link_libraries
(
${
pybind_module_name
}
PUBLIC
${
target_to_bind
}
)
target_link_libraries
(
${
module_name
}
endfunction
()
PRIVATE
Python::Module
PUBLIC
pybind11::pybind11
)
target_link_libraries
(
${
project
}
PUBLIC
${
module_name
}
)
endmacro
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment