Commit 5048cf73 authored by Austin Sanders's avatar Austin Sanders Committed by amystamile-usgs
Browse files

First working swig wrappers

parent 52fe3b35
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ option(buildStaticCore "Build libisis static as well as dynamic" OFF )
option(buildTests      "Set up unit, application, and module tests."    ON  )
option(JP2KFLAG        "Whether or not to build using JPEG2000 support" OFF )
option(pybindings      "Turn on to build Python bindings"               ON )
option(buildSwig       "Turn on to build swig wrappers"                 OFF )
option(BUILD_CORE_TESTS "Turn on to build core tests"                   ON )

# if cmake install prefix is not set, and conda env is activated, use the
# conda env as the install directory.
@@ -123,6 +125,7 @@ message("\tBUILD STATIC CORE: ${buildStaticCore}")
message("\tBUILD TESTS: ${buildTests}")
message("\tBUILD CORE: ${buildCore}")
message("\tBUILD MISSIONS: ${buildMissions}")
message("\tBUILD CORE TESTS: ${BUILD_CORE_TESTS}")
message("\tJP2K SUPPORT: ${JP2KFLAG}")
message("\tPYTHON BINDINGS: ${pybindings}")
message("\tISISDATA: ${isisData}")
@@ -178,6 +181,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS_STR}" )
# Flag to fix numeric literals problem with boost on linux
# Add gold linker (and therefore, phtread) to speed up linux (spec. Ubuntu18.04) builds
if(NOT APPLE)
  message("$ENV{CONDA_PREFIX}")
  set(thirdPartyCppFlags ${thirdPartyCppFlags} -fuse-ld=gold
	                                             -pthread
					                                     -fext-numeric-literals
+15 −1
Original line number Diff line number Diff line
@@ -83,6 +83,16 @@ find_package(Geos REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(CSPICE    65      REQUIRED)

include_directories(SYSTEM
                    ${Qt5Widgets_INCLUDE_DIRS}
                    ${Qt5Concurrent_INCLUDE_DIRS}
                    ${Qt5Network_INCLUDE_DIRS}
                    ${Qt5Xml_INCLUDE_DIRS}
                    ${CSPICE_INCLUDE_DIR}
                    ${JSON_INCLUDE_DIR})
#include_directories(${CMAKE_BINARY_DIR}/inc)
#link_directories(${JSON_LIBRARY} ${CSPICE_LIBRARY} {Qt5_Library})

target_link_libraries(core PUBLIC Qt5::Core
                                  Qt5::Concurrent
                                  Qt5::Widgets
@@ -99,3 +109,7 @@ if (BUILD_CORE_TESTS)
  enable_testing()
  add_subdirectory(tests)
endif()

if(buildSwig)
  add_subdirectory(swig)
endif()
+6 −0
Original line number Diff line number Diff line
cmake_minimum_required(VERSION 3.10)

find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})

add_subdirectory(python)
+30 −0
Original line number Diff line number Diff line
%module isispvl
%include "pvlKeyword.i"

%include std_string.i
%include std_vector.i
%include exception.i

class QString
{
public:
    static QString fromStdString(const std::string &s);
    std::string toStdString() const;
    QString(const char* str);
    ~QString();

    int size() const;
    int count() const;
    int length() const;
    bool isEmpty() const;
};

%exception{
    try {
        $action
    } catch (std::exception const& e) {
        SWIG_exception(SWIG_RuntimeError, (std::string("std::exception: ") + e.what()).c_str());
    } catch (...) {
        SWIG_exception(SWIG_UnknownError, "Unknown error");
    }
}
+16 −0
Original line number Diff line number Diff line
%module(package="isispvl") PvlKeyword
%{
    #include "PvlKeyword.h"
%}


%include "PvlKeyword.h"

%extend Isis::PvlKeyword{
  PvlKeyword(const char* key, const char* val){
            QString qkey(key);
            QString qval(val);
            Isis::PvlKeyword *kw = new Isis::PvlKeyword(qkey, qval);
            return kw;
  }
}
Loading