zig

fork of https://codeberg.org/ziglang/zig
Log | Tree | Refs | README | LICENSE

commit cd062b08d01cf2c92b05ef3e96b2ff3715f29fd5 (tree)
parent bac27731e30cbea76997fa3547791b3462ac8697
Author: Michael Dusan <michael.dusan@gmail.com>
Date:   Thu, 16 Jan 2020 18:56:13 -0500

cmake: support `make` and `make install`

- `make` or `ninja` will not build but not install
- `make install` or `ninja install` will build __and__ install

Only for build system generator Visual Studio, specify the following
to disable installation of lib files:

    ZIG_SKIP_INSTALL_LIB_FILES=ON

Diffstat:
MCMakeLists.txt | 29++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -45,7 +45,6 @@ message("Configuring zig version ${ZIG_VERSION}") set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)") set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries") -set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Disable copying lib/ files to install prefix") set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation") if(ZIG_STATIC) @@ -608,19 +607,26 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") else() set(LIBUSERLAND_RELEASE_MODE "true") endif() -if(ZIG_SKIP_INSTALL_LIB_FILES) - set(ZIG_BUILD_INSTALL_STEP "") -else() - set(ZIG_BUILD_INSTALL_STEP "install") -endif() -add_custom_target(zig_build_libuserland ALL - COMMAND zig0 build + +set(BUILD_LIBUSERLAND_COMMAND zig0 build --override-lib-dir "${CMAKE_SOURCE_DIR}/lib" - libuserland ${ZIG_BUILD_INSTALL_STEP} "-Doutput-dir=${CMAKE_BINARY_DIR}" "-Drelease=${LIBUSERLAND_RELEASE_MODE}" "-Dlib-files-only" --prefix "${CMAKE_INSTALL_PREFIX}" + libuserland +) + +# When using Visual Studio build system generator we default to libuserland install. +if(MSVC) + set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Disable copying lib/ files to install prefix") + if(NOT ZIG_SKIP_INSTALL_LIB_FILES) + set(BUILD_LIBUSERLAND_COMMAND ${BUILD_LIBUSERLAND_COMMAND} install) + endif() +endif() + +add_custom_target(zig_build_libuserland ALL + COMMAND ${BUILD_LIBUSERLAND_COMMAND} DEPENDS zig0 BYPRODUCTS "${LIBUSERLAND}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" @@ -638,4 +644,9 @@ elseif(MINGW) target_link_libraries(zig ntdll) endif() add_dependencies(zig zig_build_libuserland) + install(TARGETS zig DESTINATION bin) + +# CODE has no effect with Visual Studio build system generator +install(CODE "message(\"-- Installing: /opt/zig/lib\")") +install(CODE "execute_process(COMMAND ${BUILD_LIBUSERLAND_COMMAND} install)")