# Skipping CMake compiler checks

**URL:** https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079
**Category:** Usage
**Created:** [October 28, 2020, 10:11am UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079 "2020-10-28T10:11:59Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![mensinda](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mensinda/32/913_2.png) [@mensinda](https://discourse.cmake.org/u/mensinda)
#### Post date: [October 28, 2020, 10:11am UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/1 "2020-10-28T10:11:59Z")

</div>

The use case I am interested in is improving the CMake dependency lookup mechanism in meson ( **not** CMake subprojects but the CMake dependency / `find_package()` backend). What we are currently doing for using the `*-config.cmake` and `Find*.cmake` ecosystem is to generate a minimal `CMakeLists.txt` with basically only a `find_package("${MESON_DEP_NAME}")` and some helpers. We then use the CMake trace to extract all the required information for the dependency.

The problem is that CMake invokes the compiler for each dependency multiple times to gather data. This is naturally fine for configuring a real CMake project but slows down the dependency detection in meson considerabely (especially on Windows with MSVC). Additionally, meson already has all the required compiler and system information since meson is also a build system and could pass all this to CMake.

Not providing any languages to CMake also doesn’t work because this breaks some dependencies that rely on the presents of some languages and use `try_compile()`.

The previous solution/hack was to create a [fake, already “configured” CMake build directory](https://github.com/mesonbuild/meson/blob/0.55.3/mesonbuild/cmake/executor.py#L284-L408). However, this code path is really fragile (for obvious reasons) and may break with future CMake versions. We have also switched to generating/using CMake toolchain files to also provide better cross compilation support. Unfortunately this switch has lead to some performance regressions: [https://github.com/mesonbuild/meson/issues/7898](https://github.com/mesonbuild/meson/issues/7898)

The real fix would be to have some API in CMake itself for providing the same information in the future, however, we still also want to support older CMake versions for compatebility reasons.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 29, 2020, 12:33am UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/2 "2020-10-29T00:33:25Z")

</div>

> [@mensinda](#):
>
> Additionally, meson already has all the required compiler and system information since meson is also a build system and could pass all this to CMake.

I don’t know about that because CMake extracts a lot of information from compilers that I’d be surprised if Meson cared much about. Please look at the `CMakeFiles/$version/{CMakeSystem,CMake${lang}Compiler}.cmake` files for things that CMake cares about. I don’t know how much of this can be stuffed into the cache ahead of time, but I doubt `meson` is going to be able to list out the `_COMPILE_FEATURE` variables well enough to be accurate. You could probably pre-populate some of it, but there’s no guarantee that future versions of CMake won’t want to have additional information either.

I don’t know what happens if you provide partial information, but fiddling around too much here is liable to get into sensitive areas where our compatibility guarantee does not hold so well.

Also, how are you extracting information? With imported targets being the norm now, there are issues with extracting information reliably. See [this issue](https://gitlab.kitware.com/cmake/cmake/-/issues/17236). In ParaView, we have some consumers that don’t use CMake and I ended up making [this script](https://gitlab.kitware.com/paraview/paraview/-/blob/master/Clients/CommandLineExecutables/paraview-config.in) to extract the information. It basically makes a full project and then asks the resulting build what’s going on and computes a diff of command line flags for a target which uses the targets in question with those that do not. Not pretty, but it’s the best that can be done with the tools CMake offers today.

---

<div class="post-metadata">

### Author: ![mensinda](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mensinda/32/913_2.png) [@mensinda](https://discourse.cmake.org/u/mensinda)
#### Post date: [October 29, 2020, 10:09am UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/3 "2020-10-29T10:09:37Z")

</div>

> [@ben.boeckel](#):
>
> Also, how are you extracting information?

We are generating a CMake project (see our [`CMakeLists.txt`](https://github.com/mesonbuild/meson/blob/master/mesonbuild/dependencies/data/CMakeLists.txt) for that) which we then configure with all the necessary input variables set. Everything past line 25 is for the old style, non-target dependencies to ensure that we track the required variables correctly (we basically only track the `set()` function for variables state and some packages use `string()` to set some variables, hence we work around this by copying them to new variables)

We generally only rely on the CMake `--trace --trace-expand` (and `--trace-format=json-v1` if supported) to extract the dependency information. We then parse the trace by reimplementing the subset of CMake functions that are required to keep track of imported targets and properties. See [`traceparser.py#L105`](https://github.com/mesonbuild/meson/blob/master/mesonbuild/cmake/traceparser.py#L105) for a complete list of functions we implement.

These functions are then “executed” in the order they are in the trace output. This way we reconstruct a partial CMake state with all variables (assuming they are set with `set()` and not some fancy `string()` or `list()` function) and all imported targets (we can even keep track of the dependency tree in `INTERFACE_LINK_LIBRARIES`). Meson then uses this state to generate the compile and link flags.

This system works supprisingly well. We have never gotten a bug report because of incomplete/wrong extracted information, just issues about actually finding the dependencies by calling CMake correctly (`CMAKE_MODULE_PATH`, and other fun stuff).

What I basically want is a flag to tell CMake “I know what I am doing, yes this can break in a real project, but I really don’t want you to check any compilers because it is slow and 90% of the information you get is irrelevant for dependency lookups anyway”

The best solution would of course be a resolution to [#17236](https://gitlab.kitware.com/cmake/cmake/-/issues/17236) that would provide all the information we currently get from our traceparser.

---

<div class="post-metadata">

### Author: ![mensinda](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mensinda/32/913_2.png) [@mensinda](https://discourse.cmake.org/u/mensinda)
#### Post date: [October 29, 2020, 10:19am UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/4 "2020-10-29T10:19:04Z")

</div>

We also have a minimal parser for generator expression: [`generator.py`](https://github.com/mesonbuild/meson/blob/master/mesonbuild/cmake/generator.py)

It is by no means complete (or even guaranteed to be correct) but it works for most use cases we need to support and is only updated when we need new functionality.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 29, 2020, 10:58am UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/5 "2020-10-29T10:58:37Z")

</div>

> [@mensinda](#):
>
> We then parse the trace by reimplementing the subset of CMake functions that are required to keep track of imported targets and properties. See [`traceparser.py#L105`](https://github.com/mesonbuild/meson/blob/master/mesonbuild/cmake/traceparser.py#L105) for a complete list of functions we implement.

That seems like a more reasonable approach to the “what does CMake think is going on”. If you want to skip a lot of compiler checks, I’d say that in addition to passing basic information via `-D`, copying the `CMakeFiles/$version` directory over ahead of time from an already-working build tree may save you a lot of trouble. It would also be backwards compatible. I don’t know if CMake completely ignores it for new trees, so you might want to write a simple `CMakeCache.txt` directly instead of passing `-D` flags for compiler information.

If you want a more demanding test case, I’d be interested to see how things work for `find_package(VTK)` to extract information about how to use, say, `VTK::CommonCore`, `VTK::CommonDataModel`, and `VTK::RenderingOpenGL2`.

---

<div class="post-metadata">

### Author: ![mensinda](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mensinda/32/913_2.png) [@mensinda](https://discourse.cmake.org/u/mensinda)
#### Post date: [October 29, 2020, 11:56am UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/6 "2020-10-29T11:56:37Z")

</div>

> [@ben.boeckel](#):
>
> If you want to skip a lot of compiler checks, I’d say that in addition to passing basic information via `-D` , copying the `CMakeFiles/$version` directory over ahead of time from an already-working build tree may save you a lot of trouble.

That is more or less what we were doing in previous versions, but we were actually generating these files ourselves instead of using a “real” CMake build directory. This used to work more or less OK, but felt like a really bad hack.

> [@ben.boeckel](#):
>
> If you want a more demanding test case, I’d be interested to see how things work for `find_package(VTK)` to extract information about how to use, say, `VTK::CommonCore` , `VTK::CommonDataModel` , and `VTK::RenderingOpenGL2` .

With using the following `meson.build`:

```meson
project('test5', ['c', 'cpp'])

# dependency('VTK', modules: ['VTK::CommonCore']) # ERROR
# dependency('VTK', modules: ['VTK::CommonDataModel']) # ERROR
# dependency('VTK', modules: ['VTK::RenderingOpenGL2']) # ERROR

dependency('VTK', modules: ['vtkCommonCore'])
dependency('VTK', modules: ['vtkCommonDataModel'])
dependency('VTK', modules: ['vtkRenderingOpenGL2'])

```

The meson log output is from my Arch system with the system vtk package. Also, should the `VTK::*` targets exist? Meson only detects the `vtk*` targets.

* * *

## vtkCommonCore

```auto
CMake TARGET:
  -- name: vtkCommonCore
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonCore.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonCore.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:71 add_library(['vtkCommonCore', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtksys
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_INCLUDE_DIRECTORIES': ['/usr/include/vtk']
      'INTERFACE_LINK_LIBRARIES': ['dl', 'dl']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtksys.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtksys.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:63 add_library(['vtksys', 'SHARED', 'IMPORTED'])
WARNING: CMake: Dependency dl for VTK target vtksys was not found
WARNING: CMake: Dependency dl for VTK target vtksys was not found
Include Dirs: ['/usr/include/vtk']
Compiler Definitions: []
Compiler Options: []
Libraries: ['/usr/lib/libvtkCommonCore.so.1', '/usr/lib/libvtksys.so.1']
Run-time dependency vtk (modules: vtkCommonCore) found: YES 8.2.0

```

* * *

## vtkCommonDataModel

```auto
CMake TARGET:
  -- name: vtkCommonDataModel
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonMath', 'vtkCommonTransforms']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkCommonMisc', 'vtkCommonSystem', 'vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonDataModel.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonDataModel.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:145 add_library(['vtkCommonDataModel', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonCore
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonCore.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonCore.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:71 add_library(['vtkCommonCore', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonMath
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonMath.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonMath.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:85 add_library(['vtkCommonMath', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonTransforms
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonMath']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonTransforms.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonTransforms.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:130 add_library(['vtkCommonTransforms', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonMisc
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonMath']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonMisc.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonMisc.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:100 add_library(['vtkCommonMisc', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonSystem
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonSystem.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonSystem.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:115 add_library(['vtkCommonSystem', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtksys
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_INCLUDE_DIRECTORIES': ['/usr/include/vtk']
      'INTERFACE_LINK_LIBRARIES': ['dl', 'dl']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtksys.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtksys.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:63 add_library(['vtksys', 'SHARED', 'IMPORTED'])
WARNING: CMake: Dependency dl for VTK target vtksys was not found
WARNING: CMake: Dependency dl for VTK target vtksys was not found
Include Dirs: ['/usr/include/vtk']
Compiler Definitions: []
Compiler Options: []
Libraries: ['/usr/lib/libvtkCommonCore.so.1', '/usr/lib/libvtkCommonDataModel.so.1', '/usr/lib/libvtkCommonMath.so.1', '/usr/lib/libvtkCommonMisc.so.1', '/usr/lib/libvtkCommonSystem.so.1', '/usr/lib/libvtkCommonTransforms.so.1', '/usr/lib/libvtksys.so.1']
Run-time dependency vtk (modules: vtkCommonDataModel) found: YES 8.2.0

```

* * *

## vtkRenderingOpenGL2

```auto
CMake TARGET:
  -- name: vtkRenderingOpenGL2
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonDataModel', 'vtkRenderingCore', 'vtkRenderingCore', '/usr/lib/libSM.so', '/usr/lib/libICE.so', '/usr/lib/libX11.so', '/usr/lib/libXext.so', '/usr/lib/libXt.so']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkCommonExecutionModel', 'vtkCommonMath', 'vtkCommonSystem', 'vtkCommonTransforms', 'vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkRenderingOpenGL2.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkRenderingOpenGL2.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:475 add_library(['vtkRenderingOpenGL2', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonCore
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonCore.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonCore.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:71 add_library(['vtkCommonCore', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonDataModel
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonMath', 'vtkCommonTransforms']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkCommonMisc', 'vtkCommonSystem', 'vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonDataModel.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonDataModel.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:145 add_library(['vtkCommonDataModel', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkRenderingCore
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonDataModel', 'vtkCommonExecutionModel', 'vtkCommonMath', 'vtkFiltersCore']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkCommonColor', 'vtkCommonComputationalGeometry', 'vtkCommonSystem', 'vtkCommonTransforms', 'vtkFiltersGeneral', 'vtkFiltersGeometry', 'vtkFiltersSources', 'vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkRenderingCore.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkRenderingCore.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:340 add_library(['vtkRenderingCore', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonExecutionModel
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonDataModel']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkCommonMisc', 'vtkCommonSystem']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonExecutionModel.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonExecutionModel.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:175 add_library(['vtkCommonExecutionModel', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonMath
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonMath.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonMath.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:85 add_library(['vtkCommonMath', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonSystem
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonSystem.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonSystem.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:115 add_library(['vtkCommonSystem', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonTransforms
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonMath']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonTransforms.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonTransforms.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:130 add_library(['vtkCommonTransforms', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtksys
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_INCLUDE_DIRECTORIES': ['/usr/include/vtk']
      'INTERFACE_LINK_LIBRARIES': ['dl', 'dl']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtksys.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtksys.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:63 add_library(['vtksys', 'SHARED', 'IMPORTED'])
WARNING: CMake: Dependency dl for VTK target vtksys was not found
WARNING: CMake: Dependency dl for VTK target vtksys was not found
CMake TARGET:
  -- name: vtkCommonMisc
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonMath']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtksys']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonMisc.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonMisc.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:100 add_library(['vtkCommonMisc', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkFiltersCore
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonDataModel', 'vtkCommonExecutionModel', 'vtkCommonMisc']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkCommonMath', 'vtkCommonSystem', 'vtkCommonTransforms']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkFiltersCore.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkFiltersCore.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:205 add_library(['vtkFiltersCore', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonColor
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonDataModel']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonColor.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonColor.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:160 add_library(['vtkCommonColor', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkCommonComputationalGeometry
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonDataModel']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkCommonComputationalGeometry.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkCommonComputationalGeometry.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:190 add_library(['vtkCommonComputationalGeometry', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkFiltersGeneral
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonDataModel', 'vtkCommonExecutionModel', 'vtkCommonMisc', 'vtkFiltersCore']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkCommonComputationalGeometry', 'vtkCommonMath', 'vtkCommonSystem', 'vtkCommonTransforms']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkFiltersGeneral.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkFiltersGeneral.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:220 add_library(['vtkFiltersGeneral', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkFiltersGeometry
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonCore', 'vtkCommonDataModel', 'vtkCommonExecutionModel']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkFiltersCore']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkFiltersGeometry.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkFiltersGeometry.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:310 add_library(['vtkFiltersGeometry', 'SHARED', 'IMPORTED'])
CMake TARGET:
  -- name: vtkFiltersSources
  -- type: SHARED
  -- imported: True
  -- properties: {
      'INTERFACE_COMPILE_FEATURES': ['cxx_nullptr', 'cxx_override']
      'INTERFACE_LINK_LIBRARIES': ['vtkCommonDataModel', 'vtkCommonExecutionModel']
      'IMPORTED_CONFIGURATIONS': ['RELEASE']
      'IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE': ['vtkCommonComputationalGeometry', 'vtkCommonCore', 'vtkCommonTransforms', 'vtkFiltersCore', 'vtkFiltersGeneral']
      'IMPORTED_LOCATION_RELEASE': ['/usr/lib/libvtkFiltersSources.so.1']
      'IMPORTED_SONAME_RELEASE': ['libvtkFiltersSources.so.1']
     }
  -- tline: CMake TRACE: /usr/lib/cmake/vtk-8.2/VTKTargets.cmake:325 add_library(['vtkFiltersSources', 'SHARED', 'IMPORTED'])
Include Dirs: ['/usr/include/vtk']
Compiler Definitions: []
Compiler Options: []
Libraries: ['/usr/lib/libICE.so', '/usr/lib/libSM.so', '/usr/lib/libX11.so', '/usr/lib/libXext.so', '/usr/lib/libXt.so', '/usr/lib/libvtkCommonColor.so.1', '/usr/lib/libvtkCommonComputationalGeometry.so.1', '/usr/lib/libvtkCommonCore.so.1', '/usr/lib/libvtkCommonDataModel.so.1', '/usr/lib/libvtkCommonExecutionModel.so.1', '/usr/lib/libvtkCommonMath.so.1', '/usr/lib/libvtkCommonMisc.so.1', '/usr/lib/libvtkCommonSystem.so.1', '/usr/lib/libvtkCommonTransforms.so.1', '/usr/lib/libvtkFiltersCore.so.1', '/usr/lib/libvtkFiltersGeneral.so.1', '/usr/lib/libvtkFiltersGeometry.so.1', '/usr/lib/libvtkFiltersSources.so.1', '/usr/lib/libvtkRenderingCore.so.1', '/usr/lib/libvtkRenderingOpenGL2.so.1', '/usr/lib/libvtksys.so.1']
Run-time dependency vtk (modules: vtkRenderingOpenGL2) found: YES 8.2.0

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 29, 2020, 4:47pm UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/7 "2020-10-29T16:47:48Z")

</div>

> [@mensinda](#):
>
> That is more or less what we were doing in previous versions, but we were actually generating these files ourselves instead of using a “real” CMake build directory. This used to work more or less OK, but felt like a really bad hack.

I think I’d use a real directory. That gets rid of the guesswork and (most of?) the incompatibility question.

> [@mensinda](#):
>
> The meson log output is from my Arch system with the system vtk package. Also, should the `VTK::*` targets exist? Meson only detects the `vtk*` targets.

Ah, I should have been more specific: VTK 9.0 or newer. The build system was rewritten to make use of CMake’s targets (rather than home-grown variable management to simulate them). Granted, the system was used as a guide for what targets could be, but VTK needed to jump to make use of what they became.

I guess I can do it locally as well now that I have a template 🙂 .

---

<div class="post-metadata">

### Author: ![mensinda](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mensinda/32/913_2.png) [@mensinda](https://discourse.cmake.org/u/mensinda)
#### Post date: [October 29, 2020, 4:57pm UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/8 "2020-10-29T16:57:40Z")

</div>

> [@ben.boeckel](#):
>
> I guess I can do it locally as well now that I have a template 🙂 .

Thanks. The log file is in `<build dir>/meson-logs/meson-log.txt`. Meson 0.55.x still uses the fake CMake build dir. The new toolchain file version is new in 0.56.x (rc1 and rc2 are on [pypi](https://pypi.org/project/meson/0.56.0rc2/))

> [@ben.boeckel](#):
>
> I think I’d use a real directory. That gets rid of the guesswork and (most of?) the incompatibility question.

I guess this could work. The reason why we are not doing this currently is because CMake likes to cache stuff, especially some dependency variables. I don’t know/want to find out if this can cause issues when changing the project name and detecting multiple dependencies.

We are calling CMake once anyway for extracting system information. I could try using this build dir and see if there are any issues in our tests. See our [`CMakePathInfo.txt`](https://github.com/mesonbuild/meson/blob/master/mesonbuild/dependencies/data/CMakePathInfo.txt).

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 29, 2020, 5:05pm UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/9 "2020-10-29T17:05:44Z")

</div>

It looks like it works pretty well for VTK 🙂 . It does warn about `dl` not being known, but I guess that’s a problem with that not having a target for us to use for that.

> [@mensinda](#):
>
> The reason why we are not doing this currently is because CMake likes to cache stuff, especially some dependency variables

I’d cache the compiler extracting information and just pass the compilers via `-D`. I think I’d try and transfer as little of the `CMakeCache.txt` as possible.

---

<div class="post-metadata">

### Author: ![mensinda](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mensinda/32/913_2.png) [@mensinda](https://discourse.cmake.org/u/mensinda)
#### Post date: [October 29, 2020, 5:14pm UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/10 "2020-10-29T17:14:49Z")

</div>

> [@ben.boeckel](#):
>
> It does warn about `dl` not being known, but I guess that’s a problem with that not having a target for us to use for that.

I also noticed that on my side. Is `dl` a special target in CMake or are all non-tragets just appended with an `-l` prefix?

> [@ben.boeckel](#):
>
> I’d cache the compiler extracting information and just pass the compilers via `-D` . I think I’d try and transfer as little of the `CMakeCache.txt` as possible.

I could try that, thanks.

Also are there any plans on the CMake side to have better `pkg-config` / `pkgconf` support? While I did manage to get the dependency information from CMake, our aproach is still very far from official and convinient.

Alternatively, if `*.pc` files are to limiting, would be a custom, new format (that doesn’t require a full CMake parser + moddeling the internal CMake state) be an option?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 29, 2020, 6:01pm UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079/11 "2020-10-29T18:01:26Z")

</div>

> [@mensinda](#):
>
> I also noticed that on my side. Is `dl` a special target in CMake or are all non-tragets just appended with an `-l` prefix?

Any non-path, non-target, non-flag item is assumed to be in some standard location, so CMake just prefixes `-l` (or leaves it as is on Windows like with `opengl32.lib`) for those items and lets the linker figure it out.

> [@mensinda](#):
>
> Alternatively, if `*.pc` files are to limiting, would be a custom, new format (that doesn’t require a full CMake parser + moddeling the internal CMake state) be an option?

There have been discussions about that, but Matthew doesn’t seem to be on Discourse? The main issue tracker is [here](https://gitlab.kitware.com/cmake/cmake/-/issues/20106). I don’t know if there’s already a Discourse thread or not.
