|
| 1 | +# |
| 2 | +# Copyright (c) 2014-2025 Enrico M. Crisostomo |
| 3 | +# |
| 4 | +# This program is free software; you can redistribute it and/or modify it under |
| 5 | +# the terms of the GNU General Public License as published by the Free Software |
| 6 | +# Foundation; either version 3, or (at your option) any later version. |
| 7 | +# |
| 8 | +# This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 10 | +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 11 | +# details. |
| 12 | +# |
| 13 | +# You should have received a copy of the GNU General Public License along with |
| 14 | +# this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | +# |
| 16 | +cmake_minimum_required(VERSION 3.14) |
| 17 | +project(fswatch VERSION 1.19.0 LANGUAGES C CXX) |
| 18 | + |
| 19 | +set(VERSION_MODIFIER "-develop") |
| 20 | +set(FULL_VERSION "${PROJECT_VERSION}${VERSION_MODIFIER}") |
| 21 | + |
| 22 | +#@formatter:off |
| 23 | +set(PACKAGE "${PROJECT_NAME}") |
| 24 | +set(PACKAGE_NAME "${PACKAGE}") |
| 25 | +set(PACKAGE_VERSION "${FULL_VERSION}") |
| 26 | +set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
| 27 | +set(PACKAGE_AUTHOR "[email protected]") |
| 28 | +set(PACKAGE_BUGREPORT "${PACKAGE_AUTHOR}") |
| 29 | +set(PACKAGE_TARNAME "${PACKAGE}") |
| 30 | +set(PACKAGE_URL "https://github.com/emcrisostomo/${PACKAGE}") |
| 31 | +set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale" CACHE FILEPATH "locale dir") |
| 32 | +#@formatter:on |
| 33 | + |
| 34 | +if (NOT CMAKE_CXX_STANDARD) |
| 35 | + set(CMAKE_CXX_STANDARD 17) |
| 36 | +endif () |
| 37 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 38 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 39 | + |
| 40 | +set(CMAKE_STATIC_LIBRARY_SUFFIX ".b") |
| 41 | + |
| 42 | +# Add option to choose between shared and static libraries |
| 43 | +option(BUILD_SHARED_LIBS "Build shared libraries" OFF) |
| 44 | +# Add option to build libfswatch only (without fswatch or tests) |
| 45 | +option(BUILD_LIBS_ONLY "Build libfswatch only" OFF) |
| 46 | + |
| 47 | +# include modules |
| 48 | +include(FindGettext) |
| 49 | +include(FindIntl) |
| 50 | +include(CheckIncludeFileCXX) |
| 51 | +include(CheckStructHasMember) |
| 52 | +include(CheckCXXSymbolExists) |
| 53 | + |
| 54 | +# check for gettext and libintl |
| 55 | +check_include_file_cxx(getopt.h HAVE_GETOPT_H) |
| 56 | + |
| 57 | +if (HAVE_GETOPT_H) |
| 58 | + check_cxx_symbol_exists(getopt_long getopt.h HAVE_GETOPT_LONG) |
| 59 | +endif (HAVE_GETOPT_H) |
| 60 | + |
| 61 | +# If both gettext and libintl are found, define the USE_NLS variable to |
| 62 | +# optionally disable them |
| 63 | +if (Intl_FOUND AND GETTEXT_FOUND) |
| 64 | + option(USE_NLS "Use NLS" ON) |
| 65 | +endif () |
| 66 | + |
| 67 | +if (USE_NLS) |
| 68 | + set(ENABLE_NLS 1) |
| 69 | + |
| 70 | + # gettext configuration |
| 71 | + set(LINGUAS en en@quot en@boldquot it es) |
| 72 | + |
| 73 | + foreach (language ${LINGUAS}) |
| 74 | + configure_file(${PROJECT_SOURCE_DIR}/po/${language}.po ${PROJECT_BINARY_DIR}/${language}.po COPYONLY) |
| 75 | + endforeach () |
| 76 | + |
| 77 | + gettext_process_pot_file(po/${PACKAGE}.pot ALL INSTALL_DESTINATION share/locale LANGUAGES ${LINGUAS}) |
| 78 | +endif () |
| 79 | + |
| 80 | +add_subdirectory(libfswatch) |
| 81 | +if (NOT BUILD_LIBS_ONLY) |
| 82 | +add_subdirectory(fswatch/src) |
| 83 | +add_subdirectory(test/src) |
| 84 | +endif () |
0 commit comments