Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMakeLists.txt: fix build with ninja #8835

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,16 @@ else()
set(AUTOCONF_HOST_OPT "--host=${GNU_HOST}")
endif()

if(CMAKE_GENERATOR MATCHES "Ninja")
if(FLB_SYSTEM_WINDOWS)
MESSAGE(FATAL_ERROR "Building with Ninja is not supported on Windows")
else()
set(EXTERNAL_BUILD_TOOL "make")
endif()
else()
set(EXTERNAL_BUILD_TOOL "$(MAKE)")
endif()

# Memory Allocator
# ================
if(FLB_JEMALLOC AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Expand All @@ -953,15 +963,17 @@ if(FLB_JEMALLOC AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message(STATUS "jemalloc configure: ${FLB_JEMALLOC_OPTIONS_LIST}")

# Link to Jemalloc as an external dependency
set(FLB_LIBJEMALLOC_PATH "${CMAKE_CURRENT_BINARY_DIR}/lib/libjemalloc_pic.a")
ExternalProject_Add(jemalloc
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/jemalloc-5.3.0
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/jemalloc-5.3.0/configure ${AUTOCONF_HOST_OPT} "${FLB_JEMALLOC_OPTIONS_LIST}" --prefix=<INSTALL_DIR>
CFLAGS=-std=gnu99\ -Wall\ -pipe\ -g3\ -O3\ -funroll-loops
BUILD_COMMAND $(MAKE)
BUILD_COMMAND ${EXTERNAL_BUILD_TOOL}
BUILD_BYPRODUCTS ${FLB_LIBJEMALLOC_PATH}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/
INSTALL_COMMAND $(MAKE) install_lib_static install_include)
INSTALL_COMMAND ${EXTERNAL_BUILD_TOOL} install_lib_static install_include)
add_library(libjemalloc STATIC IMPORTED GLOBAL)
set_target_properties(libjemalloc PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/lib/libjemalloc_pic.a")
set_target_properties(libjemalloc PROPERTIES IMPORTED_LOCATION ${FLB_LIBJEMALLOC_PATH})
add_dependencies(libjemalloc jemalloc)
include_directories("${CMAKE_BINARY_DIR}/include/")
else()
Expand All @@ -979,14 +991,16 @@ if(FLB_BACKTRACE)
else()
set(DEPS_C_COMPILER "${CMAKE_C_COMPILER}")
endif()
set(FLB_LIBBACKTRACE_PATH "${CMAKE_CURRENT_BINARY_DIR}/backtrace-prefix/lib/libbacktrace.a")
ExternalProject_Add(backtrace
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-8602fda/
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbacktrace-8602fda/configure ${AUTOCONF_HOST_OPT} --prefix=<INSTALL_DIR> --enable-shared=no --enable-static=yes
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND $(MAKE) DESTDIR= install
BUILD_COMMAND ${EXTERNAL_BUILD_TOOL}
BUILD_BYPRODUCTS ${FLB_LIBBACKTRACE_PATH}
INSTALL_COMMAND ${EXTERNAL_BUILD_TOOL} DESTDIR= install
)
add_library(libbacktrace STATIC IMPORTED GLOBAL)
set_target_properties(libbacktrace PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/backtrace-prefix/lib/libbacktrace.a")
set_target_properties(libbacktrace PROPERTIES IMPORTED_LOCATION ${FLB_LIBBACKTRACE_PATH})
add_dependencies(libbacktrace backtrace)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/backtrace-prefix/include/")
endif()
Expand Down
Loading