We need to add additional lines of code in CMakeLists.txt to build a nodelet package. Here are the extra lines. You will get the complete CMakeLists.txt file from the existing package itself:
## Declare a cpp library add_library(nodelet_hello_world src/hello_world.cpp ) ## Specify libraries to link a library or executable target against target_link_libraries(nodelet_hello_world ${catkin_LIBRARIES} )