ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is this your entire CMakeLists.txt? Please provide a complete copy.

Is this your entire CMakeLists.txt? Please provide a complete copy.

If this is the complete contents, you seem to be missing two important statements. A typical CMakeLists.txt starts with:

cmake_minimum_required(VERSION 2.8.3)
project(your_package)

See also wiki/catkin/CMakeLists.txt - Overall Structure and Ordering and catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Catkin configuration overview - CMakeLists.txt

Is this your entire CMakeLists.txt? Please provide a complete copy.

If this is the complete contents, you seem to be missing two important statements. A typical CMakeLists.txt starts with:

cmake_minimum_required(VERSION 2.8.3)
project(your_package)

See also wiki/catkin/CMakeLists.txt - Overall Structure and Ordering and catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Catkin configuration overview - CMakeLists.txt

Also:

add_executable(opencv_test2 script/opencv_test2.py)

You can (and should) use a CMakeLists.txt for ROS Python nodes, but you don't use add_executable(..) then. See catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Installing Python scripts and modules for more info on using catkin with Python.

Note that you don't need to install your script / node in order to be able to rosrun or roslaunch it. You only need a minimal CMakeLists.txt to build your package, catkin will do the rest.

Is this your entire CMakeLists.txt? Please provide a complete copy.

If this is the complete contents, you seem to be missing two important statements. A typical CMakeLists.txt starts with:

cmake_minimum_required(VERSION 2.8.3)
project(your_package)

See also wiki/catkin/CMakeLists.txt - Overall Structure and Ordering and catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Catkin configuration overview - CMakeLists.txt

Also:

add_executable(opencv_test2 script/opencv_test2.py)

You can (and should) use a CMakeLists.txt for ROS Python nodes, but you don't use add_executable(..) then. See catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Installing Python scripts and modules for more info on using catkin with Python.

Note that you don't need to install your script / node in order to be able to rosrun or roslaunch it. You only need a minimal CMakeLists.txt to build your package, catkin will do the rest.


Edit:

i revised my cmakelist.txt

but occur the error that ' cannot speify link libraries for target " scripts/opencv_test1.py" which is not built by this project.

Have you read the documentation I linked? You cannot link Python nodes to anything using target_link_libraries(..). That is for C/C++/other compiled languages only. There is nothing to link with Python.

Also: include_directories(..) is useless with Python nodes. The PYTHONPATH is setup by sourcing the correct setup.(bash|sh|zsh) after building your workspace.

A minimal CMakeLists.txt for a Python only package is probably something like:

cmake_minimum_required(VERSION 2.8.3)
project(your_project_name)

find_package(catkin REQUIRED)

# depending on whether you have any libraries to install/export
#catkin_python_setup()

catkin_package()

Is this your entire CMakeLists.txt? Please provide a complete copy.

If this is the complete contents, you seem to be missing two important statements. A typical CMakeLists.txt starts with:

cmake_minimum_required(VERSION 2.8.3)
project(your_package)

See also wiki/catkin/CMakeLists.txt - Overall Structure and Ordering and catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Catkin configuration overview - CMakeLists.txt

Also:

add_executable(opencv_test2 script/opencv_test2.py)

You can (and should) use a CMakeLists.txt for ROS Python nodes, but you don't use add_executable(..) then. See catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Installing Python scripts and modules for more info on using catkin with Python.

Note that you don't need to install your script / node in order to be able to rosrun or roslaunch it. You only need a minimal CMakeLists.txt to build your package, catkin will do the rest.


Edit:

i revised my cmakelist.txt

but occur the error that ' cannot speify link libraries for target " scripts/opencv_test1.py" which is not built by this project.

Have you read the documentation I linked? You cannot link Python nodes to anything using target_link_libraries(..). That is for C/C++/other compiled languages only. There is nothing to link with Python.

Also: include_directories(..) is useless with Python nodes. The PYTHONPATH is setup by sourcing the correct setup.(bash|sh|zsh) after building your workspace.

A minimal CMakeLists.txt for a Python only package is probably something like:

cmake_minimum_required(VERSION 2.8.3)
project(your_project_name)

find_package(catkin REQUIRED)

# depending on whether you have any libraries to install/export
#catkin_python_setup()

# add relevant arguments here (CATKIN_DEPENDS etc)
catkin_package()