diff --git a/cmake/options.cmake b/cmake/options.cmake index 05d8e9e0d6895..9233575aad5ff 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -37,6 +37,7 @@ option(TOOLS "Build map/vmap/mmap extraction/assembler tools" option(USE_SCRIPTPCH "Use precompiled headers when compiling scripts" 1) option(USE_COREPCH "Use precompiled headers when compiling servers" 1) option(WITH_DYNAMIC_LINKING "Enable dynamic library linking." 0) +option(WITH_FILESYSTEM_WATCHER "Include filesystem watcher library" 0) IsDynamicLinkingRequired(WITH_DYNAMIC_LINKING_FORCED) if(WITH_DYNAMIC_LINKING AND WITH_DYNAMIC_LINKING_FORCED) set(WITH_DYNAMIC_LINKING_FORCED OFF) @@ -46,6 +47,9 @@ if(WITH_DYNAMIC_LINKING OR WITH_DYNAMIC_LINKING_FORCED) else() set(BUILD_SHARED_LIBS OFF) endif() +if(WITH_FILESYSTEM_WATCHER OR BUILD_SHARED_LIBS) + set(BUILD_EFSW ON) +endif() option(WITH_WARNINGS "Show all warnings during compile" 0) option(WITH_WARNINGS_AS_ERRORS "Treat warnings as errors" 0) option(WITH_COREDEBUG "Include additional debug-code in core" 0) @@ -55,8 +59,8 @@ option(COPY_CONF "Copy authserver and worldserver .conf.dist files to the set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.") set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders) option(WITHOUT_GIT "Disable the GIT testing routines" 0) -option(BUILD_TESTING "Build test suite" 0) +option(BUILD_TESTING "Build test suite" 0) if(UNIX) - option(USE_LD_GOLD "Use GNU gold linker" 0) + option(USE_LD_GOLD "Use GNU gold linker" 0) endif() diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 234995298c899..0aa598ca46401 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -31,10 +31,13 @@ if(SERVERS) add_subdirectory(readline) add_subdirectory(gsoap) add_subdirectory(rapidjson) - add_subdirectory(efsw) add_subdirectory(protobuf) endif() +if(SERVERS AND BUILD_EFSW) + add_subdirectory(efsw) +endif() + if(TOOLS) add_subdirectory(CascLib) endif() diff --git a/dep/efsw/CMakeLists.txt b/dep/efsw/CMakeLists.txt index 9817525931cf8..b7dab807724ae 100644 --- a/dep/efsw/CMakeLists.txt +++ b/dep/efsw/CMakeLists.txt @@ -1,131 +1,127 @@ -if (BUILD_SHARED_LIBS) - set(EFSW_CPP_SOURCE - src/efsw/Atomic.hpp - src/efsw/base.hpp - src/efsw/Debug.cpp - src/efsw/Debug.hpp - src/efsw/DirectorySnapshot.cpp - src/efsw/DirectorySnapshot.hpp - src/efsw/DirectorySnapshotDiff.cpp - src/efsw/DirectorySnapshotDiff.hpp - src/efsw/DirWatcherGeneric.cpp - src/efsw/DirWatcherGeneric.hpp - src/efsw/FileInfo.cpp - src/efsw/FileInfo.hpp - src/efsw/FileSystem.cpp - src/efsw/FileSystem.hpp - src/efsw/FileWatcher.cpp - src/efsw/FileWatcherCWrapper.cpp - src/efsw/FileWatcherGeneric.cpp - src/efsw/FileWatcherGeneric.hpp - src/efsw/FileWatcherImpl.cpp - src/efsw/FileWatcherImpl.hpp - src/efsw/Lock.hpp - src/efsw/Log.cpp - src/efsw/Mutex.cpp - src/efsw/Mutex.hpp - src/efsw/sophist.h - src/efsw/String.cpp - src/efsw/String.hpp - src/efsw/System.cpp - src/efsw/System.hpp - src/efsw/Thread.cpp - src/efsw/Thread.hpp - src/efsw/Utf.hpp - src/efsw/Watcher.cpp - src/efsw/Watcher.hpp - src/efsw/WatcherGeneric.cpp - src/efsw/WatcherGeneric.hpp - src/efsw/platform/platformimpl.hpp - ) +set(EFSW_CPP_SOURCE + src/efsw/Atomic.hpp + src/efsw/base.hpp + src/efsw/Debug.cpp + src/efsw/Debug.hpp + src/efsw/DirectorySnapshot.cpp + src/efsw/DirectorySnapshot.hpp + src/efsw/DirectorySnapshotDiff.cpp + src/efsw/DirectorySnapshotDiff.hpp + src/efsw/DirWatcherGeneric.cpp + src/efsw/DirWatcherGeneric.hpp + src/efsw/FileInfo.cpp + src/efsw/FileInfo.hpp + src/efsw/FileSystem.cpp + src/efsw/FileSystem.hpp + src/efsw/FileWatcher.cpp + src/efsw/FileWatcherCWrapper.cpp + src/efsw/FileWatcherGeneric.cpp + src/efsw/FileWatcherGeneric.hpp + src/efsw/FileWatcherImpl.cpp + src/efsw/FileWatcherImpl.hpp + src/efsw/Lock.hpp + src/efsw/Log.cpp + src/efsw/Mutex.cpp + src/efsw/Mutex.hpp + src/efsw/sophist.h + src/efsw/String.cpp + src/efsw/String.hpp + src/efsw/System.cpp + src/efsw/System.hpp + src/efsw/Thread.cpp + src/efsw/Thread.hpp + src/efsw/Utf.hpp + src/efsw/Watcher.cpp + src/efsw/Watcher.hpp + src/efsw/WatcherGeneric.cpp + src/efsw/WatcherGeneric.hpp + src/efsw/platform/platformimpl.hpp +) - if (WIN32) - list (APPEND EFSW_CPP_SOURCE - src/efsw/platform/win/FileSystemImpl.cpp - src/efsw/platform/win/FileSystemImpl.hpp - src/efsw/platform/win/MutexImpl.cpp - src/efsw/platform/win/MutexImpl.hpp - src/efsw/platform/win/SystemImpl.cpp - src/efsw/platform/win/SystemImpl.hpp - src/efsw/platform/win/ThreadImpl.cpp - src/efsw/platform/win/ThreadImpl.hpp) - else () - list (APPEND EFSW_CPP_SOURCE - src/efsw/platform/posix/FileSystemImpl.cpp - src/efsw/platform/posix/FileSystemImpl.hpp - src/efsw/platform/posix/MutexImpl.cpp - src/efsw/platform/posix/MutexImpl.hpp - src/efsw/platform/posix/SystemImpl.cpp - src/efsw/platform/posix/SystemImpl.hpp - src/efsw/platform/posix/ThreadImpl.cpp - src/efsw/platform/posix/ThreadImpl.hpp) - endif() +if (WIN32) + list (APPEND EFSW_CPP_SOURCE + src/efsw/platform/win/FileSystemImpl.cpp + src/efsw/platform/win/FileSystemImpl.hpp + src/efsw/platform/win/MutexImpl.cpp + src/efsw/platform/win/MutexImpl.hpp + src/efsw/platform/win/SystemImpl.cpp + src/efsw/platform/win/SystemImpl.hpp + src/efsw/platform/win/ThreadImpl.cpp + src/efsw/platform/win/ThreadImpl.hpp) +else () + list (APPEND EFSW_CPP_SOURCE + src/efsw/platform/posix/FileSystemImpl.cpp + src/efsw/platform/posix/FileSystemImpl.hpp + src/efsw/platform/posix/MutexImpl.cpp + src/efsw/platform/posix/MutexImpl.hpp + src/efsw/platform/posix/SystemImpl.cpp + src/efsw/platform/posix/SystemImpl.hpp + src/efsw/platform/posix/ThreadImpl.cpp + src/efsw/platform/posix/ThreadImpl.hpp) +endif() - if (APPLE) - list (APPEND EFSW_CPP_SOURCE - src/efsw/FileWatcherFSEvents.cpp - src/efsw/FileWatcherFSEvents.hpp - src/efsw/FileWatcherKqueue.cpp - src/efsw/FileWatcherKqueue.hpp - src/efsw/WatcherFSEvents.cpp - src/efsw/WatcherFSEvents.hpp - src/efsw/WatcherKqueue.cpp - src/efsw/WatcherKqueue.hpp) - set(OPTIONAL_LINK_LIBRARIES "-framework CoreFoundation" "-framework CoreServices") - elseif (WIN32) - list (APPEND EFSW_CPP_SOURCE - src/efsw/FileWatcherWin32.cpp - src/efsw/FileWatcherWin32.hpp - src/efsw/WatcherWin32.cpp - src/efsw/WatcherWin32.hpp) - elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +if (APPLE) + list (APPEND EFSW_CPP_SOURCE + src/efsw/FileWatcherFSEvents.cpp + src/efsw/FileWatcherFSEvents.hpp + src/efsw/FileWatcherKqueue.cpp + src/efsw/FileWatcherKqueue.hpp + src/efsw/WatcherFSEvents.cpp + src/efsw/WatcherFSEvents.hpp + src/efsw/WatcherKqueue.cpp + src/efsw/WatcherKqueue.hpp) + set(OPTIONAL_LINK_LIBRARIES "-framework CoreFoundation" "-framework CoreServices") +elseif (WIN32) + list (APPEND EFSW_CPP_SOURCE + src/efsw/FileWatcherWin32.cpp + src/efsw/FileWatcherWin32.hpp + src/efsw/WatcherWin32.cpp + src/efsw/WatcherWin32.hpp) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + list (APPEND EFSW_CPP_SOURCE + src/efsw/FileWatcherInotify.cpp + src/efsw/FileWatcherInotify.hpp + src/efsw/WatcherInotify.cpp + src/efsw/WatcherInotify.hpp) + find_path(EFSW_INOTIFY_H + NAMES + sys/inotify.h + NO_CACHE + ) + if (EFSW_INOTIFY_H STREQUAL "EFSW_INOTIFY_H-NOTFOUND") list (APPEND EFSW_CPP_SOURCE - src/efsw/FileWatcherInotify.cpp - src/efsw/FileWatcherInotify.hpp - src/efsw/WatcherInotify.cpp - src/efsw/WatcherInotify.hpp) - find_path(EFSW_INOTIFY_H - NAMES - sys/inotify.h - NO_CACHE + src/efsw/inotify-nosys.h ) - if (EFSW_INOTIFY_H STREQUAL "EFSW_INOTIFY_H-NOTFOUND") - list (APPEND EFSW_CPP_SOURCE - src/efsw/inotify-nosys.h - ) - set(OPTIONAL_COMPILE_DEFINITIONS "-DEFSW_INOTIFY_NOSYS") - endif() - elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - list (APPEND EFSW_CPP_SOURCE - src/efsw/FileWatcherKqueue.cpp - src/efsw/FileWatcherKqueue.hpp - src/efsw/WatcherKqueue.cpp - src/efsw/WatcherKqueue.hpp) + set(OPTIONAL_COMPILE_DEFINITIONS "-DEFSW_INOTIFY_NOSYS") endif() +elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + list (APPEND EFSW_CPP_SOURCE + src/efsw/FileWatcherKqueue.cpp + src/efsw/FileWatcherKqueue.hpp + src/efsw/WatcherKqueue.cpp + src/efsw/WatcherKqueue.hpp) +endif() - add_library(efsw STATIC ${EFSW_CPP_SOURCE}) + add_library(efsw STATIC ${EFSW_CPP_SOURCE}) - target_include_directories(efsw - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src) +target_include_directories(efsw + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src) - target_compile_definitions(efsw - PRIVATE - ${OPTIONAL_COMPILE_DEFINITIONS}) +target_compile_definitions(efsw + PRIVATE + ${OPTIONAL_COMPILE_DEFINITIONS}) - target_link_libraries(efsw - PRIVATE - trinity-dependency-interface - PUBLIC - threads - ${OPTIONAL_LINK_LIBRARIES}) +target_link_libraries(efsw + PRIVATE + trinity-dependency-interface + PUBLIC + threads + ${OPTIONAL_LINK_LIBRARIES}) - set_target_properties(efsw - PROPERTIES - FOLDER - "dep") -else () - add_library(efsw INTERFACE IMPORTED GLOBAL) -endif () +set_target_properties(efsw + PROPERTIES + FOLDER + "dep") diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt index ccd18ef8e622d..763fb83463aea 100644 --- a/src/server/game/CMakeLists.txt +++ b/src/server/game/CMakeLists.txt @@ -8,11 +8,29 @@ # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# Initialize a variable to hold Eluna directories to exclude +set(ELUNA_EXCLUDE_DIRS) + +# Exclude files in the LuaEngine directory for Mangos, CMangos and VMangos +# or the entire directory if Eluna is disabled +if(ELUNA) + list(APPEND ELUNA_EXCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/methods/Mangos + ${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/methods/CMangos + ${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/methods/VMangos + ) +else() + list(APPEND ELUNA_EXCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine + ) +endif() + CollectSourceFiles( ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES # Exclude - ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders) + ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders + ${ELUNA_EXCLUDE_DIRS}) if(USE_COREPCH) set(PRIVATE_PCH_HEADER PrecompiledHeaders/gamePCH.h) @@ -24,8 +42,9 @@ CollectIncludeDirectories( ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC_INCLUDES # Exclude - ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders) - + ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders + ${ELUNA_EXCLUDE_DIRS}) + # Provide an interface target for the game project to allow # dependent projects to build meanwhile. add_library(game-interface INTERFACE) @@ -49,9 +68,14 @@ target_include_directories(game target_link_libraries(game PRIVATE trinity-core-interface - efsw PUBLIC game-interface) + +if(TARGET efsw) + target_link_libraries(game + PRIVATE + efsw) +endif() set_target_properties(game PROPERTIES