fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
c5e4fed02
master
1cmake_minimum_required ( VERSION 3.15 ) 2 3list ( APPEND CMAKE_MODULE_PATH " ${ CMAKE_CURRENT_LIST_DIR } /cmake" ) 4 5project ( fish LANGUAGES C ) 6set ( CMAKE_EXPORT_COMPILE_COMMANDS ON ) 7 8set ( DEFAULT_BUILD_TYPE "RelWithDebInfo" ) 9 10if ( NOT CMAKE_BUILD_TYPEAND NOT CMAKE_CONFIGURATION_TYPES) 11message ( STATUS "Setting build type to default ' ${ DEFAULT_BUILD_TYPE } '" ) 12set ( CMAKE_BUILD_TYPE " ${ DEFAULT_BUILD_TYPE } " ) 13endif () 14 15# Set up standard directories. 16include ( GNUInstallDirs ) 17 18# Set up PCRE2 19# This sets an environment variable that needs to be available before the Rust stanzas 20include ( cmake/PCRE2.cmake ) 21 22include ( cmake/Rust.cmake ) 23 24# Work around issue where archive-built libs go in the wrong place. 25set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ PROJECT_BINARY_DIR }) 26 27find_program ( SPHINX_EXECUTABLE NAMES sphinx-build 28HINTS 29$ ENV { SPHINX_DIR } 30PATH_SUFFIXES bin 31DOC "Sphinx documentation generator" ) 32 33 34# Tell Cargo where our build directory is so it can find Cargo.toml. 35set ( VARS_FOR_CARGO 36"FISH_CMAKE_BINARY_DIR= ${ CMAKE_BINARY_DIR } " 37"PREFIX= ${ CMAKE_INSTALL_PREFIX } " 38"DOCDIR= ${ CMAKE_INSTALL_FULL_DOCDIR } " 39"DATADIR= ${ CMAKE_INSTALL_FULL_DATADIR } " 40"SYSCONFDIR= ${ CMAKE_INSTALL_FULL_SYSCONFDIR } " 41"BINDIR= ${ CMAKE_INSTALL_FULL_BINDIR } " 42"CARGO_TARGET_DIR= ${ FISH_RUST_BUILD_DIR } " 43"CARGO_BUILD_RUSTC= ${ Rust_COMPILER } " 44" ${ FISH_PCRE2_BUILDFLAG } " 45"FISH_SPHINX= ${ SPHINX_EXECUTABLE } " 46) 47 48# Let fish pick up when we're running out of the build directory without installing 49get_filename_component ( REAL_CMAKE_BINARY_DIR " ${ CMAKE_BINARY_DIR } " REALPATH ) 50get_filename_component ( REAL_CMAKE_SOURCE_DIR " ${ CMAKE_SOURCE_DIR } " REALPATH ) 51add_definitions ( -DCMAKE_BINARY_DIR= " ${ REAL_CMAKE_BINARY_DIR } " ) 52add_definitions ( -DCMAKE_SOURCE_DIR= " ${ REAL_CMAKE_SOURCE_DIR } " ) 53 54set ( build_types Release RelWithDebInfo Debug "" ) 55if ( NOT " ${ CMAKE_BUILD_TYPE } " IN_LIST build_types) 56message ( WARNING "Unsupported build type ${ CMAKE_BUILD_TYPE } . If this doesn't build, try one of Release, RelWithDebInfo or Debug" ) 57endif () 58 59add_custom_target ( 60fish ALL 61COMMAND 62" ${ CMAKE_COMMAND } " -E 63env ${ VARS_FOR_CARGO } 64${ Rust_CARGO } 65build --bin fish 66$ < $ <CONFIG:Release>:--release> 67$ < $ <CONFIG:RelWithDebInfo>:--profile=release-with-debug> 68--target ${ Rust_CARGO_TARGET } 69--no-default-features 70--features= ${ FISH_CARGO_FEATURES } 71${ CARGO_FLAGS } 72&& 73" ${ CMAKE_COMMAND } " -E 74copy " ${ rust_target_dir } / ${ rust_profile } /fish" " ${ CMAKE_CURRENT_BINARY_DIR } " 75WORKING_DIRECTORY " ${ CMAKE_CURRENT_SOURCE_DIR } " 76USES_TERMINAL 77) 78 79function ( CREATE_LINK target ) 80add_custom_target ( 81${ target } ALL 82DEPENDS fish 83COMMAND ln -f fish ${ target } 84WORKING_DIRECTORY " ${ CMAKE_CURRENT_BINARY_DIR } " 85) 86endfunction ( CREATE_LINK) 87 88# Define fish_indent. 89create_link ( fish_indent ) 90 91# Define fish_key_reader. 92create_link ( fish_key_reader ) 93 94# Set up the docs. 95include ( cmake/Docs.cmake ) 96 97# Set up tests. 98include ( cmake/Tests.cmake ) 99 100# Benchmarking support. 101include ( cmake/Benchmark.cmake ) 102 103# Set up install. 104include ( cmake/Install.cmake ) 105 106# Mac app. 107include ( cmake/MacApp.cmake ) 108 109include ( FeatureSummary ) 110feature_summary ( WHAT ALL )