CMake build error with first build when bundling in an external library
Opened this issue · 2 comments
rossant commented
I'm on Ubuntu 24.04, I try to bundle msd-atlas-gen into my C/C++ library using cmake (and ninja for the multicore build process).
I'm probably doing something wrong as the first build fails with:
error: ‘buildShapeFromSvgPath’ was not declared in this scope
82 | buildShapeFromSvgPath(shape, svg_path);
but all subsequent (re)builds succeed, without doing any change in the code.
The code is:
#include "msdfgen-ext.h"
#include "msdfgen.h"
...
Shape shape;
buildShapeFromSvgPath(shape, svg_path);
This is part of my cmake
set(HAS_MSDF 1)
set(MSDFGEN_CORE_ONLY OFF)
set(MSDFGEN_BUILD_STANDALONE OFF)
set(MSDFGEN_USE_SKIA OFF)
set(MSDFGEN_DISABLE_SVG OFF)
set(MSDF_ATLAS_BUILD_STANDALONE OFF)
set(MSDF_ATLAS_USE_VCPKG OFF)
set(MSDF_ATLAS_USE_SKIA OFF)
set(MSDF_ATLAS_DYNAMIC_RUNTIME ON)
set(MSDF_ATLAS_MSDFGEN_EXTERNAL OFF)
set(BUILD_SHARED_LIBS ON)
# Freetype is required for msdf-atlas-gen
find_package(Freetype REQUIRED)
# tinyxml2
FetchContent_Declare(
tinyxml2
GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
GIT_TAG 10.0.0
)
FetchContent_MakeAvailable(tinyxml2)
# MSDF atlas
FetchContent_Declare(
msdfgen-atlas
GIT_REPOSITORY https://github.com/Chlumsky/msdf-atlas-gen.git
GIT_TAG master
)
FetchContent_MakeAvailable(msdfgen-atlas)
set(INCL_DIRS ${INCL_DIRS} ${msdfgen-atlas_SOURCE_DIR}/msdfgen ${FREETYPE_INCLUDE_DIR_ft2build})
set(LINK_LIBS ${LINK_LIBS} msdfgen::msdfgen-ext msdf-atlas-gen::msdf-atlas-gen ${FREETYPE_LIBRARIES})
Does anything stand out as obviously wrong above? Thanks! (and thanks for this great library ❤️ )
Chlumsky commented
The only thing I can tell you from looking at the 4 lines of code you posted is that buildShapeFromSvgPath
only exists in the msdfgen
namespace.
rossant commented
Yes I had tried msdfgen::buildShapeFromSvgPath
and the same error occurs. Anyone else had the problem where a cmake build fails the first time but not subsequent times?