2020-05-21 17:11:45 +03:00
cmake_minimum_required ( VERSION 3.0 )
2021-02-11 15:51:06 +03:00
2021-07-09 10:29:46 +03:00
set ( CMAKE_CXX_STANDARD 11 )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
set ( CMAKE_CXX_EXTENSIONS OFF )
set ( CMAKE_EXPORT_COMPILE_COMMANDS ON )
2021-11-22 08:51:48 +03:00
# NOTE: need largefile options to prevent problems with
2021-09-23 11:58:45 +03:00
# smbclient on 32bit systems
2021-11-22 08:51:48 +03:00
add_compile_options ( -Wall -Wextra -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 )
# NOTE: Turn warnings into errors only for debug build.
# Release builds shouldn't have this because they are
# built for different repo's, architectures and
# compiler versions which can all produce different
# warnings, which breaks the build if they are treated
# as errors.
if ( CMAKE_BUILD_TYPE EQUAL "DEBUG" )
add_compile_options ( -Werror=unused-parameter -Werror=unused-variable -Werror=shadow -Werror=switch )
endif ( CMAKE_BUILD_TYPE EQUAL "DEBUG" )
2021-07-09 10:29:46 +03:00
2021-08-09 13:36:22 +03:00
# You can get version from spec by first finding Versions keyword.
# After that you can use awk to split line by : and then select second part of it.
# Finally you want to clear all the spaces around version.
# OUTPUT_VARIABLE argument of execute_process allows you to capture output of the command.
execute_process (
C O M M A N D
b a s h - c " g r e p V e r s i o n : . g e a r / a d m c . s p e c | a w k - F \ " : \ " ' { p r i n t $ 2 } ' | t r - d [ : s p a c e : ] "
O U T P U T _ V A R I A B L E G E A R _ V E R S I O N
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R } )
# To ensure that we have indeed captured the project version we use message to provide us with console output.
message ( STATUS "Project version is: " ${ GEAR_VERSION } )
project ( admc VERSION ${ GEAR_VERSION } )
2021-08-03 14:48:41 +03:00
message ( STATUS "Project version is: " ${ VERSION } )
2020-05-21 17:11:45 +03:00
set ( CMAKE_MODULE_PATH
2020-05-27 13:26:08 +03:00
$ { C M A K E _ M O D U L E _ P A T H }
2020-09-04 14:51:39 +03:00
$ { P R O J E C T _ S O U R C E _ D I R } / c m a k e
2020-05-21 17:11:45 +03:00
)
2020-09-07 12:51:25 +03:00
set ( EXECUTABLE_OUTPUT_PATH ${ CMAKE_BINARY_DIR } )
2020-09-04 13:57:14 +03:00
set ( LIBRARY_OUTPUT_PATH ${ EXECUTABLE_OUTPUT_PATH } )
2021-02-08 15:36:04 +03:00
enable_testing ( )
2021-06-01 15:26:24 +03:00
include ( GNUInstallDirs )
2023-02-14 16:27:50 +03:00
include ( ClangFormat )
2021-06-01 15:26:24 +03:00
2021-06-02 16:21:28 +03:00
option ( ADMC_BUILD_DEB "Build the deb package of ADMC." OFF )
2020-10-06 15:29:00 +03:00
add_subdirectory ( src )
2021-06-02 16:21:28 +03:00
if ( NOT ADMC_BUILD_DEB )
add_subdirectory ( tests )
endif ( NOT ADMC_BUILD_DEB )
2022-02-03 12:33:36 +03:00
add_subdirectory ( share )
2021-06-02 16:21:28 +03:00
2021-09-29 12:37:45 +03:00
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /CHANGELOG.txt
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } C O P Y O N L Y )
2022-04-05 10:43:40 +03:00
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /CHANGELOG_ru.txt
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } C O P Y O N L Y )
2021-09-29 12:37:45 +03:00
2021-06-02 16:21:28 +03:00
if ( ADMC_BUILD_DEB )
SET ( CPACK_GENERATOR "DEB" )
SET ( CPACK_DEBIAN_PACKAGE_MAINTAINER "Kees van Vloten" )
SET ( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
SET ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
SET ( CPACK_DEBIAN_PACKAGE_DESCRIPTION "Samba domain management console." )
SET ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/altlinux/admc" )
2021-06-02 16:45:26 +03:00
set ( CPACK_STRIP_FILES "${CMAKE_INSTALL_LIBDIR}/libadldap.so;${CMAKE_INSTALL_BINDIR}/admc" )
2021-06-02 16:21:28 +03:00
INCLUDE ( CPack )
endif ( ADMC_BUILD_DEB )