Initial Commit

This commit is contained in:
2026-09-07 15:16:52 -04:00
commit e8ce633e5e
54 changed files with 13079 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.20)
project(cex_cmake_demo LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(DEMO_INCREMENT 1)
configure_file(config.hpp.in generated/config.hpp @ONLY)
add_library(numbers src/numbers.cpp)
target_include_directories(numbers PUBLIC src PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
add_executable(cmake-demo main.cpp)
target_link_libraries(cmake-demo PRIVATE numbers)

View File

@@ -0,0 +1,2 @@
#pragma once
#define DEMO_INCREMENT @DEMO_INCREMENT@

7
examples/cmake/main.cpp Normal file
View File

@@ -0,0 +1,7 @@
#include "numbers.hpp"
template<Addable T>
T twice(T value) { return value + value; }
constexpr int evaluation_mode() {
if consteval { return 1; } else { return 2; }
}
int main() { return increment(twice(20)) + evaluation_mode(); }

View File

@@ -0,0 +1,3 @@
#include "numbers.hpp"
#include "config.hpp"
int increment(int value) { return value + DEMO_INCREMENT; }

View File

@@ -0,0 +1,4 @@
#pragma once
template<class T>
concept Addable = requires(T value) { value + value; };
int increment(int value);