Skip to content

Commit 1be311e

Browse files
committed
feat: Build the fun utils when cross-compiling to Windows
While fun utils are of very low quality, both code-wise and usage-wise -- not checking for failed mallocs, not offering usage instructions, etc., there are a couple of them that Windows users might find useful, like the vanity key generators or a savedata creator, for example. The building of the fun utils was broken on Windows due to the utils failing to find sodium.h, as no libsodium include dirs were set on the fun utils.
1 parent 88133f8 commit 1be311e

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

other/docker/windows/build_toxcore.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,14 @@ build() {
7777
-DENABLE_STATIC=ON \
7878
-DSTRICT_ABI=ON \
7979
-DEXPERIMENTAL_API=ON \
80+
-DBUILD_FUN_UTILS=ON \
8081
-DCMAKE_EXE_LINKER_FLAGS="-static" \
8182
-DCMAKE_SHARED_LINKER_FLAGS="-static" \
8283
"${EXTRA_CMAKE_FLAGS_ARRAY[@]}" \
8384
-S ..
8485
cmake --build . --target install --parallel "$(nproc)"
86+
# CMake doesn't install fun utils, so do it manually
87+
cp -a other/fun/*.exe "$RESULT_PREFIX_DIR/bin/"
8588

8689
if [ "$ENABLE_TEST" = "true" ]; then
8790
rm -rf /root/.wine

other/fun/CMakeLists.txt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,48 @@ function(target_link_toxcore target)
66
endif()
77
endfunction()
88

9+
function(target_link_sodium target)
10+
if(TARGET unofficial-sodium::sodium)
11+
target_link_libraries(${target} PRIVATE unofficial-sodium::sodium)
12+
else()
13+
target_link_libraries(${target} PRIVATE ${LIBSODIUM_LIBRARIES})
14+
target_link_directories(${target} PRIVATE ${LIBSODIUM_LIBRARY_DIRS})
15+
target_include_directories(${target} SYSTEM PRIVATE ${LIBSODIUM_INCLUDE_DIRS})
16+
target_compile_options(${target} PRIVATE ${LIBSODIUM_CFLAGS_OTHER})
17+
endif()
18+
endfunction()
19+
920
add_executable(save-generator save-generator.c)
1021
target_link_libraries(save-generator PRIVATE misc_tools)
1122
target_link_toxcore(save-generator)
1223

1324
add_executable(strkey strkey.c)
14-
target_link_libraries(strkey PRIVATE ${LIBSODIUM_LIBRARIES})
15-
target_link_toxcore(strkey)
25+
target_link_sodium(strkey)
1626

1727
add_executable(create_bootstrap_keys create_bootstrap_keys.c)
18-
target_link_libraries(create_bootstrap_keys PRIVATE ${LIBSODIUM_LIBRARIES})
19-
target_link_toxcore(create_bootstrap_keys)
28+
target_link_sodium(create_bootstrap_keys)
2029

2130
add_executable(create_minimal_savedata create_minimal_savedata.c)
22-
target_link_libraries(create_minimal_savedata PRIVATE ${LIBSODIUM_LIBRARIES})
31+
target_link_sodium(create_minimal_savedata)
2332

2433
add_executable(create_savedata create_savedata.c)
25-
target_link_libraries(create_savedata PRIVATE ${LIBSODIUM_LIBRARIES})
34+
target_link_sodium(create_savedata)
2635
target_link_toxcore(create_savedata)
2736

2837
add_executable(sign sign.c)
29-
target_link_libraries(sign PRIVATE ${LIBSODIUM_LIBRARIES} misc_tools)
38+
target_link_libraries(sign PRIVATE misc_tools)
39+
target_link_sodium(sign)
3040

3141
add_executable(cracker_simple cracker_simple.c)
32-
target_link_libraries(cracker_simple ${LIBSODIUM_LIBRARIES} misc_tools)
42+
target_link_libraries(cracker_simple PRIVATE misc_tools)
43+
target_link_sodium(cracker_simple)
3344

3445
# MSVC doesn't support OpenMP
3546
if(NOT MSVC)
3647
find_package(OpenMP)
3748
if(OpenMP_C_FOUND)
3849
add_executable(cracker cracker.c)
39-
target_link_libraries(cracker PRIVATE OpenMP::OpenMP_C ${LIBSODIUM_LIBRARIES})
50+
target_link_sodium(cracker)
51+
target_link_libraries(cracker PRIVATE OpenMP::OpenMP_C)
4052
endif()
4153
endif()

0 commit comments

Comments
 (0)