Skip to content
This repository was archived by the owner on Jun 6, 2026. It is now read-only.

COMP: CMake, add INCLUDE_DIRS for swig to work#5

Merged
phcerdan merged 2 commits into
InsightSoftwareConsortium:masterfrom
phcerdan:fix_cmake_for_swig
Apr 1, 2019
Merged

COMP: CMake, add INCLUDE_DIRS for swig to work#5
phcerdan merged 2 commits into
InsightSoftwareConsortium:masterfrom
phcerdan:fix_cmake_for_swig

Conversation

@phcerdan

@phcerdan phcerdan commented Mar 27, 2019

Copy link
Copy Markdown
Collaborator

WIP: Fix TotalVariation_INCLUDE_DIRS

Add itk-module-init.cmake
WIP: Remove debug CMake messages

SWIG is not reading the TotalVariationTargets.cmake file, where proxTV
library is set, with include dirs, interface libraries and compile
definitions.
This creates erorrs, the first sign is missing the INCLUDE_DIRSs.
(TVopt.h not found).
This can be solved hacking the INCLUDE_DIRS of the ITK Module TotalVariation_INCLUDE_DIRS.

Once that's fixed, the next error is missing mex.h file, this is because
the compile definition NO_MATLAB is not applied.

In Eigen3 I faced the same problems, but because it is header only,
fixing INCLUDE_DIRS and adding the compile definitions in the
Eigen3-ITK Header (itkEigen3.h) was enough.

In this case, the compile definitions of proxTV (NO_MATLAB, USE_LAPACK=0)
are ignored.

Also re-arranges to avoid duplication
@phcerdan phcerdan force-pushed the fix_cmake_for_swig branch from 7e8a942 to 9a4a689 Compare March 27, 2019 22:06
Add itk-module-init.cmake
WIP: Remove debug CMake messages

SWIG is not reading the TotalVariationTargets.cmake file, where proxTV
library is set, with include dirs, interface libraries and compile
definitions.
This creates erorrs, the first sign is missing the INCLUDE_DIRSs.
(TVopt.h not found).
This can be solved hacking the INCLUDE_DIRS of the ITK Module TotalVariation_INCLUDE_DIRS.

Once that's fixed, the next error is missing mex.h file, this is because
the compile definition NO_MATLAB is not applied.

In Eigen3 I faced the same problems, but because it is header only,
fixing INCLUDE_DIRS and adding the compile definitions in the
Eigen3-ITK Header (itkEigen3.h) was enough.

In this case, the compile definitions of proxTV (NO_MATLAB, USE_LAPACK=0)
are ignored.
@phcerdan phcerdan requested a review from thewtex March 29, 2019 14:37
@phcerdan

Copy link
Copy Markdown
Collaborator Author

Related: InsightSoftwareConsortium/ITK#650

@phcerdan

Copy link
Copy Markdown
Collaborator Author

Example error:

[1/8] Generating ../../../../../../ITK-cp37-cp37m-manylinux1_x64/Wrapping/itkProxTVImageFilter.xml
FAILED: ../../../ITK-cp37-cp37m-manylinux1_x64/Wrapping/itkProxTVImageFilter.xml
cd /work/_skbuild/linux-x86_64-3.7/cmake-build/Wrapping/Modules/TotalVariation && /work/_skbuild/linux-x86_64-3.7/cmake-build/Wrapping/Generators/CastXML/castxml/bin/castxml -o /work/ITK-cp37-cp37m-manylinux1_x64/Wrapping/itkProxTVImageFilter.xml --castxml-gccxml --target=x86_64-linux-gnu --castxml-start _wrapping_ --castxml-cc-gnu "(" /opt/rh/devtoolset-2/root/usr/bin/g++ -Wno-array-bounds -w -Wno-array-bounds -std=c++11 ")" -w -c @/work/ITK-cp37-cp37m-manylinux1_x64/Wrapping/TotalVariation.castxml.inc /work/ITK-cp37-cp37m-manylinux1_x64/Wrapping/itkProxTVImageFilter.cxx
In file included from /work/ITK-cp37-cp37m-manylinux1_x64/Wrapping/itkProxTVImageFilter.cxx:16:
In file included from /work/include/itkProxTVImageFilter.h:22:
In file included from /work/_skbuild/linux-x86_64-3.7/cmake-build/_deps/proxtv_fetch-build/src/include/TVopt.h:15:
In file included from /work/_skbuild/linux-x86_64-3.7/cmake-build/_deps/proxtv_fetch-build/src/include/general.h:22:
/work/_skbuild/linux-x86_64-3.7/cmake-build/_deps/proxtv_fetch-build/src/include/lapackFunctionsWrap.h:16:10: fatal error: 'mex.h' file not found
#include "mex.h"

