Ask Your Question
0

Getting CMake warning because of CMP0048 even after bumping up CMake Minimum Version

asked 2020-07-13 22:34:54 -0600

swaroophs gravatar image

updated 2020-07-13 23:39:09 -0600

Working on building and testing my ROS package in noetic. I get the following warning:

CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

I have edited my CMakeLists.txt to have the following line to bump up minimum version of CMake:

cmake_minimum_required(VERSION 3.0.2)

Similar to this.

But I am still getting the warning. Am I missing something? I am not seeing this in my melodic build.

Edit: My CMakeLists.txt looks like below:

cmake_minimum_required(VERSION 3.0.2)
project(rosrect-listener-agent)
find_package(catkin REQUIRED COMPONENTS
  roscpp
  roslib
  rosgraph_msgs
  std_msgs
)
set(cpprestsdk_DIR /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/cmake/)
find_package(OpenSSL REQUIRED)
find_package(cpprestsdk REQUIRED)

add_library(rosrect-listener-agent-lib src/backend_api.cpp src/robot_event.cpp src/state_manager.cpp)
target_link_libraries(rosrect-listener-agent-lib ${catkin_LIBRARIES} cpprestsdk::cpprest)
add_executable(rosrect-listener-agent src/listener_agent.cpp )
target_link_libraries(rosrect-listener-agent
  ${catkin_LIBRARIES}
  rosrect-listener-agent-lib
  cpprestsdk::cpprest
)
add_dependencies(rosrect-listener-agent ${rosrect-listener-agent_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

#############
## Testing ##
#############
if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING)
  find_package(code_coverage REQUIRED)
  # Add compiler flags for coverage instrumentation before defining any targets
  APPEND_COVERAGE_COMPILER_FLAGS()
endif()
if(CATKIN_ENABLE_TESTING)
  find_package(rostest REQUIRED)

  # Unit tests for utility classes as just gtest
  catkin_add_gtest(backend_test_node test/utests_backendapi.cpp)
  catkin_add_gtest(robotevent_test_node test/utests_robotevent.cpp)
  catkin_add_gtest(statemanager_test_node test/utests_statemanager.cpp)

  # Integration test for listener agent node as rostest
  add_rostest_gtest(listeneragent_test_node_ros test/listener_integration_test_ros.test test/itest_listeneragent_ros.cpp)
  add_rostest_gtest(listeneragent_test_node_db test/listener_integration_test_db.test test/itest_listeneragent_db.cpp)

  target_link_libraries(backend_test_node ${catkin_LIBRARIES} rosrect-listener-agent-lib cpprestsdk::cpprest)
  target_link_libraries(robotevent_test_node ${catkin_LIBRARIES} rosrect-listener-agent-lib cpprestsdk::cpprest)
  target_link_libraries(statemanager_test_node ${catkin_LIBRARIES} rosrect-listener-agent-lib cpprestsdk::cpprest)
  target_link_libraries(listeneragent_test_node_ros ${catkin_LIBRARIES} rosrect-listener-agent-lib cpprestsdk::cpprest)
  target_link_libraries(listeneragent_test_node_db ${catkin_LIBRARIES} rosrect-listener-agent-lib cpprestsdk::cpprest)

  if(ENABLE_COVERAGE_TESTING)
    set(COVERAGE_EXCLUDES "*/${PROJECT_NAME}/test*" "*/${PROJECT_NAME}/include/${PROJECT_NAME}/*.h")
    add_code_coverage(
      NAME ${PROJECT_NAME}_coverage_report
      # DEPENDENCIES tests
    )
  endif()
endif()
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-07-13 23:35:05 -0600

Dirk Thomas gravatar image

updated 2020-07-13 23:59:46 -0600

The shown warning has nothing to do with CMP0048.

It would be helpful if you would either share the content of your CMakeLists.txt as part of the question or reference the file in a public repository.

The warning literally mentions what the problem in the CMakeLists.txt (of your package) is and how you should be able to resolve it:

No project() command is present. The top-level CMakeLists.txt file must contain a literal, direct call to the project() command. Add a line of code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

Update:

The warning is being generated from to the top-level CMakeLists.txt file when using catkin_make with CMake 3.15 or newer.

You can either:

  • use catkin_make_isolated instead of catkin_make (which doesn't use a top-level CMake file,
  • apply the patch from https://github.com/ros/catkin/pull/1106 locally to the file /opt/ros/noetic/share/catkin/cmake/toplevel.cmake manually, or
  • wait for a new version of catkin to be released with the referenced patch.
edit flag offensive delete link more

Comments

Thanks @Dirk. I have pasted the contents of my CMakeLists.txt file above. I do have the project specified right below cmake_minimum_required.

swaroophs gravatar image swaroophs  ( 2020-07-13 23:40:31 -0600 )edit

How are you invoking the build? I assume you use catkin_make - see updated answer.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-07-13 23:43:37 -0600 )edit

Thanks @Dirk. I am just using catkin_make. I tried the patch of just adding project(Project) to the top-level CMake and the warning has disappeared now.

swaroophs gravatar image swaroophs  ( 2020-07-14 01:36:36 -0600 )edit

I have the same warning triggered on the buildfarm using catkin_make_isolated, see here: http://build.ros.org/job/Ndev__ixblue... at 18:09:34

rreignier gravatar image rreignier  ( 2020-09-04 02:52:30 -0600 )edit

@rreignier Your error message is different from the one described in this question. Please ask a separate question and copy-n-paste the full error message instead of just referencing a build.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-09-04 12:25:03 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-13 22:34:54 -0600

Seen: 472 times

Last updated: Jul 13 '20