cmake: Add unit test for add_custom_target() and add_dependency()

Also test commands with args separated by ';'
pull/5989/head
Xavier Claessens 5 years ago committed by Daniel Mensinger
parent f73a1dff0e
commit 8efbcb1e80
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 10
      test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt
  2. 17
      test cases/cmake/8 custom command/subprojects/cmMod/args_test.cpp
  3. 5
      test cases/cmake/8 custom command/subprojects/cmMod/cmMod.cpp

@ -44,3 +44,13 @@ add_custom_command(
add_library(cmModLib SHARED cmMod.cpp genTest.cpp cpyBase.cpp cpyBase.hpp)
include(GenerateExportHeader)
generate_export_header(cmModLib)
set(ARGS_TEST arg1)
set(ARGS_TEST ${ARGS_TEST} arg2)
add_executable(args_test args_test.cpp)
add_custom_target(args_test_cmd
COMMAND args_test ARGS ${ARGS_TEST}
)
add_dependencies(cmModLib args_test_cmd)

@ -0,0 +1,17 @@
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, const char *argv[]) {
if(argc != 3 || string(argv[1]) != "arg1" || string(argv[2]) != "arg2") {
cerr << argv[0] << " requires 2 args" << endl;
return 1;
}
ofstream out1("cmModLib.hpp");
out1 << "#define FOO = \"plop\"";
return 0;
}

@ -1,6 +1,11 @@
#include "cmMod.hpp"
#include "genTest.hpp"
#include "cpyBase.hpp"
#include "cmModLib.hpp"
#ifndef FOO
#error FOO not declared
#endif
using namespace std;

Loading…
Cancel
Save