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 / README.md
Last active November 27, 2023 17:07
Detect Windows Subsystem for Linux (WSL) from C, C++, Fortran, Python, ...
@scivision
scivision / find_web_browser.cmake
Last active September 13, 2023 17:08
CMake find web browser
# NOTE: Safari doesn't work from the command line, so Safari is omitted from the search.
find_program(browser
NAMES
"Microsoft Edge" msedge
"Google Chrome" google-chrome chrome
Chromimum chromium-browser chromium
Firefox firefox firefox-bin
PATHS
"$ENV{PROGRAMFILES\(x86\)}/Microsoft/Edge/Application"
"$ENV{PROGRAMFILES}/Google/Chrome/Application"
@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 30, 2024 01:31
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 / Readme.md
Last active May 20, 2024 18:46
oneAPI source scripts for Linux, macOS and Windows

tiny scripts to load oneAPI environment

For PowerShell and Unix-like shells, here are example scripts to load and use Intel oneAPI.