Commit aa3af142 authored by jlaura's avatar jlaura Committed by Jesse Mapel
Browse files

Restructure and adds CMake (#49)

* Refactors out bad class attribute

* Adds dynamic versioning

* Reorganize to pull Python build/wrapper

* Add CMakeLists

* Updates with minimal build instructions

* Explicit use of C++11 standard

* Keeps the entire API (via headers) private

* removes __init__
parent e00d6aea
Loading
Loading
Loading
Loading

.travis.yml

deleted100644 → 0
+0 −76
Original line number Diff line number Diff line
language: generic

matrix:
  include:
    - os: linux
      env:
        - PYTHON_VERSION=3.5
    - os: linux
      env:
        - PYTHON_VERSION=3.6
    - os: osx
      osx_image: xcode9.1
      sudo: false
      compiler:
        - clang
      env:
        - PYTHON_VERSION=3.5
    - os: osx
      osx_image: xcode9.1
      sudo: false
      compiler:
        - clang
      env:
        - PYTHON_VERSION=3.6

branches:
  only:
    - master

before_install:
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
      wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
    else
      curl -o miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh;
    fi

  # More conda setup to get miniconda in and a virtual env. setup
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda update -q conda
  - conda info -a   # Useful for debugging any issues with conda
  
  # Create the env
  - conda create -q -n test python=$PYTHON_VERSION
  - source activate test
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
      conda install gxx_linux-64;
    else
      conda install clangxx_osx-64;
    fi
  # Neecssary to get the new compilers into the PATH
  - source deactivate
  - source activate test
  # Necessary to avoid hangs due to output length
  - python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)"

install:
  # Install dependencies
  # Install dependencies
  - conda config --add channels usgs-astrogeology
  - conda config --add channels conda-forge
  - conda install -c conda-forge numpy cython pytest pytest-cov coveralls
  - conda install -c usgs-astrogeology libcsm cycsm

script:
  - python setup.py install
  - pytest --cov=usgscam

after_success:
  - coveralls
  - source deactivate
  - conda install conda-build anaconda-client
  - conda config --set anaconda_upload yes
  - conda build -q --token $CONDA_UPLOAD_TOKEN --python $PYTHON_VERSION .
 No newline at end of file

CMakeLists.txt

0 → 100644
+32 −0
Original line number Diff line number Diff line
cmake_minimum_required(VERSION 3.10)
project(usgscsm VERSION 0.0.1 DESCRIPTION "usgscsm library")

set(CMAKE_CXX_STANDARD 11)

include(GNUInstallDirs)
add_library(usgscsm SHARED 
            src/UsgsAstroFramePlugin.cpp
            src/UsgsAstroFrameSensorModel.cpp
            src/UsgsAstroLsPlugin.cpp
            src/UsgsAstroLsSensorModel.cpp
            src/UsgsAstroLsStateData.cpp)

set_target_properties(usgscsm PROPERTIES
    VERSION ${PROJECT_VERSION}
    SOVERSION 1
)

find_library(CSM_LIBRARY csmapi REQUIRED)
find_path(CSM_INCLUDE_DIR NAMES csm)

target_include_directories(usgscsm PRIVATE
                           include/
                           include/usgscsm
                           ${CSM_INCLUDE_DIR}
)

target_link_libraries(usgscsm ${CSM_LIBRARY})

