报错如下:
CMake Error at CMakeLists.txt:5 (find_package):
By not providing "Findvsomeip.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "vsomeip", but
CMake did not find one.
Could not find a package configuration file provided by "vsomeip"
(requested version 2.6.0) with any of the following names:
vsomeipConfig.cmake
vsomeip-config.cmake
Add the installation prefix of "vsomeip" to CMAKE_PREFIX_PATH or set
"vsomeip_DIR" to a directory containing one of the above files. If
"vsomeip" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/kesab/connectivity-vsomeip/req_resp/build/CMakeFiles/CMakeOutput.log".
CMakeLists.txt文件如下
cmake_minimum_required (VERSION 2.8.7)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
PROJECT(service-client)
set(vsomeip_DIR/home/ygd/vsomeip)
#find_package(Threads REQUIRED)
find_package (vsomeip 2.6.0 REQUIRED)
find_package( Boost 1.55 COMPONENTS system thread log REQUIRED )
include_directories (
${Boost_INCLUDE_DIR}
${VSOMEIP_INCLUDE_DIRS}
)
add_executable(service-example ../src/service-example.cpp)
target_link_libraries(service-example vsomeip ${Boost_LIBRARIES})
add_executable (client-example ../src/client-example.cpp)
target_link_libraries(client-example vsomeip ${Boost_LIBRARIES})
文件结构如下:
├── build ├── CMakeLists.txt │ └── src ├── service-example.cpp └── client-example.cpp
需要安装vsomeip,下载地址https://gitee.com/mirrors/vsomeip
编译和安装方法在连接中也有,安装完成后,把路径添加到CMAKE_PREFIX_PATH,然后重新编译即可。
问题主要在对CMake的不熟悉
cmake_minimum_required (VERSION 2.8.7)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
PROJECT(service-client)
find_package(Threads REQUIRED)
include_directories("/usr/local/include/vsomeip")
link_directories("/usr/local/lib")
add_compile_options( -std=c++11 -O3 -Wall -c -fmessage-length=0 -fPIC -fPIE -pie -fstack-protector-all -Wtrampolines )
include_directories (
${Boost_INCLUDE_DIR}
${VSOMEIP_INCLUDE_DIRS}
)
add_executable(service-example ../src/service-example.cpp)
target_link_libraries(service-example vsomeip3 pthread)
add_executable (client-example ../src/client-example.cpp)
target_link_libraries(client-example vsomeip3 pthread)