Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build CTK with already installed VTK #911

Open
kerim371 opened this issue Apr 29, 2020 · 15 comments
Open

Build CTK with already installed VTK #911

kerim371 opened this issue Apr 29, 2020 · 15 comments
Assignees

Comments

@kerim371
Copy link
Contributor

kerim371 commented Apr 29, 2020

Hi,

I'm a little newbie in C++. My configuration: Qt 5.14.1 on WIndows 10, MSVC 2017 x64

As I understood from here and here CTK also provides widgets for VTK.

I already have installed VTK 9.0. What options should I use to build CTK widgets for VTK?
Should I check on CTK_LIB_Visualization/VTK/Core and CTK_LIB_Visualization/VTK/Widgets (and ... Widgets_USE_TRANSFER_FUNCTION_...) in CMake GUI ?

By the way if I use these options then CTK building results with errors, and without them everything is fine. Maybe I should set some variables pointing where my VTK lib is located?

@jcfr
Copy link
Member

jcfr commented Apr 29, 2020

Welcome @KerimMatlab

I understood from here and here CTK also provides widgets for VTK

That is correct

should I check on CTK_LIB_Visualization/VTK/Core and CTK_LIB_Visualization/VTK/Widgets

yes

To understand how to configure and use CTK, I suggest you look at the external project we have in Slicer:

https://github.com/Slicer/Slicer/blob/master/SuperBuild/External_CTK.cmake

You will for example discover there that you can simply build CTK passing VTK_DIR, and then CTK will use the you provide instead of building its own.

Let us know if you have other questions,

@jcfr jcfr self-assigned this Apr 29, 2020
@kerim371
Copy link
Contributor Author

Thank you for hint
Let's suppose that I have built VTK in C:\apps\VTK_BUILD and I installed it in C:\apps\VTK_INSTALL.
Then I need to specify VTK_DIR PATH variable. Which path should I assign in it C:\apps\VTK_BUILD or C:\apps\VTK_INSTALL?

I have already tried to set VTK_DIR to C:\apps\VTK_INSTALL but the compilation fails with error:
By not providing "FindVTK.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "VTK", but
CMake did not find one.

Could not find a package configuration file provided by "VTK" (requested
version 6.1) with any of the following names:

VTKConfig.cmake
vtk-config.cmake

@jcfr
Copy link
Member

jcfr commented Apr 29, 2020

Both should work but there are some caveats.

Generally speaking, you need to pass the directory that contain the <projectName>Config.cmake or <projectName>-config.cmake file.

To keep things simple, simply pass the build directory.

@kerim371
Copy link
Contributor Author

kerim371 commented Apr 29, 2020

Thank you for reply

I have vtk-config.cmake in C:\apps\MSVC_apps_release\VTK_900_MPI\lib\cmake\vtk-9.0
I just tried to set VTK_DIR to the folder which contains C:\apps\MSVC_apps_release\VTK_900_MPI\lib\cmake\vtk-9.0 but I get errors while building ALL_BUILD project:
image

By the way these error happen no matter wether I set VTK_DIR to C:\apps\VTK_BUILD or C:\apps\VTK_INSTALL.
Maybe I should somehow use relative path?

@kerim371
Copy link
Contributor Author

@jcfr Jean don't you know how to solve my issue?
I've already tried to set VTK_INCLUDE_DIRS and VTK_LIBRARY_DIRS but somehow the compilator still search include file in CTK build directory and not in the VTK_INCLUDE_DIRS

@jcfr
Copy link
Member

jcfr commented Apr 30, 2020

I suggest you create a file called build-vtk-and-ctk.bat containing all instructions you use to build VTK and CTK. Then you would share the content of the file here, without this it is very hard to know what is wrong.

@jcfr
Copy link
Member

jcfr commented Apr 30, 2020

@kerim371
Copy link
Contributor Author

@jcfr does CMakeCache files from VTK and CTK configuration is able to replace build-vtk-and-ctk.bat? I use Cmake GUI
CMakeCache_VTK.txt
CMakeCache_CTK.txt

@kerim371
Copy link
Contributor Author

kerim371 commented Apr 30, 2020

@jcfr according to the link you give me, should I change CMakeLists.txt located in downloaded CTK directory or I should set some variables in CMake GUI?
I set VTK_DIR to the correct folder that contains vtk-config.cmake via CMake GUI

@jcfr
Copy link
Member

jcfr commented Apr 30, 2020

Without a script allowing to reproduce the problem (including checkout of sources), i will be able to help further.

Since so may different things can be wrong, I suggest you create such script. 🙏

@kerim371
Copy link
Contributor Author

Wish I knew how to use CMake via command line :)
I think I'm going to do that but few hours I need I think

@kerim371
Copy link
Contributor Author

