mirror of
https://github.com/reactos/CMake.git
synced 2025-04-02 15:21:41 +00:00
FindOctave: Add target for octinterp
This change adds the Octave::Octinterp target to make the octinterp library available without users having to resort to using the Octave_INTERP_LIBRARY variable.
This commit is contained in:
parent
1e2e12889b
commit
6725975bd8
@ -15,7 +15,10 @@ This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
``Octave::Interpreter``
|
||||
Octave interpreter (the main program)
|
||||
``Octave::Octave``
|
||||
include directories and libraries
|
||||
include directories and the octave library
|
||||
``Octave::Octinterp``
|
||||
include directories and the octinterp library including the dependency on
|
||||
Octave::Octave
|
||||
|
||||
If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
|
||||
|
||||
@ -144,6 +147,15 @@ if(Octave_Development_FOUND)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Octave::Octinterp)
|
||||
add_library(Octave::Octinterp UNKNOWN IMPORTED)
|
||||
set_target_properties(Octave::Octinterp PROPERTIES
|
||||
IMPORTED_LOCATION ${Octave_INTERP_LIBRARY}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${Octave_INCLUDE_DIR})
|
||||
target_link_libraries(Octave::Octinterp INTERFACE
|
||||
Octave::Octave)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -10,6 +10,10 @@ add_executable(test_tgt main.cpp)
|
||||
target_link_libraries(test_tgt Octave::Octave)
|
||||
add_test(NAME test_tgt COMMAND test_tgt)
|
||||
|
||||
add_executable(test_octinterp_tgt interp_main.cpp)
|
||||
target_link_libraries(test_octinterp_tgt Octave::Octinterp)
|
||||
add_test(NAME test_octinterp_tgt COMMAND test_octinterp_tgt)
|
||||
|
||||
add_test(NAME test_tgt_exe
|
||||
COMMAND Octave::Interpreter -q --eval "runtests('.')"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
26
Tests/FindOctave/Test/interp_main.cpp
Normal file
26
Tests/FindOctave/Test/interp_main.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <iostream>
|
||||
#include <oct.h>
|
||||
#include <octave.h>
|
||||
#include <parse.h>
|
||||
#include <toplev.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
string_vector argv(2);
|
||||
argv(0) = "embedded";
|
||||
argv(1) = "-q";
|
||||
|
||||
try {
|
||||
octave_main(2, argv.c_str_vec(), 1);
|
||||
octave_value_list in;
|
||||
in(0) = 72.0;
|
||||
const octave_value_list result = feval("sqrt", in);
|
||||
std::cout << "result is " << result(0).scalar_value() << std::endl;
|
||||
clean_up_and_exit(0);
|
||||
} catch (const octave::exit_exception& ex) {
|
||||
std::cerr << "Octave interpreter exited with status = " << ex.exit_status()
|
||||
<< std::endl;
|
||||
} catch (const octave::execution_exception&) {
|
||||
std::cerr << "error encountered in Octave evaluator!" << std::endl;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user