### Install regenie with Make Source: https://github.com/rgcgithub/regenie/blob/master/docs/site/install/index.html Standard installation of regenie using the 'make' command. Requires BGEN library and optionally supports Boost Iostreams and Intel MKL for enhanced functionality and performance. ```bash BGEN_PATH= make make HAS_BOOST_IOSTREAM=1 ``` -------------------------------- ### Compile and Run LBFGS++ Example in Bash Source: https://github.com/rgcgithub/regenie/blob/master/external_libs/LBFGSpp/README.md Provides the bash commands to compile and run a C++ example using the LBFGS++ library. It specifies the necessary include paths for Eigen and LBFGS++ and sets optimization flags. ```bash $ g++ -I/path/to/eigen -I/path/to/lbfgspp/include -O2 example.cpp $ ./a.out ``` -------------------------------- ### Install regenie with CMake Source: https://github.com/rgcgithub/regenie/blob/master/docs/site/install/index.html Compiling regenie using CMake version >=3.13. This method involves creating a build directory and running CMake with optional flags for Boost Iostreams and Intel MKL. ```bash mkdir -p build cd build BGEN_PATH= cmake .. make ``` -------------------------------- ### Install Regenie Executable (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt Installs the 'regenie' executable to the specified runtime destination directory during the installation phase of the build process. ```cmake install(TARGETS regenie RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### Regenie: Get Help and List Options Source: https://github.com/rgcgithub/regenie/blob/master/docs/docs/options.md Displays the full list of command-line options and flags available for the Regenie tool. This is useful for understanding all possible configurations and parameters. ```bash ./regenie --help ``` -------------------------------- ### Install regenie with Conda Source: https://github.com/rgcgithub/regenie/blob/master/docs/site/install/index.html Installing regenie using Conda package manager. This involves creating a new Conda environment and activating it to use the regenie package. ```bash # create new environment conda create -n regenie_env -c conda-forge -c bioconda regenie # load it conda activate regenie_env ``` -------------------------------- ### CMake Minimum Version and Project Setup Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt Sets the minimum required CMake version to 3.13 and defines the project name and version. It also includes necessary CMake helper modules. ```cmake cmake_minimum_required(VERSION 3.13) # detect OS architecture execute_process( COMMAND uname -s OUTPUT_VARIABLE UNAME_S OUTPUT_STRIP_TRAILING_WHITESPACE ) # Get Regenie version file(STRINGS "VERSION" RG_VERSION) project(regenie VERSION ${RG_VERSION} ) include(CMakePackageConfigHelpers) include(GNUInstallDirs) ``` -------------------------------- ### Example Regenie Step 2 Run for Mask Building and Testing Source: https://github.com/rgcgithub/regenie/blob/master/docs/docs/options.md This command demonstrates how to use Regenie to build and test genetic masks for association studies. It utilizes results from Step 1, specifies input files for genotype, covariates, and phenotypes, and applies Firth's approximation test for binary traits. The output includes generated masks and association summary statistics. ```bash ./regenie \ --step 2 \ --bed example/example_3chr \ --covarFile example/covariates.txt \ --phenoFile example/phenotype_bin.txt \ --bt \ --remove example/fid_iid_to_remove.txt \ --firth --approx \ --pred fit_bin_out_pred.list \ --anno-file example/example_3chr.annotations \ --set-list example/example_3chr.setlist \ --mask-def example/example_3chr.masks \ --aaf-bins 0.1,0.05 \ --write-mask \ --bsize 200 \ --out test_bin_out_firth ``` -------------------------------- ### Highlight.js Initialization (JavaScript) Source: https://github.com/rgcgithub/regenie/blob/master/docs/cinder/base.html Initializes Highlight.js for syntax highlighting on the page. This code is executed if the theme is configured to use Highlight.js and specific languages are enabled. It ensures code blocks are properly formatted. ```javascript if (config.theme.highlightjs) { // ... loop for languages ... hljs.initHighlightingOnLoad(); } ``` -------------------------------- ### Run Regenie Step 1 for Association Analysis Source: https://context7.com/rgcgithub/regenie/llms.txt This command executes the first step of the regenie association analysis using QC-filtered data. It requires the regenie executable, filtered genotype files (BED, extract, keep), phenotype file, and covariate file. It performs single-variant association testing and generates prediction files for Step 2. Options for low memory usage are included. ```bash # Run Step 1 with QC-filtered data ./regenie \ --step 1 \ --bed ukb_cal_allChrs \ --extract qc_pass.snplist \ --keep qc_pass.id \ --phenoFile ukb_phenotypes_BT.txt \ --covarFile ukb_covariates.txt \ --bt \ --bsize 1000 \ --lowmem \ --lowmem-prefix tmpdir/regenie_tmp_preds \ --out ukb_step1_BT ``` -------------------------------- ### Regenie Gene-based Testing Input Source: https://github.com/rgcgithub/regenie/blob/master/docs/site/options/index.html This section outlines the input files and options required for performing gene-based testing in Regenie Step 2, starting from version 3.0. ```APIDOC ## Regenie Gene-based Testing Input ### Description This endpoint details the input files and options necessary for performing gene-based testing in Regenie (version 3.0 and later). It covers specifying variant annotations, set definitions, and filtering options for gene sets. ### Method N/A (Command-line tool) ### Endpoint N/A (Command-line tool) ### Parameters #### Command-line Arguments - **`--anno-file`** (FILE) - Required - File containing variant annotations for each set. - **`--set-list`** (FILE) - Required - File listing the variant sets (e.g., genes). - **`--extract-sets`** (FILE) - Optional - Inclusion file listing variant set IDs to keep. Can be a comma-separated list of files. - **`--exclude-sets`** (FILE) - Optional - Exclusion file listing variant set IDs to remove. Can be a comma-separated list of files. - **`--extract-setlist`** (STRING) - Optional - Comma-separated list of variant set IDs to keep. - **`--exclude-setlist`** (STRING) - Optional - Comma-separated list of variant set IDs to remove. - **`--aaf-file`** (FILE) - Optional - File with variant Allele Allele Frequencies (AAF) to use when building masks, overriding estimates from the sample. - **`--mask-def`** (FILE) - Required - File defining how masks are constructed using the annotations from `--anno-file`. ### Request Example ```bash regenie --step 2 --out gene_results \ --anno-file annotations.tsv \ --set-list gene_sets.tsv \ --mask-def mask_definitions.tsv \ --extract-sets extract_genes.txt \ --aaf-file custom_aaf.tsv ``` ### Response #### Success Response (Processing) Regenie will process the specified gene sets and variants according to the provided input files and options to perform gene-based association testing. #### Response Example (No direct response body, but processing occurs based on the command and input files) ``` -------------------------------- ### Minimize Function using LBFGS++ Solver in C++ Source: https://github.com/rgcgithub/regenie/blob/master/external_libs/LBFGSpp/README.md Demonstrates how to use the LBFGS++ solver in C++ to minimize a function. It involves setting parameters, creating a solver instance, providing an initial guess, and calling the minimize method. The output includes the number of iterations and the final optimized values. ```cpp int main() { const int n = 10; // Set up parameters LBFGSParam param; param.epsilon = 1e-6; param.max_iterations = 100; // Create solver and function object LBFGSSolver solver(param); Rosenbrock fun(n); // Initial guess VectorXd x = VectorXd::Zero(n); // x will be overwritten to be the best point found double fx; int niter = solver.minimize(fun, x, fx); std::cout << niter << " iterations" << std::endl; std::cout << "x = \n" << x.transpose() << std::endl; std::cout << "f(x) = " << fx << std::endl; return 0; } ``` -------------------------------- ### Build and Link QF Library (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt This CMake snippet defines a custom target 'libqf' to build the QF library using a 'make' command within its specified directory. It then links this library to the 'regenie' target and adds it as a dependency. ```cmake set(QF_PATH "${EXTERN_LIBS_PATH}/qf") add_custom_target( libqf COMMAND make WORKING_DIRECTORY ${QF_PATH} ) target_link_libraries(regenie PRIVATE ${QF_PATH}/qf.a) add_dependencies(regenie libqf) ``` -------------------------------- ### Merge UK Biobank Chromosome Files with PLINK Source: https://context7.com/rgcgithub/regenie/llms.txt This script merges individual chromosome PLINK files (BED, BIM, FAM) into a single set of files for all chromosomes. It requires PLINK to be installed and accessible in the PATH. The output is a merged .bed, .bim, and .fam file. ```bash # Merge chromosome files into single file rm -f list_beds.txt for chr in {2..22}; do echo "ukb_cal_chr${chr}_v2.bed ukb_snp_chr${chr}_v2.bim ukbXXX_int_chr1_v2_s488373.fam" >> list_beds.txt done plink \ --bed ukb_cal_chr1_v2.bed \ --bim ukb_snp_chr1_v2.bim \ --fam ukbXXX_int_chr1_v2_s488373.fam \ --merge-list list_beds.txt \ --make-bed --out ukb_cal_allChrs ``` -------------------------------- ### Regenie Variant Inclusion/Exclusion File Format Source: https://github.com/rgcgithub/regenie/blob/master/docs/docs/options.md Specifies the format for variant inclusion/exclusion files. Each line should start with a variant ID. If additional columns are present, the file must be space/tab separated. Variants not in the genetic data files are ignored. ```text 20 31 . ``` -------------------------------- ### Link Intel MKL Libraries (Static/Dynamic) (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt This CMake snippet configures linking for Intel MKL libraries. It defines MKL-specific preprocessor macros and includes MKL headers. Based on the BUILD_STATIC flag, it either finds and links static MKL libraries using a group wrapper or dynamic MKL libraries. ```cmake if(EXISTS ${MKLROOT}) add_definitions(-DWITH_MKL -DEIGEN_USE_BLAS -DEIGEN_USE_LAPACKE) target_include_directories(regenie PRIVATE ${MKLROOT}/include/) if(${BUILD_STATIC}) # specify static libs find_library(MKL_LP64_LIB libmkl_intel_lp64.a HINTS "${MKLROOT}/lib/intel64" "${MKLROOT}/lib" REQUIRED) find_library(MKL_THREAD_LIB libmkl_gnu_thread.a HINTS "${MKLROOT}/lib/intel64" "${MKLROOT}/lib" REQUIRED) find_library(MKL_CORE_LIB libmkl_core.a HINTS "${MKLROOT}/lib/intel64" "${MKLROOT}/lib" REQUIRED) target_link_libraries(regenie PRIVATE "-Wl,--start-group" ${MKL_LP64_LIB} ${MKL_THREAD_LIB} ${MKL_CORE_LIB} "-Wl,--end-group" -lgomp) else() # use dynamic libs find_library(MKL_LP64_LIB mkl_intel_lp64 PATHS "${MKLROOT}/lib/intel64" "${MKLROOT}/lib" REQUIRED) find_library(MKL_THREAD_LIB mkl_gnu_thread PATHS "${MKLROOT}/lib/intel64" "${MKLROOT}/lib" REQUIRED) find_library(MKL_CORE_LIB mkl_core PATHS "${MKLROOT}/lib/intel64" "${MKLROOT}/lib" REQUIRED) target_link_libraries(regenie PRIVATE "-Wl,--no-as-needed" ${MKL_LP64_LIB} ${MKL_THREAD_LIB} ${MKL_CORE_LIB} -lgomp) endif() ``` -------------------------------- ### Regenie Master File Content (Split L0) Source: https://github.com/rgcgithub/regenie/wiki/Further-parallelization-for-level-0-models-in-Step-1 Displays the content of the master file generated by `--split-l0`. This file contains metadata about the total variants and block size, followed by entries for each job, specifying the output prefix, number of blocks, and variants per block. This structure guides the parallel execution of level 0 models. ```console > cat /src/test/fit_bin_parallel.master 994 100 /src/test/fit_bin_parallel_job1 3 300 /src/test/fit_bin_parallel_job2 3 300 /src/test/fit_bin_parallel_job3 2 200 /src/test/fit_bin_parallel_job4 2 194 ``` -------------------------------- ### Minimize Function with Bracketing Line Search using LBFGS++ in C++ Source: https://github.com/rgcgithub/regenie/blob/master/external_libs/LBFGSpp/README.md Illustrates using LBFGS++ with a specific line search algorithm, 'LineSearchBracketing'. This is achieved by providing a second template parameter to the LBFGSSolver constructor. The rest of the minimization process remains similar. ```cpp int main() { const int n = 10; // Set up parameters LBFGSParam param; param.epsilon = 1e-6; param.max_iterations = 100; // Create solver and function object LBFGSSolver solver(param); Rosenbrock fun(n); // Initial guess VectorXd x = VectorXd::Zero(n); // x will be overwritten to be the best point found double fx; int niter = solver.minimize(fun, x, fx); std::cout << niter << " iterations" << std::endl; std::cout << "x = \n" << x.transpose() << std::endl; std::cout << "f(x) = " << fx << std::endl; return 0; } ``` -------------------------------- ### MkDocs Theme Customization using Jinja2 Source: https://github.com/rgcgithub/regenie/blob/master/docs/cinder/main.html This snippet demonstrates the basic structure for customizing an MkDocs theme. It shows how to extend the 'base.html' template, which serves as the entry point for theme customizations. Custom themes should redefine blocks within 'base.html' to implement specific layout and functionality changes. ```html {% extends "base.html" %} {# The entry point for the MkDocs Theme. Any theme customisations should override this file to redefine blocks defined in the various templates. The custom theme should only need to define a main.html which \`{% extends \"base.html\" %}\` and defines various blocks which will replace the blocks defined in base.html and its included child templates. #} ``` -------------------------------- ### MathJax Configuration (JavaScript) Source: https://github.com/rgcgithub/regenie/blob/master/docs/cinder/base.html Configures MathJax for rendering mathematical equations on the page. It sets up inline and display math delimiters, specifies input and output formats, and enables various extensions for enhanced functionality and accessibility. This requires MathJax to be included in the project. ```javascript MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true }, jax: ["input/TeX","input/MathML","input/AsciiMath","output/CommonHTML"], extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathMenu.js","MathZoom.js","AssistiveMML.js", "[Contrib]/a11y/accessibility-menu.js"], TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"], equationNumbers: { autoNumber: "AMS" } } }); ``` -------------------------------- ### Link BGEN Library and Dependencies (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt This snippet demonstrates how to find and link the BGEN library along with its dependencies (ZSTD, DB, SQLITE3, Boost) using CMake's find_library and target_link_libraries commands. It also specifies the necessary include directories for the project. ```cmake find_library(ZSTD_LIBRARY libzstd.a HINTS "${BGEN_PATH}/build/3rd_party/zstd-1.1.0" REQUIRED) find_library(DB_LIBRARY libdb.a HINTS "${BGEN_PATH}/build/db" REQUIRED) find_library(SQLITE3_LIBRARY libsqlite3.a HINTS "${BGEN_PATH}/build/3rd_party/sqlite3" REQUIRED) find_library(Boost_LIBRARY libboost.a HINTS "${BGEN_PATH}/build/3rd_party/boost_1_55_0" REQUIRED) find_library(BGEN_LIBRARY libbgen.a HINTS "${BGEN_PATH}/build" REQUIRED) target_link_libraries(regenie PRIVATE ${ZSTD_LIBRARY} ${BGEN_LIBRARY} ${DB_LIBRARY} ${SQLITE3_LIBRARY} ${Boost_LIBRARY}) target_include_directories(regenie PRIVATE ${BGEN_PATH} ${BGEN_PATH}/genfile/include/ ${BGEN_PATH}/3rd_party/boost_1_55_0/ ${BGEN_PATH}/3rd_party/zstd-1.1.0/lib ${BGEN_PATH}/db/include/ ${BGEN_PATH}/3rd_party/sqlite3) ``` -------------------------------- ### Build and Link Quadpack Library (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt This CMake snippet defines a custom target 'libquad' to build the Quadpack library using a 'make' command within its specified directory. It then links this library to the 'regenie' target and adds it as a dependency. ```cmake set(QUAD_PATH "${EXTERN_LIBS_PATH}/quadpack") add_custom_target( libquad COMMAND make WORKING_DIRECTORY ${QUAD_PATH} ) target_link_libraries(regenie PRIVATE ${QUAD_PATH}/libquad.a) add_dependencies(regenie libquad) ``` -------------------------------- ### Include cxxopts Header-Only Library (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt This CMake snippet adds the include directory for the cxxopts library, which is a header-only library. This allows the project to use cxxopts for command-line argument parsing without needing to link a separate library file. ```cmake # cxxopts (header-only) target_include_directories(regenie PRIVATE ${EXTERN_LIBS_PATH}/cxxopts/include/) ``` -------------------------------- ### Regenie Step 1 Output Options Source: https://github.com/rgcgithub/regenie/blob/master/docs/site/options/index.html This section describes the output files generated by Regenie when using `--step 1`, focusing on the `--out` argument and its various extensions for different prediction types. ```APIDOC ## Regenie Step 1 Output ### Description This endpoint details the output files generated by Regenie when running Step 1, primarily controlled by the `--out` argument. It covers different output formats like LOCO predictions, PRS, and Firth null estimates, along with file naming conventions and compression options. ### Method N/A (Command-line tool) ### Endpoint N/A (Command-line tool) ### Parameters #### Command-line Arguments - **`--out`** (FILE PREFIX) - Required - Specifies the prefix for all output files. A log file `file.log` is always generated. - **`--gz`** - Optional - Compresses output files using gzip, appending `.gz` extension. - **`--print-prs`** - Optional - Generates whole-genome predictions (PRS) without the LOCO scheme, saved as `.prs` files. - **`--write-null-firth`** - Optional - Writes Firth null estimates to `.firth` files. ### Request Example ```bash regenie --step 1 --out my_output --gz --print-prs ``` ### Response #### Success Response (Files Generated) - **`.loco` files**: Per-chromosome LOCO predictions (e.g., `my_output_1.loco`). - **`.loco.gz` files**: Gzipped LOCO predictions if `--gz` is used. - **`.prs` files**: Whole genome predictions if `--print-prs` is used (e.g., `my_output_1.prs`). - **`.prs.gz` files**: Gzipped PRS files if `--print-prs` and `--gz` are used. - **`.firth` files**: Firth null estimates if `--write-null-firth` is used (e.g., `my_output_1.firth`). - **`.firth.gz` files**: Gzipped Firth null estimates if `--write-null-firth` and `--gz` are used. - **`.pred.list`**: List of BLUP files for Step 2. - **`.prs.list`**: List of PRS files for Step 2. - **`.firth.list`**: List of Firth null estimate files for Step 2. #### Response Example (No direct response body, but files are generated based on the command) ``` -------------------------------- ### Build and Link PGEN Library (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt This CMake snippet defines a custom target 'pgenlib' to build the PGEN library using a 'make' command within its specified directory. It then links this library to the 'regenie' target, specifies include directories, and adds it as a dependency. ```cmake set(PGEN_PATH "${EXTERN_LIBS_PATH}/pgenlib") add_custom_target( pgenlib COMMAND make WORKING_DIRECTORY ${PGEN_PATH} ) target_link_libraries(regenie PRIVATE ${PGEN_PATH}/pgenlib.a) target_include_directories(regenie PRIVATE ${PGEN_PATH} ${PGEN_PATH}/simde/ ${PGEN_PATH}/include/) add_dependencies(regenie pgenlib) ``` -------------------------------- ### Regenie Step 2 Output Options Source: https://github.com/rgcgithub/regenie/blob/master/docs/site/options/index.html This section details the output files produced by Regenie during Step 2, focusing on association test results and various formatting options like splitting by phenotype, GZIP compression, and HTP format. ```APIDOC ## Regenie Step 2 Output ### Description This endpoint describes the output generated by Regenie when running Step 2, focusing on association test results. It covers default file naming, GZIP compression, options for writing all results to a single file (`--no-split`), using HTP format (`--htp`), and writing sample IDs (`--write-samples`). ### Method N/A (Command-line tool) ### Endpoint N/A (Command-line tool) ### Parameters #### Command-line Arguments - **`--out`** (FILE PREFIX) - Required - Specifies the prefix for all output files. - **`--gz`** - Optional - Compresses output files using gzip, appending `.regenie.gz` extension. - **`--no-split`** - Optional - Writes all summary statistics to a single file (`file.regenie`) and generates a dictionary file (`file.regenie.Ydict`). - **`--htp`** - Optional - Formats the summary statistics file according to the HTP specification. - **`--write-samples`** - Optional - Writes the IDs of samples used for each trait to separate `.regenie.ids` files. ### Request Example ```bash regenie --step 2 --out results --gz --no-split ``` ### Response #### Success Response (Files Generated) - **`.regenie` files**: Default output for each phenotype (e.g., `results_trait1.regenie`). - **`.regenie.gz` files**: Gzipped output if `--gz` is used. - **`file.regenie`**: Single summary statistics file if `--no-split` is used. - **`file.regenie.Ydict`**: Trait name dictionary for the `--no-split` output. - **`file.regenie.htp`**: Summary statistics in HTP format if `--htp` is used. - **`.regenie.ids` files**: Sample IDs if `--write-samples` is used. #### Response Example (No direct response body, but files are generated based on the command) ``` -------------------------------- ### Define Regenie Executable and Include Directories Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt Defines the main executable 'regenie' and lists all its source files. It also specifies the include directory for the project's source files. ```cmake # list each file specifically add_executable(regenie ${CMAKE_SOURCE_DIR}/src/Data.cpp ${CMAKE_SOURCE_DIR}/src/Files.cpp ${CMAKE_SOURCE_DIR}/src/Geno.cpp ${CMAKE_SOURCE_DIR}/src/HLM.cpp ${CMAKE_SOURCE_DIR}/src/Interaction.cpp ${CMAKE_SOURCE_DIR}/src/Joint_Tests.cpp ${CMAKE_SOURCE_DIR}/src/Masks.cpp ${CMAKE_SOURCE_DIR}/src/NNLS.cpp ${CMAKE_SOURCE_DIR}/src/Pheno.cpp ${CMAKE_SOURCE_DIR}/src/Regenie.cpp ${CMAKE_SOURCE_DIR}/src/SKAT.cpp ${CMAKE_SOURCE_DIR}/src/Step1_Models.cpp ${CMAKE_SOURCE_DIR}/src/Step2_Models.cpp ${CMAKE_SOURCE_DIR}/src/MultiTrait_Tests.cpp ${CMAKE_SOURCE_DIR}/src/MCC.cpp ${CMAKE_SOURCE_DIR}/src/Ordinal.cpp ${CMAKE_SOURCE_DIR}/src/survival_data.cpp ${CMAKE_SOURCE_DIR}/src/cox_ridge.cpp ${CMAKE_SOURCE_DIR}/src/cox_score.cpp ${CMAKE_SOURCE_DIR}/src/cox_firth.cpp ) target_include_directories(regenie PRIVATE ${CMAKE_SOURCE_DIR}/src) ``` -------------------------------- ### Run Regenie Step 2 for Chromosome-Specific Association Source: https://context7.com/rgcgithub/regenie/llms.txt This command executes the second step of the regenie association analysis for a specific chromosome. It requires the regenie executable, BGEN genotype files, sample file, phenotype file, covariate file, and the prediction list from Step 1. It performs Firth or approximate Firth correction for binary traits and outputs association results per chromosome. ```bash # Run Step 2 per chromosome ./regenie \ --step 2 \ --bgen ukb_imp_chr1_v3.bgen \ --ref-first \ --sample ukbXXX_imp_chr1_v3_s487395.sample \ --phenoFile ukb_phenotypes_BT.txt \ --covarFile ukb_covariates.txt \ --bt \ --firth --approx --pThresh 0.01 \ --pred ukb_step1_BT_pred.list \ --bsize 400 \ --out ukb_step2_BT_chr1 ``` -------------------------------- ### Link Other Libraries (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt Finds and links essential libraries such as zlib, math library (m), dynamic linking library (dl), and the gfortran library to the 'regenie' target. The gfortran library linking is platform-dependent. ```cmake find_library(ZLIB_LIBRARY libz.a z REQUIRED) find_library(M_LIB m REQUIRED) find_library(DL_LIB dl REQUIRED) if("${UNAME_S}" STREQUAL "Linux") set(GFORTRAN_LIBRARY "-lgfortran") elseif("${UNAME_S}" STREQUAL "Darwin") find_library(GFORTRAN_LIBRARY gfortran REQUIRED) endif() target_link_libraries( regenie PRIVATE ${ZLIB_LIBRARY} ${M_LIB} ${DL_LIB} ${PTHREAD_LIB} ${GFORTRAN_LIBRARY} ) ``` -------------------------------- ### Build and Link MVTNorm Library (CMake) Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt This CMake snippet defines a custom target 'libMvtnorm' to build the MVTNorm library using a 'make' command within its specified directory. It then links this library to the 'regenie' target and adds it as a dependency. ```cmake set(MVTN_PATH "${EXTERN_LIBS_PATH}/mvtnorm") add_custom_target( libMvtnorm COMMAND make WORKING_DIRECTORY ${MVTN_PATH} ) target_link_libraries(regenie PRIVATE ${MVTN_PATH}/libMvtnorm.a) add_dependencies(regenie libMvtnorm) ``` -------------------------------- ### Enable Static Compilation with CMake Source: https://github.com/rgcgithub/regenie/blob/master/CMakeLists.txt Enables static compilation on Linux systems by setting the STATIC=1 variable when running CMake. This excludes GLIBC. ```bash STATIC=1 cmake ... ```