@jcfr I did it for CTK. Please look at the attached file.
It is really difficult to reproduce the CMake commands that I used when I was building VTK.
CTK_CMake_command.txt

@jcfr
Copy link
Member

jcfr commented May 5, 2020

Thanks. I am copying the original content of the text file below by including ^ allowing to split command over multiple lines on windows (see here):

C:\Qt\Tools\CMake_64\bin\cmake ^
  F:\Qt\Downloaded\CTK-master ^
  -DCMAKE_CONFIGURATION_TYPES:STRING=Release ^
  -DCMAKE_INSTALL_PREFIX:PATH=C:/apps/CTK ^
  -DCTK_QT_VERSION:STRING=5  ^
  -DQT_QMAKE_EXECUTABLE:FILEPATH=C:/Qt/5.14.1/msvc2017_64/bin/qmake.exe  ^
  -DQt5_DIR:PATH=C:/Qt/5.14.1/msvc2017_64/lib/cmake/Qt5 ^
  -DCTK_ENABLE_PluginFramework:BOOL=ON ^
  -DCTK_ENABLE_Widgets:BOOL=ON ^
  -DCTK_LIB_PluginFramework:BOOL=ON ^
  -DCTK_LIB_Widgets:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Core:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Widgets:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Widgets_USE_TRANSFER_FUNCTION_CHARTS:BOOL=ON ^
  -DVTK_DIR:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/lib/cmake/vtk-9.0 ^
  -DVTK_INCLUDE_DIRS:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/include/vtk-9.0 ^
  -DVTK_LIBRARY_DIRS:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/lib 

@jcfr
Copy link
Member

jcfr commented May 5, 2020

Remarks:

  • You should not pass QT_QMAKE_EXECUTABLE when using Qt 5, passing Qt5_DIR is sufficient.
  • Passing CMAKE_CONFIGURATION_TYPES is not needed as you can select the configuration when building
  • To be consistent with the CMake documentation, pass the source dir at the end of the command line.

I suggest you try the following command and report back the errors. Make sure to re-run the command from an empty build directory.

To configure:

C:\Qt\Tools\CMake_64\bin\cmake ^
  -DCMAKE_INSTALL_PREFIX:PATH=C:/apps/CTK ^
  -DCTK_QT_VERSION:STRING=5  ^
  -DQt5_DIR:PATH=C:/Qt/5.14.1/msvc2017_64/lib/cmake/Qt5 ^
  -DCTK_ENABLE_PluginFramework:BOOL=ON ^
  -DCTK_ENABLE_Widgets:BOOL=ON ^
  -DCTK_LIB_PluginFramework:BOOL=ON ^
  -DCTK_LIB_Widgets:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Core:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Widgets:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Widgets_USE_TRANSFER_FUNCTION_CHARTS:BOOL=ON ^
  -DVTK_DIR:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/lib/cmake/vtk-9.0 ^
  -DVTK_INCLUDE_DIRS:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/include/vtk-9.0 ^
  -DVTK_LIBRARY_DIRS:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/lib 
  F:\Qt\Downloaded\CTK-master

Then, to build:

C:\Qt\Tools\CMake_64\bin\cmake --build . --config Release -- /maxcpucount:4

@kerim371
Copy link
Contributor Author

kerim371 commented May 5, 2020

@jcfr thank you for help
Here is the command I used to configure with CMake (I added -G "Visual Studio 15 2017" -A "x64", I use this configuration for all my libraries including VTK):

C:\Qt\Tools\CMake_64\bin\cmake ^
  -DCMAKE_INSTALL_PREFIX:PATH=C:/apps/CTK ^
  -DCTK_QT_VERSION:STRING=5  ^
  -DQt5_DIR:PATH=C:/Qt/5.14.1/msvc2017_64/lib/cmake/Qt5 ^
  -DCTK_ENABLE_PluginFramework:BOOL=ON ^
  -DCTK_ENABLE_Widgets:BOOL=ON ^
  -DCTK_LIB_PluginFramework:BOOL=ON ^
  -DCTK_LIB_Widgets:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Core:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Widgets:BOOL=ON ^
  -DCTK_LIB_Visualization/VTK/Widgets_USE_TRANSFER_FUNCTION_CHARTS:BOOL=ON ^
  -DVTK_DIR:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/lib/cmake/vtk-9.0 ^
  -DVTK_INCLUDE_DIRS:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/include/vtk-9.0 ^
  -DVTK_LIBRARY_DIRS:PATH=C:/apps/MSVC_apps_release/VTK_900_MPI/lib ^
  -G "Visual Studio 15 2017" -A "x64" ^
  F:\Qt\Downloaded\CTK-master

I did what you said but I got the same errors. I attach the output from build command C:\Qt\Tools\CMake_64\bin\cmake --build . --config Release -- /maxcpucount:4
build_CTK_output.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants