Skip to content

Commit

Permalink
add cxxopts dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed May 12, 2023
1 parent 1479320 commit 6280c35
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third_party/cxxopts"]
path = third_party/cxxopts
url = https://github.com/jarro2783/cxxopts.git
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ project(RayTracing VERSION 0.1.0)

add_subdirectory(third_party/stb_image_write)
add_subdirectory(third_party/nlohmann)
add_subdirectory(third_party/cxxopts)

include_directories(include)
add_executable(RayTracing src/main.cpp
Expand All @@ -19,7 +20,7 @@ if(UNIX)
target_link_libraries(RayTracing pthread)
endif(UNIX)

target_link_libraries(RayTracing StbImageWrite Nlohmann)
target_link_libraries(RayTracing StbImageWrite Nlohmann cxxopts)

install(TARGETS RayTracing
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin)
16 changes: 15 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "nlohmann/json.hpp"
using json = nlohmann::json;

#include "cxxopts.hpp"

HittableList random_scene()
{
HittableList world;
Expand Down Expand Up @@ -61,8 +63,20 @@ HittableList random_scene()
return world;
}

int main()
int main(int argc, char* argv[])
{
cxxopts::Options option("Raytracing");
option.add_options()
("v,version", "Print the version", cxxopts::value<bool>()->default_value("false"))
;
auto result = option.parse(argc,argv);

if (result["version"].as<bool>())
{
std::cout << "RayTracing - v0.0.0" << std::endl;
exit(EXIT_SUCCESS);
}

std::ifstream confFile("conf.json");
json conf;
confFile >> conf;
Expand Down

0 comments on commit 6280c35

Please sign in to comment.