File size: 3,155 Bytes
68ce2fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#
# (C) Copyright 2005-2012 Johns Hopkins University (JHU), All Rights Reserved.
#
# --- begin cisst license - do not edit ---
#
# This software is provided "as is" under an open source license, with
# no warranty.  The complete license can be found in license.txt and
# http://www.cisst.org/cisst/license.txt.
#
# --- end cisst license ---

project (pythonEmbeddedIRE)

set (REQUIRED_CISST_LIBRARIES cisstCommon cisstVector cisstOSAbstraction cisstMultiTask cisstInteractive)
find_package (cisst COMPONENTS ${REQUIRED_CISST_LIBRARIES} QUIET)

if (cisst_FOUND AND CISST_HAS_SWIG_PYTHON)

  # Create SineGenerator as a shared library
  add_library (SineGenerator SHARED SineGenerator.cpp SineGenerator.h)
  set_property (TARGET SineGenerator PROPERTY FOLDER "cisstInteractive/examples")
  target_link_libraries (SineGenerator ${REQUIRED_CISST_LIBRARIES})

  # If OS Abstraction is compiled, offer a choice
  # if (CISST_cisstOSAbstraction)
  #  option (EXAMPLE_IRE_USE_OSATHREAD "Use osaThread in pythonEmbeddedIRE example." OFF)
  #  mark_as_advanced (EXAMPLE_IRE_USE_OSATHREAD)
  #endif (CISST_cisstOSAbstraction)

  # Allow generated c++ code to find header files
  include_directories (${CMAKE_CURRENT_SOURCE_DIR})

  # To link with build libraries
  link_directories (${CMAKE_CURRENT_BINARY_DIR})

  # Run SWIG on the interface file
  cisst_add_swig_module (MODULE SineGenerator
                         INTERFACE_FILENAME SineGeneratorPython.i
                         FOLDER "cisstMultiTask/examples"
                         MODULE_LINK_LIBRARIES SineGenerator)

  add_executable (pythonEmbeddedIRE pythonEmbeddedIRE.cpp)
  set_property (TARGET pythonEmbeddedIRE PROPERTY FOLDER "cisstInteractive/examples")
  target_include_directories (pythonEmbeddedIRE PRIVATE ${PYTHON_ALL_INCLUDE_DIRS})

  # if (EXAMPLE_IRE_USE_OSATHREAD)
  add_definitions (-DCISST_OSATHREAD)
  target_link_libraries (pythonEmbeddedIRE
    cisstCommon
    cisstInteractive
    cisstOSAbstraction
    SineGenerator
    ${CMAKE_THREAD_LIBS_INIT}
    ${PYTHON_ALL_LIBRARIES}
    util)
  #else (EXAMPLE_IRE_USE_OSATHREAD)
  #target_link_libraries (pythonEmbeddedIRE cisstCommon cisstInteractive)
  #endif (EXAMPLE_IRE_USE_OSATHREAD)

  if (UNIX)
    if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    endif (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  endif (UNIX)

  # Add custom dependencies on dynamically loaded modules
  add_dependencies (pythonEmbeddedIRE
                    cisstCommonPython
                    SineGeneratorPython)

  # Copy the Python example to the binary tree
  add_custom_command (TARGET pythonEmbeddedIRE
                      POST_BUILD
                      COMMAND ${CMAKE_COMMAND}
                      ARGS -E copy
                           ${CMAKE_CURRENT_SOURCE_DIR}/pythonEmbeddedIRE.py
                           ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/pythonEmbeddedIRE.py
                      COMMENT "Copy of pythonEmbeddedIRE.py to the library directory")

else ()
  message ("Information: code in ${CMAKE_CURRENT_SOURCE_DIR} will not be compiled, it requires ${REQUIRED_CISST_LIBRARIES} and cisst Python/SWIG support")
endif ()