# Configure custom commands and targets (e.g., for generating docs) without compiler checks

**URL:** <https://discourse.cmake.org/t/configure-custom-commands-and-targets-e-g-for-generating-docs-without-compiler-checks/14382>\
**Category:** Code\
**Created:** [July 16, 2025, 5:10pm UTC](https://discourse.cmake.org/t/configure-custom-commands-and-targets-e-g-for-generating-docs-without-compiler-checks/14382 "2025-07-16T17:10:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DukeOfKirkcaldy](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@DukeOfKirkcaldy](https://discourse.cmake.org/u/DukeOfKirkcaldy)\
**Post date:** [July 16, 2025, 5:10pm UTC](https://discourse.cmake.org/t/configure-custom-commands-and-targets-e-g-for-generating-docs-without-compiler-checks/14382/1 "2025-07-16T17:10:42Z")

</div>

Following the documentation I am able to define a custom commands and targets for generating documentation.

However, when integrated into my project’s `CMakeLists.txt`, the configuration stage performs checks that the compiler is able to compile a simple source file, which I’d like to avoid.

In some cases, developers may be working solely on writing and updating documentation, and it would be helpful to be able to build it without the needing the compiler, especially because it occupies a floating license for a period of time.

Is there a recommended way to isolate such targets from the main configuration process to prevent the compiler from being used?

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [July 17, 2025, 1:51am UTC](https://discourse.cmake.org/t/configure-custom-commands-and-targets-e-g-for-generating-docs-without-compiler-checks/14382/2 "2025-07-17T01:51:58Z")

</div>

By default, the `project()` command enables the `C` and `CXX` languages. If you don’t want that, you have to explicitly say so. Here’s an example of the start of a top level `CMakeLists.txt` file that does that:

```cmake
cmake_minimum_required(VERSION 3.24)
project(some_proj LANGUAGES NONE)

```

I chose a fairly arbitrary version for the first line.

---

<div class="post-metadata">

**Author:** ![DukeOfKirkcaldy](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@DukeOfKirkcaldy](https://discourse.cmake.org/u/DukeOfKirkcaldy)\
**Post date:** [July 17, 2025, 9:37am UTC](https://discourse.cmake.org/t/configure-custom-commands-and-targets-e-g-for-generating-docs-without-compiler-checks/14382/3 "2025-07-17T09:37:45Z")

</div>

Thanks for that! Do you know if there are side effects from this? My project is a C project, so I’m not sure I want to remove this entirely. I suppose I could always add an option to conditionally set the language:

```auto
option(DOCS_ONLY "Build only documentation without compiler checks" OFF)

if(DOCS_ONLY)
    project(MyProject LANGUAGES NONE)
else()
    project(MyProject LANGUAGES C)
endif()

```

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [July 17, 2025, 9:51am UTC](https://discourse.cmake.org/t/configure-custom-commands-and-targets-e-g-for-generating-docs-without-compiler-checks/14382/4 "2025-07-17T09:51:55Z")

</div>

Another variation:

```cmake
cmake_minimum_required(VERSION 3.24)
project(some_proj LANGUAGES NONE)

if(NOT DOCS_ONLY)
    enable_language(C)
endif()

```
