Good day!
I have to start saying that building and installing SNMP++ and AGENT++ works as expected without any issue.
That said, I have to build a simple SNMP Agent and I have mainly 2 requirements: 1) Do not install any file in the system, 2) Use CMake self contained build.
I have a folder structure and CMakeLists.txt as follows:
* MySnmpAgent
- snmppp ---> SNMP++ sources
- agentpp ---> Agent++ sources
My CMakeLists.txt
cmake_minimum_required(VERSION 3.25)
project(MySnmpAgent)
add_executable(MySnmpAgent
src/main.cpp
)
add_subdirectory(snmppp)
add_subdirectory(agentpp)
target_link_libraries(MySnmpAgent PUBLIC
snmp++_static
agent++_static
)
I have found 2 issues.
The first one, I receive a build error:
libsnmp.h:268:11: fatal error: iostream.h: No such file or directory
This error is caused by the following line in both snmp++ and agent++ CMakeLists.txt:
check_include_files ("iostream" CNF_HAVE_IOSTREAM)
Since “iostream” is a C++ header file, the line would be:
include (CheckIncludeFileCXX)
...
check_include_file_cxx ("iostream" CNF_HAVE_IOSTREAM)
Probably the same fix needs to be applied to the line:
check_include_files ("cctype;cerrno;climits;csignal;cstddef;cstdio;cstdlib;cstring;ctime" CNF_STDCXX_98_HEADERS)
This solves the issue. It would be nice to have this fix applied for the next release.
So far so good.
The second issue is not that straightforward. Agent++ complains about SNMP++ root dir. The issue goes away if I precompile SNMP++ and provide SNMP_PP_ROOT_DIR but does not look to me like the CMake-ish way of building the code. I would like to be able to just do (example):
cmake <path-to-my-CMakeLists.txt> [-DCMAKE_BUILD_TYPE=Debug]
And then build both SNMP++ and AGENT++ in the following make step:
make
I can probably solve the issue by issuing something like:
execute_command(
COMMAND "cmake <path_to_snmppp>"
WORKING DIRECTORY ${SNMP_BUILD_DIR}
)
Would certainly work if there is no other option, but it is not what I am looking for since that would trigger the build of SNMP++ when the cmake command is triggered for my CMakeLists.txt
Is there a way of building both SNMP++ and AGENT++ in the ‘make’ step following to CMake command?
Thanks in advance