install(TARGETS usgscsm
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 No newline at end of file
+4 −22
Original line number Diff line number Diff line
# CSM-CameraModel

[![Build Status](https://travis-ci.org/USGS-Astrogeology/CSM-CameraModel.svg?branch=master)](https://travis-ci.org/USGS-Astrogeology/CSM-CameraModel)
To build:

This repository stores USGS CSM compliant camera models and the associated
plugins.  These camera models are compliant with the [Community Sensor
Model](https://github.com/sminster/csm) and can be utilized within any application supporting the CSM.

The CSM requires associated Image Support Data.  This data is primarily
provided by the NASA Navigation and Ancillary Information (NAIF) SPICE system.
We provide a seperate
[CSM-SpiceISD](https://github.com/USGS-Astrogeology/CSM-SpiceISD) library to interface with the NAIF Spice
functionality and provide a standard ISD file.  

## Installation

For Linux and MacOS we have prebuilt packages.  To install:

- `conda install -c usgs-astrogeology usgscam`

If you would like to use the conda environment feature:

- `conda create -n usgscam python=3`
- `source activate usgscam`
- `conda install -c usgs-astrogeology usgscam`
1. Ensure that the CSM is installed in a place that CMake searches (e.g., /usr or /usr/local).
2. `mkdir build` && `cd build`
3. `cmake .. && make`
 No newline at end of file

appveyor.yml

deleted100644 → 0
+0 −32
Original line number Diff line number Diff line
branches:
  only:
  - master

version: '0.1.0.{build}'

platform:
  - x64

configuration:
  - Release

install:
  - cmd: call C:\\Miniconda36-x64\Scripts\activate.bat
  - cmd: conda config --set always_yes yes --set changeps1 no
  - cmd: conda update -q conda
  - cmd: conda config --add channels usgs-astrogeology
  - cmd: conda config --add channels conda-forge
  - cmd: conda install -c conda-forge numpy cython pytest
  - cmd: conda install -c usgs-astrogeology libcsm cycsm
  - cmd: conda install conda-build anaconda-client pytest-cov

build_script:
  - cmd: conda build .
  - cmd: conda install --use-local usgscam

test_script:
  - cmd: pytest --cov=cycsm

on_success:
  - cmd: conda config --set anaconda_upload yes
  - cmd: conda build --token %CONDA_UPLOAD_TOKEN% .

include/orex/ORexPlugin.h

deleted100644 → 0
+0 −71
Original line number Diff line number Diff line
#ifndef ORexPlugin_h
#define ORexPlugin_h

#ifdef _WIN32
#  ifdef OREX_LIBRARY
#    define OREX_EXPORT_API __declspec(dllexport)
#  else
#    define OREX_EXPORT_API __declspec(dllimport)
# endif
#else
#  define OREX_EXPORT_API
#endif

#include <string>

#include <csm/Plugin.h>
#include <csm/Version.h>

namespace csm {
  class Isd;
  class Model;
  class Warning;
}

class OREX_EXPORT_API ORexPlugin : public csm::Plugin {

  public:
    ORexPlugin();
    ~ORexPlugin();

    virtual std::string getPluginName() const;
    virtual std::string getManufacturer() const;
    virtual std::string getReleaseDate() const;
    virtual csm::Version getCsmVersion() const;
    virtual size_t getNumModels() const;
    virtual std::string getModelName(size_t modelIndex) const;
    virtual std::string getModelFamily(size_t modelIndex) const;
    virtual csm::Version getModelVersion(const std::string &modelName) const;
    virtual bool canModelBeConstructedFromState(const std::string &modelName,
                                                const std::string &modelState,
                                                csm::WarningList *warnings = NULL) const;
    virtual bool canModelBeConstructedFromISD(const csm::Isd &imageSupportData,
                                              const std::string &modelName,
                                              csm::WarningList *warnings = NULL) const;
    virtual csm::Model *constructModelFromState(const std::string &modelState,
                                                csm::WarningList *warnings = NULL) const;
    virtual csm::Model *constructModelFromISD(const csm::Isd &imageSupportData,
                                              const std::string &modelName,
                                              csm::WarningList *warnings = NULL) const;
    virtual std::string getModelNameFromModelState(const std::string &modelState,
                                                   csm::WarningList *warnings = NULL) const;
    virtual bool canISDBeConvertedToModelState(const csm::Isd &imageSupportData,
                                               const std::string &modelName,
                                               csm::WarningList *warnings = NULL) const;
    virtual std::string convertISDToModelState(const csm::Isd &imageSupportData,
                                               const std::string &modelName,
                                               csm::WarningList *warnings = NULL) const;

  private:
    static const ORexPlugin m_registeredPlugin;

    static const std::string m_pluginName;
    static const std::string m_manufacturerName;
    static const std::string m_releaseDate;
    static const csm::Version m_csmVersion;
    static const int m_numModels;

    // TODO when implementing, add any other necessary members.
};

#endif
Loading