aboutsummaryrefslogtreecommitdiff
path: root/test cases/cmake
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2020-08-08 15:37:51 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2020-08-09 19:36:38 +0300
commita98db022aa4cc0798fba4bb2f723e5b0cc3b2570 (patch)
tree95c445f899f3dbed7f86b219a7fd97df7c3806cf /test cases/cmake
parent948741355f1d624f209e2b2d02740372fc9aa8c2 (diff)
downloadmeson-a98db022aa4cc0798fba4bb2f723e5b0cc3b2570.zip
meson-a98db022aa4cc0798fba4bb2f723e5b0cc3b2570.tar.gz
meson-a98db022aa4cc0798fba4bb2f723e5b0cc3b2570.tar.bz2
cmake: Detect custom command targets in compiler args
This is required to make `-include /path/to/custom/target.hpp` work. This setup is used by wxWidgets and this PR is required to use wxWidgets as a CMake subproject.
Diffstat (limited to 'test cases/cmake')
-rw-r--r--test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt10
-rw-r--r--test cases/cmake/8 custom command/subprojects/cmMod/cpyInc.hpp.am3
-rw-r--r--test cases/cmake/8 custom command/subprojects/cmMod/macro_name.cpp6
3 files changed, 19 insertions, 0 deletions
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 1498c36..199c2e9 100644
--- a/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt
+++ b/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt
@@ -134,6 +134,16 @@ add_custom_target(args_test_cmd
)
add_custom_target(macro_name_cmd COMMAND macro_name)
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ message(STATUS "Running the -include test case on macro_name")
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cpyInc.hpp"
+ COMMAND mycpy "${CMAKE_CURRENT_SOURCE_DIR}/cpyInc.hpp.am" "${CMAKE_CURRENT_BINARY_DIR}/cpyInc.hpp"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cpyInc.hpp.am"
+ )
+ target_compile_options(macro_name PUBLIC -DTEST_CMD_INCLUDE -include "${CMAKE_CURRENT_BINARY_DIR}/cpyInc.hpp")
+endif()
+
# Only executable targets are replaced in the command
# all other target names are kept as is
add_custom_target(clang-format COMMAND clang-format -i cmMod.cpp)
diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/cpyInc.hpp.am b/test cases/cmake/8 custom command/subprojects/cmMod/cpyInc.hpp.am
new file mode 100644
index 0000000..07c8ff7
--- /dev/null
+++ b/test cases/cmake/8 custom command/subprojects/cmMod/cpyInc.hpp.am
@@ -0,0 +1,3 @@
+#pragma once
+
+#define CPY_INC_WAS_INCLUDED 1
diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/macro_name.cpp b/test cases/cmake/8 custom command/subprojects/cmMod/macro_name.cpp
index 790557b..964062f 100644
--- a/test cases/cmake/8 custom command/subprojects/cmMod/macro_name.cpp
+++ b/test cases/cmake/8 custom command/subprojects/cmMod/macro_name.cpp
@@ -5,6 +5,12 @@
using namespace std;
+#ifdef TEST_CMD_INCLUDE
+#if CPY_INC_WAS_INCLUDED != 1
+#error "cpyInc.hpp was not included"
+#endif
+#endif
+
int main() {
this_thread::sleep_for(chrono::seconds(1));
ofstream out1("macro_name.txt");