From 4199cb32a513370b6dd68ea90cdd0e5b852dff23 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 12 Apr 2020 15:11:37 +0200 Subject: cmake: Fix custom command CMake list issue --- test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test cases/cmake') diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt index 39b19d7..5c75e65 100644 --- a/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt @@ -16,9 +16,15 @@ add_custom_command( COMMAND gen ARGS genTest ) +set(CMD_PART) +list(APPEND CMD_PART COMMAND mycpy cpyBase.cpp.in cpyBase.cpp.in.gen) +list(APPEND CMD_PART COMMAND mycpy cpyBase.cpp.in.gen cpyBase.cpp.out) +list(APPEND CMD_PART COMMAND mycpy cpyBase.cpp.out cpyBase.cpp.something) + add_custom_command( OUTPUT cpyBase.cpp COMMAND mycpy "${CMAKE_CURRENT_SOURCE_DIR}/cpyBase.cpp.am" cpyBase.cpp.in + ${CMD_PART} COMMAND mycpy cpyBase.cpp.in cpyBase.cpp.something COMMAND mycpy cpyBase.cpp.something cpyBase.cpp.IAmRunningOutOfIdeas COMMAND mycpy cpyBase.cpp.IAmRunningOutOfIdeas cpyBase.cpp -- cgit v1.1 From 1be660ff64f2cb69cac0376ae57f65908b34238b Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 12 Apr 2020 15:11:54 +0200 Subject: cmake: Capture stdout with UNIX pipes --- .../subprojects/cmMod/CMakeLists.txt | 3 ++ .../8 custom command/subprojects/cmMod/genMain.cpp | 40 ++++++++++++++++++++++ .../8 custom command/subprojects/cmMod/main.cpp | 30 ---------------- 3 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 test cases/cmake/8 custom command/subprojects/cmMod/genMain.cpp delete mode 100644 test cases/cmake/8 custom command/subprojects/cmMod/main.cpp (limited to 'test cases/cmake') diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt index 5c75e65..1498c36 100644 --- a/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt @@ -7,6 +7,9 @@ set (CMAKE_CXX_STANDARD_REQUIRED ON) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_definitions("-DDO_NOTHING_JUST_A_FLAG=1") +add_executable(genMain genMain.cpp) +add_custom_command(OUTPUT main.cpp COMMAND genMain > main.cpp) + add_executable(gen main.cpp) add_executable(mycpy cp.cpp) diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/genMain.cpp b/test cases/cmake/8 custom command/subprojects/cmMod/genMain.cpp new file mode 100644 index 0000000..33f0201 --- /dev/null +++ b/test cases/cmake/8 custom command/subprojects/cmMod/genMain.cpp @@ -0,0 +1,40 @@ +#include + +using namespace std; + +int main() { + cout << R"asd( +#include +#include + +using namespace std; + +int main(int argc, const char *argv[]) { + if(argc < 2) { + cerr << argv[0] << " requires an output file!" << endl; + return 1; + } + ofstream out1(string(argv[1]) + ".hpp"); + ofstream out2(string(argv[1]) + ".cpp"); + out1 << R"( +#pragma once + +#include + +std::string getStr(); +)"; + + out2 << R"( +#include ")" << argv[1] << R"(.hpp" + +std::string getStr() { + return "Hello World"; +} +)"; + + return 0; +} +)asd"; + + return 0; +} diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/main.cpp b/test cases/cmake/8 custom command/subprojects/cmMod/main.cpp deleted file mode 100644 index 9fade21..0000000 --- a/test cases/cmake/8 custom command/subprojects/cmMod/main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -using namespace std; - -int main(int argc, const char *argv[]) { - if(argc < 2) { - cerr << argv[0] << " requires an output file!" << endl; - return 1; - } - ofstream out1(string(argv[1]) + ".hpp"); - ofstream out2(string(argv[1]) + ".cpp"); - out1 << R"( -#pragma once - -#include - -std::string getStr(); -)"; - - out2 << R"( -#include ")" << argv[1] << R"(.hpp" - -std::string getStr() { - return "Hello World"; -} -)"; - - return 0; -} -- cgit v1.1