NASA C SPICE toolkit (#8859)

This commit is contained in:
Hleb Valoshka 2019-11-21 01:04:54 +03:00 committed by Griffin Downs
parent 5318373300
commit f07efb4a1d
6 changed files with 150 additions and 0 deletions

View File

@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.1)
project(cspice LANGUAGES C)
set(SOVERSION 66)
# Include all *.c files from the library
file(GLOB CSPICE_SOURCE ${PROJECT_SOURCE_DIR}/cspice/src/cspice/*.c)
set(INCLUDE_PATH "${PROJECT_SOURCE_DIR}/cspice/include")
if (_STATIC_BUILD)
add_library(cspice STATIC ${CSPICE_SOURCE})
else()
add_library(cspice SHARED ${CSPICE_SOURCE})
endif()
target_include_directories(cspice PUBLIC "${INCLUDE_PATH}")
if (WIN32)
target_compile_definitions(cspice PUBLIC "_COMPLEX_DEFINED;MSDOS;OMIT_BLANK_CC;NON_ANSI_STDIO")
set_target_properties(cspice PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
elseif (UNIX)
target_compile_definitions(cspice PUBLIC "NON_ANSI_STDIO")
target_compile_options(cspice PUBLIC -m64 -ansi -fPIC)
endif ()
if (NOT _SKIP_HEADERS)
file(GLOB SPICE_HEADERS ${INCLUDE_PATH}/*.h)
install(FILES ${SPICE_HEADERS} DESTINATION include/cspice)
endif()
set_target_properties(
cspice
PROPERTIES SOVERSION ${SOVERSION}
)
install(
TARGETS cspice
EXPORT cspice
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

3
ports/cspice/CONTROL Normal file
View File

@ -0,0 +1,3 @@
Source: cspice
Version: 66-1
Description: NASA C SPICE toolkit

16
ports/cspice/License.txt Normal file
View File

@ -0,0 +1,16 @@
This software and any related materials were created by the California
Institute of Technology (Caltech) under U.S. government contract with the
National Aeronautics and Space Administration (NASA). The software is
Technology and Software Publicly Available under U.S. export laws and is
provided "as-is" to the recipient without warranty of any kind, including any
warranties of performance or merchantability or fitness for particular use or
purpose (as set forth in United States UCC§2312-§2313) or for any purpose
whatsoever, for the software and related materials, however used. In no event
shall Caltech, its Jet Propulsion Laboratory, or NASA be liable for any damages
and/or costs, including, but not limited to, incidental or consequential
damages of any kind, including economic damage or injury to property and lost
profits, regardless of whether Caltech, JPL, or NASA be advised, have reason to
know, or, in fact, shall know of the possibility. Recipient bears all risk
relating to quality and performance of the software and any related materials,
and agrees to indemnify Caltech and NASA for all third-party claims resulting
from the actions of recipient in the use of the software.

19
ports/cspice/isatty.patch Normal file
View File

@ -0,0 +1,19 @@
--- a/cspice/src/cspice/fio.h 2019-11-01 20:51:53.198400000 +0300
+++ b/cspice/src/cspice/fio.h 2019-11-01 21:19:58.123200000 +0300
@@ -1,3 +1,6 @@
+#ifdef _WIN32
+#include <io.h> /* for isatty() */
+#endif
#include "stdio.h"
#include "errno.h"
#ifndef NULL
@@ -75,7 +76,9 @@
extern int (*f__donewrec)(void), t_putc(int), x_wSL(void);
extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*);
extern int c_sfe(cilist*), z_rnew(void);
+#ifndef _WIN32
extern int isatty(int);
+#endif
extern int err__fl(int,int,char*);
extern int xrd_SL(void);
extern int f__putbuf(int);

11
ports/cspice/mktemp.patch Normal file
View File

@ -0,0 +1,11 @@
--- a/cspice/src/cspice/open.c 2019-11-02 10:57:10.073886963 +0300
+++ b/cspice/src/cspice/open.c 2019-11-02 10:57:49.230398941 +0300
@@ -324,7 +324,7 @@
#ifdef NON_ANSI_STDIO
(void) strcpy(buf,"tmp.FXXXXXX");
- (void) mktemp(buf);
+ fclose(mktemp(buf));
goto replace;
#else

View File

@ -0,0 +1,60 @@
include(vcpkg_common_functions)
if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
message(FATAL_ERROR "${PORT} does not currently support UWP")
endif()
if (WIN32)
vcpkg_download_distfile(ARCHIVE
URLS "https://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Windows_VisualC_32bit/packages/cspice.zip"
FILENAME "cspice.zip"
SHA512 4f6129b26543729f4eb4f8240b43ca87530db9c6d9a5c0e3f43faf30561eaad95dcf507e3fecfd1c3d4388ccaa4e22a76df7bf7945b6ce9a68eb3b4893885992
)
elseif (APPLE)
vcpkg_download_distfile(ARCHIVE
URLS "https://naif.jpl.nasa.gov/pub/naif/toolkit//C/MacIntel_OSX_AppleC_32bit/packages/cspice.tar.Z"
FILENAME "cspice.tar.Z"
SHA512 bd5cc20206e48b3712c5077a2beb05c98cd58a25ce374ed363699a04998eb8ba93e42b5f7c2104c5296db95b3bccdc7cc9b6a2ba45875454d0c3914834aa4c42
)
else ()
vcpkg_download_distfile(ARCHIVE
URLS "https://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Linux_GCC_32bit/packages/cspice.tar.Z"
FILENAME "cspice.tar.Z"
SHA512 b387bc2cfca4deccc451d198af49564ea0b19cf665ba143d39196ed532639cbc11aad7e1d63f71f1bb88d72c0e6ac30757b6e1babca9e0ee3b92f9c205c1b908
)
endif()
set(PATCHES isatty.patch)
if (NOT WIN32)
set(PATCHES ${PATCHES} mktemp.patch)
endif()
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
NO_REMOVE_ONE_LEVEL
PATCHES ${PATCHES}
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
set(_STATIC_BUILD ON)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS -D_STATIC_BUILD=${_STATIC_BUILD}
OPTIONS_DEBUG -D_SKIP_HEADERS=ON
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
file(
INSTALL ${CMAKE_CURRENT_LIST_DIR}/License.txt
DESTINATION ${CURRENT_PACKAGES_DIR}/share/cspice
RENAME copyright
)