Skip to content

Instantly share code, notes, and snippets.

@RafaelPalomar
Created February 9, 2023 09:25
Show Gist options
  • Save RafaelPalomar/be318acabd68e4bfec9f161e31ea83fb to your computer and use it in GitHub Desktop.
Save RafaelPalomar/be318acabd68e4bfec9f161e31ea83fb to your computer and use it in GitHub Desktop.
Simple CMakeLists.txt to test out globbing patterns
# This is a simple CMakeLists to test out globbing patterns
#
# .
# ├── CMakeLists.txt
# ├── file1.h
# ├── file2.h
# ├── file3.txx
# └── file4.txx
cmake_minimum_required(VERSION 3.20)
project(GlobbingTest)
file(GLOB headers "*.h")
file(GLOB templates "*.txx")
file(GLOB allv1 "*.(h|txx)") # This does not work
file(GLOB allv2 "*.(h,txx)") # This does not work
file(GLOB allv3 "*.{h,txx}") # This does not work (it would work on `ls` command)
message(STATUS "Headers: ${headers}")
message(STATUS "Templates: ${templates}")
message(STATUS "Allv1: ${allv1}")
message(STATUS "Allv2: ${allv2}")
message(STATUS "Allv3: ${allv3}")
# Results after running `cmake ../` in the `build` directory
#
# -- Headers: /tmp/GlobbingTest/file1.h;/tmp/GlobbingTest/file2.h
# -- Templates: /tmp/GlobbingTest/file3.txx;/tmp/GlobbingTest/file4.txx
# -- Allv1:
# -- Allv2:
# -- Allv3:
# -- Configuring done
# -- Generating done
# -- Build files have been written to: /tmp/GlobbingTest/build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment