mirror of
https://github.com/tbamud/tbamud.git
synced 2025-09-22 05:50:48 +02:00
Support for building utils
This commit is contained in:
parent
7196c012a6
commit
bf5ee52c2a
3 changed files with 87 additions and 10 deletions
|
@ -162,7 +162,9 @@ if (NOT HAVE_SOCKET)
|
|||
endif()
|
||||
|
||||
# ========== Define generelt UNIX-system ==========
|
||||
if (UNIX)
|
||||
set(CIRCLE_UNIX 1)
|
||||
endif()
|
||||
|
||||
# ========== Generate conf.h ==========
|
||||
configure_file(
|
||||
|
@ -177,6 +179,7 @@ file(GLOB SRC_FILES src/*.c)
|
|||
add_executable(circle ${SRC_FILES})
|
||||
target_link_libraries(circle ${EXTRA_LIBS})
|
||||
|
||||
add_subdirectory(src/util)
|
||||
|
||||
if (MEMORY_DEBUG)
|
||||
message(STATUS "MEMORY_DEBUG is activated, setting up zmalloc")
|
||||
|
|
|
@ -14,6 +14,8 @@ instructions below for the platform you are building on.
|
|||
CMake builds can be configured either from the command line, or from one of
|
||||
CMake's GUIs.
|
||||
|
||||
NOTE: The current CMakeLists.txt only supports linux.
|
||||
|
||||
# Configuring
|
||||
|
||||
A CMake configuration of tbamud is similar to the autotools build of curl.
|
||||
|
@ -30,35 +32,61 @@ that is apart from the source tree.
|
|||
example). The build directory is created for you. This is recommended over
|
||||
building in the source tree to separate source and build artifacts.
|
||||
|
||||
```shell
|
||||
$ cmake -B build -S .
|
||||
```
|
||||
|
||||
- Build in the source tree. Not recommended.
|
||||
|
||||
```shell
|
||||
$ cmake -B .
|
||||
```
|
||||
|
||||
The examples below will assume you have created a build folder.
|
||||
|
||||
The above commands will generate the build files. If you need to regenerate
|
||||
the files, you can delete the cmake cache file, and rerun the above command:
|
||||
|
||||
```shell
|
||||
$ rm build/CMakeCache.txt
|
||||
```
|
||||
|
||||
Once the build files are generated, the build is run with cmake
|
||||
|
||||
```shell
|
||||
$ cmake --build build
|
||||
# or, if
|
||||
$ cmake --build .
|
||||
```
|
||||
|
||||
This will generate the object files in a subdirectory under the specified
|
||||
build folder and link the executable. The resulting binaries will be in the
|
||||
bin/ folder.
|
||||
|
||||
### Utilities
|
||||
|
||||
It is possible to build only single tools, none or all of them,
|
||||
by specifying the target in the build command:
|
||||
|
||||
```shell
|
||||
# only build the mud
|
||||
$ cmake --build build --target circle
|
||||
|
||||
# only build tools
|
||||
$ cmake --build build --target utils
|
||||
|
||||
# only build one tool
|
||||
$ cmake --build build --target wld2html
|
||||
```
|
||||
|
||||
### Debugging memory
|
||||
|
||||
In case you want to run the mud with memory debugging turned on, you
|
||||
can set the MEMORY_DEBUG flag during configuration by specifying the
|
||||
flag:
|
||||
|
||||
```shell
|
||||
$ cmake -B build -S . -DMEMORY_DEBUG:int=1
|
||||
$ cmake --build build
|
||||
```
|
||||
|
||||
When the mud is shut down, the zmalloc code will identify any leaks in your code.
|
||||
Note that memory debugging may consume quite a lot of memory and take some time
|
||||
|
|
46
src/util/CMakeLists.txt
Normal file
46
src/util/CMakeLists.txt
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
set(TOOLS
|
||||
asciipasswd
|
||||
autowiz
|
||||
plrtoascii
|
||||
rebuildIndex
|
||||
rebuildMailIndex
|
||||
shopconv
|
||||
sign
|
||||
split
|
||||
wld2html
|
||||
webster
|
||||
)
|
||||
|
||||
# common includes and flags
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||
add_definitions(-DCIRCLE_UTIL)
|
||||
|
||||
find_library(CRYPT_LIBRARY crypt)
|
||||
find_library(NETLIB_LIBRARY nsl socket) # for sign.c, hvis nødvendig
|
||||
|
||||
foreach(tool ${TOOLS})
|
||||
if(${tool} STREQUAL "rebuildIndex")
|
||||
add_executable(rebuildIndex rebuildAsciiIndex.c)
|
||||
else()
|
||||
add_executable(${tool} ${tool}.c)
|
||||
endif()
|
||||
|
||||
# Set output location
|
||||
set_target_properties(${tool} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin
|
||||
)
|
||||
|
||||
# Link to libcrypt for asciipasswd
|
||||
if(${tool} STREQUAL "asciipasswd" AND CRYPT_LIBRARY)
|
||||
target_link_libraries(${tool} ${CRYPT_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Link to netlib for sign
|
||||
if(${tool} STREQUAL "sign" AND NETLIB_LIBRARY)
|
||||
target_link_libraries(${tool} ${NETLIB_LIBRARY})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
add_custom_target(utils DEPENDS ${TOOLS})
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue