CMakeLists.txt 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. cmake_minimum_required(VERSION 3.11)
  2. project(rAthena)
  3. # Configure CMake Modules
  4. list(APPEND CMAKE_MODULE_PATH
  5. "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake"
  6. "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
  7. # options
  8. set(PACKETVER 20211103 CACHE STRING "Sets the PACKETVER define of the servers (see src/common/mmo.hpp)")
  9. option(ENABLE_PRERENEWAL "Whether or not to enable Pre-renewal (default=OFF)" OFF)
  10. option(ENABLE_WEB_SERVER "Build web-server (default=ON)" ON)
  11. option(ENABLE_RDTSC "Enable RDTSC instruction as a timing source (default=OFF)" OFF)
  12. option(ENABLE_EXTRA_DEBUG_CODE "Enable extra debug code (default=OFF)" OFF)
  13. option(ENABLE_MEMMGR "Enable memory manager (default=ON)" ON)
  14. # TODO(vstumpf): If no one uses this, we can just remove it
  15. # set(ENABLE_MEMORY "system" CACHE STRING "Enable memory library (default=system)")
  16. option(ENABLE_PROFILER "Enable profiler (default=OFF)" OFF)
  17. option(ENABLE_EXTRA_BUILDBOT_CODE "Enable extra buildbot code (default=OFF)" OFF)
  18. option(ENABLE_EPOLL "Use epoll instead of select (default=OFF)" OFF)
  19. option(ENABLE_VIP "Enable VIP system (default=OFF)" OFF)
  20. # Set a default build type if none was specified
  21. set(default_build_type "Release")
  22. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  23. set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
  24. STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE)
  25. message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
  26. endif()
  27. if(CMAKE_GENERATOR MATCHES "Visual Studio")
  28. set(ENABLE_MSVC_PARALLEL ON CACHE STRING "\
  29. Enables /MP flag for parallel builds using MSVC. Specify an integer value to control \
  30. the number of threads used (Only works on versions of Visual Studio). Setting to ON \
  31. lets the toolchain decide how many threads to use. Set to OFF to disable /MP completely." )
  32. if(ENABLE_MSVC_PARALLEL)
  33. if(ENABLE_MSVC_PARALLEL GREATER 0)
  34. string(APPEND CMAKE_C_FLAGS " /MP${ENABLE_MSVC_PARALLEL}")
  35. string(APPEND CMAKE_CXX_FLAGS " /MP${ENABLE_MSVC_PARALLEL}")
  36. else()
  37. string(APPEND CMAKE_C_FLAGS " /MP")
  38. string(APPEND CMAKE_CXX_FLAGS " /MP")
  39. endif()
  40. endif()
  41. endif()
  42. #
  43. # Prevent building in the source directory by default
  44. #
  45. if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR )
  46. message( FATAL_ERROR
  47. "Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n"
  48. "Example: (build in subdir 'build' and install to source dir)\n"
  49. " rm -f CMakeCache.txt\n"
  50. " mkdir build\n"
  51. " cd build\n"
  52. " cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n"
  53. " make install\n"
  54. " cd ..\n"
  55. " rm -rf build\n")
  56. endif()
  57. if(WIN32)
  58. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  59. endif()
  60. # Configure C++ Standard
  61. set(CMAKE_CXX_STANDARD 17)
  62. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  63. # Set build directories
  64. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
  65. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
  66. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  67. add_subdirectory(db)
  68. add_subdirectory(conf)
  69. add_subdirectory(3rdparty)
  70. add_subdirectory(src)
  71. add_subdirectory(tools)
  72. add_custom_target(server
  73. DEPENDS login-server char-server map-server web-server scripts
  74. )