parent
316f4f4948
commit
d9481f2359
5 changed files with 57 additions and 0 deletions
@ -0,0 +1,8 @@ |
||||
#include <iostream> |
||||
#include "test.hpp" |
||||
|
||||
using namespace std; |
||||
|
||||
int main() { |
||||
cout << getStr() << endl; |
||||
} |
@ -0,0 +1,18 @@ |
||||
project('cmake_code_gen', ['cpp']) |
||||
|
||||
# Subproject with the "code generator" |
||||
sub_pro = subproject('cmCodeGen') |
||||
sub_exe = sub_pro.get_variable('genA') |
||||
|
||||
# Generate the source |
||||
generated = custom_target( |
||||
'cmake-generated', |
||||
input: [], |
||||
output: ['test.cpp'], |
||||
command: [sub_exe, '@OUTPUT@'] |
||||
) |
||||
|
||||
# Build the exe |
||||
exe1 = executable('main1', ['main.cpp', generated]) |
||||
|
||||
test('test1', exe1) |
@ -0,0 +1,5 @@ |
||||
cmake_minimum_required(VERSION 3.7) |
||||
|
||||
set(CMAKE_CXX_STANDARD 14) |
||||
|
||||
add_executable(genA main.cpp) |
@ -0,0 +1,21 @@ |
||||
#include <iostream> |
||||
#include <fstream> |
||||
|
||||
using namespace std; |
||||
|
||||
int main(int argc, const char *argv[]) { |
||||
if(argc < 2) { |
||||
cerr << argv[0] << " requires an output file!" << endl; |
||||
return 1; |
||||
} |
||||
ofstream out(argv[1]); |
||||
out << R"( |
||||
#include "test.hpp" |
||||
|
||||
std::string getStr() { |
||||
return "Hello World"; |
||||
} |
||||
)"; |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,5 @@ |
||||
#pragma once |
||||
|
||||
#include <string> |
||||
|
||||
std::string getStr(); |
Loading…
Reference in new issue