Use CMake list directives where appropriate

I think this communicates the intent a little better than using a `set`
directive, and it makes the code a little less verbose, too.
This commit is contained in:
JosiahWI 2024-12-03 09:52:15 -06:00 committed by GitHub
parent 818bca68d1
commit 03813a5b5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 19 deletions

View file

@ -273,7 +273,7 @@ set(PLATFORM_LIBS Threads::Threads)
if(WIN32) if(WIN32)
# Windows # Windows
if(MSVC) # MSVC Specifics if(MSVC) # MSVC Specifics
set(PLATFORM_LIBS dbghelp.lib ${PLATFORM_LIBS}) list(APPEND PLATFORM_LIBS dbghelp.lib)
# Surpress some useless warnings # Surpress some useless warnings
add_compile_options(/W1) add_compile_options(/W1)
add_compile_definitions( add_compile_definitions(
@ -285,7 +285,7 @@ if(WIN32)
NOMINMAX NOMINMAX
) )
endif() endif()
set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib winmm.lib ${PLATFORM_LIBS}) list(APPEND PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib winmm.lib)
set(EXTRA_DLL "" CACHE FILEPATH "Optional paths to additional DLLs that should be packaged") set(EXTRA_DLL "" CACHE FILEPATH "Optional paths to additional DLLs that should be packaged")
@ -312,28 +312,28 @@ if(WIN32)
endif() endif()
else() else()
# Unix probably # Unix probably
set(PLATFORM_LIBS ${PLATFORM_LIBS} ${CMAKE_DL_LIBS}) list(APPEND PLATFORM_LIBS ${CMAKE_DL_LIBS})
if(APPLE) if(APPLE)
set(PLATFORM_LIBS "-framework CoreFoundation" ${PLATFORM_LIBS}) list(APPEND PLATFORM_LIBS "-framework CoreFoundation")
else() else()
check_library_exists(rt clock_gettime "" HAVE_LIBRT) check_library_exists(rt clock_gettime "" HAVE_LIBRT)
if (HAVE_LIBRT) if (HAVE_LIBRT)
set(PLATFORM_LIBS -lrt ${PLATFORM_LIBS}) list(APPEND PLATFORM_LIBS -lrt)
endif(HAVE_LIBRT) endif(HAVE_LIBRT)
endif(APPLE) endif(APPLE)
find_library(ICONV_LIBRARY iconv) find_library(ICONV_LIBRARY iconv)
mark_as_advanced(ICONV_LIBRARY) mark_as_advanced(ICONV_LIBRARY)
if (ICONV_LIBRARY) if (ICONV_LIBRARY)
set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY}) list(APPEND PLATFORM_LIBS ${ICONV_LIBRARY})
endif() endif()
if (HAIKU) if (HAIKU)
set(PLATFORM_LIBS ${PLATFORM_LIBS} network) list(APPEND PLATFORM_LIBS network)
endif() endif()
if (ANDROID) if (ANDROID)
set(PLATFORM_LIBS ${PLATFORM_LIBS} android log) list(APPEND PLATFORM_LIBS android log)
endif() endif()
endif() endif()
@ -347,7 +347,7 @@ if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
check_c_source_compiles("int main(){}" HAVE_LINK_ATOMIC) check_c_source_compiles("int main(){}" HAVE_LINK_ATOMIC)
set(CMAKE_REQUIRED_LIBRARIES "") set(CMAKE_REQUIRED_LIBRARIES "")
if(HAVE_LINK_ATOMIC) if(HAVE_LINK_ATOMIC)
set(PLATFORM_LIBS ${PLATFORM_LIBS} "-latomic") list(APPEND PLATFORM_LIBS "-latomic")
endif() endif()
endif() endif()
@ -471,21 +471,21 @@ set(common_SRCS
) )
if(ANDROID) if(ANDROID)
set(common_SRCS ${common_SRCS} porting_android.cpp) list(APPEND common_SRCS porting_android.cpp)
endif() endif()
if(BUILD_UNITTESTS) if(BUILD_UNITTESTS)
add_subdirectory(unittest) add_subdirectory(unittest)
set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS}) list(APPEND common_SRCS ${UNITTEST_SRCS})
endif() endif()
if(BUILD_BENCHMARKS) if(BUILD_BENCHMARKS)
add_subdirectory(benchmark) add_subdirectory(benchmark)
set(common_SRCS ${common_SRCS} ${BENCHMARK_SRCS}) list(APPEND common_SRCS ${BENCHMARK_SRCS})
endif() endif()
if(BUILD_UNITTESTS OR BUILD_BENCHMARKS) if(BUILD_UNITTESTS OR BUILD_BENCHMARKS)
set(common_SRCS ${common_SRCS} catch.cpp) list(APPEND common_SRCS catch.cpp)
endif() endif()
# This gives us the icon and file version information # This gives us the icon and file version information
@ -516,8 +516,7 @@ if (BUILD_CLIENT)
add_subdirectory(irrlicht_changes) add_subdirectory(irrlicht_changes)
endif(BUILD_CLIENT) endif(BUILD_CLIENT)
set(client_SRCS list(APPEND client_SRCS
${client_SRCS}
${common_SRCS} ${common_SRCS}
${gui_SRCS} ${gui_SRCS}
${client_network_SRCS} ${client_network_SRCS}
@ -526,11 +525,11 @@ set(client_SRCS
) )
if(BUILD_UNITTESTS) if(BUILD_UNITTESTS)
set(client_SRCS ${client_SRCS} ${UNITTEST_CLIENT_SRCS}) list(APPEND client_SRCS ${UNITTEST_CLIENT_SRCS})
endif() endif()
if(BUILD_BENCHMARKS) if(BUILD_BENCHMARKS)
set(client_SRCS ${client_SRCS} ${BENCHMARK_CLIENT_SRCS}) list(APPEND client_SRCS ${BENCHMARK_CLIENT_SRCS})
endif() endif()
# Server sources # Server sources
@ -1106,7 +1105,7 @@ elseif (USE_GETTEXT)
COMMENT "mo-update [${LOCALE}]: Creating mo file." COMMENT "mo-update [${LOCALE}]: Creating mo file."
) )
set(MO_FILES ${MO_FILES} ${MO_FILE_PATH}) list(APPEND MO_FILES ${MO_FILE_PATH})
endforeach() endforeach()
add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES}) add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES})

View file

@ -1,7 +1,7 @@
set(sound_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/sound.cpp) set(sound_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/sound.cpp)
if(USE_SOUND) if(USE_SOUND)
set(sound_SRCS ${sound_SRCS} list(APPEND sound_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/sound/al_extensions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sound/al_extensions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sound/al_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sound/al_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sound/ogg_file.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sound/ogg_file.cpp