diff --git a/CMakeLists.txt b/CMakeLists.txt index 83bf5633e9..1d89197901 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,11 +116,11 @@ find_package(Boost 1.72.0 REQUIRED) find_package(SQLite3) if(SQLITE3_LIBRARY AND SQLITE3_INCLUDE) - set(NGEN_WITH_SQLITE3 ON) + set(NGEN_WITH_SQLITE3 ON) + add_compile_definitions(NGEN_WITH_SQLITE3) else() set(NGEN_WITH_SQLITE3 OFF) endif() -add_compile_definitions(NGEN_WITH_SQLITE3) message(INFO " SQLite3 support is ${NGEN_WITH_SQLITE3}") # UDUNITS diff --git a/src/NGen.cpp b/src/NGen.cpp index 7ed7d52ced..07e5b5827c 100644 --- a/src/NGen.cpp +++ b/src/NGen.cpp @@ -7,7 +7,7 @@ #include #include -#if NGEN_WITH_SQLITE3 +#ifdef NGEN_WITH_SQLITE3 #include #endif @@ -265,10 +265,10 @@ int main(int argc, char *argv[]) { // TODO: Instead of iterating through a collection of FeatureBase objects mapping to nexi, we instead want to iterate through HY_HydroLocation objects geojson::GeoJSON nexus_collection; if (boost::algorithm::ends_with(nexusDataFile, "gpkg")) { - #if NGEN_WITH_SQLITE3 + #ifdef NGEN_WITH_SQLITE3 nexus_collection = geopackage::read(nexusDataFile, "nexus", nexus_subset_ids); #else - throw std::runtime_error("SQLite3 support required to read GeoPackage files.") + throw std::runtime_error("SQLite3 support required to read GeoPackage files."); #endif } else { nexus_collection = geojson::read(nexusDataFile, nexus_subset_ids); @@ -278,10 +278,10 @@ int main(int argc, char *argv[]) { // TODO: Instead of iterating through a collection of FeatureBase objects mapping to catchments, we instead want to iterate through HY_Catchment objects geojson::GeoJSON catchment_collection; if (boost::algorithm::ends_with(catchmentDataFile, "gpkg")) { - #if NGEN_WITH_SQLITE3 + #ifdef NGEN_WITH_SQLITE3 catchment_collection = geopackage::read(catchmentDataFile, "divides", catchment_subset_ids); #else - throw std::runtime_error("SQLite3 support required to read GeoPackage files.") + throw std::runtime_error("SQLite3 support required to read GeoPackage files."); #endif } else { catchment_collection = geojson::read(catchmentDataFile, catchment_subset_ids);