Initial CMake import

This adds a basic CMakeLists.txt. It also adds a ConfigureChecks.cmake
and config_cmake.h.in that produces a config.h.
This commit is contained in:
ridiculousfish 2017-08-31 13:24:20 -07:00
parent fb8ae04f80
commit 9f8ae95b0e
3 changed files with 405 additions and 0 deletions

View file

@ -0,0 +1,92 @@
# Detect curses.
INCLUDE(FindCurses)
# Get threads.
set(THREADS_PREFER_PTHREAD_FLAG ON)
FIND_PACKAGE(Threads REQUIRED)
IF(APPLE)
# 10.7+ only.
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Werror=unguarded-availability")
ENDIF()
# Set up the config.h file.
SET(PACKAGE_NAME "fish")
SET(PACKAGE_TARNAME "fish")
INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckStructHasMember)
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(CheckTypeSize)
CHECK_FUNCTION_EXISTS(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
CHECK_FUNCTION_EXISTS(ctermid_r HAVE_CTERMID_R)
CHECK_INCLUDE_FILES(curses.h HAVE_CURSES_H)
CHECK_STRUCT_HAS_MEMBER(dirent d_type dirent.h HAVE_STRUCT_DIRENT_D_TYPE)
CHECK_FUNCTION_EXISTS(dirfd HAVE_DIRFD)
CHECK_INCLUDE_FILES(execinfo.h HAVE_EXECINFO_H)
CHECK_FUNCTION_EXISTS(flock 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_SYMBOL_EXISTS(futimens sys/stat.h HAVE_FUTIMENS)
CHECK_FUNCTION_EXISTS(futimes HAVE_FUTIMES)
CHECK_FUNCTION_EXISTS(getifaddrs HAVE_GETIFADDRS)
CHECK_INCLUDE_FILES(getopt.h HAVE_GETOPT_H)
CHECK_FUNCTION_EXISTS(getpwent HAVE_GETPWENT)
CHECK_FUNCTION_EXISTS(gettext HAVE_GETTEXT)
CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H)
CHECK_FUNCTION_EXISTS(killpg HAVE_KILLPG)
CHECK_INCLUDE_FILES(libintl.h HAVE_LIBINTL_H)
CHECK_FUNCTION_EXISTS(lrand48_r HAVE_LRAND48_R)
CHECK_INCLUDE_FILES(memory.h HAVE_MEMORY_H)
CHECK_FUNCTION_EXISTS(mkostemp HAVE_MKOSTEMP)
SET(HAVE_CURSES_H ${CURSES_HAVE_CURSES_H})
SET(HAVE_NCURSES_CURSES_H ${CURSES_HAVE_NCURSES_CURSES_H})
SET(HAVE_CURSES_H ${CURSES_HAVE_CURSES_H})
SET(HAVE_NCURSES_H ${CURSES_HAVE_NCURSES_H})
CHECK_INCLUDE_FILES("ncurses/term.h" HAVE_NCURSES_TERM_H)
CHECK_FUNCTION_EXISTS(DIR HAVE_NDIR_H)
CHECK_FUNCTION_EXISTS(shm_open HAVE_SHM_OPEN)
CHECK_INCLUDE_FILES(siginfo.h HAVE_SIGINFO_H)
CHECK_INCLUDE_FILES(spawn.h HAVE_SPAWN_H)
CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
CHECK_FUNCTION_EXISTS(std::wcscasecmp HAVE_STD__WCSCASECMP)
CHECK_FUNCTION_EXISTS(std::wcsdup HAVE_STD__WCSDUP)
CHECK_FUNCTION_EXISTS(std::wcsncasecmp HAVE_STD__WCSNCASECMP)
CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
CHECK_INCLUDE_FILES(stropts.h HAVE_STROPTS_H)
CHECK_FUNCTION_EXISTS(struct dirent HAVE_STRUCT_DIRENT_D_TYPE)
CHECK_FUNCTION_EXISTS(struct stat HAVE_STRUCT_STAT_ST_CTIME_NSEC)
CHECK_FUNCTION_EXISTS(struct stat HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
CHECK_FUNCTION_EXISTS(struct stat HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
CHECK_SYMBOL_EXISTS(sys_errlist stdio.h HAVE_SYS_ERRLIST)
CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H)
CHECK_INCLUDE_FILES(sys/resource.h HAVE_SYS_RESOURCE_H)
CHECK_INCLUDE_FILES(sys/select.h HAVE_SYS_SELECT_H)
CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES(sys/sysctl.h HAVE_SYS_SYSCTL_H)
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES(termios.h HAVE_TERMIOS_H)
CHECK_INCLUDE_FILES(term.h HAVE_TERM_H)
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
CHECK_FUNCTION_EXISTS(wcscasecmp HAVE_WCSCASECMP)
CHECK_FUNCTION_EXISTS(wcsdup HAVE_WCSDUP)
CHECK_FUNCTION_EXISTS(wcslcpy HAVE_WCSLCPY)
CHECK_FUNCTION_EXISTS(wcsncasecmp HAVE_WCSNCASECMP)
CHECK_FUNCTION_EXISTS(wcsndup HAVE_WCSNDUP)
CHECK_SYMBOL_EXISTS(_nl_msg_cat_cntr stdlib.h HAVE__NL_MSG_CAT_CNTR)
CHECK_SYMBOL_EXISTS(_sys_errs stdlib.h HAVE__SYS__ERRS)
SET(CMAKE_EXTRA_INCLUDE_FILES termios.h sys/ioctl.h)
CHECK_TYPE_SIZE("struct winsize" STRUCT_WINSIZE)
CHECK_SYMBOL_EXISTS("TIOCGWINSZ" "termios.h sys/ioctl.h" HAVE_TIOCGWINSZ)
IF(${STRUCT_WINSIZE} AND (DEFINED HAVE_TIOCGWINSZ))
SET(HAVE_WINSIZE 1)
ENDIF()
SET(CMAKE_EXTRA_INCLUDE_FILES)
SET(HAVE__PROC_SELF_STAT (EXISTS "/proc/self/stat"))
CHECK_TYPE_SIZE("wchar_t[8]" WCHAR_T_BITS)

75
CMakeLists.txt Normal file
View file

@ -0,0 +1,75 @@
PROJECT(fish-shell)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
# We are C++11.
SET(CMAKE_CXX_STANDARD 11)
# All objects that the system needs to build fish, except fish.cpp
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
src/builtin_complete.cpp src/builtin_contains.cpp src/builtin_disown.cpp
src/builtin_echo.cpp src/builtin_emit.cpp src/builtin_exit.cpp
src/builtin_fg.cpp src/builtin_function.cpp src/builtin_functions.cpp
src/builtin_argparse.cpp src/builtin_history.cpp src/builtin_jobs.cpp
src/builtin_math.cpp src/builtin_printf.cpp src/builtin_pwd.cpp
src/builtin_random.cpp src/builtin_read.cpp src/builtin_realpath.cpp
src/builtin_return.cpp src/builtin_set.cpp src/builtin_set_color.cpp
src/builtin_source.cpp src/builtin_status.cpp src/builtin_string.cpp
src/builtin_test.cpp src/builtin_ulimit.cpp src/color.cpp src/common.cpp
src/complete.cpp src/env.cpp src/env_universal_common.cpp src/event.cpp
src/exec.cpp src/expand.cpp src/fallback.cpp src/fish_version.cpp
src/function.cpp src/highlight.cpp src/history.cpp src/input.cpp
src/input_common.cpp src/intern.cpp src/io.cpp src/iothread.cpp
src/kill.cpp src/output.cpp src/pager.cpp src/parse_execution.cpp
src/parse_productions.cpp src/parse_tree.cpp src/parse_util.cpp
src/parser.cpp src/parser_keywords.cpp src/path.cpp src/postfork.cpp
src/proc.cpp src/reader.cpp src/sanity.cpp src/screen.cpp src/signal.cpp
src/tokenizer.cpp src/utf8.cpp src/util.cpp src/wcstringutil.cpp
src/wgetopt.cpp src/wildcard.cpp src/wutil.cpp
)
# Set up FISH-BUILD-VERSION-FILE
# Note this happens when CMake runs, not when the generated build system runs
EXECUTE_PROCESS(COMMAND build_tools/git_version_gen.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_QUIET)
# Set up config.h
INCLUDE(CMakeFiles/ConfigureChecks.cmake)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config_cmake.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
# Set up standard directories.
INCLUDE(GNUInstallDirs)
ADD_DEFINITIONS(-D_UNICODE=1
-DFISH_BUILD_VERSION="${FISH_BUILD_VERSION}"
-DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
-DPREFIX=L"${CMAKE_INSTALL_PREFIX}"
-DDATADIR=L"${CMAKE_INSTALL_FULL_DATADIR}"
-DSYSCONFDIR=L"${CMAKE_INSTALL_FULL_SYSCONFDIR}"
-DBINDIR=L"${CMAKE_INSTALL_FULL_BINDIR}"
-DDOCDIR=L"${CMAKE_INSTALL_FULL_DOCDIR}")
# Set up dependency paths.
INCLUDE_DIRECTORIES(muparser-2.2.5/include/ pcre2-10.22/src/)
LINK_DIRECTORIES(muparser-2.2.5/lib/ pcre2-10.22/.libs/)
# PCRE2 needs a define.
SET(PCRE2_WIDTH ${WCHAR_T_BITS})
# Define a function to link dependencies.
FUNCTION(FISH_LINK_DEPS target)
TARGET_LINK_LIBRARIES(${target} ${CURSES_LIBRARIES} Threads::Threads)
TARGET_LINK_LIBRARIES(${target} pcre2-${PCRE2_WIDTH} muparser)
ENDFUNCTION(FISH_LINK_DEPS)
# Define fish.
ADD_EXECUTABLE(fish src/fish.cpp ${FISH_SRCS})
TARGET_LINK_LIBRARIES(fish ${CURSES_LIBRARIES})
# Link PCRE and muparser.
SET(PCRE2_WIDTH ${WCHAR_T_BITS})
TARGET_LINK_LIBRARIES(fish pcre2-${PCRE2_WIDTH} muparser)

238
config_cmake.h.in Normal file
View file

@ -0,0 +1,238 @@
/* Define to 1 if you have the `backtrace_symbols' function. */
#cmakedefine HAVE_BACKTRACE_SYMBOLS 1
/* Define to 1 if you have the `clock_gettime' function. */
#cmakedefine HAVE_CLOCK_GETTIME 1
/* Define to 1 if you have the `ctermid_r' function. */
#cmakedefine HAVE_CTERMID_R 1
/* Define to 1 if you have the <curses.h> header file. */
#cmakedefine HAVE_CURSES_H 1
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */
#cmakedefine HAVE_DIRENT_H 1
/* Define to 1 if you have the `dirfd' function. */
#cmakedefine HAVE_DIRFD 1
/* Define to 1 if you have the <execinfo.h> header file. */
#cmakedefine HAVE_EXECINFO_H 1
/* Define to 1 if you have the `flock' function. */
#cmakedefine HAVE_FLOCK 1
/* Define to 1 if you have the `futimens' function. */
#cmakedefine HAVE_FUTIMENS 1
/* Define to 1 if you have the `futimes' function. */
#cmakedefine HAVE_FUTIMES 1
/* Define to 1 if you have the `getifaddrs' function. */
#cmakedefine HAVE_GETIFADDRS 1
/* Define to 1 if you have the <getopt.h> header file. */
#cmakedefine HAVE_GETOPT_H 1
/* Define to 1 if you have the `getpwent' function. */
#cmakedefine HAVE_GETPWENT 1
/* Define to 1 if you have the `gettext' function. */
#cmakedefine HAVE_GETTEXT 1
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1
/* Define to 1 if you have the `killpg' function. */
#cmakedefine HAVE_KILLPG 1
/* Define to 1 if you have the <libintl.h> header file. */
#cmakedefine HAVE_LIBINTL_H 1
/* Define to 1 if you have the `lrand48_r' function. */
#cmakedefine HAVE_LRAND48_R 1
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H 1
/* Define to 1 if you have the `mkostemp' function. */
#cmakedefine HAVE_MKOSTEMP 1
/* Define to 1 if you have the <ncurses/curses.h> header file. */
#cmakedefine HAVE_NCURSES_CURSES_H 1
/* Define to 1 if you have the <ncurses.h> header file. */
#cmakedefine HAVE_NCURSES_H 1
/* Define to 1 if you have the <ncurses/term.h> header file. */
#cmakedefine HAVE_NCURSES_TERM_H 1
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#cmakedefine HAVE_NDIR_H 1
/* Define to 1 if the shm_open() function exists */
#cmakedefine HAVE_SHM_OPEN 1
/* Define to 1 if you have the <siginfo.h> header file. */
#cmakedefine HAVE_SIGINFO_H 1
/* Define to 1 if you have the <spawn.h> header file. */
#cmakedefine HAVE_SPAWN_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H 1
/* Define to 1 if you have the `std::wcscasecmp' function. */
#cmakedefine HAVE_STD__WCSCASECMP 1
/* Define to 1 if you have the `std::wcsdup' function. */
#cmakedefine HAVE_STD__WCSDUP 1
/* Define to 1 if you have the `std::wcsncasecmp' function. */
#cmakedefine HAVE_STD__WCSNCASECMP 1
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H 1
/* Define to 1 if you have the <stropts.h> header file. */
#cmakedefine HAVE_STROPTS_H 1
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#cmakedefine HAVE_STRUCT_DIRENT_D_TYPE 1
/* Define to 1 if `st_ctime_nsec' is a member of `struct stat'. */
#cmakedefine HAVE_STRUCT_STAT_ST_CTIME_NSEC 1
/* Define to 1 if `st_mtimespec.tv_nsec' is a member of `struct stat'. */
#cmakedefine HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */
#cmakedefine HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#cmakedefine HAVE_SYS_DIR_H 1
/* Define to 1 if the sys_errlist array is available. */
#cmakedefine HAVE_SYS_ERRLIST 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#cmakedefine HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#cmakedefine HAVE_SYS_NDIR_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#cmakedefine HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/select.h> header file. */
#cmakedefine HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/sysctl.h> header file. */
#cmakedefine HAVE_SYS_SYSCTL_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <termios.h> header file. */
#cmakedefine HAVE_TERMIOS_H 1
/* Define to 1 if you have the <term.h> header file. */
#cmakedefine HAVE_TERM_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1
/* Define to 1 if you have the `wcscasecmp' function. */
#cmakedefine HAVE_WCSCASECMP 1
/* Define to 1 if you have the `wcsdup' function. */
#cmakedefine HAVE_WCSDUP 1
/* Define to 1 if you have the `wcslcpy' function. */
#cmakedefine HAVE_WCSLCPY 1
/* Define to 1 if you have the `wcsncasecmp' function. */
#cmakedefine HAVE_WCSNCASECMP 1
/* Define to 1 if you have the `wcsndup' function. */
#cmakedefine HAVE_WCSNDUP 1
/* Define to 1 if the winsize struct and TIOCGWINSZ macro exist */
#cmakedefine HAVE_WINSIZE 1
/* Define to 1 if the _nl_msg_cat_cntr symbol is exported. */
#cmakedefine HAVE__NL_MSG_CAT_CNTR 1
/* Define to 1 if you have the file `/proc/self/stat'. */
#cmakedefine HAVE__PROC_SELF_STAT 1
/* Define to 1 if the _sys_errs array is available. */
#cmakedefine HAVE__SYS__ERRS 1
/* Define to 1 to disable ncurses macros that conflict with the STL */
#define NCURSES_NOMACROS 1
/* Define to 1 to disable curses macros that conflict with the STL */
#define NOMACROS 1
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "fish-users@lists.sourceforge.net"
/* Define to the full name of this package. */
#define PACKAGE_NAME "fish"
/* Define to the full name and version of this package. */
// #define PACKAGE_STRING "FIXME" # FISH-BUILD-VERSION-FILE
/* Define to the one symbol short name of this package. */
#cmakedefine PACKAGE_TARNAME "fish" 1
/* Define to the version of this package. */
// #define PACKAGE_VERSION "FIXME"
/* Define to 1 if tparm accepts a fixed amount of paramters. */
// #cmakedefine TPARM_SOLARIS_KLUDGE 1
/* Perform string translations with gettext */
// #cmakedefine USE_GETTEXT 1
/* The size of wchar_t in bits. */
#define WCHAR_T_BITS ${WCHAR_T_BITS}
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
// TODO #cmakedefine _FILE_OFFSET_BITS 1
/* Define for large files, on AIX-style hosts. */
// TODO #cmakedefine _LARGE_FILES 1
#if __GNUC__ >= 3
#ifndef __warn_unused
#define __warn_unused __attribute__ ((warn_unused_result))
#endif
#ifndef __sentinel
#define __sentinel __attribute__ ((sentinel))
#endif
#ifndef __packed
#define __packed __attribute__ ((packed))
#endif
#else
#define __warn_unused
#define __sentinel
#define __packed
#endif