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 / CMakeLists.txt
Created February 12, 2024 16:37
benchmark CMake ExternalProject/FetchContent URL vs GIT_REPOSITORY
# benchmark download of URL vs. Git
# benchmark with CMake 3.28.2 on Windows with gigabit internet connection.
#
# Python 3.12.2 source
# 7 seconds: URL archive 27583112 bytes
# 84 seconds GIT_SHALLOW=true
# 132 seconds GIT_SHALLOW=false
#
# CMake 3.28.3 source:
@scivision
scivision / listeners.ps1
Created February 7, 2024 17:04
PowerShell list ports that programs are listening on
# copied from https://superuser.com/a/1808022
$procs = Get-Process
$ports = netstat -ano
$ports[4..$ports.length] |
# First column comes back empty, so we set to "ProcessName" as a placeholder for later
ConvertFrom-String -PropertyNames ProcessName,Proto,Local,Remote,State,PID |
where State -eq 'LISTENING' |
foreach {
$_.ProcessName = ($procs | where ID -eq $_.PID).ProcessName
@scivision
scivision / CMakeLists.txt
Created February 1, 2024 20:19
CTest by design combines stdout and stderr. It would be nice if they were separate.
cmake_minimum_required(VERSION 3.19)
project(piper LANGUAGES C)
enable_testing()
add_executable(piper main.c)
add_test(NAME piper COMMAND piper)
@scivision
scivision / CMakeLists.txt
Last active January 31, 2024 16:02
CMake force use of presets
# force use of presets via sentinel environment variable set in presets only
cmake_minimum_required(VERSION 3.21)
project(envpre LANGUAGES C)
message(STATUS "sentinel: $ENV{sentinel}")
include(CheckSentinel.cmake)
add_executable(main main.c)
@scivision
scivision / Readme.md
Last active January 24, 2024 22:26
Python print basic version info and hostname

Python Numpy array allocation test

Simple check that a system can allocate a large numpy array.

python array_allocate.py
@scivision
scivision / dll_path.cmake
Created January 17, 2024 14:54
way to automatically get DLL paths
function(dll_test_path libs test_names)
# if shared lib on Windows, need DLL on PATH
if(NOT WIN32)
return()
endif()
if(CMAKE_VERSION VERSION_LESS 3.22)
message(VERBOSE " CMake ${CMAKE_VERSION} < 3.22: cannot apply ENVIRONMENT_MODIFICATION to ${test_names}")
return()
@scivision
scivision / CMakeLists.txt
Last active January 11, 2024 20:31
Cyclical Fortran dependencies are not supported: https://gitlab.kitware.com/cmake/cmake/-/issues/25584
cmake_minimum_required(VERSION 3.12...3.29)
project(mods LANGUAGES Fortran)
if(CMAKE_GENERATOR MATCHES "Ninja")
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version
OUTPUT_VARIABLE ninja_version OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
message(STATUS "CMake ${CMAKE_VERSION} CMAKE_GENERATOR ${CMAKE_GENERATOR} ${ninja_version}")
@scivision
scivision / CMakeLists.txt
Last active December 20, 2023 14:10
CMake print all target properties
cmake_minimum_required(VERSION 3.5)
project(demoTgtProps LANGUAGES C)
find_package(ZLIB REQUIRED)
include(print_target_props.cmake)
print_target_props(ZLIB::ZLIB)
@scivision
scivision / CMakeLists.txt
Last active December 6, 2023 03:05
CMake C++ library and Fortran main program LINKER_LANGUAGE heuristic issue
cmake_minimum_required(VERSION 3.19)
project(link LANGUAGES CXX Fortran)
file(GENERATE OUTPUT lib.cpp CONTENT "extern \"C\" int addtwo(int N){ return N + 2; }")
file(GENERATE OUTPUT main.f90 CONTENT "program adder
use, intrinsic :: iso_c_binding, only : C_INT
@scivision
scivision / CMakeLists.txt
Last active December 3, 2023 19:41
MinGW C++ filesystem glitches
cmake_minimum_required(VERSION 3.10...3.28)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed.
cmake -Bbuild")
endif()
project(fs_unc LANGUAGES CXX)
enable_testing()