This is the program I want to run, main.cpp:
#include <iostream>
#include "yaracpp/yaracpp.h"
int main() {
yaracpp::YaraDetector yara;
yara.addRules(R"(
rule example {
strings:
$s = "Hello"
condition:
$s
})");
if (yara.analyze("test_file")) {
for (const auto& rule : yara.getDetectedRules()) {
std::cout << rule << '\n';
}
}
}
When I run this command on the terminal it compiles successfully:
g++ -Iinclude -Ibuild/deps/yara/src/yara/libyara/include/ -Lbuild/src/
-Lbuild/deps/yara/src/yara/libyara/.libs/ main.cpp -lyaracpp -lyara
-lpthread -lssl -lcrypto
*Approach 1:*
My CMakeLists.txt is:
cmake_minimum_required(VERSION 3.6)
project(main CXX C)
add_executable(main main.cpp)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Iinclude
-Ibuild/deps/yara/src/yara/libyara/include -Lbuild/src
-Lbuild/deps/yara/src/yara/libyara/.libs/")
target_link_libraries (main yaracpp yara pthread ssl crypto)
But this was not able to link it properly and threw errors that it cannot
find "yaracpp/yaracpp.h". The references for writing CMakeLists.txt like
this were:
https://stackoverflow.com/questions/43136418/how-to-add-l-ell-compiler-flag-in-cmake
https://stackoverflow.com/questions/53879422/how-to-set-g-compile-options-in-clion?answertab=oldest#tab-top
--
Sent from: http://cmake.3232098.n2.nabble.com/
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake