Build fail without jansson
mkirilin opened this issue · comments
Description
Build with cmkae fails on a system without jansson library.
To Reproduce
- p4est repository is on 2e44 commit. sc repository is on 83bd.
- Configure and build sc in debug mode and with mpi.
- Configure and build p4est in debug and with mpi.
p4est configure output: -- Could NOT find jansson (missing: jansson_DIR)
p4est build output:
/opt/software/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: ../local/lib/libsc.a(sc_options.c.o): in function `sc_options_json_lookup':
sc_options.c:(.text+0x95): undefined reference to `json_object_get'
/opt/software/easybuild/software/binutils/2.38-GCCcore-11.3.0/bin/ld: sc_options.c:(.text+0x105): undefined reference to `json_object_get'
etc...
Hi @mkirilin
Could you provide the full commit hash (at least first 7 characters) because I was not able to identify 2e44 in p4est repository, while I found 83bd019 in libsc (current master) ?
I tried to build both current p4est develop branch and master branch on a system where libjansson is not available; I didn't encounter any problem, it builds fine.
@pkestene
I double checked current commit states: both p4est and sc are on master.
The problem appears when jansson is not found via find_package() but is found via PkgConfig:
-- Could NOT find jansson (missing: jansson_DIR)
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- jansson library found via pkg-config
Ok. I understand now and I can reproduce. This is a bug.
I'll push a fix shortly.
there are actually two bugs (not directly related):
- at p4est level, linking to lib jansson is enabled when SC_HAVE_JSON is true, but here SC_HAVE_JSON was not defined even though cmake/jansson.cmake was included
- when using an installed version of libsc, installed
SC-targets.cmake
is referencing libraryPkgConfig::LIBSC_JANSSON
instead ofjansson::jansson
(as it is the case when jansson is detected viafind_package
. This will be fixed in libsc
you can try this branch : https://github.com/pkestene/p4est/tree/fix/jansson-pkgconfig for cross-checking
@pkestene
With p4est HEAD on 31aeaf2 and libsc on both cburstedde/libsc@f622a4c and cburstedde/libsc@116a91b the problem persists.
@mkirilin I'm really sorry for the trouble
I made a silly copy paste error while working on a working branch; thanks for being persevering
https://github.com/cburstedde/p4est/blob/develop/cmake/jansson.cmake#L24 and https://github.com/cburstedde/p4est/blob/develop/cmake/jansson.cmake#L25 should use prefix P4EST and not LIBSC
@cburstedde would you prefer cancelling PR #229 and re-open a new PR (I've updated my fork with the new fix), or consider an additional PR ? sorry about that silly mistake.
No worries @pkestener, thanks for your contributions! We have already merged PR #229. You may start a new PR no problem.
@pkestene With p4est HEAD on 31aeaf2 and libsc on both cburstedde/libsc@f622a4c and cburstedde/libsc@116a91b the problem persists.
Thanks for double-checking!
Thanks for the fix. It builds well now on my machine.