Cantera / cantera

Chemical kinetics, thermodynamics, and transport tool suite
https://cantera.org
Other
624 stars 350 forks source link

Relative paths in the `boost_inc_dir` are adjusted to be relative to `build` rather than the source root on Windows #1743

Closed bryanwweber closed 4 months ago

bryanwweber commented 4 months ago

Problem description

If Boost is specified with a relative directory in the boost_inc_dir option, SCons adjusts the include path to be relative to the build and src directories when writing command lines for compiling. For example:

cl /Fobuild\src\base\AnyMap.obj /c src\base\AnyMap.cpp /TP /EHsc /std:c++17 /utf-8 /MD /nologo /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /O2 /Zi /Fdbuild\src\base\AnyMap.obj.pdb /W3 /DNDEBUG /Iinclude\cantera\ext /Iinclude /Ibuild\src /Ibuild\src\boost.1.85.0\lib\native\include /Isrc\boost.1.85.0\lib\native\include
AnyMap.cpp
C:\Users\Quickemu\Documents\cantera\src\base\application.h(12): fatal error C1083: Cannot open include file: 'boost/algorithm/string/join.hpp': No such file or directory
scons: *** [build\src\base\AnyMap.obj] Error 2

Note the /Ibuild\src\boost.1.85.0\lib\native\include. In cantera.conf, I set boost_inc_dir = 'boost.1.85.0/lib/native/include' and SCons added the build\src prefix. This seems to only happen on Windows, Linux seems to use a relative path to the cantera.conf file, as expected.

Changing

 env["boost_inc_dir"] = Path(env["boost_inc_dir"]).as_posix()

to

 env["boost_inc_dir"] = Path(env["boost_inc_dir"]).resolve().as_posix()

fixes the issue and doesn't seem to break anything on Linux. This change should also be made to other include and library config options for consistency.

bryanwweber commented 4 months ago

I think a better solution here might be to use the SCons Dir() object and prepend a # to the string if it isn't absolute. That way, SCons will interpret it as relative to the source root.