diff options
author | Sebastian Würl <s.wuerl@mailbox.org> | 2020-08-30 18:22:45 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-08-30 23:53:00 +0200 |
commit | 8e004afc90ee82c7e51817d8a7046a894eb90485 (patch) | |
tree | 43897649fdc7c92d610299f5367f21965d9a63b5 | |
parent | ac8cc2106f319fc93a5e38ffb88a70be09e9ee3e (diff) | |
download | meson-8e004afc90ee82c7e51817d8a7046a894eb90485.zip meson-8e004afc90ee82c7e51817d8a7046a894eb90485.tar.gz meson-8e004afc90ee82c7e51817d8a7046a894eb90485.tar.bz2 |
CMake module: Allow paths of generated CMake sources for include directories
4 files changed, 24 insertions, 5 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index c2affd0..8a7122d 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -432,9 +432,17 @@ class ConverterTarget: if not os.path.isabs(x): x = os.path.normpath(os.path.join(self.src_dir, x)) if not os.path.exists(x) and not any([x.endswith(y) for y in obj_suffixes]) and not is_generated: - mlog.warning('CMake: path', mlog.bold(x), 'does not exist.') - mlog.warning(' --> Ignoring. This can lead to build errors.') - return None + if ( + any([os.path.commonpath([x, y]) == x for y in self.generated]) + and os.path.isabs(x) + and os.path.commonpath([x, self.env.get_build_dir()]) == self.env.get_build_dir() + ): + os.makedirs(x) + return os.path.relpath(x, os.path.join(self.env.get_build_dir(), subdir)) + else: + mlog.warning('CMake: path', mlog.bold(x), 'does not exist.') + mlog.warning(' --> Ignoring. This can lead to build errors.') + return None if Path(x) in trace.explicit_headers: return None if ( 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 199c2e9..e27a469 100644 --- a/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt @@ -120,7 +120,14 @@ add_custom_command( add_subdirectory(cpyTest ccppyyTTeesstt) -add_library(cmModLib SHARED cmMod.cpp genTest.cpp cpyBase.cpp cpyBase.hpp cpyNext.cpp cpyNext.hpp cpyTest.cpp cpyTest.hpp cpyTest2.hpp cpyTest3.hpp) +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cpyTest/some/directory/cpyTest5.hpp" + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/cpyTest/cpyTest5.hpp" "${CMAKE_CURRENT_BINARY_DIR}/cpyTest/some/directory/cpyTest5.hpp" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cpyTest/cpyTest5.hpp" +) +include_directories("${CMAKE_CURRENT_BINARY_DIR}/cpyTest/some") + +add_library(cmModLib SHARED cmMod.cpp genTest.cpp cpyBase.cpp cpyBase.hpp cpyNext.cpp cpyNext.hpp cpyTest.cpp cpyTest.hpp cpyTest2.hpp cpyTest3.hpp cpyTest/some/directory/cpyTest5.hpp) include(GenerateExportHeader) generate_export_header(cmModLib) diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/cpyTest.cpp b/test cases/cmake/8 custom command/subprojects/cmMod/cpyTest.cpp index f762251..627b8f9 100644 --- a/test cases/cmake/8 custom command/subprojects/cmMod/cpyTest.cpp +++ b/test cases/cmake/8 custom command/subprojects/cmMod/cpyTest.cpp @@ -2,7 +2,8 @@ #include "cpyTest2.hpp" #include "cpyTest3.hpp" #include "ccppyyTTeesstt/cpyTest4.hpp" +#include "directory/cpyTest5.hpp" std::string getStrCpyTest() { - return CPY_TEST_STR_2 CPY_TEST_STR_3 CPY_TEST_STR_4; + return CPY_TEST_STR_2 CPY_TEST_STR_3 CPY_TEST_STR_4 CPY_TEST_STR_5; } diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/cpyTest/cpyTest5.hpp b/test cases/cmake/8 custom command/subprojects/cmMod/cpyTest/cpyTest5.hpp new file mode 100644 index 0000000..3669f00 --- /dev/null +++ b/test cases/cmake/8 custom command/subprojects/cmMod/cpyTest/cpyTest5.hpp @@ -0,0 +1,3 @@ +#pragma once + +#define CPY_TEST_STR_5 " test" |