diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-10-20 14:24:48 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-10-24 19:31:15 +0200 |
commit | fc57089bc509e63f9376858f8038b3efb142418a (patch) | |
tree | 95aecb38697dc6ac8ee62654e95ed85ef55a9a53 | |
parent | 1eb9d8ad6e30fb5381e720f50dcda9965e19a399 (diff) | |
download | meson-fc57089bc509e63f9376858f8038b3efb142418a.zip meson-fc57089bc509e63f9376858f8038b3efb142418a.tar.gz meson-fc57089bc509e63f9376858f8038b3efb142418a.tar.bz2 |
cmake: Disable the new (CMake 3.16) PCH support
Subprojects that use the CMake PCH feature will cause
compilation/linker errors. The CMake PCH support
should thus be disabled until this can be properly
translated to meson.
-rw-r--r-- | mesonbuild/cmake/data/preload.cmake | 10 | ||||
-rw-r--r-- | mesonbuild/cmake/traceparser.py | 8 | ||||
-rw-r--r-- | mesonbuild/mesondata.py | 13 | ||||
-rw-r--r-- | test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt | 6 | ||||
-rw-r--r-- | test cases/cmake/1 basic/subprojects/cmMod/cpp_pch.hpp | 2 | ||||
-rwxr-xr-x | tools/gen_data.py | 3 |
6 files changed, 40 insertions, 2 deletions
diff --git a/mesonbuild/cmake/data/preload.cmake b/mesonbuild/cmake/data/preload.cmake index f8caae9..d875cff 100644 --- a/mesonbuild/cmake/data/preload.cmake +++ b/mesonbuild/cmake/data/preload.cmake @@ -11,6 +11,11 @@ endmacro() macro(meson_ps_reload_vars) endmacro() +macro(meson_ps_disabled_function) + message(WARNING "The function '${ARGV0}' is disabled in the context of CMake subporjects.\n" + "This should not be an issue but may lead to compilaton errors.") +endmacro() + # Helper macro to inspect the current CMake state macro(meson_ps_inspect_vars) set(MESON_PS_CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") @@ -63,5 +68,10 @@ function(set_source_files_properties) endwhile() endfunction() +# Disable some functions that would mess up the CMake meson integration +macro(target_precompile_headers) + meson_ps_disabled_function(target_precompile_headers) +endmacro() + set(MESON_PS_DELAYED_CALLS add_custom_command;add_custom_target;set_property) meson_ps_reload_vars() diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py index 518db4f..c6f2b9d 100644 --- a/mesonbuild/cmake/traceparser.py +++ b/mesonbuild/cmake/traceparser.py @@ -123,6 +123,7 @@ class CMakeTraceParser: # meaning here in the trace parser. 'meson_ps_execute_delayed_calls': self._meson_ps_execute_delayed_calls, 'meson_ps_reload_vars': self._meson_ps_reload_vars, + 'meson_ps_disabled_function': self._meson_ps_disabled_function, } # type: T.Dict[str, T.Callable[[CMakeTraceLine], None]] def trace_args(self) -> T.List[str]: @@ -618,6 +619,13 @@ class CMakeTraceParser: def _meson_ps_reload_vars(self, tline: CMakeTraceLine) -> None: self.delayed_commands = self.get_cmake_var('MESON_PS_DELAYED_CALLS') + def _meson_ps_disabled_function(self, tline: CMakeTraceLine) -> None: + args = list(tline.args) + if not args: + mlog.error('Invalid preload.cmake script! At least one argument to `meson_ps_disabled_function` is expected') + return + mlog.warning('The CMake function "{}" was disabed to avoid compatibility issues with Meson.'.format(args[0])) + def _lex_trace_human(self, trace: str) -> T.Generator[CMakeTraceLine, None, None]: # The trace format is: '<file>(<line>): <func>(<args -- can contain \n> )\n' reg_tline = re.compile(r'\s*(.*\.(cmake|txt))\(([0-9]+)\):\s*(\w+)\(([\s\S]*?) ?\)\s*\n', re.MULTILINE) diff --git a/mesonbuild/mesondata.py b/mesonbuild/mesondata.py index f2e35f1..a75e802 100644 --- a/mesonbuild/mesondata.py +++ b/mesonbuild/mesondata.py @@ -19,6 +19,7 @@ #### +# TODO: Remember to remove this also from tools/gen_data.py from ._pathlib import Path import typing as T @@ -272,6 +273,11 @@ endmacro() macro(meson_ps_reload_vars) endmacro() +macro(meson_ps_disabled_function) + message(WARNING "The function '${ARGV0}' is disabled in the context of CMake subporjects.\n" + "This should not be an issue but may lead to compilaton errors.") +endmacro() + # Helper macro to inspect the current CMake state macro(meson_ps_inspect_vars) set(MESON_PS_CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") @@ -324,6 +330,11 @@ function(set_source_files_properties) endwhile() endfunction() +# Disable some functions that would mess up the CMake meson integration +macro(target_precompile_headers) + meson_ps_disabled_function(target_precompile_headers) +endmacro() + set(MESON_PS_DELAYED_CALLS add_custom_command;add_custom_target;set_property) meson_ps_reload_vars() ''' @@ -368,7 +379,7 @@ mesondata = { ), 'cmake/data/preload.cmake': DataFile( Path('cmake/data/preload.cmake'), - '064d047b18a5c919ad016b838bed50c5d40aebe9e53da0e70eff9d52a2c1ca1f', + 'bbc441ededf2c7da2d0e640038ccbf4e818b73a2ba75084e1b4dbf05d8bca865', file_3_data_preload_cmake, ), } diff --git a/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt index 9c95636..2197667 100644 --- a/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt @@ -10,5 +10,11 @@ add_definitions("-DDO_NOTHING_JUST_A_FLAG=1") add_library(cmModLib++ SHARED cmMod.cpp) target_compile_definitions(cmModLib++ PRIVATE MESON_MAGIC_FLAG=21) target_compile_definitions(cmModLib++ INTERFACE MESON_MAGIC_FLAG=42) + +# Test PCH support +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0") + target_precompile_headers(cmModLib++ PRIVATE "cpp_pch.hpp") +endif() + include(GenerateExportHeader) generate_export_header(cmModLib++) diff --git a/test cases/cmake/1 basic/subprojects/cmMod/cpp_pch.hpp b/test cases/cmake/1 basic/subprojects/cmMod/cpp_pch.hpp new file mode 100644 index 0000000..aa7ceb3 --- /dev/null +++ b/test cases/cmake/1 basic/subprojects/cmMod/cpp_pch.hpp @@ -0,0 +1,2 @@ +#include <vector> +#include <string> diff --git a/tools/gen_data.py b/tools/gen_data.py index 2cc05a4..32a5347 100755 --- a/tools/gen_data.py +++ b/tools/gen_data.py @@ -78,7 +78,8 @@ def main() -> int: #### - from pathlib import Path + # TODO: Remember to remove this also from tools/gen_data.py + from ._pathlib import Path import typing as T if T.TYPE_CHECKING: |