Skip to content
Snippets Groups Projects
Commit 99a5ac16 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

cmake: build bundled libyaml as external project

Currently, we simply include the libyaml source directory into the main
project. The problem is that libyaml uses ICU. If ICU is built outside
the main project cmake config, as it's the case with the static-build,
both the main project and libyaml cmake configs will use the same ICU
version. However, if we build ICU in the main project, as we intend to
do to resolve #9242, it may not work. To fix that, we need to use the
external project API to build libyaml.

Needed for #9242

NO_DOC=build
NO_TEST=build
NO_CHANGELOG=build

(cherry picked from commit 8820f5c9)
parent d13498ef
No related branches found
No related tags found
No related merge requests found
...@@ -664,7 +664,7 @@ option(ENABLE_BUNDLED_LIBYAML "Enable building of the bundled libyaml" ON) ...@@ -664,7 +664,7 @@ option(ENABLE_BUNDLED_LIBYAML "Enable building of the bundled libyaml" ON)
if (ENABLE_BUNDLED_LIBYAML) if (ENABLE_BUNDLED_LIBYAML)
include(BuildLibYAML) include(BuildLibYAML)
libyaml_build() libyaml_build()
add_dependencies(build_bundled_libs yaml) add_dependencies(build_bundled_libs bundled-libyaml)
else() else()
set(LIBYAML_FIND_REQUIRED ON) set(LIBYAML_FIND_REQUIRED ON)
find_package(LibYAML) find_package(LibYAML)
......
# #
# A macro to build the bundled libyaml # A macro to build the bundled libyaml
macro(libyaml_build) macro(libyaml_build)
set(LIBYAML_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/third_party/libyaml/include) set(LIBYAML_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/libyaml)
set(LIBYAML_LIBRARIES yaml) set(LIBYAML_INSTALL_DIR ${PROJECT_BINARY_DIR}/build/libyaml)
set(LIBYAML_INCLUDE_DIR ${LIBYAML_INSTALL_DIR}/include)
set(LIBYAML_LIBRARY ${LIBYAML_INSTALL_DIR}/lib/libyaml_static.a)
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/libyaml EXCLUDE_FROM_ALL) set(LIBYAML_CMAKE_FLAGS
# See comments in BuildLibEV.cmake "-DCMAKE_INSTALL_PREFIX=${LIBYAML_INSTALL_DIR}"
set_target_properties(yaml PROPERTIES COMPILE_FLAGS "${DEPENDENCY_CFLAGS} -w") "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
)
find_package_message(LIBYAML if(DEFINED ICU_ROOT)
"Using bundled libyaml" list(APPEND LIBYAML_CMAKE_FLAGS "-DICU_ROOT=${ICU_ROOT}")
"${LIBYAML_LIBRARIES}:${LIBYAML_INCLUDE_DIRS}") endif()
unset(yaml_src) ExternalProject_Add(bundled-libyaml-project
PREFIX ${LIBYAML_INSTALL_DIR}
SOURCE_DIR ${LIBYAML_SOURCE_DIR}
CMAKE_ARGS ${LIBYAML_CMAKE_FLAGS}
BUILD_BYPRODUCTS ${LIBYAML_LIBRARY}
)
add_library(bundled-libyaml STATIC IMPORTED GLOBAL)
set_target_properties(bundled-libyaml PROPERTIES IMPORTED_LOCATION
${LIBYAML_LIBRARY})
add_dependencies(bundled-libyaml bundled-libyaml-project)
set(LIBYAML_LIBRARIES ${LIBYAML_LIBRARY})
set(LIBYAML_INCLUDE_DIRS ${LIBYAML_INCLUDE_DIR})
message(STATUS "Using bundled libyaml")
endmacro(libyaml_build) endmacro(libyaml_build)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment