Commit 6534d65c authored by Guillaume Pasero's avatar Guillaume Pasero

ENH: split wrappers into sub-folders

parent 01a69280
......@@ -18,124 +18,28 @@
# limitations under the License.
#
if ( OTB_WRAP_PYTHON OR OTB_WRAP_JAVA )
if ( OTB_WRAP_PYTHON OR OTB_WRAP_JAVA OR OTB_WRAP_PYTHON3)
include ( UseSWIGLocal )
set_source_files_properties ( otbApplication.i PROPERTIES CPLUSPLUS ON )
list(APPEND SWIG_EXTRA_DEPS
otbWrapperSWIGIncludes.h
itkBase.includes
${CMAKE_CURRENT_SOURCE_DIR}/itkBase.i
${CMAKE_CURRENT_SOURCE_DIR}/itkMacro.i
)
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} )
endif()
#
# Python SWIG configuration
#
if ( OTB_WRAP_PYTHON )
include_directories ( ${PYTHON_INCLUDE_DIR} )
# Run swig
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_GLOBAL_FLAGS})
if(NUMPY_FOUND)
include_directories(${NUMPY_INCLUDE_DIRS})
list(APPEND CMAKE_SWIG_FLAGS "-DOTB_SWIGNUMPY=1")
endif()
set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR})
set(SWIG_MODULE_otbApplication_EXTRA_DEPS
${CMAKE_CURRENT_SOURCE_DIR}/Python.i
${CMAKE_CURRENT_SOURCE_DIR}/PyCommand.i
itkPyCommand.h
OTBApplicationEngine)
SWIG_add_module( otbApplication python otbApplication.i otbApplicationPYTHON_wrap.cxx itkPyCommand.cxx )
SWIG_link_libraries( otbApplication ${PYTHON_LIBRARIES} OTBApplicationEngine )
set_target_properties(_otbApplication PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR})
if(MSVC)
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "/wd4005" )
else()
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "-w" )
endif()
# byte-compile the resulting python file
add_custom_command(
TARGET _otbApplication
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Byte-compiling otbApplication.py"
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_SOURCE_DIR}/CMake/PythonCompile.py
${CMAKE_SWIG_OUTDIR}/otbApplication.py
DEPENDS _otbApplication
)
otb_module_target_label( _otbApplication )
install( TARGETS _otbApplication
DESTINATION ${OTB_INSTALL_PYTHON_DIR}
COMPONENT RuntimeLibraries )
install( FILES ${CMAKE_SWIG_OUTDIR}/otbApplication.py
${CMAKE_SWIG_OUTDIR}/otbApplication.pyc
DESTINATION ${OTB_INSTALL_PYTHON_DIR}
COMPONENT RuntimeLibraries )
add_subdirectory(python)
endif()
# Python 3 SWIG configuration
if ( OTB_WRAP_PYTHON3 )
add_subdirectory(python3)
endif()
#
# JAVA SWIG configuration
#
if ( OTB_WRAP_JAVA )
include_directories ( ${JAVA_INCLUDE_PATH} ${JNI_INCLUDE_DIRS} )
# Make sure the nested directory structure exists
set(JAVA_SOURCE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/org/otb/application)
set(JAVA_BINARY_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build)
file(MAKE_DIRECTORY ${JAVA_SOURCE_DIRECTORY})
file(MAKE_DIRECTORY ${JAVA_BINARY_DIRECTORY})
# Nicely write the bridge code in org/itk/simple
set(CMAKE_SWIG_OUTDIR ${JAVA_SOURCE_DIRECTORY})
set(CMAKE_SWIG_FLAGS -package "org.otb.application" ${CMAKE_SWIG_GLOBAL_FLAGS})
set(SWIG_MODULE_otbApplicationJava_EXTRA_DEPS
${CMAKE_CURRENT_SOURCE_DIR}/Java.i
OTBApplicationEngine)
SWIG_add_module ( otbApplicationJava java otbApplication.i otbApplicationJAVA_wrap.cxx)
SWIG_link_libraries(otbApplicationJava OTBApplicationEngine )
if(MSVC)
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationJAVA_wrap.cxx COMPILE_FLAGS "/wd4005" )
else()
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/otbApplicationJAVA_wrap.cxx COMPILE_FLAGS "-w")
endif()
# Add target for org.otb.Application.jar
add_custom_target(org_otb_Application_jar ALL DEPENDS org.otb.application.jar)
otb_module_target_label( org_otb_Application_jar )
# Add custom command and target to compile the generated files and put them in a jar file
# Make sure the commands depend on the output library from SWIG
add_custom_command(
OUTPUT org.otb.application.jar
COMMENT "Creating jar file..."
COMMAND ${Java_JAVAC_EXECUTABLE} -d ${JAVA_BINARY_DIRECTORY} ${JAVA_SOURCE_DIRECTORY}/*.java
COMMAND ${Java_JAR_EXECUTABLE} cf ${CMAKE_CURRENT_BINARY_DIR}/org.otb.application.jar -C ${JAVA_BINARY_DIRECTORY} org
DEPENDS ${SWIG_MODULE_otbApplication_REAL_NAME} otbApplicationJava OTBApplicationEngine
)
# Get the location of the extension directory
string(REGEX REPLACE "include" "jre/lib/ext" JAVA_EXTENSION_DIR ${JAVA_INCLUDE_PATH} )
# Add the install target
# -- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.otb.application.jar DESTINATION ${JAVA_EXTENSION_DIR})
# Prefer using OTB_INSTALL_JAVA_DIR which defaults to something that honors CMAKE_INSTALL_PREFIX
# Using the system-wide Java extension dir usually require admin privileges,
# and shall better be left to packagers.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.otb.application.jar
DESTINATION ${OTB_INSTALL_JAVA_DIR}
COMPONENT RuntimeLibraries )
add_subdirectory(java)
endif()
#
# Copyright (C) 2005-2017 CS Systemes d'Information (CS SI)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_directories ( ${JAVA_INCLUDE_PATH} ${JNI_INCLUDE_DIRS} )
set_source_files_properties ( ../otbApplication.i PROPERTIES CPLUSPLUS ON )
# Make sure the nested directory structure exists
set(JAVA_SOURCE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/org/otb/application)
set(JAVA_BINARY_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build)
file(MAKE_DIRECTORY ${JAVA_SOURCE_DIRECTORY})
file(MAKE_DIRECTORY ${JAVA_BINARY_DIRECTORY})
# Nicely write the bridge code in org/itk/simple
set(CMAKE_SWIG_OUTDIR ${JAVA_SOURCE_DIRECTORY})
set(CMAKE_SWIG_FLAGS -package "org.otb.application" ${CMAKE_SWIG_GLOBAL_FLAGS})
set(SWIG_MODULE_otbApplicationJava_EXTRA_DEPS
${CMAKE_CURRENT_SOURCE_DIR}/../Java.i
OTBApplicationEngine)
SWIG_add_module ( otbApplicationJava java ../otbApplication.i otbApplicationJAVA_wrap.cxx)
SWIG_link_libraries(otbApplicationJava OTBApplicationEngine )
if(MSVC)
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationJAVA_wrap.cxx COMPILE_FLAGS "/wd4005" )
else()
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/otbApplicationJAVA_wrap.cxx COMPILE_FLAGS "-w")
endif()
# Add target for org.otb.Application.jar
add_custom_target(org_otb_Application_jar ALL DEPENDS org.otb.application.jar)
otb_module_target_label( org_otb_Application_jar )
# Add custom command and target to compile the generated files and put them in a jar file
# Make sure the commands depend on the output library from SWIG
add_custom_command(
OUTPUT org.otb.application.jar
COMMENT "Creating jar file..."
COMMAND ${Java_JAVAC_EXECUTABLE} -d ${JAVA_BINARY_DIRECTORY} ${JAVA_SOURCE_DIRECTORY}/*.java
COMMAND ${Java_JAR_EXECUTABLE} cf ${CMAKE_CURRENT_BINARY_DIR}/org.otb.application.jar -C ${JAVA_BINARY_DIRECTORY} org
DEPENDS ${SWIG_MODULE_otbApplication_REAL_NAME} otbApplicationJava OTBApplicationEngine
)
# Get the location of the extension directory
string(REGEX REPLACE "include" "jre/lib/ext" JAVA_EXTENSION_DIR ${JAVA_INCLUDE_PATH} )
# Add the install target
# -- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.otb.application.jar DESTINATION ${JAVA_EXTENSION_DIR})
# Prefer using OTB_INSTALL_JAVA_DIR which defaults to something that honors CMAKE_INSTALL_PREFIX
# Using the system-wide Java extension dir usually require admin privileges,
# and shall better be left to packagers.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.otb.application.jar
DESTINATION ${OTB_INSTALL_JAVA_DIR}
COMPONENT RuntimeLibraries )
#
# Copyright (C) 2005-2017 CS Systemes d'Information (CS SI)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_directories ( ${PYTHON_INCLUDE_DIR} )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} )
set_source_files_properties ( ../otbApplication.i PROPERTIES CPLUSPLUS ON )
# Run swig
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_GLOBAL_FLAGS})
if(NUMPY_FOUND)
include_directories(${NUMPY_INCLUDE_DIRS})
list(APPEND CMAKE_SWIG_FLAGS "-DOTB_SWIGNUMPY=1")
endif()
set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR})
set(SWIG_MODULE_otbApplication_EXTRA_DEPS
${CMAKE_CURRENT_SOURCE_DIR}/../Python.i
${CMAKE_CURRENT_SOURCE_DIR}/../PyCommand.i
itkPyCommand.h
OTBApplicationEngine)
SWIG_add_module( otbApplication python ../otbApplication.i otbApplicationPYTHON_wrap.cxx itkPyCommand.cxx )
SWIG_link_libraries( otbApplication ${PYTHON_LIBRARIES} OTBApplicationEngine )
set_target_properties(_otbApplication PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR})
if(MSVC)
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "/wd4005" )
else()
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "-w" )
endif()
# byte-compile the resulting python file
add_custom_command(
TARGET _otbApplication
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Byte-compiling otbApplication.py"
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_SOURCE_DIR}/CMake/PythonCompile.py
${CMAKE_SWIG_OUTDIR}/otbApplication.py
DEPENDS _otbApplication
)
otb_module_target_label( _otbApplication )
install( TARGETS _otbApplication
DESTINATION ${OTB_INSTALL_PYTHON_DIR}
COMPONENT RuntimeLibraries )
install( FILES ${CMAKE_SWIG_OUTDIR}/otbApplication.py
DESTINATION ${OTB_INSTALL_PYTHON_DIR}
COMPONENT RuntimeLibraries )
if(PYTHON_VERSION_STRING VERSION_LESS "3.2.0")
install( FILES ${CMAKE_SWIG_OUTDIR}/otbApplication.pyc
DESTINATION ${OTB_INSTALL_PYTHON_DIR}
COMPONENT RuntimeLibraries )
else()
# TODO : pyc file is in a subfolder.
endif()
#
# Copyright (C) 2005-2017 CS Systemes d'Information (CS SI)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_directories ( ${PYTHON3_INCLUDE_DIR} )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/../python )
set_source_files_properties ( ../otbApplication.i PROPERTIES CPLUSPLUS ON )
# Run swig
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_GLOBAL_FLAGS})
if(NUMPY_PYTHON3_FOUND)
include_directories(${NUMPY_PYTHON3_INCLUDE_DIRS})
list(APPEND CMAKE_SWIG_FLAGS "-DOTB_SWIGNUMPY=1")
endif()
set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/${OTB_INSTALL_PYTHON3_DIR})
set(SWIG_MODULE_otbApplication_EXTRA_DEPS
${CMAKE_CURRENT_SOURCE_DIR}/../Python.i
${CMAKE_CURRENT_SOURCE_DIR}/../PyCommand.i
itkPyCommand.h
OTBApplicationEngine)
SWIG_add_module( otbApplicationPy3 python ../otbApplication.i otbApplicationPYTHON_wrap.cxx ../python/itkPyCommand.cxx )
SWIG_link_libraries( otbApplicationPy3 ${PYTHON3_LIBRARIES} OTBApplicationEngine )
set_target_properties(_otbApplicationPy3 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR})
set_target_properties(_otbApplicationPy3 PROPERTIES LIBRARY_OUTPUT_NAME _otbApplication)
if(MSVC)
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "/wd4005" )
else()
set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "-w" )
endif()
# byte-compile the resulting python file
add_custom_command(
TARGET _otbApplicationPy3
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Byte-compiling otbApplication.py"
COMMAND ${PYTHON3_EXECUTABLE}
${CMAKE_SOURCE_DIR}/CMake/PythonCompile.py
${CMAKE_SWIG_OUTDIR}/otbApplication.py
DEPENDS _otbApplicationPy3
)
otb_module_target_label( _otbApplicationPy3 )
install( TARGETS _otbApplicationPy3
DESTINATION ${OTB_INSTALL_PYTHON3_DIR}
COMPONENT RuntimeLibraries )
install( FILES ${CMAKE_SWIG_OUTDIR}/otbApplication.py
DESTINATION ${OTB_INSTALL_PYTHON3_DIR}
COMPONENT RuntimeLibraries )
if(PYTHON3_VERSION_STRING VERSION_LESS "3.2.0")
install( FILES ${CMAKE_SWIG_OUTDIR}/otbApplication.pyc
DESTINATION ${OTB_INSTALL_PYTHON3_DIR}
COMPONENT RuntimeLibraries )
else()
# TODO : pyc file is in a subfolder.
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment