Use lowercase CMake function names

This is a best practice to distinguish them from variables.
This commit is contained in:
ridiculousfish 2020-03-14 16:11:35 -07:00
parent f9f5775ccc
commit f117addf7c
11 changed files with 419 additions and 419 deletions

View file

@ -1,33 +1,33 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
cmake_minimum_required(VERSION 3.2)
IF(POLICY CMP0066)
CMAKE_POLICY(SET CMP0066 OLD)
ENDIF()
IF(POLICY CMP0067)
CMAKE_POLICY(SET CMP0067 NEW)
ENDIF()
if(POLICY CMP0066)
cmake_policy(SET CMP0066 OLD)
endif()
if(POLICY CMP0067)
cmake_policy(SET CMP0067 NEW)
endif()
INCLUDE(cmake/Mac.cmake)
include(cmake/Mac.cmake)
PROJECT(fish)
project(fish)
# We are C++11.
SET(CMAKE_CXX_STANDARD 11)
SET(DEFAULT_BUILD_TYPE "RelWithDebInfo")
set(CMAKE_CXX_STANDARD 11)
set(DEFAULT_BUILD_TYPE "RelWithDebInfo")
# Use the default flags (#6296) but remove -DNDEBUG so that asserts remain enabled.
STRING(REPLACE "-DNDEBUG" ""
string(REPLACE "-DNDEBUG" ""
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
STRING(REPLACE "-DNDEBUG" ""
string(REPLACE "-DNDEBUG" ""
CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE}")
IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
MESSAGE(STATUS "Setting build type to default '${DEFAULT_BUILD_TYPE}'")
SET(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
ENDIF()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to default '${DEFAULT_BUILD_TYPE}'")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
endif()
# Force colored warnings in Ninja's output, if the compiler has -fdiagnostics-color support.
# Rationale in https://github.com/ninja-build/ninja/issues/814
@ -53,11 +53,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra \
")
# Disable exception handling.
ADD_COMPILE_OPTIONS(-fno-exceptions)
add_compile_options(-fno-exceptions)
# Prefer the gold linker because it doesn't emit useless warnings about sys_nerr and _sys_errlist.
if (UNIX AND NOT APPLE)
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
@ -65,37 +65,37 @@ if (UNIX AND NOT APPLE)
endif()
# Hide the CMake Rules directories in Xcode projects.
SOURCE_GROUP("CMake Rules" REGULAR_EXPRESSION "^$")
source_group("CMake Rules" REGULAR_EXPRESSION "^$")
# Put source and header files at top level under targets.
SOURCE_GROUP("Source Files" REGULAR_EXPRESSION "^$")
SOURCE_GROUP("Header Files" REGULAR_EXPRESSION "^$")
SOURCE_GROUP("Builtins" REGULAR_EXPRESSION "builtin_.*")
source_group("Source Files" REGULAR_EXPRESSION "^$")
source_group("Header Files" REGULAR_EXPRESSION "^$")
source_group("Builtins" REGULAR_EXPRESSION "builtin_.*")
# Support folders.
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Work around issue where archive-built libs go in the wrong place.
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
IF(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
SET(FISH_IN_TREE_BUILD TRUE)
ELSE()
SET(FISH_IN_TREE_BUILD FALSE)
ENDIF()
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
set(FISH_IN_TREE_BUILD TRUE)
else()
set(FISH_IN_TREE_BUILD FALSE)
endif()
# NetBSD does weird things with finding libraries,
# making the tests fail by failing to find pcre.
#
# Keep the rpath used to build.
IF(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
ENDIF()
if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
# All objects that the system needs to build fish, except fish.cpp
SET(FISH_SRCS
set(FISH_SRCS
src/autoload.cpp src/builtin.cpp src/builtin_bg.cpp src/builtin_bind.cpp
src/builtin_block.cpp src/builtin_builtin.cpp src/builtin_cd.cpp
src/builtin_command.cpp src/builtin_commandline.cpp
@ -124,18 +124,18 @@ SET(FISH_SRCS
)
# Header files are just globbed.
FILE(GLOB FISH_HEADERS src/*.h)
file(GLOB FISH_HEADERS src/*.h)
# Set up config.h
INCLUDE(cmake/ConfigureChecks.cmake)
INCLUDE(cmake/gettext.cmake)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config_cmake.h.in
include(cmake/ConfigureChecks.cmake)
include(cmake/gettext.cmake)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config_cmake.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Set up standard directories.
INCLUDE(GNUInstallDirs)
ADD_DEFINITIONS(-D_UNICODE=1
include(GNUInstallDirs)
add_definitions(-D_UNICODE=1
-DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
-DPREFIX=L"${CMAKE_INSTALL_PREFIX}"
-DDATADIR=L"${CMAKE_INSTALL_FULL_DATADIR}"
@ -145,85 +145,85 @@ ADD_DEFINITIONS(-D_UNICODE=1
# Set up the machinery around FISH-BUILD-VERSION-FILE
# This defines the FBVF variable.
INCLUDE(Version)
include(Version)
# Let fish pick up when we're running out of the build directory without installing
GET_FILENAME_COMPONENT(REAL_CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}" REALPATH)
GET_FILENAME_COMPONENT(REAL_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}" REALPATH)
ADD_DEFINITIONS(-DCMAKE_BINARY_DIR="${REAL_CMAKE_BINARY_DIR}")
ADD_DEFINITIONS(-DCMAKE_SOURCE_DIR="${REAL_CMAKE_SOURCE_DIR}")
get_filename_component(REAL_CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}" REALPATH)
get_filename_component(REAL_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}" REALPATH)
add_definitions(-DCMAKE_BINARY_DIR="${REAL_CMAKE_BINARY_DIR}")
add_definitions(-DCMAKE_SOURCE_DIR="${REAL_CMAKE_SOURCE_DIR}")
# Teach fish_version.o to rebuild when FBVF changes.
# The standard C++ include detection machinery misses this.
SET_SOURCE_FILES_PROPERTIES(src/fish_version.cpp
set_source_files_properties(src/fish_version.cpp
PROPERTIES OBJECT_DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/${FBVF})
# Enable thread-safe errno on Solaris (#5611)
ADD_DEFINITIONS(-D_REENTRANT)
add_definitions(-D_REENTRANT)
# Set up PCRE2
INCLUDE(cmake/PCRE2.cmake)
include(cmake/PCRE2.cmake)
# Define a function to link dependencies.
FUNCTION(FISH_LINK_DEPS_AND_SIGN target)
TARGET_LINK_LIBRARIES(${target} fishlib)
CODESIGN_ON_MAC(${target})
ENDFUNCTION(FISH_LINK_DEPS_AND_SIGN)
function(FISH_LINK_DEPS_AND_SIGN target)
target_link_libraries(${target} fishlib)
codesign_on_mac(${target})
endfunction(FISH_LINK_DEPS_AND_SIGN)
# Define libfish.a.
ADD_LIBRARY(fishlib STATIC ${FISH_SRCS})
TARGET_SOURCES(fishlib PRIVATE ${FISH_HEADERS})
TARGET_LINK_LIBRARIES(fishlib
add_library(fishlib STATIC ${FISH_SRCS})
target_sources(fishlib PRIVATE ${FISH_HEADERS})
target_link_libraries(fishlib
${CURSES_LIBRARY} ${CURSES_EXTRA_LIBRARY} Threads::Threads ${CMAKE_DL_LIBS}
${PCRE2_LIB} ${Intl_LIBRARIES} ${ATOMIC_LIBRARY})
# Define fish.
ADD_EXECUTABLE(fish src/fish.cpp)
FISH_LINK_DEPS_AND_SIGN(fish)
add_executable(fish src/fish.cpp)
fish_link_deps_and_sign(fish)
# Define fish_indent.
ADD_EXECUTABLE(fish_indent
add_executable(fish_indent
src/fish_indent.cpp src/print_help.cpp)
FISH_LINK_DEPS_AND_SIGN(fish_indent)
fish_link_deps_and_sign(fish_indent)
# Define fish_key_reader.
ADD_EXECUTABLE(fish_key_reader
add_executable(fish_key_reader
src/fish_key_reader.cpp src/print_help.cpp)
FISH_LINK_DEPS_AND_SIGN(fish_key_reader)
fish_link_deps_and_sign(fish_key_reader)
# Set up the docs.
INCLUDE(cmake/Docs.cmake)
include(cmake/Docs.cmake)
# A helper for running tests.
ADD_EXECUTABLE(fish_test_helper src/fish_test_helper.cpp)
add_executable(fish_test_helper src/fish_test_helper.cpp)
# Set up tests.
INCLUDE(cmake/Tests.cmake)
include(cmake/Tests.cmake)
# Benchmarking support.
INCLUDE(cmake/Benchmark.cmake)
include(cmake/Benchmark.cmake)
# Set up install.
INCLUDE(cmake/Install.cmake)
include(cmake/Install.cmake)
# Mac app.
INCLUDE(cmake/MacApp.cmake)
include(cmake/MacApp.cmake)
# Lint targets
# This could be implemented as target properties, but the script has the useful feature of only
# checking the currently-staged commands
# The generator expressions below rebuild the command line for the fishlib targets
# CMake does not support the "iquote" flag - https://gitlab.kitware.com/cmake/cmake/issues/15491
SET(LINT_ARGS "-D$<JOIN:$<TARGET_PROPERTY:fishlib,COMPILE_DEFINITIONS>, -D>" "-I$<JOIN:$<TARGET_PROPERTY:fishlib,INCLUDE_DIRECTORIES>, -I>")
ADD_CUSTOM_TARGET(lint
set(LINT_ARGS "-D$<JOIN:$<TARGET_PROPERTY:fishlib,COMPILE_DEFINITIONS>, -D>" "-I$<JOIN:$<TARGET_PROPERTY:fishlib,INCLUDE_DIRECTORIES>, -I>")
add_custom_target(lint
COMMAND build_tools/lint.fish -- ${LINT_ARGS}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
ADD_CUSTOM_TARGET(lint-all
add_custom_target(lint-all
COMMAND build_tools/lint.fish --all -- ${LINT_ARGS}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
INCLUDE(FeatureSummary)
FEATURE_SUMMARY(WHAT ALL)
include(FeatureSummary)
feature_summary(WHAT ALL)

View file

@ -1,6 +1,6 @@
# Support for benchmarking fish.
ADD_CUSTOM_TARGET(benchmark
add_custom_target(benchmark
COMMAND ${CMAKE_SOURCE_DIR}/benchmarks/driver.sh $<TARGET_FILE:fish>
USES_TERMINAL
)

View file

@ -3,153 +3,153 @@
# and CMAKE_REQUIRED_INCLUDES
# `wcstod_l` is a GNU-extension, sometimes hidden behind GNU-related defines.
# This is the case for at least Cygwin and Newlib.
LIST(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1)
IF(APPLE)
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-Werror=unguarded-availability" REQUIRES_UNGUARDED_AVAILABILITY)
IF(REQUIRES_UNGUARDED_AVAILABILITY)
LIST(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Werror=unguarded-availability")
ENDIF()
ENDIF()
if(APPLE)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Werror=unguarded-availability" REQUIRES_UNGUARDED_AVAILABILITY)
if(REQUIRES_UNGUARDED_AVAILABILITY)
list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Werror=unguarded-availability")
endif()
endif()
# Try using CMake's own logic to locate curses/ncurses
FIND_PACKAGE(Curses)
IF(NOT ${CURSES_FOUND})
find_package(Curses)
if(NOT ${CURSES_FOUND})
# CMake has trouble finding platform-specific system libraries
# installed to multiarch paths (e.g. /usr/lib/x86_64-linux-gnu)
# if not symlinked or passed in as a manual define.
MESSAGE("Falling back to pkg-config for (n)curses detection")
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(CURSES REQUIRED ncurses curses)
SET(CURSES_CURSES_LIBRARY ${CURSES_LIBRARIES})
SET(CURSES_LIBRARY ${CURSES_LIBRARIES})
ENDIF()
message("Falling back to pkg-config for (n)curses detection")
include(FindPkgConfig)
pkg_search_module(CURSES REQUIRED ncurses curses)
set(CURSES_CURSES_LIBRARY ${CURSES_LIBRARIES})
set(CURSES_LIBRARY ${CURSES_LIBRARIES})
endif()
# Get threads.
set(THREADS_PREFER_PTHREAD_FLAG ON)
# FindThreads < 3.4.0 doesn't work for C++-only projects
IF(CMAKE_VERSION VERSION_LESS 3.4.0)
ENABLE_LANGUAGE(C)
ENDIF()
FIND_PACKAGE(Threads REQUIRED)
if(CMAKE_VERSION VERSION_LESS 3.4.0)
enable_language(C)
endif()
find_package(Threads REQUIRED)
# Detect WSL. Does not match against native Windows/WIN32.
if (CMAKE_HOST_SYSTEM_VERSION MATCHES ".*-Microsoft")
SET(WSL 1)
set(WSL 1)
endif()
# Set up the config.h file.
SET(PACKAGE_NAME "fish")
SET(PACKAGE_TARNAME "fish")
INCLUDE(CheckCXXSymbolExists)
INCLUDE(CheckIncludeFileCXX)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckStructHasMember)
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(CheckTypeSize)
INCLUDE(CMakePushCheckState)
CHECK_CXX_SYMBOL_EXISTS(backtrace_symbols execinfo.h HAVE_BACKTRACE_SYMBOLS)
CHECK_CXX_SYMBOL_EXISTS(clock_gettime time.h HAVE_CLOCK_GETTIME)
CHECK_CXX_SYMBOL_EXISTS(ctermid_r stdio.h HAVE_CTERMID_R)
CHECK_STRUCT_HAS_MEMBER("struct dirent" d_type dirent.h HAVE_STRUCT_DIRENT_D_TYPE LANGUAGE CXX)
CHECK_CXX_SYMBOL_EXISTS(dirfd "sys/types.h;dirent.h" HAVE_DIRFD)
CHECK_INCLUDE_FILE_CXX(execinfo.h HAVE_EXECINFO_H)
CHECK_CXX_SYMBOL_EXISTS(flock sys/file.h HAVE_FLOCK)
set(PACKAGE_NAME "fish")
set(PACKAGE_TARNAME "fish")
include(CheckCXXSymbolExists)
include(CheckIncludeFileCXX)
include(CheckIncludeFiles)
include(CheckStructHasMember)
include(CheckCXXSourceCompiles)
include(CheckTypeSize)
include(CMakePushCheckState)
check_cxx_symbol_exists(backtrace_symbols execinfo.h HAVE_BACKTRACE_SYMBOLS)
check_cxx_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
check_cxx_symbol_exists(ctermid_r stdio.h HAVE_CTERMID_R)
check_struct_has_member("struct dirent" d_type dirent.h HAVE_STRUCT_DIRENT_D_TYPE LANGUAGE CXX)
check_cxx_symbol_exists(dirfd "sys/types.h;dirent.h" HAVE_DIRFD)
check_include_file_cxx(execinfo.h HAVE_EXECINFO_H)
check_cxx_symbol_exists(flock sys/file.h HAVE_FLOCK)
# futimens is new in OS X 10.13 but is a weak symbol.
# Don't assume it exists just because we can link - it may be null.
CHECK_CXX_SYMBOL_EXISTS(futimens sys/stat.h HAVE_FUTIMENS)
CHECK_CXX_SYMBOL_EXISTS(futimes sys/time.h HAVE_FUTIMES)
CHECK_CXX_SYMBOL_EXISTS(getifaddrs ifaddrs.h HAVE_GETIFADDRS)
CHECK_CXX_SYMBOL_EXISTS(getpwent pwd.h HAVE_GETPWENT)
CHECK_CXX_SYMBOL_EXISTS(getrusage sys/resource.h HAVE_GETRUSAGE)
CHECK_CXX_SYMBOL_EXISTS(gettext libintl.h HAVE_GETTEXT)
CHECK_CXX_SYMBOL_EXISTS(killpg "sys/types.h;signal.h" HAVE_KILLPG)
CHECK_CXX_SYMBOL_EXISTS(lrand48_r stdlib.h HAVE_LRAND48_R)
check_cxx_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
check_cxx_symbol_exists(futimes sys/time.h HAVE_FUTIMES)
check_cxx_symbol_exists(getifaddrs ifaddrs.h HAVE_GETIFADDRS)
check_cxx_symbol_exists(getpwent pwd.h HAVE_GETPWENT)
check_cxx_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
check_cxx_symbol_exists(gettext libintl.h HAVE_GETTEXT)
check_cxx_symbol_exists(killpg "sys/types.h;signal.h" HAVE_KILLPG)
check_cxx_symbol_exists(lrand48_r stdlib.h HAVE_LRAND48_R)
# mkostemp is in stdlib in glibc and FreeBSD, but unistd on macOS
CHECK_CXX_SYMBOL_EXISTS(mkostemp "stdlib.h;unistd.h" HAVE_MKOSTEMP)
SET(HAVE_CURSES_H ${CURSES_HAVE_CURSES_H})
SET(HAVE_NCURSES_CURSES_H ${CURSES_HAVE_NCURSES_CURSES_H})
SET(HAVE_NCURSES_H ${CURSES_HAVE_NCURSES_H})
IF(HAVE_CURSES_H)
CHECK_INCLUDE_FILES("curses.h;term.h" HAVE_TERM_H)
ENDIF()
IF(NOT HAVE_TERM_H)
CHECK_INCLUDE_FILE_CXX("ncurses/term.h" HAVE_NCURSES_TERM_H)
ENDIF()
CHECK_INCLUDE_FILE_CXX(siginfo.h HAVE_SIGINFO_H)
CHECK_INCLUDE_FILE_CXX(spawn.h HAVE_SPAWN_H)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_ctime_nsec "sys/stat.h" HAVE_STRUCT_STAT_ST_CTIME_NSEC
check_cxx_symbol_exists(mkostemp "stdlib.h;unistd.h" HAVE_MKOSTEMP)
set(HAVE_CURSES_H ${CURSES_HAVE_CURSES_H})
set(HAVE_NCURSES_CURSES_H ${CURSES_HAVE_NCURSES_CURSES_H})
set(HAVE_NCURSES_H ${CURSES_HAVE_NCURSES_H})
if(HAVE_CURSES_H)
check_include_files("curses.h;term.h" HAVE_TERM_H)
endif()
if(NOT HAVE_TERM_H)
check_include_file_cxx("ncurses/term.h" HAVE_NCURSES_TERM_H)
endif()
check_include_file_cxx(siginfo.h HAVE_SIGINFO_H)
check_include_file_cxx(spawn.h HAVE_SPAWN_H)
check_struct_has_member("struct stat" st_ctime_nsec "sys/stat.h" HAVE_STRUCT_STAT_ST_CTIME_NSEC
LANGUAGE CXX)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec "sys/stat.h"
check_struct_has_member("struct stat" st_mtimespec.tv_nsec "sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC LANGUAGE CXX)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec "sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
check_struct_has_member("struct stat" st_mtim.tv_nsec "sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
LANGUAGE CXX)
CHECK_CXX_SYMBOL_EXISTS(sys_errlist stdio.h HAVE_SYS_ERRLIST)
CHECK_INCLUDE_FILE_CXX(sys/ioctl.h HAVE_SYS_IOCTL_H)
CHECK_INCLUDE_FILE_CXX(sys/select.h HAVE_SYS_SELECT_H)
CHECK_INCLUDE_FILES("sys/types.h;sys/sysctl.h" HAVE_SYS_SYSCTL_H)
CHECK_INCLUDE_FILE_CXX(termios.h HAVE_TERMIOS_H) # Needed for TIOCGWINSZ
check_cxx_symbol_exists(sys_errlist stdio.h HAVE_SYS_ERRLIST)
check_include_file_cxx(sys/ioctl.h HAVE_SYS_IOCTL_H)
check_include_file_cxx(sys/select.h HAVE_SYS_SELECT_H)
check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYS_SYSCTL_H)
check_include_file_cxx(termios.h HAVE_TERMIOS_H) # Needed for TIOCGWINSZ
CHECK_CXX_SYMBOL_EXISTS(wcscasecmp wchar.h HAVE_WCSCASECMP)
CHECK_CXX_SYMBOL_EXISTS(wcsdup wchar.h HAVE_WCSDUP)
CHECK_CXX_SYMBOL_EXISTS(wcslcpy wchar.h HAVE_WCSLCPY)
CHECK_CXX_SYMBOL_EXISTS(wcsncasecmp wchar.h HAVE_WCSNCASECMP)
CHECK_CXX_SYMBOL_EXISTS(wcsndup wchar.h HAVE_WCSNDUP)
check_cxx_symbol_exists(wcscasecmp wchar.h HAVE_WCSCASECMP)
check_cxx_symbol_exists(wcsdup wchar.h HAVE_WCSDUP)
check_cxx_symbol_exists(wcslcpy wchar.h HAVE_WCSLCPY)
check_cxx_symbol_exists(wcsncasecmp wchar.h HAVE_WCSNCASECMP)
check_cxx_symbol_exists(wcsndup wchar.h HAVE_WCSNDUP)
# These are for compatibility with Solaris 10, which places the following
# in the std namespace.
IF(NOT HAVE_WCSNCASECMP)
CHECK_CXX_SYMBOL_EXISTS(std::wcscasecmp wchar.h HAVE_STD__WCSCASECMP)
ENDIF()
IF(NOT HAVE_WCSDUP)
CHECK_CXX_SYMBOL_EXISTS(std::wcsdup wchar.h HAVE_STD__WCSDUP)
ENDIF()
IF(NOT HAVE_WCSNCASECMP)
CHECK_CXX_SYMBOL_EXISTS(std::wcsncasecmp wchar.h HAVE_STD__WCSNCASECMP)
ENDIF()
if(NOT HAVE_WCSNCASECMP)
check_cxx_symbol_exists(std::wcscasecmp wchar.h HAVE_STD__WCSCASECMP)
endif()
if(NOT HAVE_WCSDUP)
check_cxx_symbol_exists(std::wcsdup wchar.h HAVE_STD__WCSDUP)
endif()
if(NOT HAVE_WCSNCASECMP)
check_cxx_symbol_exists(std::wcsncasecmp wchar.h HAVE_STD__WCSNCASECMP)
endif()
# `xlocale.h` is required to find `wcstod_l` in `wchar.h` under FreeBSD,
# but it's not present under Linux.
CHECK_INCLUDE_FILES("xlocale.h" HAVE_XLOCALE_H)
IF(HAVE_XLOCALE_H)
LIST(APPEND WCSTOD_L_INCLUDES "xlocale.h")
ENDIF()
LIST(APPEND WCSTOD_L_INCLUDES "wchar.h")
CHECK_CXX_SYMBOL_EXISTS(wcstod_l "${WCSTOD_L_INCLUDES}" HAVE_WCSTOD_L)
check_include_files("xlocale.h" HAVE_XLOCALE_H)
if(HAVE_XLOCALE_H)
list(APPEND WCSTOD_L_INCLUDES "xlocale.h")
endif()
list(APPEND WCSTOD_L_INCLUDES "wchar.h")
check_cxx_symbol_exists(wcstod_l "${WCSTOD_L_INCLUDES}" HAVE_WCSTOD_L)
CHECK_CXX_SYMBOL_EXISTS(_sys_errs stdlib.h HAVE__SYS__ERRS)
check_cxx_symbol_exists(_sys_errs stdlib.h HAVE__SYS__ERRS)
CMAKE_PUSH_CHECK_STATE()
SET(CMAKE_EXTRA_INCLUDE_FILES termios.h sys/ioctl.h)
CHECK_TYPE_SIZE("struct winsize" STRUCT_WINSIZE LANGUAGE CXX)
CHECK_CXX_SYMBOL_EXISTS("TIOCGWINSZ" "termios.h;sys/ioctl.h" HAVE_TIOCGWINSZ)
IF(STRUCT_WINSIZE GREATER -1 AND HAVE_TIOCGWINSZ EQUAL 1)
SET(HAVE_WINSIZE 1)
ENDIF()
CMAKE_POP_CHECK_STATE()
cmake_push_check_state()
set(CMAKE_EXTRA_INCLUDE_FILES termios.h sys/ioctl.h)
check_type_size("struct winsize" STRUCT_WINSIZE LANGUAGE CXX)
check_cxx_symbol_exists("TIOCGWINSZ" "termios.h;sys/ioctl.h" HAVE_TIOCGWINSZ)
if(STRUCT_WINSIZE GREATER -1 AND HAVE_TIOCGWINSZ EQUAL 1)
set(HAVE_WINSIZE 1)
endif()
cmake_pop_check_state()
CHECK_TYPE_SIZE("wchar_t[8]" WCHAR_T_BITS LANGUAGE CXX)
check_type_size("wchar_t[8]" WCHAR_T_BITS LANGUAGE CXX)
SET(TPARM_INCLUDES)
IF(HAVE_NCURSES_H)
SET(TPARM_INCLUDES "${TPARM_INCLUDES}#include <ncurses.h>\n")
ELSEIF(HAVE_NCURSES_CURSES_H)
SET(TPARM_INCLUDES "${TPARM_INCLUDES}#include <ncurses/curses.h>\n")
ELSE()
SET(TPARM_INCLUDES "${TPARM_INCLUDES}#include <curses.h>\n")
ENDIF()
set(TPARM_INCLUDES)
if(HAVE_NCURSES_H)
set(TPARM_INCLUDES "${TPARM_INCLUDES}#include <ncurses.h>\n")
elseif(HAVE_NCURSES_CURSES_H)
set(TPARM_INCLUDES "${TPARM_INCLUDES}#include <ncurses/curses.h>\n")
else()
set(TPARM_INCLUDES "${TPARM_INCLUDES}#include <curses.h>\n")
endif()
IF(HAVE_TERM_H)
SET(TPARM_INCLUDES "${TPARM_INCLUDES}#include <term.h>\n")
ELSEIF(HAVE_NCURSES_TERM_H)
SET(TPARM_INCLUDES "${TPARM_INCLUDES}#include <ncurses/term.h>\n")
ENDIF()
if(HAVE_TERM_H)
set(TPARM_INCLUDES "${TPARM_INCLUDES}#include <term.h>\n")
elseif(HAVE_NCURSES_TERM_H)
set(TPARM_INCLUDES "${TPARM_INCLUDES}#include <ncurses/term.h>\n")
endif()
# Solaris and X/Open-conforming systems have a fixed-args tparm
CMAKE_PUSH_CHECK_STATE()
LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
CHECK_CXX_SOURCE_COMPILES("
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
check_cxx_source_compiles("
#define TPARM_VARARGS
${TPARM_INCLUDES}
@ -160,23 +160,23 @@ int main () {
TPARM_TAKES_VARARGS
)
IF(TPARM_TAKES_VARARGS)
SET(TPARM_VARARGS 1)
ELSE()
SET(TPARM_SOLARIS_KLUDGE 1)
ENDIF()
CMAKE_POP_CHECK_STATE()
if(TPARM_TAKES_VARARGS)
set(TPARM_VARARGS 1)
else()
set(TPARM_SOLARIS_KLUDGE 1)
endif()
cmake_pop_check_state()
# Work around the fact that cmake does not propagate the language standard flag into
# the CHECK_CXX_SOURCE_COMPILES function. See CMake issue #16456.
# Ensure we do this after the FIND_PACKAGE calls which use C, and will error on a C++
# standards flag.
# Also see https://github.com/fish-shell/fish-shell/issues/5865
IF(NOT POLICY CMP0067)
LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_EXTENSION_COMPILE_OPTION}")
ENDIF()
if(NOT POLICY CMP0067)
list(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_EXTENSION_COMPILE_OPTION}")
endif()
CHECK_CXX_SOURCE_COMPILES("
check_cxx_source_compiles("
#include <memory>
int main () {
@ -186,9 +186,9 @@ int main () {
HAVE_STD__MAKE_UNIQUE
)
FIND_PROGRAM(SED sed)
find_program(SED sed)
CHECK_CXX_SOURCE_COMPILES("
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
std::atomic<uint64_t> x;
@ -197,5 +197,5 @@ int main() {
}"
LIBATOMIC_NOT_NEEDED)
IF (NOT LIBATOMIC_NOT_NEEDED)
SET(ATOMIC_LIBRARY "atomic")
ENDIF()
set(ATOMIC_LIBRARY "atomic")
endif()

View file

@ -1,21 +1,21 @@
FIND_PROGRAM(SPHINX_EXECUTABLE NAMES sphinx-build
find_program(SPHINX_EXECUTABLE NAMES sphinx-build
HINTS
$ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx documentation generator")
INCLUDE(FeatureSummary)
include(FeatureSummary)
SET(SPHINX_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc_src")
SET(SPHINX_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/user_doc")
SET(SPHINX_BUILD_DIR "${SPHINX_ROOT_DIR}/build")
SET(SPHINX_CACHE_DIR "${SPHINX_ROOT_DIR}/doctrees")
SET(SPHINX_HTML_DIR "${SPHINX_ROOT_DIR}/html")
SET(SPHINX_MANPAGE_DIR "${SPHINX_ROOT_DIR}/man")
set(SPHINX_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc_src")
set(SPHINX_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/user_doc")
set(SPHINX_BUILD_DIR "${SPHINX_ROOT_DIR}/build")
set(SPHINX_CACHE_DIR "${SPHINX_ROOT_DIR}/doctrees")
set(SPHINX_HTML_DIR "${SPHINX_ROOT_DIR}/html")
set(SPHINX_MANPAGE_DIR "${SPHINX_ROOT_DIR}/man")
# sphinx-docs uses fish_indent for highlighting.
# Prepend the output dir of fish_indent to PATH.
ADD_CUSTOM_TARGET(sphinx-docs
add_custom_target(sphinx-docs
mkdir -p ${SPHINX_HTML_DIR}/_static/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SPHINX_SRC_DIR}/_static/pygments.css ${SPHINX_HTML_DIR}/_static/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SPHINX_SRC_DIR}/_static/custom.css ${SPHINX_HTML_DIR}/_static/
@ -30,7 +30,7 @@ ADD_CUSTOM_TARGET(sphinx-docs
COMMENT "Building HTML documentation with Sphinx")
# sphinx-manpages needs the fish_indent binary for the version number
ADD_CUSTOM_TARGET(sphinx-manpages
add_custom_target(sphinx-manpages
env PATH="$<TARGET_FILE_DIR:fish_indent>:$$PATH"
${SPHINX_EXECUTABLE}
-q -b man
@ -42,46 +42,46 @@ ADD_CUSTOM_TARGET(sphinx-manpages
DEPENDS fish_indent
COMMENT "Building man pages with Sphinx")
IF(SPHINX_EXECUTABLE)
OPTION(BUILD_DOCS "build documentation (requires Sphinx)" ON)
ELSE(SPHINX_EXECUTABLE)
OPTION(BUILD_DOCS "build documentation (requires Sphinx)" OFF)
ENDIF(SPHINX_EXECUTABLE)
if(SPHINX_EXECUTABLE)
option(BUILD_DOCS "build documentation (requires Sphinx)" ON)
else(SPHINX_EXECUTABLE)
option(BUILD_DOCS "build documentation (requires Sphinx)" OFF)
endif(SPHINX_EXECUTABLE)
IF(BUILD_DOCS AND NOT SPHINX_EXECUTABLE)
MESSAGE(FATAL_ERROR "build documentation selected, but sphinx-build could not be found")
ENDIF()
if(BUILD_DOCS AND NOT SPHINX_EXECUTABLE)
message(FATAL_ERROR "build documentation selected, but sphinx-build could not be found")
endif()
IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/user_doc/html
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/user_doc/html
AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/user_doc/man)
SET(HAVE_PREBUILT_DOCS TRUE)
ELSE()
SET(HAVE_PREBUILT_DOCS FALSE)
ENDIF()
set(HAVE_PREBUILT_DOCS TRUE)
else()
set(HAVE_PREBUILT_DOCS FALSE)
endif()
IF(BUILD_DOCS OR HAVE_PREBUILT_DOCS)
SET(INSTALL_DOCS ON)
ELSE()
SET(INSTALL_DOCS OFF)
ENDIF()
if(BUILD_DOCS OR HAVE_PREBUILT_DOCS)
set(INSTALL_DOCS ON)
else()
set(INSTALL_DOCS OFF)
endif()
ADD_FEATURE_INFO(Documentation INSTALL_DOCS "user manual and documentation")
add_feature_info(Documentation INSTALL_DOCS "user manual and documentation")
IF(BUILD_DOCS)
CONFIGURE_FILE("${SPHINX_SRC_DIR}/conf.py" "${SPHINX_BUILD_DIR}/conf.py" @ONLY)
ADD_CUSTOM_TARGET(doc ALL
if(BUILD_DOCS)
configure_file("${SPHINX_SRC_DIR}/conf.py" "${SPHINX_BUILD_DIR}/conf.py" @ONLY)
add_custom_target(doc ALL
DEPENDS sphinx-docs sphinx-manpages)
# Group docs targets into a DocsTargets folder
SET_PROPERTY(TARGET doc sphinx-docs sphinx-manpages
set_property(TARGET doc sphinx-docs sphinx-manpages
PROPERTY FOLDER cmake/DocTargets)
ELSEIF(HAVE_PREBUILT_DOCS)
IF(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
elseif(HAVE_PREBUILT_DOCS)
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
# Out of tree build - link the prebuilt documentation to the build tree
ADD_CUSTOM_TARGET(link_doc ALL)
ADD_CUSTOM_COMMAND(TARGET link_doc
add_custom_target(link_doc ALL)
add_custom_command(TARGET link_doc
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/user_doc ${CMAKE_CURRENT_BINARY_DIR}/user_doc
POST_BUILD)
ENDIF()
ENDIF(BUILD_DOCS)
endif()
endif(BUILD_DOCS)

View file

@ -5,39 +5,39 @@
# -DBINDIR=L"${CMAKE_INSTALL_FULL_BINDIR}"
# -DDOCDIR=L"${CMAKE_INSTALL_FULL_DOCDIR}")
SET(CMAKE_INSTALL_MESSAGE NEVER)
set(CMAKE_INSTALL_MESSAGE NEVER)
SET(PROGRAMS fish fish_indent fish_key_reader)
set(PROGRAMS fish fish_indent fish_key_reader)
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(bindir ${CMAKE_INSTALL_BINDIR})
SET(sysconfdir ${CMAKE_INSTALL_SYSCONFDIR})
SET(mandir ${CMAKE_INSTALL_MANDIR})
set(prefix ${CMAKE_INSTALL_PREFIX})
set(bindir ${CMAKE_INSTALL_BINDIR})
set(sysconfdir ${CMAKE_INSTALL_SYSCONFDIR})
set(mandir ${CMAKE_INSTALL_MANDIR})
SET(rel_datadir ${CMAKE_INSTALL_DATADIR})
SET(datadir ${CMAKE_INSTALL_FULL_DATADIR})
set(rel_datadir ${CMAKE_INSTALL_DATADIR})
set(datadir ${CMAKE_INSTALL_FULL_DATADIR})
SET(docdir ${CMAKE_INSTALL_DOCDIR})
set(docdir ${CMAKE_INSTALL_DOCDIR})
# Comment at the top of some .in files
SET(configure_input
set(configure_input
"This file was generated from a corresponding .in file.\
DO NOT MANUALLY EDIT THIS FILE!")
SET(extra_completionsdir
set(extra_completionsdir
/usr/local/share/fish/vendor_completions.d
CACHE STRING "Path for extra completions")
SET(extra_functionsdir
set(extra_functionsdir
/usr/local/share/fish/vendor_functions.d
CACHE STRING "Path for extra functions")
SET(extra_confdir
set(extra_confdir
/usr/local/share/fish/vendor_conf.d
CACHE STRING "Path for extra configuration")
# These are the man pages that go in system manpath; all manpages go in the fish-specific manpath.
SET(MANUALS ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish.1
set(MANUALS ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish_indent.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish_key_reader.1)
@ -46,42 +46,42 @@ SET(MANUALS ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish.1
# function on OS X.
# On other operating systems, don't install a realpath man page, as they almost all have a realpath
# command, while macOS does not.
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(CONDEMNED_PAGE "open.1")
ELSE()
SET(CONDEMNED_PAGE "realpath.1")
ENDIF()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CONDEMNED_PAGE "open.1")
else()
set(CONDEMNED_PAGE "realpath.1")
endif()
# Define a function to help us create directories.
FUNCTION(FISH_CREATE_DIRS)
FOREACH(dir ${ARGV})
INSTALL(DIRECTORY DESTINATION ${dir})
ENDFOREACH(dir)
ENDFUNCTION(FISH_CREATE_DIRS)
function(FISH_CREATE_DIRS)
foreach(dir ${ARGV})
install(DIRECTORY DESTINATION ${dir})
endforeach(dir)
endfunction(FISH_CREATE_DIRS)
FUNCTION(FISH_TRY_CREATE_DIRS)
FOREACH(dir ${ARGV})
IF(NOT IS_ABSOLUTE ${dir})
SET(abs_dir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${dir}")
ELSE()
SET(abs_dir "\$ENV{DESTDIR}${dir}")
ENDIF()
INSTALL(SCRIPT CODE "EXECUTE_PROCESS(COMMAND mkdir -p ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
EXECUTE_PROCESS(COMMAND chmod 755 ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
function(FISH_TRY_CREATE_DIRS)
foreach(dir ${ARGV})
if(NOT IS_ABSOLUTE ${dir})
set(abs_dir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${dir}")
else()
set(abs_dir "\$ENV{DESTDIR}${dir}")
endif()
install(SCRIPT CODE "EXECUTE_PROCESS(COMMAND mkdir -p ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND chmod 755 ${abs_dir} OUTPUT_QUIET ERROR_QUIET)
")
ENDFOREACH()
ENDFUNCTION(FISH_TRY_CREATE_DIRS)
endforeach()
endfunction(FISH_TRY_CREATE_DIRS)
INSTALL(TARGETS ${PROGRAMS}
install(TARGETS ${PROGRAMS}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${bindir})
FISH_CREATE_DIRS(${sysconfdir}/fish/conf.d ${sysconfdir}/fish/completions
fish_create_dirs(${sysconfdir}/fish/conf.d ${sysconfdir}/fish/completions
${sysconfdir}/fish/functions)
INSTALL(FILES etc/config.fish DESTINATION ${sysconfdir}/fish/)
install(FILES etc/config.fish DESTINATION ${sysconfdir}/fish/)
FISH_CREATE_DIRS(${rel_datadir}/fish ${rel_datadir}/fish/completions
fish_create_dirs(${rel_datadir}/fish ${rel_datadir}/fish/completions
${rel_datadir}/fish/functions ${rel_datadir}/fish/groff
${rel_datadir}/fish/man/man1 ${rel_datadir}/fish/tools
${rel_datadir}/fish/tools/web_config
@ -89,53 +89,53 @@ FISH_CREATE_DIRS(${rel_datadir}/fish ${rel_datadir}/fish/completions
${rel_datadir}/fish/tools/web_config/partials
${rel_datadir}/fish/tools/web_config/sample_prompts)
CONFIGURE_FILE(share/__fish_build_paths.fish.in share/__fish_build_paths.fish)
INSTALL(FILES share/config.fish
configure_file(share/__fish_build_paths.fish.in share/__fish_build_paths.fish)
install(FILES share/config.fish
${CMAKE_CURRENT_BINARY_DIR}/share/__fish_build_paths.fish
DESTINATION ${rel_datadir}/fish)
# Create only the vendor directories inside the prefix (#5029 / #6508)
FISH_CREATE_DIRS(${rel_datadir}/fish/vendor_completions.d ${rel_datadir}/fish/vendor_functions.d
fish_create_dirs(${rel_datadir}/fish/vendor_completions.d ${rel_datadir}/fish/vendor_functions.d
${rel_datadir}/fish/vendor_conf.d)
FISH_TRY_CREATE_DIRS(${rel_datadir}/pkgconfig)
CONFIGURE_FILE(fish.pc.in fish.pc.noversion)
fish_try_create_dirs(${rel_datadir}/pkgconfig)
configure_file(fish.pc.in fish.pc.noversion)
ADD_CUSTOM_COMMAND(OUTPUT fish.pc
add_custom_command(OUTPUT fish.pc
COMMAND sed '/Version/d' fish.pc.noversion > fish.pc
COMMAND printf "Version: " >> fish.pc
COMMAND sed 's/FISH_BUILD_VERSION=//\;s/\"//g' ${FBVF} >> fish.pc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FBVF} ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion)
ADD_CUSTOM_TARGET(build_fish_pc ALL DEPENDS fish.pc)
add_custom_target(build_fish_pc ALL DEPENDS fish.pc)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/fish.pc
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fish.pc
DESTINATION ${rel_datadir}/pkgconfig)
INSTALL(DIRECTORY share/completions/
install(DIRECTORY share/completions/
DESTINATION ${rel_datadir}/fish/completions
FILES_MATCHING PATTERN "*.fish")
INSTALL(DIRECTORY share/functions/
install(DIRECTORY share/functions/
DESTINATION ${rel_datadir}/fish/functions
FILES_MATCHING PATTERN "*.fish")
INSTALL(DIRECTORY share/groff
install(DIRECTORY share/groff
DESTINATION ${rel_datadir}/fish)
# CONDEMNED_PAGE is managed by the conditional above
# Building the man pages is optional: if sphinx isn't installed, they're not built
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/
DESTINATION ${rel_datadir}/fish/man/man1
FILES_MATCHING
PATTERN "*.1"
PATTERN ${CONDEMNED_PAGE} EXCLUDE)
INSTALL(PROGRAMS share/tools/create_manpage_completions.py share/tools/deroff.py
install(PROGRAMS share/tools/create_manpage_completions.py share/tools/deroff.py
DESTINATION ${rel_datadir}/fish/tools/)
INSTALL(DIRECTORY share/tools/web_config
install(DIRECTORY share/tools/web_config
DESTINATION ${rel_datadir}/fish/tools/
FILES_MATCHING
PATTERN "*.png"
@ -146,34 +146,34 @@ INSTALL(DIRECTORY share/tools/web_config
PATTERN "*.fish")
# Building the man pages is optional: if Sphinx isn't installed, they're not built
INSTALL(FILES ${MANUALS} DESTINATION ${mandir}/man1/ OPTIONAL)
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/html/ # Trailing slash is important!
install(FILES ${MANUALS} DESTINATION ${mandir}/man1/ OPTIONAL)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/html/ # Trailing slash is important!
DESTINATION ${docdir} OPTIONAL)
INSTALL(FILES CHANGELOG.md DESTINATION ${docdir})
install(FILES CHANGELOG.md DESTINATION ${docdir})
INSTALL(FILES share/lynx.lss DESTINATION ${rel_datadir}/fish/)
install(FILES share/lynx.lss DESTINATION ${rel_datadir}/fish/)
# These files are built by cmake/gettext.cmake, but using GETTEXT_PROCESS_PO_FILES's
# INSTALL_DESTINATION leads to them being installed as ${lang}.gmo, not fish.mo
# The ${languages} array comes from cmake/gettext.cmake
IF(GETTEXT_FOUND)
FOREACH(lang ${languages})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo DESTINATION
if(GETTEXT_FOUND)
foreach(lang ${languages})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${lang}.gmo DESTINATION
${CMAKE_INSTALL_LOCALEDIR}/${lang}/LC_MESSAGES/ RENAME fish.mo)
ENDFOREACH()
ENDIF()
endforeach()
endif()
INSTALL(FILES fish.desktop DESTINATION ${rel_datadir}/applications)
INSTALL(FILES fish.png DESTINATION ${rel_datadir}/pixmaps)
install(FILES fish.desktop DESTINATION ${rel_datadir}/applications)
install(FILES fish.png DESTINATION ${rel_datadir}/pixmaps)
# Group install targets into a InstallTargets folder
SET_PROPERTY(TARGET build_fish_pc CHECK-FISH-BUILD-VERSION-FILE
set_property(TARGET build_fish_pc CHECK-FISH-BUILD-VERSION-FILE
test_fishscript
test_prep tests_buildroot_target
PROPERTY FOLDER cmake/InstallTargets)
# Make a target build_root that installs into the buildroot directory, for testing.
SET(BUILDROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/buildroot)
ADD_CUSTOM_TARGET(build_root
set(BUILDROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/buildroot)
add_custom_target(build_root
COMMAND DESTDIR=${BUILDROOT_DIR} ${CMAKE_COMMAND}
--build ${CMAKE_CURRENT_BINARY_DIR} --target install)

View file

@ -1,24 +1,24 @@
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
# Code signing ID on Mac. A default '-' is ad-hoc codesign.
SET(MAC_CODESIGN_ID "-" CACHE STRING "Mac code-signing identity")
set(MAC_CODESIGN_ID "-" CACHE STRING "Mac code-signing identity")
# Whether to inject the "get-task-allow" entitlement, which permits debugging
# on the Mac.
SET(MAC_INJECT_GET_TASK_ALLOW ON CACHE BOOL "Inject get-task-allow on Mac")
set(MAC_INJECT_GET_TASK_ALLOW ON CACHE BOOL "Inject get-task-allow on Mac")
FUNCTION(CODESIGN_ON_MAC target)
IF(APPLE)
IF(MAC_INJECT_GET_TASK_ALLOW)
SET(ENTITLEMENTS "--entitlements" "${CMAKE_SOURCE_DIR}/osx/fish_debug.entitlements")
ELSE()
SET(ENTITLEMENTS "")
ENDIF(MAC_INJECT_GET_TASK_ALLOW)
ADD_CUSTOM_COMMAND(
function(CODESIGN_ON_MAC target)
if(APPLE)
if(MAC_INJECT_GET_TASK_ALLOW)
set(ENTITLEMENTS "--entitlements" "${CMAKE_SOURCE_DIR}/osx/fish_debug.entitlements")
else()
set(ENTITLEMENTS "")
endif(MAC_INJECT_GET_TASK_ALLOW)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND codesign --force --deep --options runtime ${ENTITLEMENTS} --sign "${MAC_CODESIGN_ID}" $<TARGET_FILE:${target}>
VERBATIM
)
ENDIF()
ENDFUNCTION(CODESIGN_ON_MAC target)
endif()
endfunction(CODESIGN_ON_MAC target)

View file

@ -1,12 +1,12 @@
# This is Mac-only.
if (NOT APPLE)
RETURN()
return()
endif (NOT APPLE)
# The source tree containing certain macOS resources.
SET(OSX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/osx)
set(OSX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/osx)
SET(RESOURCE_FILES
set(RESOURCE_FILES
${OSX_DIR}/launch_fish.scpt
${OSX_DIR}/fish_term_icon.icns
${CMAKE_CURRENT_SOURCE_DIR}/build_tools/osx_package_scripts/add-shell
@ -14,7 +14,7 @@ SET(RESOURCE_FILES
)
# Resource files must be present in the source list.
ADD_EXECUTABLE(fish_macapp EXCLUDE_FROM_ALL
add_executable(fish_macapp EXCLUDE_FROM_ALL
${OSX_DIR}/osx_fish_launcher.m
${RESOURCE_FILES}
)
@ -22,7 +22,7 @@ ADD_EXECUTABLE(fish_macapp EXCLUDE_FROM_ALL
# Compute the version. Note this is done at generation time, not build time,
# so cmake must be re-run after version changes for the app to be updated. But
# generally this will be run by make_pkg.sh which always re-runs cmake.
EXECUTE_PROCESS(
execute_process(
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh --stdout
COMMAND cut -d- -f1
OUTPUT_VARIABLE FISH_SHORT_VERSION
@ -31,12 +31,12 @@ EXECUTE_PROCESS(
# Note CMake appends .app, so the real output name will be fish.app.
# This target does not include the 'base' resource.
SET_TARGET_PROPERTIES(fish_macapp PROPERTIES OUTPUT_NAME "fish")
set_target_properties(fish_macapp PROPERTIES OUTPUT_NAME "fish")
FIND_LIBRARY(FOUNDATION_LIB Foundation)
TARGET_LINK_LIBRARIES(fish_macapp ${FOUNDATION_LIB})
find_library(FOUNDATION_LIB Foundation)
target_link_libraries(fish_macapp ${FOUNDATION_LIB})
SET_TARGET_PROPERTIES(fish_macapp PROPERTIES
set_target_properties(fish_macapp PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${OSX_DIR}/CMakeMacAppInfo.plist.in
MACOSX_BUNDLE_GUI_IDENTIFIER "com.ridiculousfish.fish-shell"
@ -47,9 +47,9 @@ SET_TARGET_PROPERTIES(fish_macapp PROPERTIES
# The fish Mac app contains a fish installation inside the package.
# Here is where it gets built.
# Copy into the fish mac app after.
SET(MACAPP_FISH_BUILDROOT ${CMAKE_CURRENT_BINARY_DIR}/macapp_buildroot/base)
set(MACAPP_FISH_BUILDROOT ${CMAKE_CURRENT_BINARY_DIR}/macapp_buildroot/base)
ADD_CUSTOM_COMMAND(TARGET fish_macapp POST_BUILD
add_custom_command(TARGET fish_macapp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${MACAPP_FISH_BUILDROOT}
COMMAND DESTDIR=${MACAPP_FISH_BUILDROOT} ${CMAKE_COMMAND}
--build ${CMAKE_CURRENT_BINARY_DIR} --target install
@ -59,12 +59,12 @@ ADD_CUSTOM_COMMAND(TARGET fish_macapp POST_BUILD
)
# The entitlements file.
SET(MACAPP_ENTITLEMENTS "${CMAKE_SOURCE_DIR}/osx/MacApp.entitlements")
set(MACAPP_ENTITLEMENTS "${CMAKE_SOURCE_DIR}/osx/MacApp.entitlements")
# Target to sign the macapp.
# Note that a POST_BUILD step happens before resources are copied,
# and therefore would be too early.
ADD_CUSTOM_TARGET(signed_fish_macapp
add_custom_target(signed_fish_macapp
DEPENDS fish_macapp "${MACAPP_ENTITLEMENTS}"
COMMAND codesign --force --deep
--options runtime

View file

@ -1,22 +1,22 @@
# PCRE2 needs some settings.
SET(PCRE2_WIDTH ${WCHAR_T_BITS})
SET(PCRE2_BUILD_PCRE2_8 OFF CACHE BOOL "Build 8bit PCRE2 library")
SET(PCRE2_BUILD_PCRE2_${PCRE2_WIDTH} ON CACHE BOOL "Build ${PCRE2_WIDTH}bit PCRE2 library")
SET(PCRE2_SHOW_REPORT OFF CACHE BOOL "Show the final configuration report")
SET(PCRE2_BUILD_TESTS OFF CACHE BOOL "Build tests")
SET(PCRE2_BUILD_PCRE2GREP OFF CACHE BOOL "Build pcre2grep")
set(PCRE2_WIDTH ${WCHAR_T_BITS})
set(PCRE2_BUILD_PCRE2_8 OFF CACHE BOOL "Build 8bit PCRE2 library")
set(PCRE2_BUILD_PCRE2_${PCRE2_WIDTH} ON CACHE BOOL "Build ${PCRE2_WIDTH}bit PCRE2 library")
set(PCRE2_SHOW_REPORT OFF CACHE BOOL "Show the final configuration report")
set(PCRE2_BUILD_TESTS OFF CACHE BOOL "Build tests")
set(PCRE2_BUILD_PCRE2GREP OFF CACHE BOOL "Build pcre2grep")
SET(PCRE2_MIN_VERSION 10.21)
set(PCRE2_MIN_VERSION 10.21)
IF (NOT APPLE)
FIND_LIBRARY(PCRE2_LIB pcre2-${PCRE2_WIDTH})
FIND_PATH(PCRE2_INCLUDE_DIR pcre2.h)
ENDIF()
find_library(PCRE2_LIB pcre2-${PCRE2_WIDTH})
find_path(PCRE2_INCLUDE_DIR pcre2.h)
endif()
IF (PCRE2_LIB AND PCRE2_INCLUDE_DIR)
MESSAGE(STATUS "Found system PCRE2 library ${PCRE2_INCLUDE_DIR}")
ELSE()
MESSAGE(STATUS "Using bundled PCRE2 library")
ADD_SUBDIRECTORY(pcre2 EXCLUDE_FROM_ALL)
SET(PCRE2_INCLUDE_DIR ${CMAKE_BINARY_DIR}/pcre2)
SET(PCRE2_LIB pcre2-${PCRE2_WIDTH})
ENDIF(PCRE2_LIB AND PCRE2_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${PCRE2_INCLUDE_DIR})
message(STATUS "Found system PCRE2 library ${PCRE2_INCLUDE_DIR}")
else()
message(STATUS "Using bundled PCRE2 library")
add_subdirectory(pcre2 EXCLUDE_FROM_ALL)
set(PCRE2_INCLUDE_DIR ${CMAKE_BINARY_DIR}/pcre2)
set(PCRE2_LIB pcre2-${PCRE2_WIDTH})
endif(PCRE2_LIB AND PCRE2_INCLUDE_DIR)
include_directories(${PCRE2_INCLUDE_DIR})

View file

@ -1,38 +1,38 @@
# Define fish_tests.
ADD_EXECUTABLE(fish_tests EXCLUDE_FROM_ALL
add_executable(fish_tests EXCLUDE_FROM_ALL
src/fish_tests.cpp)
FISH_LINK_DEPS_AND_SIGN(fish_tests)
fish_link_deps_and_sign(fish_tests)
# The "test" directory.
SET(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
# The directory into which fish is installed.
SET(TEST_INSTALL_DIR ${TEST_DIR}/buildroot)
set(TEST_INSTALL_DIR ${TEST_DIR}/buildroot)
# The directory where the tests expect to find the fish root (./bin, etc)
SET(TEST_ROOT_DIR ${TEST_DIR}/root)
set(TEST_ROOT_DIR ${TEST_DIR}/root)
# Copy tests files.
FILE(GLOB TESTS_FILES tests/*)
ADD_CUSTOM_TARGET(tests_dir DEPENDS tests)
file(GLOB TESTS_FILES tests/*)
add_custom_target(tests_dir DEPENDS tests)
IF(NOT FISH_IN_TREE_BUILD)
ADD_CUSTOM_COMMAND(TARGET tests_dir
if(NOT FISH_IN_TREE_BUILD)
add_custom_command(TARGET tests_dir
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/tests/ ${CMAKE_BINARY_DIR}/tests/
COMMENT "Copying test files to binary dir"
VERBATIM)
ADD_DEPENDENCIES(fish_tests tests_dir)
ENDIF()
add_dependencies(fish_tests tests_dir)
endif()
# Copy littlecheck.py
CONFIGURE_FILE(build_tools/littlecheck.py littlecheck.py COPYONLY)
configure_file(build_tools/littlecheck.py littlecheck.py COPYONLY)
# Make the directory in which to run tests.
# Also symlink fish to where the tests expect it to be.
# Lastly put fish_test_helper there too.
ADD_CUSTOM_TARGET(tests_buildroot_target
add_custom_target(tests_buildroot_target
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_INSTALL_DIR}
COMMAND DESTDIR=${TEST_INSTALL_DIR} ${CMAKE_COMMAND}
--build ${CMAKE_CURRENT_BINARY_DIR} --target install
@ -43,20 +43,20 @@ ADD_CUSTOM_TARGET(tests_buildroot_target
${TEST_ROOT_DIR}
DEPENDS fish fish_test_helper)
IF(NOT FISH_IN_TREE_BUILD)
if(NOT FISH_IN_TREE_BUILD)
# We need to symlink share/functions for the tests.
# This should be simplified.
ADD_CUSTOM_TARGET(symlink_functions
add_custom_target(symlink_functions
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/share/functions
${CMAKE_CURRENT_BINARY_DIR}/share/functions)
ADD_DEPENDENCIES(tests_buildroot_target symlink_functions)
ELSE()
ADD_CUSTOM_TARGET(symlink_functions)
ENDIF()
add_dependencies(tests_buildroot_target symlink_functions)
else()
add_custom_target(symlink_functions)
endif()
# Prep the environment for running the unit tests.
ADD_CUSTOM_TARGET(test_prep
add_custom_target(test_prep
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/data
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/home
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/temp
@ -69,46 +69,46 @@ ADD_CUSTOM_TARGET(test_prep
# Each test is conceptually independent.
# However when running all tests, we want to run them serially for sanity's sake.
# So define both a normal target, and a serial variant which enforces ordering.
FOREACH(TESTTYPE test serial_test)
ADD_CUSTOM_TARGET(${TESTTYPE}_low_level
foreach(TESTTYPE test serial_test)
add_custom_target(${TESTTYPE}_low_level
COMMAND env XDG_DATA_HOME=test/data XDG_CONFIG_HOME=test/home ./fish_tests
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS fish_tests
USES_TERMINAL)
ADD_CUSTOM_TARGET(${TESTTYPE}_fishscript
add_custom_target(${TESTTYPE}_fishscript
COMMAND cd tests && ${TEST_ROOT_DIR}/bin/fish test.fish
DEPENDS test_prep
USES_TERMINAL)
ADD_CUSTOM_TARGET(${TESTTYPE}_interactive
add_custom_target(${TESTTYPE}_interactive
COMMAND cd tests && ${TEST_ROOT_DIR}/bin/fish interactive.fish
DEPENDS test_prep
USES_TERMINAL)
ENDFOREACH(TESTTYPE)
endforeach(TESTTYPE)
# Now add a dependency chain between the serial versions.
# This ensures they run in order.
ADD_DEPENDENCIES(serial_test_fishscript serial_test_low_level)
ADD_DEPENDENCIES(serial_test_interactive serial_test_fishscript)
add_dependencies(serial_test_fishscript serial_test_low_level)
add_dependencies(serial_test_interactive serial_test_fishscript)
ADD_CUSTOM_TARGET(serial_test_high_level
add_custom_target(serial_test_high_level
DEPENDS serial_test_interactive serial_test_fishscript)
# Create the 'test' target.
# Set a policy so CMake stops complaining about the name 'test'.
CMAKE_POLICY(PUSH)
cmake_policy(PUSH)
IF(${CMAKE_VERSION} VERSION_LESS 3.11.0 AND POLICY CMP0037)
CMAKE_POLICY(SET CMP0037 OLD)
ENDIF()
ADD_CUSTOM_TARGET(test)
CMAKE_POLICY(POP)
ADD_DEPENDENCIES(test serial_test_high_level)
if(${CMAKE_VERSION} VERSION_LESS 3.11.0 AND POLICY CMP0037)
cmake_policy(SET CMP0037 OLD)
endif()
add_custom_target(test)
cmake_policy(POP)
add_dependencies(test serial_test_high_level)
# Group test targets into a TestTargets folder
SET_PROPERTY(TARGET test tests_dir
set_property(TARGET test tests_dir
test_low_level
test_fishscript
test_interactive

View file

@ -31,25 +31,25 @@
# stays the same (incremental builds must be fast).
# Just a handy abbreviation.
SET(FBVF FISH-BUILD-VERSION-FILE)
set(FBVF FISH-BUILD-VERSION-FILE)
# TODO: find a cleaner way to do this.
IF (${CMAKE_GENERATOR} STREQUAL Ninja)
SET(FBVF-OUTPUT fish-build-version-witness.txt)
SET(CFBVF-BYPRODUCTS ${FBVF})
ELSE(${CMAKE_GENERATOR} STREQUAL Ninja)
SET(FBVF-OUTPUT ${FBVF})
SET(CFBVF-BYPRODUCTS)
ENDIF(${CMAKE_GENERATOR} STREQUAL Ninja)
set(FBVF-OUTPUT fish-build-version-witness.txt)
set(CFBVF-BYPRODUCTS ${FBVF})
else(${CMAKE_GENERATOR} STREQUAL Ninja)
set(FBVF-OUTPUT ${FBVF})
set(CFBVF-BYPRODUCTS)
endif(${CMAKE_GENERATOR} STREQUAL Ninja)
# Set up the version targets
ADD_CUSTOM_TARGET(CHECK-FISH-BUILD-VERSION-FILE
add_custom_target(CHECK-FISH-BUILD-VERSION-FILE
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh ${CMAKE_CURRENT_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
BYPRODUCTS ${CFBVF-BYPRODUCTS})
ADD_CUSTOM_COMMAND(OUTPUT ${FBVF-OUTPUT}
add_custom_command(OUTPUT ${FBVF-OUTPUT}
DEPENDS CHECK-FISH-BUILD-VERSION-FILE)
# Abbreviation for the target.
SET(CFBVF CHECK-FISH-BUILD-VERSION-FILE)
set(CFBVF CHECK-FISH-BUILD-VERSION-FILE)

View file

@ -1,36 +1,36 @@
SET(languages de en fr nb nn pl pt_BR sv zh_CN)
set(languages de en fr nb nn pl pt_BR sv zh_CN)
INCLUDE(FeatureSummary)
include(FeatureSummary)
OPTION(WITH_GETTEXT "translate messages if gettext is available" ON)
IF(WITH_GETTEXT)
FIND_PACKAGE(Intl)
FIND_PACKAGE(Gettext)
IF(GETTEXT_FOUND)
SET(HAVE_GETTEXT 1)
INCLUDE_DIRECTORIES(${Intl_INCLUDE_DIR})
ENDIF()
ENDIF()
ADD_FEATURE_INFO(gettext GETTEXT_FOUND "translate messages with gettext")
option(WITH_GETTEXT "translate messages if gettext is available" ON)
if(WITH_GETTEXT)
find_package(Intl)
find_package(Gettext)
if(GETTEXT_FOUND)
set(HAVE_GETTEXT 1)
include_directories(${Intl_INCLUDE_DIR})
endif()
endif()
add_feature_info(gettext GETTEXT_FOUND "translate messages with gettext")
# Define translations
IF(GETTEXT_FOUND)
FOREACH(lang ${languages})
if(GETTEXT_FOUND)
foreach(lang ${languages})
# Our translations aren't set up entirely as CMake expects, so installation is done in
# cmake/Install.cmake instead of using INSTALL_DESTINATION
GETTEXT_PROCESS_PO_FILES(${lang} ALL
gettext_process_po_files(${lang} ALL
PO_FILES po/${lang}.po)
ENDFOREACH()
ENDIF()
endforeach()
endif()
CMAKE_PUSH_CHECK_STATE()
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Intl_INCLUDE_DIR})
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${Intl_LIBRARIES})
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Intl_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${Intl_LIBRARIES})
# libintl.h can be compiled into the stdlib on some GLibC systems
IF(Intl_FOUND AND Intl_LIBRARIES)
SET(LIBINTL_INCLUDE "#include <libintl.h>")
ENDIF()
CHECK_CXX_SOURCE_COMPILES("
if(Intl_FOUND AND Intl_LIBRARIES)
set(LIBINTL_INCLUDE "#include <libintl.h>")
endif()
check_cxx_source_compiles("
${LIBINTL_INCLUDE}
#include <stdlib.h>
int main () {
@ -40,4 +40,4 @@ int main () {
}
"
HAVE__NL_MSG_CAT_CNTR)
CMAKE_POP_CHECK_STATE()
cmake_pop_check_state()