Skip to content

Instantly share code, notes, and snippets.

@AlecTaylor
Created June 16, 2016 14:52
Show Gist options
  • Save AlecTaylor/e416efbea8793da599513bf28e7d92d7 to your computer and use it in GitHub Desktop.
Save AlecTaylor/e416efbea8793da599513bf28e7d92d7 to your computer and use it in GitHub Desktop.
cmake_minimum_required(VERSION 3.5)
project(foo_proj)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(SOURCE_FILES main.cpp)
add_custom_command(
OUTPUT bar.h
COMMAND echo \#define bar 10 > bar.h
DEPENDS main.cpp
)
add_executable(foo_proj ${SOURCE_FILES} bar.h)
#include <iostream>
#include "bar.h"
// Also tried `#include <bar.h>`
int main() {
std::cout << bar << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment