How to use external fmt and boost but other libraries as internal
ludekvodicka opened this issue · 7 comments
We have our own copy of boost and fmt lib but no other libraries.
So I tried to use the recommended "external" mode (https://jinja2cpp.dev/docs/build_and_install.html#external)
My CMake string:
SET CMAKE_PARAMS= -DJINJA2CPP_BUILD_TESTS="OFF" -DBOOST_CMAKE_BUILD_TESTS="OFF" -DJINJA2CPP_DEPS_MODE=external -DCMAKE_PREFIX_PATH="%LIB_PATH%/thirdparty/nonstd/expected-lite;%LIB_PATH%/thirdparty/nonstd/variant-lite;%LIB_PATH%/thirdparty/nonstd/optional-lite;%LIB_PATH%/thirdparty/nonstd/string-view-lite;" -Dfmt-header-only_INCLUDE_DIR="%SHL_PATH%/fmtlib32/include" -DBoost_INCLUDE_DIR="%SHL_PATH%/boost32/include"
cmake .. -G "%CMAKE_PLATFORM_PARAM%" -A "%CMAKE_ARCHITECTURE_PARAM%" %CMAKE_PARAMS% -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%LIB_DEST%
But after initial library successful checks:
-- Found expected-lite: Q:/ExternalLibraries/jinja2/thirdparty/nonstd/expected-lite/include
-- Found variant-lite: Q:/ExternalLibraries/jinja2/thirdparty/nonstd/variant-lite/include
-- Found optional-lite: Q:/ExternalLibraries/jinja2/thirdparty/nonstd/optional-lite/include
-- Found string-view-lite: Q:/ExternalLibraries/jinja2/thirdparty/nonstd/string-view-lite/include
-- Found fmt-header-only: Q:/SharedLibraries2019/fmtlib32/include
I receive the following errors:
-- infix: EXPECTED-LITE target: expected-lite
-- infix: VARIANT-LITE target: variant-lite
-- infix: OPTIONAL-LITE target: optional-lite
-- infix: STRING-VIEW-LITE target: string-view-lite
-- Configuring done
CMake Error in CMakeLists.txt:
Target "expected-lite" INTERFACE_INCLUDE_DIRECTORIES property contains
path:
"Q:/ExternalLibraries/jinja2/thirdparty/nonstd/expected-lite/include"
which is prefixed in the source directory.
CMake Error in CMakeLists.txt:
Target "variant-lite" INTERFACE_INCLUDE_DIRECTORIES property contains path:
"Q:/ExternalLibraries/jinja2/thirdparty/nonstd/variant-lite/include"
which is prefixed in the source directory.
CMake Error in CMakeLists.txt:
Target "optional-lite" INTERFACE_INCLUDE_DIRECTORIES property contains
path:
"Q:/ExternalLibraries/jinja2/thirdparty/nonstd/optional-lite/include"
which is prefixed in the source directory.
CMake Error in CMakeLists.txt:
Target "string-view-lite" INTERFACE_INCLUDE_DIRECTORIES property contains
path:
"Q:/ExternalLibraries/jinja2/thirdparty/nonstd/string-view-lite/include"
which is prefixed in the source directory.
Should I move all third party libraries outside the jinja2 directory?
When I move 3rd party libraries outside the jinja2 directory, make continues but there is still some issue:
Although ALL_BUILD.vcxproj, INSTALL.vcxproj and other files are created, file all.vcxproj doesn't exists.
q:\ExternalLibraries\jinja2\debug>cmake --build . --target all
Microsoft (R) Build Engine version 16.3.2+e481bbf88 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1009: Project file does not exist.
Switch: all.vcxproj
q:\ExternalLibraries\jinja2\debug>cmake --build . --target install
Microsoft (R) Build Engine version 16.3.2+e481bbf88 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Checking Build System
Building Custom Rule Q:/ExternalLibraries/jinja2/CMakeLists.txt
error_info.cpp
Q:\ExternalLibraries\jinja2\src\error_info.cpp(89,17): error C2988: unrecognizable template declaration/definition [Q:\ExternalLibraries\jinja2\debug\jinja2cpp.vcxproj]
Q:\ExternalLibraries\jinja2\src\error_info.cpp(89,17): error C2143: syntax error: missing ';' before '<' [Q:\ExternalLibraries\jinja2\debug\jinja2cpp.vcxproj]
Q:\ExternalLibraries\jinja2\src\error_info.cpp(89,17): error C2059: syntax error: '<' [Q:\ExternalLibraries\jinja2\debug\jinja2cpp.vcxproj]
Q:\ExternalLibraries\jinja2\src\error_info.cpp(90,1): error C2143: syntax error: missing ';' before '{' [Q:\ExternalLibraries\jinja2\debug\jinja2cpp.vcxproj]
expression_evaluator.cpp
Q:\ExternalLibraries\jinja2\src\error_info.cpp(90,1): error C2447: '{': missing function header (old-style formal list?) [Q:\ExternalLibraries\jinja2\debug\jinja2cpp.vcxproj]
expression_parser.cpp
Q:\ExternalLibraries\jinja2\src\internal_value.h(10,10): fatal error C1083: Cannot open include file: 'fmt/core.h': No such file or directory [Q:\ExternalLibraries\jinja2\debug\jinja2cpp.vcxproj]
And another problem is that we're using another version of fmt ;-(.
I have to try to update it first on our side before I will be able to continue with tests.
is there any reason why you're using fmt 5.4.0 instead of the latest 6.1.2?
Do you have an idea if I will be able to use it with 6.1.2 version?
Isn't there any way how to encapsulate all jinja2 dependencies together with jinja2 into one DLL so we don't have to deal with different versions of boost/fmt/etc?
Hi, @ludekvodicka
Firstly, thanks for testing and issues reporing.
-
Regarding to the version of
fmt
. Actually, for now it doesn't matter which exactly version offmt
library you build Jinja2Cpp with. It can be built both with 5.4.0 and 6.1.2. -
Regarding to the
external
mode problems. Please, consider this sample: https://github.com/jinja2cpp/examples-build/blob/master/external/external/build.bat
It contains fully-functional (and checked) script for build Jinja2Cpp with externally-provided third-parties. -
Regarding to the
all
target. CMake Visual Studio solution generator doesn't createall.vcxproj
. It createsALL_BUILD.vcxproj
file instead. The more proper way to run build with CMake and VS project files is:cmake --build . --config <your_config>
-
Regarding problems on build. Looks like you've got misconfigured solution files. Try to run CMake in the clean build directory and, in case of errors, provide full cmake output here. The good cmake run for jinja2cpp and visual studio generator looks like this:
https://ci.appveyor.com/project/flexferrum/examples-build/build/job/e6c8lpvevc9gqg28#L170
Thanks a lot for replies and help.
I'm now working on migration to the latest fmt. We heavily used 4.5 versions in our apps so I need to update a lot of code (mostly FMT_VARIADIC() and Memory handling and writers).
As soon as I do that, I will continue with integration of jinja2 to our codebase.
Thanks a lot
Actually, fmt
is a private dependency, so you can try to build jinja2cpp in external-boost
mode.
I can try it. But I'm not sure if this will work in case we're using fmt in our project too.
And because jinja is a static library, I believe there will be symbol mishmash after in-app linking.
Maybe if jinja would be compiled as DLL, it will be possible to use a different versions of non-public libraries.