Улучшен CMakeLists.txt

This commit is contained in:
Arseniy Romenskiy 2026-03-03 22:21:57 +03:00
parent 9393d91906
commit a73ef29fd9
2 changed files with 25 additions and 10 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

@ -6,11 +6,15 @@ 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`
Проект имеет необязательную зависимость [jemalloc](https://github.com/jemalloc/jemalloc.git)<br>
Вы можете его отключить **`cmake .. -DUSE_JEMALLOC=OFF`**<br>
Вы также можете собрать его с jemalloc не статично **`-DJEMALLOC_STATIC=OFF`**<br>
Но тогда пожалуйста позаботьтесь о .so файле, так как jemalloc сконфигурирован иначе.<br>
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 `
The project has an optional [jemalloc](https://github.com/jemalloc/jemalloc.git) dependency<br>
You can disable it by removing **`-DUSE_JEMALLOC`**<br>
You can also build it with jemalloc non-statically **`-DJEMALLOC_STATIC=OFF`**<br>
But then please take care of the .so file, as jemalloc is configured differently.<br>
### Сборка/Build **jemalloc**
```bash
git clone https://github.com/jemalloc/jemalloc.git