| ... | @@ -87,11 +87,6 @@ message(STATUS "Configuring zig version ${RESOLVED_ZIG_VERSION}") | ... | @@ -87,11 +87,6 @@ message(STATUS "Configuring zig version ${RESOLVED_ZIG_VERSION}") |
| 87 | set(ZIG_NO_LIB off CACHE BOOL | 87 | set(ZIG_NO_LIB off CACHE BOOL |
| 88 | "Disable copying lib/ files to install prefix during the build phase") | 88 | "Disable copying lib/ files to install prefix during the build phase") |
| 89 | | 89 | |
| 90 | # This used to do something and it may or may not do something in the future. | | |
| 91 | # Right now it does nothing. | | |
| 92 | set(ZIG_NO_LANGREF off CACHE BOOL | | |
| 93 | "Disable copying of langref to the install prefix during the build phase") | | |
| 94 | | | |
| 95 | set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)") | 90 | set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)") |
| 96 | set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries") | 91 | set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries") |
| 97 | set(ZIG_STATIC_LLVM ${ZIG_STATIC} CACHE BOOL "Prefer linking against static LLVM libraries") | 92 | set(ZIG_STATIC_LLVM ${ZIG_STATIC} CACHE BOOL "Prefer linking against static LLVM libraries") |
| ... | @@ -136,7 +131,17 @@ if(ZIG_AR_WORKAROUND) | ... | @@ -136,7 +131,17 @@ if(ZIG_AR_WORKAROUND) |
| 136 | string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE}) | 131 | string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE}) |
| 137 | endif() | 132 | endif() |
| 138 | | 133 | |
| 139 | set(ZIG_PIE off CACHE BOOL "produce a position independent zig executable") | 134 | |
| | 135 | option(ZIG_PIE "Produce a position independent zig executable" ${CMAKE_POSITION_INDEPENDENT_CODE}) |
| | 136 | include(CheckPIESupported) |
| | 137 | check_pie_supported( |
| | 138 | OUTPUT_VARIABLE ZIG_PIE_SUPPORTED_BY_CMAKE |
| | 139 | LANGUAGES C CXX |
| | 140 | ) |
| | 141 | if(ZIG_PIE AND NOT ZIG_PIE_SUPPORTED_BY_CMAKE) |
| | 142 | message(SEND_ERROR "ZIG_PIE was requested but CMake does not support it for \"zigcpp\" target") |
| | 143 | endif() |
| | 144 | |
| 140 | | 145 | |
| 141 | # Detect system libcxx name. | 146 | # Detect system libcxx name. |
| 142 | if ("c++" IN_LIST CMAKE_CXX_IMPLICIT_LINK_LIBRARIES) | 147 | if ("c++" IN_LIST CMAKE_CXX_IMPLICIT_LINK_LIBRARIES) |
| ... | @@ -925,56 +930,51 @@ if(MSVC OR MINGW) | ... | @@ -925,56 +930,51 @@ if(MSVC OR MINGW) |
| 925 | target_link_libraries(zig2 LINK_PUBLIC version) | 930 | target_link_libraries(zig2 LINK_PUBLIC version) |
| 926 | endif() | 931 | endif() |
| 927 | | 932 | |
| | 933 | |
| | 934 | # "-Dno-langref" and "-Dstd-docs=false" are hardcoded because they take too long to build. |
| | 935 | # To obtain these two forms of documentation, run zig build against stage3 rather than stage2. |
| | 936 | set(ZIG_BUILD_ARGS |
| | 937 | --zig-lib-dir "${PROJECT_SOURCE_DIR}/lib" |
| | 938 | |
| | 939 | "-Dversion-string=${RESOLVED_ZIG_VERSION}" |
| | 940 | "-Dtarget=${ZIG_TARGET_TRIPLE}" |
| | 941 | "-Dcpu=${ZIG_TARGET_MCPU}" |
| | 942 | |
| | 943 | -Denable-llvm |
| | 944 | "-Dconfig_h=${ZIG_CONFIG_H_OUT}" |
| | 945 | |
| | 946 | -Dno-langref |
| | 947 | -Dstd-docs=false |
| | 948 | ) |
| | 949 | |
| 928 | if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") | 950 | if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") |
| 929 | set(ZIG_RELEASE_ARG "") | 951 | list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug) |
| 930 | elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") | 952 | elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") |
| 931 | set(ZIG_RELEASE_ARG -Doptimize=ReleaseFast) | 953 | list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast) |
| 932 | else() | 954 | else() |
| 933 | set(ZIG_RELEASE_ARG -Doptimize=ReleaseFast -Dstrip) | 955 | list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast -Dstrip) |
| | 956 | endif() |
| | 957 | |
| | 958 | if(ZIG_STATIC AND NOT MSVC) |
| | 959 | list(APPEND ZIG_BUILD_ARGS -Duse-zig-libcxx) |
| 934 | endif() | 960 | endif() |
| | 961 | |
| 935 | if(ZIG_NO_LIB) | 962 | if(ZIG_NO_LIB) |
| 936 | set(ZIG_NO_LIB_ARG "-Dno-lib") | 963 | list(APPEND ZIG_BUILD_ARGS -Dno-lib) |
| 937 | else() | | |
| 938 | set(ZIG_NO_LIB_ARG "") | | |
| 939 | endif() | 964 | endif() |
| | 965 | |
| 940 | if(ZIG_SINGLE_THREADED) | 966 | if(ZIG_SINGLE_THREADED) |
| 941 | set(ZIG_SINGLE_THREADED_ARG "-Dsingle-threaded") | 967 | list(APPEND ZIG_BUILD_ARGS -Dsingle-threaded) |
| 942 | else() | | |
| 943 | set(ZIG_SINGLE_THREADED_ARG "") | | |
| 944 | endif() | 968 | endif() |
| 945 | if(ZIG_STATIC AND NOT MSVC) | 969 | |
| 946 | set(ZIG_STATIC_ARG "-Duse-zig-libcxx") | 970 | if(ZIG_PIE) |
| 947 | else() | 971 | list(APPEND ZIG_BUILD_ARGS -Dpie) |
| 948 | set(ZIG_STATIC_ARG "") | | |
| 949 | endif() | | |
| 950 | if(CMAKE_POSITION_INDEPENDENT_CODE OR ZIG_PIE) | | |
| 951 | set(ZIG_PIE_ARG "-Dpie") | | |
| 952 | else() | | |
| 953 | set(ZIG_PIE_ARG "") | | |
| 954 | endif() | 972 | endif() |
| 955 | if("${ZIG_TARGET_DYNAMIC_LINKER}" STREQUAL "") | 973 | |
| 956 | set(ZIG_DYNAMIC_LINKER_ARG "") | 974 | if(NOT "${ZIG_TARGET_DYNAMIC_LINKER}" STREQUAL "") |
| 957 | else() | 975 | list(APPEND ZIG_BUILD_ARGS "-Ddynamic-linker=${ZIG_TARGET_DYNAMIC_LINKER}") |
| 958 | set(ZIG_DYNAMIC_LINKER_ARG "-Ddynamic-linker=${ZIG_TARGET_DYNAMIC_LINKER}") | | |
| 959 | endif() | 976 | endif() |
| 960 | | 977 | |
| 961 | # -Dno-langref is currently hardcoded because building the langref takes too damn long | | |
| 962 | # To obtain these two forms of documentation, run zig build against stage3 rather than stage2. | | |
| 963 | set(ZIG_BUILD_ARGS | | |
| 964 | --zig-lib-dir "${PROJECT_SOURCE_DIR}/lib" | | |
| 965 | "-Dconfig_h=${ZIG_CONFIG_H_OUT}" | | |
| 966 | "-Denable-llvm" | | |
| 967 | ${ZIG_RELEASE_ARG} | | |
| 968 | ${ZIG_STATIC_ARG} | | |
| 969 | ${ZIG_NO_LIB_ARG} | | |
| 970 | "-Dno-langref" | | |
| 971 | ${ZIG_SINGLE_THREADED_ARG} | | |
| 972 | ${ZIG_PIE_ARG} | | |
| 973 | "-Dtarget=${ZIG_TARGET_TRIPLE}" | | |
| 974 | "-Dcpu=${ZIG_TARGET_MCPU}" | | |
| 975 | ${ZIG_DYNAMIC_LINKER_ARG} | | |
| 976 | "-Dversion-string=${RESOLVED_ZIG_VERSION}" | | |
| 977 | ) | | |
| 978 | | 978 | |
| 979 | add_custom_target(stage3 ALL | 979 | add_custom_target(stage3 ALL |
| 980 | DEPENDS "${PROJECT_BINARY_DIR}/stage3/bin/zig" | 980 | DEPENDS "${PROJECT_BINARY_DIR}/stage3/bin/zig" |