diff --git a/.github/workflows/prebuild.sh b/.github/workflows/prebuild.sh index 5269afc..9223a98 100644 --- a/.github/workflows/prebuild.sh +++ b/.github/workflows/prebuild.sh @@ -87,6 +87,7 @@ cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=./install \ -DGREEDY_BUILD_LMSHOOT=ON \ + -DGREEDY_BUILD_WRAPPING=ON \ -DCMAKE_PREFIX_PATH="$PWD/install" \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DVTK_DIR=$PWD/install/vtk/vtk-9.3.1.data/headers/cmake \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 28970ac..7b92feb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,12 +113,6 @@ IF(GREEDY_BUILD_LMSHOOT) ENDIF() ENDIF() -# Stuff for python wrapping -IF(GREEDY_BUILD_WRAPPING) - ADD_SUBDIRECTORY(src/wrapping) - SET(GREEDY_BUILD_LDDMM ON CACHE BOOL "" FORCE) -ENDIF() - #-------------------------------------------------------------------------------- # Hard-coded documentation #-------------------------------------------------------------------------------- @@ -468,3 +462,17 @@ IF(NOT GREEDY_BUILD_AS_SUBPROJECT) ENDIF() ENDIF(NOT GREEDY_BUILD_AS_SUBPROJECT) + +# Stuff for python wrapping +OPTION(GREEDY_BUILD_WRAPPING "Build greedy python wrapping" ON) +IF(GREEDY_BUILD_WRAPPING) + message("Configurating Greedy Python wrapping...") + SET(GREEDY_BUILD_LDDMM ON CACHE BOOL "" FORCE) + SET(PYBIND11_FINDPYTHON ON) + ADD_SUBDIRECTORY(src/wrapping/external/pybind11) + INCLUDE_DIRECTORIES(src/wrapping/external/pybind11) + pybind11_add_module(picsl_greedy src/wrapping/GreedyPythonBindings.cxx) + TARGET_INCLUDE_DIRECTORIES(picsl_greedy PRIVATE ${Greedy_INCLUDE_DIRS} src/multichunk src/lmshoot/) + TARGET_LINK_LIBRARIES(picsl_greedy PUBLIC ${ITK_LIBRARIES} ${VTK_LIBRARIES} greedyapi lmshootapi multichunkgreedyapi) + install(TARGETS picsl_greedy DESTINATION .) +ENDIF() diff --git a/src/wrapping/CMakeLists.txt b/src/wrapping/CMakeLists.txt deleted file mode 100644 index edcca3e..0000000 --- a/src/wrapping/CMakeLists.txt +++ /dev/null @@ -1,94 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.15) -PROJECT(PICSL_Greedy) - -# Enable languages -ENABLE_LANGUAGE(CXX) - -# Specify the C++ standard -SET(CMAKE_CXX_STANDARD 17) -SET(CMAKE_CXX_STANDARD_REQUIRED ON) - -# Avoid -fPIC errors -SET(CMAKE_POSITION_INDEPENDENT_CODE ON) - -# Option, whether to fetch external dependencies or to find locally -set(FETCH_DEPENDENCIES OFF CACHE BOOL "Fetch dependencies (ITK, VTK and Greedy)?") -set(DEPENDENCIES_ONLY OFF CACHE BOOL "Only build dependencies, skip main build") - -# If requested, fetch the dependencies -IF(FETCH_DEPENDENCIES) - - # Dependency: ITK - include(FetchContent) - set(Module_MorphologicalContourInterpolation ON CACHE BOOL "" FORCE) - set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) - set(BUILD_TESTING OFF CACHE BOOL "" FORCE) - FetchContent_Declare( - ITK - GIT_REPOSITORY https://github.com/InsightSoftwareConsortium/ITK.git - GIT_TAG v5.4.0 - ) - FetchContent_MakeAvailable(ITK) - SET(ITK_DIR ${itk_BINARY_DIR}) - FIND_PACKAGE(ITK CONFIG REQUIRED) - INCLUDE(${ITK_USE_FILE}) - - # ITK seems to mess things up by setting these variables - UNSET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY) - UNSET(CMAKE_RUNTIME_OUTPUT_DIRECTORY) - UNSET(CMAKE_LIBRARY_OUTPUT_DIRECTORY) - - # Dependency: VTK - set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) - set(BUILD_TESTING OFF CACHE BOOL "" FORCE) - set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) - set(VTK_REQUIRED_OBJCXX_FLAGS "" CACHE STRING "" FORCE) - set(VTK_MODULE_ENABLE_VTK_IOHDF5 OFF CACHE BOOL "" FORCE) - FetchContent_Declare( - VTK - GIT_REPOSITORY https://github.com/Kitware/VTK.git - GIT_TAG v9.3.1 - ) - FetchContent_MakeAvailable(VTK) - SET(VTK_DIR ${vtk_BINARY_DIR}) - FIND_PACKAGE(VTK REQUIRED COMPONENTS CommonCore IOCore IOLegacy IOPLY IOGeometry FiltersModeling) - - # Dependency: Greedy - SET(GREEDY_BUILD_LDDMM ON CACHE BOOL "" FORCE) - FetchContent_Declare( - Greedy - GIT_REPOSITORY https://github.com/pyushkevich/greedy.git - GIT_TAG master - ) - FetchContent_MakeAvailable(Greedy) - # INCLUDE_DIRECTORIES(${greedy_SOURCE_DIR}/src) - INCLUDE_DIRECTORIES(..) - -ELSE() - - # Find ITK and C3D - MESSAGE(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") - FIND_PACKAGE(ITK REQUIRED) - INCLUDE(${ITK_USE_FILE}) - - FIND_PACKAGE(VTK REQUIRED COMPONENTS CommonCore IOCore IOLegacy IOPLY IOGeometry FiltersModeling) - - FIND_PACKAGE(Greedy REQUIRED) - -ENDIF() - -# Set up VTK -vtk_module_autoinit( - TARGETS greedyapi lmshootapi - MODULES ${VTK_LIBRARIES}) - -# Python bindings -IF(NOT DEPENDENCIES_ONLY) - SET(PYBIND11_FINDPYTHON ON) - ADD_SUBDIRECTORY(external/pybind11) - INCLUDE_DIRECTORIES(external/pybind11) - pybind11_add_module(picsl_greedy GreedyPythonBindings.cxx) - TARGET_INCLUDE_DIRECTORIES(picsl_greedy PRIVATE ${Greedy_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(picsl_greedy PUBLIC ${ITK_LIBRARIES} ${VTK_LIBRARIES} greedyapi lmshootapi multichunkgreedyapi) - install(TARGETS picsl_greedy DESTINATION .) -ENDIF()