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
Last active August 10, 2025 22:40
Identify if CPU is x86_64v3 capable
cmake_minimum_required(VERSION 3.19...4.2)
project(InstructionSet LANGUAGES CXX)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
enable_testing()
include(CheckIncludeFileCXX)
@scivision
scivision / CMakeLists.txt
Last active November 18, 2024 10:35
CMake add_compile_option() SHELL: to allow spaces in options, including generator expressions. Useful for Intel oneAPI.
cmake_minimum_required(VERSION 3.15)
project(opt LANGUAGES Fortran)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2024-2/warn.html
# SHELL: allows using
# * spaces in compiler options (especially important for Intel oneAPI
# * repeated option prefix, that might otherwise get deduplicated incorrectly
@scivision
scivision / CMakeLists.txt
Last active November 7, 2025 22:06
Xcode 16 Homebrew GCC 14.2 breaks with CMake
cmake_minimum_required(VERSION 3.20)
project(min LANGUAGES CXX Fortran)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
# set OFF if not using C++ modules, or it can trip similar compiler errors due to "-fmodules-ts" flags auto-added when ON.
message(STATUS "CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}")
foreach(i IN ITEMS OS_NAME OS_VERSION OS_RELEASE OS_PLATFORM)
@scivision
scivision / Readme.md
Last active September 12, 2024 16:00
Test simple .tar.gz archive

Just a simple tar.gz with a text file for testing

@scivision
scivision / CMakeLists.txt
Last active August 23, 2024 17:43
Show CMake detecting change in Fortran module code
cmake_minimum_required (VERSION 3.20)
project(detectChange LANGUAGES Fortran)
add_executable(main.x main.f90 moda.f90 modb.f90)
@scivision
scivision / CMakeLists.txt
Last active July 18, 2025 00:27
Benchmark CMake check*() vs. CMAKE_TRY_COMPILE_TARGET_TYPE
cmake_minimum_required(VERSION 3.23...4.2)
# 3.23 for string(TIMESTAMP ... "%f")
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/CMakeCache.txt)
message(FATAL_ERROR "CMakeCache.txt already exists. Please use --fresh to regenerate the cache.")
endif()
project(BenchmarkCheck LANGUAGES C)
include(CheckIncludeFile)
@scivision
scivision / .gitignore
Last active July 24, 2024 05:21
Need capital suffix ".F" or ".F90" for preprocessed Fortran source files
.DUMMY
.dummy
@scivision
scivision / Readme.md
Last active April 24, 2025 19:10
build script for LLVM & Flang-f18 Fortran compiler

Build LLVM Flang Fortran (and C/C++ Clang) compilers

This is a Bash script (macOS, Linux, ...) for building Flang-f18 and LLVM from source. It is adapted from Jeff Hammond

Ninja: recommended for best build efficiency and speed.

In general, a recent GCC would work. On macOS, system AppleClang compiler can be used as well.

@scivision
scivision / CMakeLists.txt
Last active May 5, 2024 17:37
CMake MPI TEST_LAUNCHER
cmake_minimum_required(VERSION 3.15)
project(mpitest LANGUAGES Fortran)
enable_testing()
find_package(MPI COMPONENTS Fortran REQUIRED)
include(TestMPILauncher.cmake)
@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: