Skip to content

Instantly share code, notes, and snippets.

View scivision's full-sized avatar
💭
I will be slow to respond.

scivision

💭
I will be slow to respond.
View GitHub Profile
@scivision
scivision / hsts_check.cmake
Last active September 13, 2023 17:08
CMake test if Curl has HSTS enabled
cmake_minimum_required(VERSION 3.6)
set(url https://hsts.badssl.com/hsts-test/status.svg)
set(file ${CMAKE_CURRENT_BINARY_DIR}/status.svg)
file(DOWNLOAD ${url} ${file} LOG log STATUS status TLS_VERIFY true)
message(VERBOSE "log: ${log}")
message(STATUS "status: ${status}")
@scivision
scivision / images2pdf.py
Last active September 19, 2023 02:36
Python script to collect a directory of images/plots into a single HTML document
#!/usr/bin/env python3
"""
Collect all images (.png) into a single HTML document
Create a PDF from your web browser as usual.
Example:
python images2pdf.py ~/my_plot_folder
@scivision
scivision / CMakeLists.txt
Last active September 5, 2023 17:09
Debugging CMake Ninja generation for Fortran modules
cmake_minimum_required(VERSION 3.10)
project(LotOfModules LANGUAGES Fortran)
message(STATUS "CMake ${CMAKE_VERSION}")
add_library(m1 OBJECT m1.f90)
add_library(m2 OBJECT m2.f90)
target_link_libraries(m2 PRIVATE m1)
@scivision
scivision / CMakeLists.txt
Last active September 4, 2023 17:56
CMake FetchContent specific source files from other project with current project
cmake_minimum_required(VERSION 3.14...3.27)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "please use out-of-source build
cmake -Bbuild")
endif()
project(otherSource LANGUAGES C)
set(NRF_SDK_NAME nRF5_SDK_17.1.0_ddde560)
@scivision
scivision / CMakeLists.txt
Last active April 21, 2024 04:55
OpenMP with CMake
cmake_minimum_required(VERSION 3.19)
project(OpenMPdemo LANGUAGES C)
find_package(OpenMP COMPONENTS C REQUIRED)
add_executable(hello hello_openmp.c)
target_link_libraries(hello PRIVATE OpenMP::OpenMP_C)
@scivision
scivision / CMakeLists.txt
Last active August 30, 2023 21:36
Intel oneMKL build Lapack built-in examples
cmake_minimum_required(VERSION 3.20.2...3.27)
project(LapackMKL LANGUAGES Fortran)
message(STATUS "ENV{MKLROOT}: $ENV{MKLROOT}")
# this find_package() isn't required, but we do it here
# to discover if MKL is missing
find_package(MKL CONFIG REQUIRED)
@scivision
scivision / CMakeLists.txt
Last active August 30, 2023 21:25
Intel oneMKL Scalapack build built-in examples
cmake_minimum_required(VERSION 3.20.2...3.27)
project(ScalapackMKL LANGUAGES Fortran)
message(STATUS "ENV{MKLROOT}: $ENV{MKLROOT}")
# this find_package() isn't required, but we do it here
# to discover if Scalapack is missing
set(ENABLE_BLACS true)
set(ENABLE_SCALAPACK true)
@scivision
scivision / oneapi.ps1
Last active November 17, 2023 15:38
oneAPI source scripts for Linux, macOS and Windows
$env:CC="icx"
$env:FC="ifx"
$env:CXX="icx"
& $env:comspec /c '"%PROGRAMFILES(X86)%\Intel\oneAPI\setvars.bat" && pwsh'
@scivision
scivision / extract_unc.cmake
Created August 29, 2023 19:15
CMake extract file to UNC path example
# extract file to UNC path example
cmake_minimum_required(VERSION 3.20)
# using WSL as example UNC network path
set(bin "\\\\wsl$\\Ubuntu\\home\\username")
if(NOT IS_DIRECTORY ${bin})
message(FATAL_ERROR "${bin} is not a directory")
endif()
@scivision
scivision / CMakeLists.txt
Last active August 29, 2023 18:56
CMake Intel oneMKL example with LAPACK
cmake_minimum_required(VERSION 3.19)
project(intel_mkl LANGUAGES C Fortran)
message(STATUS "ENV{MKLROOT}: $ENV{MKLROOT}")
# variables set before find_package(MKL)
# https://www.intel.com/content/www/us/en/docs/onemkl/developer-guide-linux/2023-2/cmake-config-for-onemkl.html
# default: lp64