@thewtex thewtex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@phcerdan

phcerdan commented Apr 1, 2019

Copy link
Copy Markdown
Collaborator Author

Merging but the problem where castxml does not read the ModuleTargets.cmake is still there.

@phcerdan phcerdan merged commit 3a1f99e into InsightSoftwareConsortium:master Apr 1, 2019
@thewtex

thewtex commented Apr 2, 2019

Copy link
Copy Markdown
Member

I will take a look... 👀

@bpaniagua

Copy link
Copy Markdown

Hi @phcerdan @thewtex

I am trying to compile this external package and I am experiencing this error:

In file included from /work/Dev/ITK/ITK-build/_deps/proxtv_fetch-build/src/include/general.h:22: /work/Dev/ITK/ITK-build/_deps/proxtv_fetch-build/src/include/lapackFunctionsWrap.h:16:10: fatal error: 'mex.h' file not found #include "mex.h" ^~~~~~~ 1 error generated. make[2]: *** [Wrapping/itkProxTVImageFilter.xml] Error 1 make[1]: *** [Wrapping/Modules/TotalVariation/CMakeFiles/TotalVariationCastXML.dir/all] Error 2 make: *** [all] Error 2

I see that the most recent commit of the TV sources that get pulled at /path-to-ITKbuild/_deps/proxtv_fetch-src is from April 11th

commit 187f868861f53b74fd00eeb40eb7ba83c2b7809d (HEAD -> use_eigen, origin/use_eigen)
Author: Pablo Hernandez-Cerdan pablo.hernandez.cerdan@outlook.com
Date: Thu Apr 11 14:59:10 2019 -0400

COMP: Remove ifdef DEBUG for pragma omp

When I look for these changes by typing git log --all --grep='swig to work' I dont have any commits coming up.

Has this commit been fully integrated into ITK?

Thank you! 🙏 ☺️

@phcerdan

phcerdan commented Jul 9, 2019

Copy link
Copy Markdown
Collaborator Author

Hi @bpaniagua,
What version of ITK are you using? Does it have this PR Add COMPILE_DEFINITIONS to castxml?

@bpaniagua

Copy link
Copy Markdown

Yes, it looks like ITK does (If i grep the log in my ITKsources - not the tv sources - I can see that commit)
Maybe I am not doing things right?

@bpaniagua

Copy link
Copy Markdown

ITK version:
commit e7e78524e4ef9e86d828c7a053fdecdd3b603d33 (HEAD -> master, origin/python-builds, origin/nightly-master, origin/master, origin/HEAD)
Merge: c8fde5fe20 0c7d03f86a
Author: Dženan Zukić dzenan.zukic@kitware.com
Date: Mon Jun 24 09:32:41 2019 -0400

Merge branch 'release'

@phcerdan

phcerdan commented Jul 9, 2019

Copy link
Copy Markdown
Collaborator Author

yeah, I can reproduce it, it seems that the compile definition is not added to castxml.
A hacky workaround to keep you going meanwhile:
In your ITK build folder, find the file: TotalVariation.castxml.inc
and append a new line with -DNOMATLAB

image

