problem with find_package()

i am completely new to use cmake. i am facing an issue with debugging the following error.

Observed:

CMake Error at CMakeLists.txt:30 (find_package):
  find_package called with incorrect number of arguments


 was not found. Please specify vsomeip_DIR
-- Configuring incomplete, errors occurred!

CMakeLists.txt content:

cmake_minimum_required (VERSION 2.8.7)
project (vSomeIPHelloWorld)

find_package(Threads REQUIRED)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

include_directories(${VSOMEIP_INCLUDE_DIRS})

add_library(vsomeip_hello_world_service INTERFACE)
target_sources(vsomeip_hello_world_service INTERFACE
    "${CMAKE_CURRENT_SOURCE_DIR}/hello_world_service.hpp"
)
target_include_directories(vsomeip_hello_world_service INTERFACE
        "${CMAKE_CURRENT_SOURCE_DIR}"
)

add_library(vsomeip_hello_world_client INTERFACE)
target_sources(vsomeip_hello_world_client INTERFACE
    "${CMAKE_CURRENT_SOURCE_DIR}/hello_world_client.hpp"
)
target_include_directories(vsomeip_hello_world_client INTERFACE
        "${CMAKE_CURRENT_SOURCE_DIR}"
        )

if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
    # This will get us acces to
    #   VSOMEIP_INCLUDE_DIRS - include directories for vSomeIP
    #   VSOMEIP_LIBRARIES    - libraries to link against
    find_package(${VSOMEIP_NAME})
    if (NOT ${VSOMEIP_NAME}_FOUND)
        message("${VSOMEIP_NAME} was not found. Please specify vsomeip_DIR")
    endif()

    add_executable (hello_world_service hello_world_service_main.cpp)
    target_link_libraries(hello_world_service vsomeip_hello_world_service ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

    add_executable (hello_world_client hello_world_client_main.cpp)
    target_link_libraries(hello_world_client vsomeip_hello_world_client ${VSOMEIP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()

Kindly help me in resolving the issue.

The error message indicates that you’ve called find_package with the wrong number of arguments. What is the value of the VSOMEIP_NAME variable?

i don’t know how to check the variable value.

You can use something like:

message("-->${VSOMEIP_NAME}<--")

with the arrows there to help pinpoint the value.

it is displaying nothing as follows

CMake Error at CMakeLists.txt:30 (find_package):
find_package called with incorrect number of arguments

–><–
was not found. Please specify vsomeip_DIR
– Configuring incomplete, errors occurred!

That variable is then empty. You’ll need to set it to the name of the package that should be found.

okay.
will try setting the variable.

Thanks a lot. It is working after setting the variable value.

Hi @kondachaitanya1993, I have the same problem.
Could you explain how you set the variable value?
I’ve tried setting VSOMEIP_NAME as an environment variable like this: “export VSOMEIP_NAME=/mnt/c/Users/Elias/wsl/vsomeip/build” (notice I’m using WSL… /vsomeip/build is the directory where I’ve built the vsomeip stack).
This does not work for me, however.

That variable is a CMake variable. It doesn’t read the environment. You’ll need to add set(VSOMEIP_NAME …) to the CMake code, pass -DVSOMEIP_NAME=… on the command line, or set the variable in the GUI.

Adding set(VSOMEIP_NAME …) in the CMake file indeed fixed it.
Thanks!

For future newbies like me

VSOMEIP_NAME is found in your original vsomeip build folder rootfolder/build/<VSOMEIP_NAME>Config.cmake

So

set(VSOMEIP_NAME "vsomeip3") in my case