how to set read path as root path in xmake project ? #5630
-
i want to read file in project root path when i run #include <exception>
#include <fmt/args.h>
#include <fstream>
#include <iostream>
#include <sstream>
int main() {
std::cout << "hello world" << std::endl;
std::ifstream file;
try {
file.open(".env.local");
fmt::println("reading file...");
std::stringstream strstream;
strstream << file.rdbuf();
file.close();
fmt::println("closing file...");
auto str = strstream.str();
fmt::println("file content : {}", str);
} catch (std::exception e) {
fmt::println(e.what());
}
} xmake.lua: add_rules("mode.debug", "mode.release")
add_rules("plugin.compile_commands.autoupdate")
add_requires("fmt")
add_requires("glfw", "glad", "glm")
on_config(function(target)
target:add("includedirs", "include")
end)
target("window")
set_kind("binary")
add_files("src/main.cpp")
add_packages("fmt", "glad", "glfw", "glm") |
Beta Was this translation helpful? Give feedback.
Answered by
star-hengxing
Sep 17, 2024
Replies: 1 comment 3 replies
-
https://xmake.io/#/manual/project_target?id=targetset_rundir |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Fodesu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://xmake.io/#/manual/project_target?id=targetset_rundir