Skip to content

Commit

Permalink
feat(python): add scripts support and example
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaumebeuzeboc committed Jan 29, 2019
1 parent ac8ef3a commit c585879
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 25 deletions.
11 changes: 4 additions & 7 deletions cmake/python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ macro(SETUP_PYTHON_PKG)

endmacro()

macro(INSTALL_PYTHON_FILES)
#install(
#PROGRAMS
# scripts/my_scrip.py
#DESTINATION
#${CAMKE_PYTHON_INSTALL}/${PROJECT_NAME} COMPONENT ${${PROJECT_NAME}_UPPER}
#)
macro(INSTALL_PYTHON_SCRIPTS)
set (SCRIPTS ${ARGN})
install(PROGRAMS ${SCRIPTS} DESTINATION lib/${PROJECT_NAME} COMPONENT ${${PROJECT_NAME}_UPPER}
)
endmacro()

2 changes: 2 additions & 0 deletions src/a_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ INSTALL_BIN_LIB(a_lib a_lib)

INSTALL_ALL_HEADERS()

INSTALL_PYTHON_SCRIPTS(scripts/a_test.py)

SETUP_PKG(a_lib a_lib) # First arg is pkg name and after they are the targets names

BUILDDEB()
6 changes: 6 additions & 0 deletions src/a_lib/scripts/a_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/python3

from a_lib.a_lib import a_lib_function

if __name__ == '__main__':
a_lib_function()
8 changes: 0 additions & 8 deletions src/a_lib/setup.py

This file was deleted.

4 changes: 4 additions & 0 deletions src/g_app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ find_package(z_lib)

INIT_PKG()

SETUP_PYTHON_PKG()

add_executable(g_app
src/app.cpp)

Expand All @@ -12,6 +14,8 @@ target_link_libraries(g_app z_lib a_lib)

INSTALL_BIN_LIB(g_app g_app)

INSTALL_PYTHON_SCRIPTS(scripts/test.py)

SETUP_PKG(g_app g_app) # First arg is pkg name and after they are the targets names

BUILDDEB()
Expand Down
6 changes: 6 additions & 0 deletions src/g_app/scripts/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/python3

from g_app.app import main

if __name__ == '__main__':
main()
2 changes: 0 additions & 2 deletions src/g_app/src/g_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ def main():
z_lib.z_lib_function()
print("HelloWorld")

if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions src/z_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ find_package(Eigen3 REQUIRED)

INIT_PKG()

SETUP_PYTHON_PKG()

include_directories(include ${Boost_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR})
add_library(z_lib
src/lib.cpp)
Expand Down
8 changes: 0 additions & 8 deletions src/z_lib/setup.py

This file was deleted.

0 comments on commit c585879

Please sign in to comment.