cgal
cgal copied to clipboard
missing boost include dir with cmake build on Windows
Issue Details
I am trying to build CGAL 5.6 (cloned from github) on Windows with cmake. The cmake log correctly reports:
[...]
Using header-only CGAL
Found Boost: E:/libs/boost_1_84_0/lib64-msvc-14.1/cmake/Boost-1.84.0/BoostConfig.cmake (found suitable version "1.84.0", minimum required is "1.66")
Boost include dirs: E:/libs/boost_1_84_0
[...]
When building from Visual Studio, I get tons of errors: E:\libs\CGAL\CGAL-5.6\include\CGAL\config.h(116,10): error C1083: Cannot open include file: 'boost/config.hpp': No such file or directory
of course, given that the boost include dir is not present:
CGAL does not need to be built, it is now a header-only library.
Which CMakeLists.txt file are you using to run CMake?
If you set BOOST_ROOT=E:/libs/boost_1_84_0
and BOOST_LIBRARYDIR=E:/libs/boost_1_84_0/lib64-msvc-14.1
as environment variables before running CMake, everything should be fine
CGAL does not need to be built, it is now a header-only library.
If that's not CGAL per se, but demos, tests etc it makes little difference for my evaluation purposes. Cmake produces a VS solution made of 104 C++ projects, and that's exactly what I'd like to build. Possibly, this should be as 'out-of-the-box' as possibile.
If you set BOOST_ROOT=E:/libs/boost_1_84_0 and BOOST_LIBRARYDIR=E:/libs/boost_1_84_0/lib64-msvc-14.1
Now I'm getting even more errors at configure time:
CMake Warning (dev) at cmake/modules/CGAL_SetupBoost.cmake:20 (find_package):
Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT
variables. Run "cmake --help-policy CMP0144" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
CMake variable BOOST_ROOT is set to:
E:/libs/boost_1_84_0
For compatibility, find_package is ignoring the variable, but code in a
.cmake module might still use it.
Call Stack (most recent call first):
cmake/modules/CGAL_SetupCGALDependencies.cmake:48 (include)
lib/cmake/CGAL/CGALConfig.cmake:168 (include)
BUILD/CGALConfig.cmake:5 (include)
examples/CMakeLists.txt:20 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
and nothing changed at build time.
With recent version of boost, it should be enough to set Boost_DIR to E:/libs/boost_1_84_0/lib64-msvc-14.1/cmake/Boost-1.84.0
. If it's not working directly, then either your boost is not correctly installed or there is an issue with boost 1.84 and CGAL on Windows. The lastest boost version tested in the testsuite on Windows is boost 1.82 (but I'd be surprised it's a version issue).
https://doc.cgal.org/latest/Manual/configurationvariables.html#title7
With recent version of boost, it should be enough to set Boost_DIR to E:/libs/boost_1_84_0/lib64-msvc-14.1/cmake/Boost-1.84.0.
Indeed, that's what I did; and it also seems that Cmake likes it.
Maybe this problem is not directly related to the Boost library. Actually, shouldn't the "Additional Include Directories" string be much longer than a mere "E:\libs\CGAL\CGAL-5.6\BUILD\include"? I mean, where the gmp, mpfi, mpfr etc include directories are supposed to be specified?
Call Stack (most recent call first): cmake/modules/CGAL_SetupCGALDependencies.cmake:48 (include) lib/cmake/CGAL/CGALConfig.cmake:168 (include) BUILD/CGALConfig.cmake:5 (include) examples/CMakeLists.txt:20 (find_package)
Hi Marco, I see that you are using examples/
as the CMake sources directory, that is probably E:/libs/CGAL/CGAL-5.6/examples
. And from your screenshot in the first message, your CMake build directory is almost certainly E:/libs/CGAL/CGAL-5.6/BUILD
What is the value of CGAL_DIR
, in E:/libs/CGAL/CGAL-5.6/BUILD/CMakeCache.txt
?
Hello Laurent,
please find CMakeCache.txt attached (can't see CGAL_DIR defined). CMakeCache.txt
Thanks, Marco.
I was actually quite wrong in my guess. Your CMake sources directory was E:/libs/CGAL/CGAL-5.6
, and you configured CGAL with:
//Select demos
WITH_demos:BOOL=ON
//Select examples
WITH_examples:BOOL=ON
We will have to try and reproduce your issue. Can you please tell us more about the versions you used?
- CGAL-5.6, for sure,
- Boost 1.84.0, it seems,
- which version of Visual Studio?
- Any special toolset, or Visual Studio default one?
- Which version of CMake? All we know is that it is >= 3.27 (because of the warning about
CMP0144
).
I think that the problem is at 'generation' time (Cmake-gui goes configure/generate/open project).
Somewhere at configure time the (expected) long path with all the include dirs is generated, concatenated by ;. Then, on 'generate' button:
CMake Error in examples/Arrangement_on_surface_2/CMakeLists.txt:
Imported target "CGAL" includes non-existent path
"C:\msys64\home\mcecchi\mpfr-4.2.1\src;C:/msys64/home/mcecchi/gmp-6.3.0"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
- CGAL-5.6, for sure,
- Boost 1.84.0, it seems,
- which version of Visual Studio?
VS 2022 (anyhow the problem is that the generated vcproj files miss some crucial data)
The C compiler identification is MSVC 19.38.33134.0
The CXX compiler identification is MSVC 19.38.33134.0
- Any special toolset, or Visual Studio default one?
Nope. VS Professional edition.
- Which version of CMake? All we know is that it is >= 3.27 (because of the warning about
CMP0144
).
3.27.5
Marco, can you please try again without configuring MPFI, in the CMake cache for CGAL? MPFI has not been tested for a long time with CGAL, and I am pretty certain it was never tested under Windows.
What is more, I see really old and ugly CMake code in cmake/modules/CGAL_UseMPFI.cmake
and I have the intuition it could be the source of your issues.
Also try to change the \
to /
in the configuration variable MPFR_INCLUDE_DIR
. It should not be responsible for an error, but the behavior of CMake seems so strange, in your log.
I have just tried with a similar setup, and I cannot reproduce the issue.
You CMake log shows the following error for quite a few of the targets (for example Alpha_shapes_2
)
CMake Error in demo/Alpha_shapes_2/CMakeLists.txt:
Imported target "CGAL" includes non-existent path
"C:\msys64\home\mcecchi\mpfr-4.2.1\src;C:/msys64/home/mcecchi/gmp-6.3.0"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
Are you sure that these paths are correct? Another hint : maybe you should avoid mixing slashes and backslashes in paths given to CMake (though it does not change anything with my setup)
About the additional includes, you can have a look at the complete command line in a given target properties.
For example, the target mesh_polyhedral_domain
has the include directories of CGAL-5.6, GMP, MPFR, boost, zlib and Eigen. Do you have them too in the full command line?
Hello Jane,
You CMake log shows the following error for quite a few of the targets (for example Alpha_shapes_2)
Yes, I reported this strange message this morning. Cmake is able to deal with forward and backward slashes undistinctively (of course, otherwise it would be a mess), the problem is that this:
"C:\msys64\home\mcecchi\mpfr-4.2.1\src;C:/msys64/home/mcecchi/gmp-6.3.0"
is seen as a whole string.
I will also try Laurent's suggestion as soon as I can.
For mesh_polyhedral_domain, that is affected by the same issue:
In the full command line section, you should have something similar to
Why would this be taken as a whole string? Do you give them together to CMake, and not separately?
No Jane, it's the Cmake machinery.
Please take a closer look at the CMakeCache.txt that I posted earlier in this thread.
Hi Laurent,
Marco, can you please try again without configuring MPFI,
same. Please see the included log. CGAL56-cmake-nompfi.zip
Marco, your current approach is unusual. You seem to have been installed all optional dependencies of all of the examples and demos of CGAL. Let's keep it simpler: try with a new fresh binary directory, and configure CGAL with WITH_demos
and WITH_examples
set to ON
, but with only the minimal set of dependencies of CGAL:
- Boost
- GMP
- MPFR
- Eigen
and nothing else. Then try to compile something, like mesh_polyhedral_domain.vcproj
.
Then:
- If that fails, please send use again the new
CMakeCache.txt
and the full log. - If that works, you can try to reintroduce more dependencies, one by one.
MSVC 2022 is tested every night with different versions of CGAL, including CGAL-5.6. Several colleges of mines (including Jane) use MSVC 2022 with CGAL at work, and without any issue.
There must be something different in the way you are using CGAL.
And if then it still does not work let's do a shared screen session with you.
try with a new fresh binary directory, and configure CGAL with WITH_demos and WITH_examples set to ON, but with only the minimal set of dependencies of CGAL
Same or worse, in the sense that the "Additional Include Directories" is now void. Usual error:
CMake Error in Surface_mesh_deformation/demo/Surface_mesh_deformation/CMakeLists.txt:
Imported target "CGAL" includes non-existent path
"C:\msys64\home\mcecchi\mpfr-4.2.1\src;E:/libs/boost_1_84_0"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
Now, I understand that you are trying to isolate the problem, that it must be something in my environment etc, but, just to narrow it down even more, can someone please point me to where cmake creates the "additional include directories" in the vcxproj, somewhere near that "CAGL" target?
For example, the AdditionalDependencies
tag is properly built.
mcecchi@ITRIMUSRLT372 MSYS ~/CGAL-5.6-minimal
$ grep -r "mpfr-4.2.1" BUILD/demo/Surface_mesh_deformation/ 2>/dev/null
BUILD/demo/Surface_mesh_deformation/deform_mesh_for_botsch08_format.vcxproj: <AdditionalDependencies>C:\msys64\home\mcecchi\mpfr-4.2.1\src\.libs\libmpfr-6.dll.lib;C:\msys64\home\mcecchi\gmp-6.3.0\.libs\libgmp-10.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
BUILD/demo/Surface_mesh_deformation/deform_mesh_for_botsch08_format.vcxproj: <AdditionalDependencies>C:\msys64\home\mcecchi\mpfr-4.2.1\src\.libs\libmpfr-6.dll.lib;C:\msys64\home\mcecchi\gmp-6.3.0\.libs\libgmp-10.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
BUILD/demo/Surface_mesh_deformation/deform_mesh_for_botsch08_format.vcxproj: <AdditionalDependencies>C:\msys64\home\mcecchi\mpfr-4.2.1\src\.libs\libmpfr-6.dll.lib;C:\msys64\home\mcecchi\gmp-6.3.0\.libs\libgmp-10.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
BUILD/demo/Surface_mesh_deformation/deform_mesh_for_botsch08_format.vcxproj: <AdditionalDependencies>C:\msys64\home\mcecchi\mpfr-4.2.1\src\.libs\libmpfr-6.dll.lib;C:\msys64\home\mcecchi\gmp-6.3.0\.libs\libgmp-10.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
A vcxproj file is an XML file. In the source code of CMake, the "additional include directories" property is created by the function cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories. That is the technical part in CMake source code, but I am pretty sure that is not what you are looking for.
The CGAL
CMake target is created in lib/cmake/CGAL/CGALConfig.cmake
, line 181, by that loop:
https://github.com/CGAL/cgal/blob/de4fa0d7d57b5a997012f2804161386ff4bc0d0f/Installation/lib/cmake/CGAL/CGALConfig.cmake#L178-L187
And then the function CGAL_setup_target_dependencies(CGAL)
is called, and then CGAL_setup_CGAL_dependencies(CGAL)
. And then:
-
use_CGAL_GMP_support(CGAL INTERFACE)
sets up GMP and MPFR, -
use_CGAL_Boost_support(CGAL INTERFACE)
sets up Boost.
For all three dependencies of CGAL, the target CGAL property INTERFACE_INCLUDE_DIRECTORIES
is modified by calls to target_include_directories
(for GMP and MPFR), or target_link_libraries
for imported CMake targets (like Boost).
I do not know if that is the level of details you were hoping to get.
"C:\msys64\home\mcecchi\mpfr-4.2.1\src;E:/libs/boost_1_84_0"
There seems to be an issue with the path C:\msys64\home\mcecchi\mpfr-4.2.1\src
. How do you pass it to CMake?
- Is it using the CMake command line?
- Is it using the CMake GUI? And in that case, does the GUI recognize that path as a directory path?
- Or is it by editing the file
CMakeCache.txt
in yourBUILD/
directory?
I see that the path in the file CMakeCache.txt
ends with a \
:
MPFR_INCLUDE_DIR:PATH=C:\msys64\home\mcecchi\mpfr-4.2.1\src\
Can you please remove the last \
, that is useless, and might confuse CMake (because \;
would then be a "quote of ;
" instead of being the CMake lists separator ;
.
And same for:
EIGEN3_INCLUDE_DIR:PATH=E:\libs\eigen-3.4.0\
This makes sense. Unfortunately, as you can see:
MPFR_INCLUDE_DIR=C:\msys64\home\mcecchi\mpfr-4.2.1\src\,
but the error reports:
"C:\msys64\home\mcecchi\mpfr-4.2.1\src;C:/msys64/home/mcecchi/gmp-6.3.0"
where the trailing / has been stripped,
Anyway I manually edited all the possibly offending paths allover, even if I really hope that Cmake is able to deal with this...
This trailing slash must be added by cmake-gui, which is the one tool that I am using.
Thanks for anyway your support, see you next week.
The CGAL CMake target is created in lib/cmake/CGAL/CGALConfig.cmake, line 181, by that loop:
I checked, but that does not seem to be the precise point.
Looking at the logs:
== Generating build files for demos (DONE) ==
== Setting paths ==
== Generating build files for demos (DONE) ==
CMake Error in examples/Arrangement_on_surface_2/CMakeLists.txt:
Imported target "CGAL" includes non-existent path
== Setting paths ==
in the root, CMakeLists.txt has this part:
message("== Setting paths ==\n")
[...]
message("== Setting paths (DONE) ==\n")
where the include paths are checked.
Hello Laurent,
Can you please remove the last , that is useless, and might confuse CMake (because ; would then be a "quote of ;" instead of being the CMake lists separator ;. It works. I apologize for the confusion, but on Friday I was about to leave and was looking for the tag<AdditionalIncludeDirectories> in the generated vcxprojs.
I still can't see the boost, gmp include dirs there, but it compiles (don't know/don't care how).
For the record, I was using Cmake-gui and copy/pasting the paths taken from a file manager, in some cases. This file manager happens to add a trailing backslash at the end (which is ok). So I'd say the problem is in cmake-gui.
Thanks for your support.