The compile definition is added here: https://github.com/InsightSoftwareConsortium/ITKTotalVariation/blob/master/CMakeLists.txt#L26 . But castxml is ignoring it, even though compile definitions are added there.

I will have a look.

@bpaniagua

Copy link
Copy Markdown

The hacky solution works, @phcerdan Thank you so so much!
Please, let me know if can I help to integrate a patch into ITK.

phcerdan added a commit to phcerdan/ITK that referenced this pull request Jul 9, 2019
itk_wrap_module_castxml now gets the COMPILE_DEFINITIONS of the
module top directory, instead of the wrapping directory.

The old behavior wasn't respecting the add_compile_definitions
set in the CMakeLists of the module.

Triggered by:
InsightSoftwareConsortium/ITKTotalVariation#5

This is a follow on from: e3a908b
@phcerdan

phcerdan commented Jul 9, 2019

Copy link
Copy Markdown
Collaborator Author

@bpaniagua I created a PR in ITK to fix this 1079, not sure why the add_compile_definitions set in the top CMakeLists.txt of the modules are not propagated to the wrapping subdirectory.

That PR just gets the COMPILE_DEFINITIONS of the parent module directory (instead of the wrapping folder).

It would be great if you are able to give it a test!

@phcerdan phcerdan deleted the fix_cmake_for_swig branch July 9, 2019 12:45
phcerdan added a commit to phcerdan/ITK that referenced this pull request Jul 15, 2019
itk_wrap_module_castxml now gets the COMPILE_DEFINITIONS of the
module top directory, instead of the wrapping directory.

The old behavior wasn't respecting the add_compile_definitions
set in the CMakeLists of the module.

Triggered by:
InsightSoftwareConsortium/ITKTotalVariation#5

This is a follow on from: e3a908b
thewtex pushed a commit to InsightSoftwareConsortium/ITK that referenced this pull request Jul 17, 2019
itk_wrap_module_castxml now gets the COMPILE_DEFINITIONS of the
module top directory, instead of the wrapping directory.

The old behavior wasn't respecting the add_compile_definitions
set in the CMakeLists of the module.

Triggered by:
InsightSoftwareConsortium/ITKTotalVariation#5

This is a follow on from: e3a908b
mseng10 pushed a commit to mseng10/ITK that referenced this pull request Jul 24, 2019
itk_wrap_module_castxml now gets the COMPILE_DEFINITIONS of the
module top directory, instead of the wrapping directory.

The old behavior wasn't respecting the add_compile_definitions
set in the CMakeLists of the module.

Triggered by:
InsightSoftwareConsortium/ITKTotalVariation#5

This is a follow on from: e3a908b
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
itk_wrap_module_castxml now gets the COMPILE_DEFINITIONS of the
module top directory, instead of the wrapping directory.

The old behavior wasn't respecting the add_compile_definitions
set in the CMakeLists of the module.

Triggered by:
InsightSoftwareConsortium/ITKTotalVariation#5

This is a follow on from: 8c922bb
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
itk_wrap_module_castxml now gets the COMPILE_DEFINITIONS of the
module top directory, instead of the wrapping directory.

The old behavior wasn't respecting the add_compile_definitions
set in the CMakeLists of the module.

Triggered by:
InsightSoftwareConsortium/ITKTotalVariation#5

This is a follow on from: 8c922bb
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 12, 2026
itk_wrap_module_castxml now gets the COMPILE_DEFINITIONS of the
module top directory, instead of the wrapping directory.

The old behavior wasn't respecting the add_compile_definitions
set in the CMakeLists of the module.

Triggered by:
InsightSoftwareConsortium/ITKTotalVariation#5

This is a follow on from: 5d2f0ed
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 12, 2026
itk_wrap_module_castxml now gets the COMPILE_DEFINITIONS of the
module top directory, instead of the wrapping directory.

The old behavior wasn't respecting the add_compile_definitions
set in the CMakeLists of the module.

Triggered by:
InsightSoftwareConsortium/ITKTotalVariation#5

This is a follow on from: 5d2f0ed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants