Улучшен CMakeLists.txt

This commit is contained in:
Arseniy Romenskiy 2026-03-03 22:21:57 +03:00
parent 9393d91906
commit 485c2e0b8e
2 changed files with 23 additions and 8 deletions

View file

@ -3,13 +3,24 @@ cmake_minimum_required(VERSION 3.5)
project(webdisk_c LANGUAGES C)
add_executable(webdisk_c main.c cJSON/cJSON.c)
set (CMAKE_C_FLAGS "-g -O3 -DUSE_JEMALLOC")# -DUSE_JEMALLOC
target_link_libraries(webdisk_c jemalloc)
option(USE_JEMALLOC "Build JEMALLOC" ON)
option(JEMALLOC_STATIC "JEMALLOC static" ON)
if(USE_JEMALLOC)
target_compile_definitions(webdisk_c PRIVATE USE_JEMALLOC)
if(JEMALLOC_STATIC)
target_link_libraries(webdisk_c PRIVATE
"${CMAKE_SOURCE_DIR}/jemalloc/build/lib/libjemalloc.a"
)
else()
target_link_libraries(webdisk_c jemalloc)
target_link_directories(webdisk_c PRIVATE
"${CMAKE_SOURCE_DIR}/jemalloc/build/lib"
)
endif()
endif()
target_include_directories(webdisk_c PRIVATE
"${CMAKE_SOURCE_DIR}/jemalloc/build/include"
)
# Правильно указываем папку с .so для линковки
target_link_directories(webdisk_c PRIVATE
"${CMAKE_SOURCE_DIR}/jemalloc/build/lib"
)
install(TARGETS webdisk_c RUNTIME DESTINATION bin)

View file

@ -7,10 +7,14 @@ WebDisk_C is a project that implements Filelight functionality in a Web Browser.
# Зависимости
## jemalloc
Проект имеет необязательную зависимость [jemalloc](https://github.com/jemalloc/jemalloc.git)
Вы можете его отключить убрав **`-DUSE_JEMALLOC`** и **`jemalloc`** из файла `CMakeLists.txt`
Вы можете его отключить **`cmake .. -DUSE_JEMALLOC=OFF`**
Вы также можете собрать его с jemalloc не статично **`-DJEMALLOC_STATIC=OFF`**
Но тогда пожалуйста позаботьтесь о .so файле, так как jemalloc сконфигурирован иначе.
The project has an optional [jemalloc](https://github.com/jemalloc/jemalloc.git) dependency
You can disable it by removing **`-DUSE_JEMALLOC`** and **`jemalloc`** from the file `CMakeLists.txt `
You can disable it by removing **`-DUSE_JEMALLOC`**
You can also build it with jemalloc non-statically **`-DJEMALLOC_STATIC=OFF`**
But then please take care of the .so file, as jemalloc is configured differently.
### Сборка/Build **jemalloc**
```bash
git clone https://github.com/jemalloc/jemalloc.git