╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ CMakeLists.txt ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
672 673 set(BUILD_ZIG2_ARGS 674 "${PROJECT_SOURCE_DIR}/lib" 675 build-exe -ofmt=c -lc -OReleaseSmall 676 --name zig2 677 -femit-bin="${ZIG2_C_SOURCE}" 678 -target "${ZIG_HOST_TARGET_TRIPLE}" 679 --dep "build_options" 680 "-Mroot=src/main.zig" 681 "-Mbuild_options=${ZIG_CONFIG_ZIG_OUT}" 682 ) 683 684 add_custom_command( 685 OUTPUT "${ZIG2_C_SOURCE}" 686 COMMAND zig1 ${BUILD_ZIG2_ARGS} 687 DEPENDS zig1 "${ZIG_STAGE2_SOURCES}" 688 COMMENT "Running zig1.wasm to produce ${ZIG2_C_SOURCE}" 689 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 690 ) 691 692 set(BUILD_COMPILER_RT_ARGS 693 "${PROJECT_SOURCE_DIR}/lib" 694 build-obj -ofmt=c -OReleaseSmall 695 --name compiler_rt 696 -femit-bin="${ZIG_COMPILER_RT_C_SOURCE}" 697 -target "${ZIG_HOST_TARGET_TRIPLE}" 698 "-Mroot=lib/compiler_rt.zig" 699 ) 700 701 add_custom_command( 702 OUTPUT "${ZIG_COMPILER_RT_C_SOURCE}" 703 COMMAND zig1 ${BUILD_COMPILER_RT_ARGS} 704 DEPENDS zig1 "${ZIG_STAGE2_SOURCES}" 705 COMMENT "Running zig1.wasm to produce ${ZIG_COMPILER_RT_C_SOURCE}" 706 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 707 ) 708 709 add_executable(zig2 ${ZIG2_C_SOURCE} ${ZIG_COMPILER_RT_C_SOURCE}) 710 set_target_properties(zig2 PROPERTIES 711 COMPILE_FLAGS ${ZIG2_COMPILE_FLAGS} 712 LINK_FLAGS "${ZIG2_LINK_FLAGS}" 713 ) 714 target_include_directories(zig2 PUBLIC stage1) 715 target_link_libraries(zig2 LINK_PUBLIC zigcpp) 716 717 if(MSVC) 718 target_link_libraries(zig2 LINK_PUBLIC ntdll.lib ws2_32.lib) 719 elseif(MINGW) 720 target_link_libraries(zig2 LINK_PUBLIC ntdll ws2_32) 721 endif() 722 723 if(NOT MSVC) 724 target_link_libraries(zig2 LINK_PUBLIC ${LIBXML2}) 725 endif() 726 727 if(ZIG_DIA_GUIDS_LIB) 728 target_link_libraries(zig2 LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB}) 729 endif() 730 731 if(MSVC OR MINGW) 732 target_link_libraries(zig2 LINK_PUBLIC version) 733 endif() 734 735 736 set(ZIG_BUILD_ARGS 737 "--zig-lib=${PROJECT_SOURCE_DIR}/lib" 738 739 "-Dversion-string=${RESOLVED_ZIG_VERSION}" 740 "-Dtarget=${ZIG_TARGET_TRIPLE}" 741 "-Dcpu=${ZIG_TARGET_MCPU}" 742 743 -Denable-llvm 744 "-Dconfig_h=${ZIG_CONFIG_H_OUT}" 745 ) 746 747 set(ZIG_EXTRA_BUILD_ARGS "" CACHE STRING "Extra zig build args") 748 if(ZIG_EXTRA_BUILD_ARGS) 749 list(APPEND ZIG_BUILD_ARGS ${ZIG_EXTRA_BUILD_ARGS}) 750 endif() 751 752 set(ZIG_RELEASE_SAFE OFF CACHE BOOL "Build Zig as ReleaseSafe (with debug assertions on)") 753 754 if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 755 list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug) 756 else() 757 if("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel") 758 list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSmall) 759 else() 760 # Release and RelWithDebInfo 761 if(ZIG_RELEASE_SAFE) 762 list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSafe) 763 else() 764 list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast) 765 endif() 766 if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") 767 list(APPEND ZIG_BUILD_ARGS -Dstrip) 768 endif() 769 endif() 770 endif() 771 772 if(ZIG_STATIC AND NOT MSVC) 773 list(APPEND ZIG_BUILD_ARGS -Duse-zig-libcxx) 774 endif() 775 776 if(ZIG_NO_LIB) 777 list(APPEND ZIG_BUILD_ARGS -Dno-lib) 778 endif() 779 780 if(ZIG_SINGLE_THREADED) 781 list(APPEND ZIG_BUILD_ARGS -Dsingle-threaded) 782 endif() 783 784 if(ZIG_PIE) 785 list(APPEND ZIG_BUILD_ARGS -Dpie) 786 endif() 787 788 if(NOT "${ZIG_TARGET_DYNAMIC_LINKER}" STREQUAL "") 789 list(APPEND ZIG_BUILD_ARGS "-Ddynamic-linker=${ZIG_TARGET_DYNAMIC_LINKER}") 790 endif() 791 792 793 add_custom_target(stage3 ALL 794 DEPENDS "${PROJECT_BINARY_DIR}/stage3/bin/zig" 795 ) 796 797 set(ZIG2_WORKING_DIR "${PROJECT_SOURCE_DIR}") 798 799 add_custom_command( 800 OUTPUT "${PROJECT_BINARY_DIR}/stage3/bin/zig" 801 COMMAND zig2 build ${ZIG_BUILD_ARGS} --prefix "${PROJECT_BINARY_DIR}/stage3" 802 COMMENT "Building stage3" 803 WORKING_DIRECTORY "${ZIG2_WORKING_DIR}" 804 ) 805 806 set(ZIG_EXECUTABLE "$<TARGET_FILE:zig2>") 807 808 install(CODE "set(ZIG_EXECUTABLE \"${ZIG_EXECUTABLE}\")") 809 install(CODE "set(ZIG_BUILD_ARGS \"${ZIG_BUILD_ARGS}\")") 810 install(CODE "set(ZIG2_WORKING_DIR \"${ZIG2_WORKING_DIR}\")") 811 install(CODE "set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") 812 install(SCRIPT cmake/install.cmake) 813