Skip to content

Instantly share code, notes, and snippets.

@kopp
Created November 12, 2024 13:17
Show Gist options
  • Save kopp/a98a803ff2eff5738815f6cfa8e88f91 to your computer and use it in GitHub Desktop.
Save kopp/a98a803ff2eff5738815f6cfa8e88f91 to your computer and use it in GitHub Desktop.
cmake: Selecting a generator within CMakeLists.txt (SO https://stackoverflow.com/q/11269833)
cmake_minimum_required(VERSION 3.31.0)
project(build_with_ninja CXX)
set(CMAKE_GENERATOR "Ninja" CACHE INTERNAL "" FORCE)
message("generator is set to ${CMAKE_GENERATOR}")
mkdir source
mv CMakeLists.txt source/
mkdir build
cmake -S source -B build
ls build/Makefile build/build.ninja
@kopp
Copy link
Author

kopp commented Nov 12, 2024

ok, interesting. So I cannot confirm, but glad that it works for you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment