authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2020-01-16 18:56:13-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2020-01-16 18:56:13-05:00
logcd062b08d01cf2c92b05ef3e96b2ff3715f29fd5
tree3d885db89c95a215dece283b964db15adb9b1b1d
parentbac27731e30cbea76997fa3547791b3462ac8697
signaturelock-open Commit is signed but in an unrecognized format.

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

1 files changed, 20 insertions(+), 9 deletions(-)

CMakeLists.txt+20-9
...@@ -45,7 +45,6 @@ message("Configuring zig version ${ZIG_VERSION}")...@@ -45,7 +45,6 @@ message("Configuring zig version ${ZIG_VERSION}")
4545
46set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")46set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
47set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")47set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
48set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Disable copying lib/ files to install prefix")
49set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation")48set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation")
5049
51if(ZIG_STATIC)50if(ZIG_STATIC)
...@@ -608,19 +607,26 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")...@@ -608,19 +607,26 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
608else()607else()
609 set(LIBUSERLAND_RELEASE_MODE "true")608 set(LIBUSERLAND_RELEASE_MODE "true")
610endif()609endif()
611if(ZIG_SKIP_INSTALL_LIB_FILES)610
612 set(ZIG_BUILD_INSTALL_STEP "")611set(BUILD_LIBUSERLAND_COMMAND zig0 build
613else()
614 set(ZIG_BUILD_INSTALL_STEP "install")
615endif()
616add_custom_target(zig_build_libuserland ALL
617 COMMAND zig0 build
618 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"612 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
619 libuserland ${ZIG_BUILD_INSTALL_STEP}
620 "-Doutput-dir=${CMAKE_BINARY_DIR}"613 "-Doutput-dir=${CMAKE_BINARY_DIR}"
621 "-Drelease=${LIBUSERLAND_RELEASE_MODE}"614 "-Drelease=${LIBUSERLAND_RELEASE_MODE}"
622 "-Dlib-files-only"615 "-Dlib-files-only"
623 --prefix "${CMAKE_INSTALL_PREFIX}"616 --prefix "${CMAKE_INSTALL_PREFIX}"
617 libuserland
618)
619
620# When using Visual Studio build system generator we default to libuserland install.
621if(MSVC)
622 set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Disable copying lib/ files to install prefix")
623 if(NOT ZIG_SKIP_INSTALL_LIB_FILES)
624 set(BUILD_LIBUSERLAND_COMMAND ${BUILD_LIBUSERLAND_COMMAND} install)
625 endif()
626endif()
627
628add_custom_target(zig_build_libuserland ALL
629 COMMAND ${BUILD_LIBUSERLAND_COMMAND}
624 DEPENDS zig0630 DEPENDS zig0
625 BYPRODUCTS "${LIBUSERLAND}"631 BYPRODUCTS "${LIBUSERLAND}"
626 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"632 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
...@@ -638,4 +644,9 @@ elseif(MINGW)...@@ -638,4 +644,9 @@ elseif(MINGW)
638 target_link_libraries(zig ntdll)644 target_link_libraries(zig ntdll)
639endif()645endif()
640add_dependencies(zig zig_build_libuserland)646add_dependencies(zig zig_build_libuserland)
647
641install(TARGETS zig DESTINATION bin)648install(TARGETS zig DESTINATION bin)
649
650# CODE has no effect with Visual Studio build system generator
651install(CODE "message(\"-- Installing: /opt/zig/lib\")")
652install(CODE "execute_process(COMMAND ${BUILD_LIBUSERLAND_COMMAND} install)")