NGSolve / netgen

https://ngsolve.org
GNU Lesser General Public License v2.1
298 stars 131 forks source link

inconsistent nggui/netgen_gui (USE_GUI) configuration triggers tcl.h error #166

Open drew-parsons opened 1 year ago

drew-parsons commented 1 year ago

I'm trying to build netgen 6.2.2305. My build configuration sets USE_OCC=ON and keeps the default USE_GUI=ON. Tcl is found (8.6.13) setting TCL_INCLUDE_PATH=/usr/include/tcl (which contains tcl.h). But the build fails at libsrc/occ/occpkg.cpp via inctcl.hpp,

[ 85%] Building CXX object CMakeFiles/nggui.dir/libsrc/occ/occpkg.cpp.o
/usr/bin/c++ -DHAVE_DLFCN_H -DHAVE_FREEIMAGE -DHAVE_FREETYPE -DHAVE_OPENGL_EXT -DHAVE_RAPIDJSON -DHAVE_TBB -DHAVE_TK -DHAVE_XLIB -DNETGEN_PYTHON -DNG_PYTHON -DOCCGEOMETRY -DOCC_CONVERT_SIGNALS -DPARALLEL -DPYBIN
D11_SIMPLE_GIL_MANAGEMENT -Dnggui_EXPORTS -I/projects/netgen/obj-x86_64-linux-gnu -I/projects/netgen -I/projects/netgen/include -I/project/netgen/libsrc -I/projects/netgen/libsrc/include -I/usr/include/opencascade -I/usr/lib/x86_64-linux-gnu/openmpi/include -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr
/include/python3.11 -DMPICH_SKIP_MPICXX -lmpi -fPIC -Wall -g -O2 -ffile-prefix-map=/projects/netgen=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-
protection -O2 -g -DNDEBUG -std=gnu++17 -fPIC -fvisibility=hidden -MD -MT CMakeFiles/nggui.dir/libsrc/occ/occpkg.cpp.o -MF CMakeFiles/nggui.dir/libsrc/occ/occpkg.cpp.o.d -o CMakeFiles/nggui.dir/libsrc/occ/occpkg
.cpp.o -c /projects/netgen/libsrc/occ/occpkg.cpp
...
In file included from /projects/netgen/libsrc/occ/occpkg.cpp:10:
/projects/netgen/libsrc/include/inctcl.hpp:1:10: fatal error: tcl.h: No such file or directory
    1 | #include <tcl.h>
      |          ^~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/nggui.dir/build.make:93: CMakeFiles/nggui.dir/libsrc/occ/occpkg.cpp.o] Error 1

As far as I can tell the error arises due to an inconsistency introduced in https://github.com/NGSolve/netgen/commit/03347e8e33962e810f6bfbe4d63c7d522fd762c5, where (CMakeLists.txt)

target_include_directories(nggui PRIVATE ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH})

was replaced with

target_include_directories(netgen_gui INTERFACE ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH})

But libsrc/occ/CMakeLists.txt still uses

target_sources(nggui PRIVATE vsocc.cpp occpkg.cpp)

occpkg.cpp includes inctcl.hpp, so needs TCL_INCLUDE_PATH. But it is built for nggui, while TCL_INCLUDE_PATH is only added to netgen_gui

There seems to be an inconsistency between the nggui and netgen_gui targets.