diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c9e9e6..cc61c7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,16 +2,24 @@ cmake_minimum_required(VERSION "3.12") project("spackexample" VERSION 0.3.0) -find_package(Boost - 1.65.1 - REQUIRED - filesystem - ) +option(WITH_BOOST "Include optional functionality and boost dependency" ON) +option(WITH_YAML "Build with included YAML-parsing" ON) + +if (WITH_BOOST) + find_package(Boost + 1.65.1 + REQUIRED + filesystem + ) +endif() + +if (WITH_YAML) + find_package(yaml-cpp + 0.7.0 + REQUIRED + ) +endif() -find_package(yaml-cpp - 0.7.0 - REQUIRED - ) add_library(spackexamplelib filesystem/filesystem.cpp flatset/flatset.cpp yamlParser/yamlParser.cpp) @@ -22,11 +30,20 @@ set_target_properties(spackexamplelib PUBLIC_HEADER yamlParser/yamlParser.hpp ) -include_directories(${YAML_CPP_INCLUDE_DIR}) +if (WITH_YAML) + include_directories(${YAML_CPP_INCLUDE_DIR}) +endif() add_executable(spackexample main.cpp) target_link_libraries(spackexample spackexamplelib) -target_link_libraries(spackexamplelib Boost::filesystem yaml-cpp) +if (WITH_YAML) + target_link_libraries(spackexamplelib yaml-cpp) + target_compile_definitions(spackexamplelib PRIVATE WITH_YAML) +endif() +if (WITH_BOOST) + target_link_libraries(spackexamplelib Boost::filesystem) + target_compile_definitions(spackexamplelib PRIVATE WITH_BOOST) +endif() target_include_directories(spackexamplelib PRIVATE diff --git a/change_git_repo.patch b/change_git_repo.patch new file mode 100644 index 0000000..908f903 --- /dev/null +++ b/change_git_repo.patch @@ -0,0 +1,8 @@ +14c14 +< git = "https://github.com/Simulation-Software-Engineering/spack-exercise.git" +--- +> git = "https://github.com/menkalian/spack-exercise.git" +20c20 +< version("main", branch="main") +--- +> version("main", branch="exercise-spack-krampfkn") diff --git a/filesystem/filesystem.cpp b/filesystem/filesystem.cpp index 4428da4..afe7ac1 100644 --- a/filesystem/filesystem.cpp +++ b/filesystem/filesystem.cpp @@ -2,6 +2,8 @@ #include #include #include + +#if WITH_BOOST #include using namespace boost::filesystem; @@ -44,3 +46,11 @@ void inspectDirectory() } } + +#else + +void inspectDirectory() { + std::cout << "Filesystem operations are not available without Boost. Build package with '+boost' to enable functionality" << std::endl; +} + +#endif diff --git a/flatset/flatset.cpp b/flatset/flatset.cpp index 9b5279f..abbae98 100644 --- a/flatset/flatset.cpp +++ b/flatset/flatset.cpp @@ -1,5 +1,7 @@ #include "flatset.hpp" #include + +#ifdef WITH_BOOST #include void modifyAndPrintSets() { @@ -20,3 +22,10 @@ void modifyAndPrintSets() { std::cout< +#ifdef WITH_YAML + +#include "yaml-cpp/yaml.h" void parseConfig(const std::string yamlFile){ YAML::Node config = YAML::LoadFile(yamlFile); std::cout << "Version: " << config["version"].as() << std::endl; } + +#else + +void parseConfig(const std::string yamlFile) { + std::cout << "Yaml-Parser was disabled at build time. Build package with '+yaml' to enable functionality" << std::endl; +} + +#endif