authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2020-01-16 21:40:05-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-01-16 21:40:05-05:00
log0240fd91401c8a20064da0efd5b1e8955e481f1b
tree3d885db89c95a215dece283b964db15adb9b1b1d
parentbac27731e30cbea76997fa3547791b3462ac8697
parentcd062b08d01cf2c92b05ef3e96b2ff3715f29fd5
signature Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #4206 from mikdusan/cmake-install

cmake: support `make` and `make install`

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

CMakeLists.txt+20-9
......@@ -45,7 +45,6 @@ message("Configuring zig version ${ZIG_VERSION}")
4545
4646set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
4747set(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")
4948set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation")
5049
5150if(ZIG_STATIC)
......@@ -608,19 +607,26 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
608607else()
609608 set(LIBUSERLAND_RELEASE_MODE "true")
610609endif()
611if(ZIG_SKIP_INSTALL_LIB_FILES)
612 set(ZIG_BUILD_INSTALL_STEP "")
613else()
614 set(ZIG_BUILD_INSTALL_STEP "install")
615endif()
616add_custom_target(zig_build_libuserland ALL
617 COMMAND zig0 build
610
611set(BUILD_LIBUSERLAND_COMMAND zig0 build
618612 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
619 libuserland ${ZIG_BUILD_INSTALL_STEP}
620613 "-Doutput-dir=${CMAKE_BINARY_DIR}"
621614 "-Drelease=${LIBUSERLAND_RELEASE_MODE}"
622615 "-Dlib-files-only"
623616 --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}
624630 DEPENDS zig0
625631 BYPRODUCTS "${LIBUSERLAND}"
626632 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
......@@ -638,4 +644,9 @@ elseif(MINGW)
638644 target_link_libraries(zig ntdll)
639645endif()
640646add_dependencies(zig zig_build_libuserland)
647
641648install(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)")