340 lines
13 KiB
CMake
340 lines
13 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
project(mars_nwe)
|
|
|
|
# Enable CTest from the top-level build tree so tests added by subprojects,
|
|
# such as third_party/flaim, are visible to `ctest` when it is run from the
|
|
# mars-nwe build directory.
|
|
include(CTest)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
|
|
|
|
enable_language(C)
|
|
|
|
SET (VERSION_MAJOR "0")
|
|
SET (VERSION_MINOR "99")
|
|
SET (VERSION_PATCH "28")
|
|
|
|
SET (MARS_NWE_VERSION_BASE "${VERSION_MAJOR}.${VERSION_MINOR}.pl${VERSION_PATCH}")
|
|
SET (MARS_NWE_VERSION "${MARS_NWE_VERSION_BASE}")
|
|
|
|
set(MARS_NWE_BUILD_DATE "" CACHE STRING "Mars NWE build date used in server info (DD-Mon-YY)")
|
|
if(MARS_NWE_BUILD_DATE STREQUAL "")
|
|
string(TIMESTAMP MARS_NWE_BUILD_DATE "%d-%b-%y" UTC)
|
|
endif()
|
|
|
|
find_package(Git QUIET)
|
|
|
|
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
execute_process(
|
|
COMMAND "${GIT_EXECUTABLE}" describe --tags --exact-match
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
OUTPUT_VARIABLE GIT_EXACT_TAG
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
ERROR_QUIET
|
|
)
|
|
|
|
if(GIT_EXACT_TAG STREQUAL "v${MARS_NWE_VERSION_BASE}" OR
|
|
GIT_EXACT_TAG STREQUAL "${MARS_NWE_VERSION_BASE}")
|
|
set(MARS_NWE_VERSION "${MARS_NWE_VERSION_BASE}")
|
|
else()
|
|
execute_process(
|
|
COMMAND "${GIT_EXECUTABLE}" rev-list --count HEAD
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
OUTPUT_VARIABLE GIT_COMMIT_COUNT
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
execute_process(
|
|
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
OUTPUT_VARIABLE GIT_SHORT_SHA
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
execute_process(
|
|
COMMAND "${GIT_EXECUTABLE}" diff --quiet
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
RESULT_VARIABLE GIT_DIRTY_RESULT
|
|
)
|
|
|
|
set(MARS_NWE_VERSION
|
|
"${MARS_NWE_VERSION_BASE}-dev.${GIT_COMMIT_COUNT}-g${GIT_SHORT_SHA}")
|
|
|
|
if(NOT GIT_DIRTY_RESULT EQUAL 0)
|
|
string(APPEND MARS_NWE_VERSION "-dirty")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
INCLUDE(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake)
|
|
INCLUDE(${CMAKE_MODULE_PATH}/MarsNweInstallDirs.cmake)
|
|
|
|
# Add options for build
|
|
option(ENABLE_DEBUG "Compile in MARS NWE debug logging code (DO_DEBUG)" OFF)
|
|
option(ENABLE_DEBUG_BUILD "Build with debug compiler flags (-g3 -O0 -fno-omit-frame-pointer)" OFF)
|
|
option(ENABLE_DEBUG_DOSUTILS "Enable NCP 17/02 debugging support for mars_dosutils" OFF)
|
|
option(ENABLE_BURSTMODE "Enable experimental Packet Burst support" ON)
|
|
option(MAINTAINER_BUILD "Enable maintainer-only test helpers and diagnostics" OFF)
|
|
option(ENABLE_INTERNAL_RIP_SAP "Should we build Mars Nwe with Internal Router?" ON)
|
|
option(ENABLE_SHADOW_PWD "Should we build Mars Nwe with Shadow Password Support?" ON)
|
|
option(ENABLE_QUOTA_SUPPORT "Should we build Mars Nwe with Quota Support?" ON)
|
|
option(ENABLE_XATTR "Should we build Mars Nwe with extended attribute support?" ON)
|
|
option(MARS_NWE_INSTALL_DOSUTILS "Install DOS client utilities" ON)
|
|
option(MARS_NWE_INSTALL_NEW_DOSUTILS "Install the new/experimental DOS client utilities instead of legacy netold.exe" OFF)
|
|
option(MARS_NWE_BUILD_TESTS "Build optional mars_nwe integration tests" OFF)
|
|
option(MARS_NWE_BUILD_NWFS_TESTS "Build libnwfs unit tests" OFF)
|
|
option(ENABLE_DIRECTORY "Build the optional nwdirectory/TinyLDAP subsystem" OFF)
|
|
option(MARS_NWE_BUILD_MATRIXSSL_PROGRAMS "Build MatrixSSL example apps, tests and helper tools" OFF)
|
|
|
|
# Maintainer builds rebuild the DOS tools from source. In that mode install
|
|
# the freshly built/new DOS utility set automatically so developers do not have
|
|
# to set both MAINTAINER_BUILD and MARS_NWE_INSTALL_NEW_DOSUTILS.
|
|
if(MAINTAINER_BUILD AND NOT MARS_NWE_INSTALL_NEW_DOSUTILS)
|
|
set(MARS_NWE_INSTALL_NEW_DOSUTILS ON CACHE BOOL
|
|
"Install the new/experimental DOS client utilities instead of legacy netold.exe"
|
|
FORCE)
|
|
endif()
|
|
|
|
set(MARS_NWE_SMART_ADMIN_GROUP "root" CACHE STRING "Unix group allowed to log in to the SMArT/nwwebui admin interface")
|
|
|
|
|
|
# ENABLE_DEBUG controls the legacy DO_DEBUG code paths used by XDPRINTF().
|
|
# ENABLE_DEBUG_BUILD is separate and only changes compiler flags / build type.
|
|
# This allows release builds with compiled-in Mars debug logging, and also
|
|
# explicit -g/-O0 builds when debugging the server with gdb or valgrind.
|
|
if(ENABLE_DEBUG_BUILD)
|
|
if(NOT CMAKE_CONFIGURATION_TYPES)
|
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
|
|
endif()
|
|
|
|
add_compile_options(
|
|
$<$<COMPILE_LANGUAGE:C>:-g3>
|
|
$<$<COMPILE_LANGUAGE:C>:-O0>
|
|
$<$<COMPILE_LANGUAGE:C>:-fno-omit-frame-pointer>
|
|
)
|
|
endif()
|
|
|
|
if(MAINTAINER_BUILD)
|
|
add_compile_definitions(MAINTAINER_BUILD)
|
|
endif()
|
|
|
|
if(NOT CMAKE_CONFIGURATION_TYPES)
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
|
"Debug" "Release" "RelWithDebInfo" "MinSizeRel")
|
|
endif()
|
|
|
|
IF (ENABLE_DEBUG)
|
|
SET (MARS_NWE_DEBUG "1")
|
|
ELSE (ENABLE_DEBUG)
|
|
SET (MARS_NWE_DEBUG "0")
|
|
ENDIF (ENABLE_DEBUG)
|
|
|
|
IF (ENABLE_DEBUG_DOSUTILS)
|
|
SET (MARS_NWE_DEBUG_DOSUTILS "1")
|
|
ELSE (ENABLE_DEBUG_DOSUTILS)
|
|
SET (MARS_NWE_DEBUG_DOSUTILS "0")
|
|
ENDIF (ENABLE_DEBUG_DOSUTILS)
|
|
|
|
IF (ENABLE_BURSTMODE)
|
|
SET (MARS_NWE_ENABLE_BURSTMODE "1")
|
|
ELSE (ENABLE_BURSTMODE)
|
|
SET (MARS_NWE_ENABLE_BURSTMODE "0")
|
|
ENDIF (ENABLE_BURSTMODE)
|
|
|
|
IF (ENABLE_INTERNAL_RIP_SAP)
|
|
SET (MARS_NWE_INTERNAL_RIP_SAP "1")
|
|
ELSE (ENABLE_INTERNAL_RIP_SAP)
|
|
SET (MARS_NWE_INTERNAL_RIP_SAP "0")
|
|
ENDIF (ENABLE_INTERNAL_RIP_SAP)
|
|
|
|
IF (ENABLE_SHADOW_PWD)
|
|
SET (MARS_NWE_SHADOW_PWD "1")
|
|
ELSE (ENABLE_SHADOW_PWD)
|
|
SET (MARS_NWE_SHADOW_PWD "0")
|
|
ENDIF (ENABLE_SHADOW_PWD)
|
|
|
|
find_package(Quota QUIET)
|
|
IF (ENABLE_QUOTA_SUPPORT AND QUOTA_FOUND)
|
|
SET (MARS_NWE_QUOTA_SUPPORT "1")
|
|
ELSE (ENABLE_QUOTA_SUPPORT AND QUOTA_FOUND)
|
|
SET (MARS_NWE_QUOTA_SUPPORT "0")
|
|
ENDIF (ENABLE_QUOTA_SUPPORT AND QUOTA_FOUND)
|
|
|
|
find_package(XAttr QUIET)
|
|
IF (ENABLE_XATTR AND XATTR_FOUND)
|
|
SET (MARS_NWE_XATTR_SUPPORT "1")
|
|
ELSE (ENABLE_XATTR AND XATTR_FOUND)
|
|
SET (MARS_NWE_XATTR_SUPPORT "0")
|
|
ENDIF (ENABLE_XATTR AND XATTR_FOUND)
|
|
|
|
IF (NOT MAX_CONNECTIONS)
|
|
SET (MAX_CONNECTIONS "50")
|
|
ENDIF (NOT MAX_CONNECTIONS)
|
|
|
|
IF (NOT MAX_VOLS)
|
|
SET (MAX_VOLS "50")
|
|
ENDIF (NOT MAX_VOLS)
|
|
|
|
IF (NOT MAX_FILES)
|
|
SET (MAX_FILES "256")
|
|
ENDIF (NOT MAX_FILES)
|
|
|
|
find_package(Crypt REQUIRED)
|
|
find_package(GDBM REQUIRED)
|
|
|
|
find_package(PAM REQUIRED)
|
|
find_package(DL REQUIRED)
|
|
find_library(ACL_LIBRARY acl)
|
|
find_path(ACL_INCLUDE_DIR sys/acl.h)
|
|
set(MARS_NWE_ACL_LIBRARIES "")
|
|
set(MARS_NWE_ACL_INCLUDE_DIRS "")
|
|
if(ACL_LIBRARY AND ACL_INCLUDE_DIR)
|
|
set(MARS_NWE_ACL_LIBRARIES ${ACL_LIBRARY})
|
|
set(MARS_NWE_ACL_INCLUDE_DIRS ${ACL_INCLUDE_DIR})
|
|
add_compile_definitions(MARS_NWE_HAVE_POSIX_ACL)
|
|
message(STATUS "POSIX ACL trustee projection: enabled")
|
|
else()
|
|
message(STATUS "POSIX ACL trustee projection: disabled (libacl headers/library not found)")
|
|
endif()
|
|
|
|
if(MARS_NWE_QUOTA_SUPPORT)
|
|
message(STATUS "Quota support: enabled")
|
|
else()
|
|
if(ENABLE_QUOTA_SUPPORT)
|
|
message(STATUS "Quota support: disabled (required headers/symbols not found)")
|
|
else()
|
|
message(STATUS "Quota support: disabled")
|
|
endif()
|
|
endif()
|
|
|
|
if(MARS_NWE_XATTR_SUPPORT)
|
|
message(STATUS "XAttr support: enabled")
|
|
else()
|
|
message(STATUS "XAttr support: disabled")
|
|
endif()
|
|
|
|
if(MARS_NWE_XATTR_SUPPORT)
|
|
message(STATUS "AFP metadata backend: mars_nwe xattrs")
|
|
else()
|
|
message(STATUS "AFP metadata backend: disabled (requires xattr support)")
|
|
endif()
|
|
|
|
# Bundled and vendored dependencies live below third_party/. Keep root at
|
|
# project-policy level; third_party/CMakeLists.txt owns individual dependency
|
|
# checks, pins, local target names and build policy.
|
|
add_subdirectory(third_party)
|
|
|
|
# mars-nwe base libraries and legacy server executables live below src/.
|
|
# Keep the root CMake file at project-policy level; src/CMakeLists.txt owns the
|
|
# src/core, src/nwtui, src/ssl, src/nwfs and legacy executable subdirectories.
|
|
|
|
|
|
# we want to use systemd, if possible
|
|
find_package(PkgConfig QUIET)
|
|
set(SYSTEMD_SERVICES_INSTALL_DIR "" CACHE PATH "Directory for systemd service files")
|
|
INCLUDE(${CMAKE_MODULE_PATH}/systemdservice.cmake)
|
|
INCLUDE(${CMAKE_MODULE_PATH}/cupsutils.cmake)
|
|
|
|
message(STATUS "Mars Nwe version: ${MARS_NWE_VERSION}")
|
|
message(STATUS "bin: ${CMAKE_INSTALL_FULL_BINDIR}")
|
|
message(STATUS "sbin: ${CMAKE_INSTALL_FULL_SBINDIR}")
|
|
message(STATUS "lib: ${CMAKE_INSTALL_FULL_LIBDIR}")
|
|
message(STATUS "include: ${CMAKE_INSTALL_FULL_INCLUDEDIR}")
|
|
message(STATUS "libexec: ${CMAKE_INSTALL_FULL_LIBEXECDIR}")
|
|
message(STATUS "doc: ${CMAKE_INSTALL_FULL_DOCDIR}")
|
|
message(STATUS "man: ${CMAKE_INSTALL_FULL_MANDIR}")
|
|
message(STATUS "sysconf: ${CMAKE_INSTALL_FULL_SYSCONFDIR}")
|
|
message(STATUS "Mars Nwe libexec: ${MARS_NWE_INSTALL_FULL_LIBEXECDIR}")
|
|
message(STATUS "Mars Nwe config: ${MARS_NWE_INSTALL_FULL_CONFDIR}")
|
|
message(STATUS "Mars Nwe data: ${MARS_NWE_DATA_DIR}")
|
|
message(STATUS "Mars Nwe log: ${MARS_NWE_LOG_DIR}")
|
|
message(STATUS "Mars Nwe pid: ${MARS_NWE_PID_DIR}")
|
|
message(STATUS "SMArT admin group: ${MARS_NWE_SMART_ADMIN_GROUP}")
|
|
message(STATUS "Install DOS utilities: ${MARS_NWE_INSTALL_DOSUTILS}")
|
|
message(STATUS "Install new DOS utilities: ${MARS_NWE_INSTALL_NEW_DOSUTILS}")
|
|
message(STATUS "Build DOS utilities: ${MAINTAINER_BUILD} (maintainer build)")
|
|
message(STATUS "Build nwdirectory: ${ENABLE_DIRECTORY}")
|
|
message(STATUS "Build FLAIM storage: ${ENABLE_DIRECTORY} (required by nwdirectory)")
|
|
message(STATUS "Build MatrixSSL programs: ${MARS_NWE_BUILD_MATRIXSSL_PROGRAMS}")
|
|
message(STATUS "Build nwcore: ON")
|
|
message(STATUS "Build nwtui: ON")
|
|
message(STATUS "Build nwssl: ON")
|
|
message(STATUS "Maintainer build: ${MAINTAINER_BUILD}")
|
|
message(STATUS "Packet Burst support: ${ENABLE_BURSTMODE}")
|
|
|
|
# put the include dirs which are in the source or build tree
|
|
# before all other include dirs, so the headers in the sources
|
|
# are prefered over the already installed ones
|
|
# since cmake 2.4.1
|
|
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
|
|
|
|
add_custom_target(uninstall
|
|
"${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")
|
|
|
|
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
|
|
|
|
add_subdirectory(include)
|
|
add_subdirectory(src)
|
|
|
|
# Optional nwdirectory stack uses FLAIM storage and depends on nwssl from
|
|
# src/ssl, so keep it after add_subdirectory(src).
|
|
if(ENABLE_DIRECTORY)
|
|
# Bundled FLAIM storage stack. Keep the imported sources unchanged; the
|
|
# third_party owner function builds only the nwdirectory-needed
|
|
# libraries/tools after src/ssl has created mars_nwe::ssl.
|
|
mars_nwe_add_flaim_third_party()
|
|
|
|
set(TINYLDAP_OUTPUT_NAME nwdirectory CACHE STRING "" FORCE)
|
|
set(TINYLDAP_TOOL_PREFIX nw CACHE STRING "" FORCE)
|
|
set(TINYLDAP_BUILD_SHARED ON CACHE BOOL "" FORCE)
|
|
set(TINYLDAP_BUILD_STATIC OFF CACHE BOOL "" FORCE)
|
|
set(TINYLDAP_LIBOWFAT_INCLUDE_SUBDIR nwlibowfat CACHE STRING "" FORCE)
|
|
set(TINYLDAP_NWSSL_TARGET mars_nwe::ssl CACHE STRING "" FORCE)
|
|
set(TINYLDAP_ALLOW_SYSTEM_OPENSSL OFF CACHE BOOL "" FORCE)
|
|
add_subdirectory(directory)
|
|
endif()
|
|
|
|
add_subdirectory(opt)
|
|
add_subdirectory(sys)
|
|
|
|
if(MARS_NWE_BUILD_TESTS OR MARS_NWE_BUILD_NWFS_TESTS)
|
|
add_subdirectory(tests)
|
|
endif()
|
|
add_subdirectory(dosutils)
|
|
add_subdirectory(mail)
|
|
add_subdirectory(smart)
|
|
add_subdirectory(admin)
|
|
|
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MARtin Stovers NetWare-Emulator.")
|
|
SET(CPACK_PACKAGE_VENDOR "http://www.compu-art.de/mars_nwe/")
|
|
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
SET(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.md" MARS_NWE_GPL_LICENSE_TEXT)
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LGPL-2.1.md" MARS_NWE_LGPL_LICENSE_TEXT)
|
|
set(MARS_NWE_CPACK_LICENSE_FILE "${CMAKE_CURRENT_BINARY_DIR}/CPack-LICENSES.md")
|
|
file(WRITE "${MARS_NWE_CPACK_LICENSE_FILE}"
|
|
"# MARS-NWE Package Licenses\n\n")
|
|
file(APPEND "${MARS_NWE_CPACK_LICENSE_FILE}"
|
|
"## GPL-2.0-only project license\n\n"
|
|
"${MARS_NWE_GPL_LICENSE_TEXT}\n\n"
|
|
"---\n\n"
|
|
"## LGPL-2.1-only library license\n\n"
|
|
"${MARS_NWE_LGPL_LICENSE_TEXT}\n")
|
|
SET(CPACK_RESOURCE_FILE_LICENSE "${MARS_NWE_CPACK_LICENSE_FILE}")
|
|
|
|
install(FILES
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/COPYING.md"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LGPL-2.1.md"
|
|
DESTINATION "${CMAKE_INSTALL_DOCDIR}")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
|
|
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
|
|
set(CPACK_PACKAGE_VERSION_PATCH "pl${VERSION_PATCH}")
|
|
set(CPACK_SOURCE_GENERATOR "TBZ2")
|
|
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "mars_nwe-${MARS_NWE_VERSION}")
|
|
SET(CPACK_SOURCE_IGNORE_FILES "/build/" "/_build/" CMakeCache.txt CMakeFiles progress.make cmake_install.cmake CPackConfig.cmake CPackSourceConfig.cmake "\\\\.git" "\\\\.svn" "\\\\.swp$" "\\\\.cvs" "\\\\.tar.gz" "\\\\.o")
|
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${MARS_NWE_VERSION}")
|
|
include(CPack)
|