diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-02-23 12:18:33 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-06-06 18:27:02 +0200 |
commit | d9481f23599d8eab5ef4bceb9cde23a14ef4f066 (patch) | |
tree | e03b56eb4a2a9952d7f00f5d26cf27a8cb28451c /test cases | |
parent | 316f4f49485ed51e29942364f11692638d47cfc1 (diff) | |
download | meson-d9481f23599d8eab5ef4bceb9cde23a14ef4f066.zip meson-d9481f23599d8eab5ef4bceb9cde23a14ef4f066.tar.gz meson-d9481f23599d8eab5ef4bceb9cde23a14ef4f066.tar.bz2 |
cmake: Added Code generation test
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/cmake/3 code gen/main.cpp | 8 | ||||
-rw-r--r-- | test cases/cmake/3 code gen/meson.build | 18 | ||||
-rw-r--r-- | test cases/cmake/3 code gen/subprojects/cmCodeGen/CMakeLists.txt | 5 | ||||
-rw-r--r-- | test cases/cmake/3 code gen/subprojects/cmCodeGen/main.cpp | 21 | ||||
-rw-r--r-- | test cases/cmake/3 code gen/test.hpp | 5 |
5 files changed, 57 insertions, 0 deletions
diff --git a/test cases/cmake/3 code gen/main.cpp b/test cases/cmake/3 code gen/main.cpp new file mode 100644 index 0000000..3ddbf63 --- /dev/null +++ b/test cases/cmake/3 code gen/main.cpp @@ -0,0 +1,8 @@ +#include <iostream> +#include "test.hpp" + +using namespace std; + +int main() { + cout << getStr() << endl; +} diff --git a/test cases/cmake/3 code gen/meson.build b/test cases/cmake/3 code gen/meson.build new file mode 100644 index 0000000..daa93ce --- /dev/null +++ b/test cases/cmake/3 code gen/meson.build @@ -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)
\ No newline at end of file diff --git a/test cases/cmake/3 code gen/subprojects/cmCodeGen/CMakeLists.txt b/test cases/cmake/3 code gen/subprojects/cmCodeGen/CMakeLists.txt new file mode 100644 index 0000000..268743c --- /dev/null +++ b/test cases/cmake/3 code gen/subprojects/cmCodeGen/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.7) + +set(CMAKE_CXX_STANDARD 14) + +add_executable(genA main.cpp) diff --git a/test cases/cmake/3 code gen/subprojects/cmCodeGen/main.cpp b/test cases/cmake/3 code gen/subprojects/cmCodeGen/main.cpp new file mode 100644 index 0000000..5b7fed2 --- /dev/null +++ b/test cases/cmake/3 code gen/subprojects/cmCodeGen/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; +} diff --git a/test cases/cmake/3 code gen/test.hpp b/test cases/cmake/3 code gen/test.hpp new file mode 100644 index 0000000..8e25a0a --- /dev/null +++ b/test cases/cmake/3 code gen/test.hpp @@ -0,0 +1,5 @@ +#pragma once + +#include <string> + +std::string getStr(); |