Skip to content

Commit

Permalink
Merge pull request #372 from lasp/feature/spice-download-optional
Browse files Browse the repository at this point in the history
Add optional url to de430.bsp download
  • Loading branch information
patkenneally authored Jan 23, 2025
2 parents 02f1842 + 5a4f118 commit 0911ea1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
}
bskModuleOptionsString = {
"autoKey": "",
"pathToExternalModules": ""
"pathToExternalModules": "",
"url_spice_kernel": ""
}
bskModuleOptionsFlag = {
"clean": False,
Expand Down Expand Up @@ -251,6 +252,7 @@ def build(self):
cmake.definitions["CONAN_LINK_RUNTIME_MULTI"] = cmake.definitions["CONAN_LINK_RUNTIME"]
cmake.definitions["CONAN_LINK_RUNTIME"] = False
cmake.definitions["BUILD_OPNAV"] = self.options.opNav
if self.options.url_spice_kernel: cmake.definitions["URL_SPICE_KERNEL"] = self.options.url_spice_kernel
cmake.definitions["BUILD_VIZINTERFACE"] = self.options.vizInterface
cmake.definitions["EXTERNAL_MODULES_PATH"] = self.options.pathToExternalModules
cmake.definitions["PYTHON_VERSION"] = f"{sys.version_info.major}.{sys.version_info.minor}"
Expand Down
13 changes: 9 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,16 @@ FetchContent_MakeAvailable(googletest)
include(GoogleTest)
enable_testing()

# Check if the large Spice files are present. If not, download from JPL site directly
# Download spice file if not present
set(URL_SPICE_KERNEL
"https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de430.bsp"
CACHE
STRING
"URL from which to download spice kernel de430.bsp dependency")
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/../supportData/EphemerisData/de430.bsp")
message(STATUS "File de430.bsp not found, downloading file:")
message(STATUS "File de430.bsp not found, downloading file from ${URL_SPICE_KERNEL}:")
file(DOWNLOAD
"https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de430.bsp"
"${URL_SPICE_KERNEL}"
# Download it to the build directory (in case the download gets interrupted).
"${CMAKE_BINARY_DIR}/data/de430.bsp"
SHOW_PROGRESS
Expand All @@ -351,7 +356,7 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/../supportData/EphemerisData/de430.bsp")
list(GET DOWNLOAD_RESULT 1 RESULT_MESSAGE)
list(GET DOWNLOAD_RESULT 0 RESULT_CODE)
if(NOT RESULT_CODE EQUAL 0)
message(FATAL_ERROR "Failed downloading de430.bsp with error code: ${RESULT_CODE} : ${RESULT_MESSAGE}.")
message(WARNING "Failed downloading de430.bsp with error code: ${RESULT_CODE} : ${RESULT_MESSAGE}.")
endif()
# Move the SPICE file into the appropriate directory.
file(RENAME "${CMAKE_BINARY_DIR}/data/de430.bsp" "${CMAKE_SOURCE_DIR}/../supportData/EphemerisData/de430.bsp")
Expand Down

0 comments on commit 0911ea1

Please sign in to comment.