# Types of cmakelist.txt

**URL:** https://discourse.cmake.org/t/types-of-cmakelist-txt/629
**Category:** Code
**Created:** [February 13, 2020, 3:39pm UTC](https://discourse.cmake.org/t/types-of-cmakelist-txt/629 "2020-02-13T15:39:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Bravepaulo](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/65b543/32.png) [@Bravepaulo](https://discourse.cmake.org/u/Bravepaulo)
#### Post date: [February 13, 2020, 3:39pm UTC](https://discourse.cmake.org/t/types-of-cmakelist-txt/629/1 "2020-02-13T15:39:10Z")

</div>

Hello  
I evaluating the following project and I have some questions regarding the cmakelist.txt files that are part t his project.  
The structure is the following:

proj:

-CMakeLists.txt  
-Subdirectory 1  
-CMakeLists.txt  
-main1.cpp  
-subdirectory 2  
-CMakeLists.txt  
-main2.cpp

The first one in subdirectory 1 is pretty standard with all the expected commands like:  
cmake\_minimum\_required(VERSION 3.2…

On the other hand, the second one is totally not standard, at least for me.  
It does not start with the cmake\_minimum\_required command.  
Its content is like:

```cmake
 app_add_module(

	MODULE examples__app_simple_app
        MAIN app_simple_app
	SRCS
		app_simple_app.c
	DEPENDS
	)

```

where app\_add\_module is a function that builds a static library.  
My question regards the content of second cmakelist.txt.

Is it possible allowed to write a cmakelist.txt without following the standard structure?  
Any help will be highly appreciated.

Thanks

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [February 13, 2020, 3:45pm UTC](https://discourse.cmake.org/t/types-of-cmakelist-txt/629/2 "2020-02-13T15:45:32Z")

</div>

The `CMakeLists.txt` in the subdirectory inherits `cmake_minimum_required()` and `project()` from the top-level `CMakeLists.txt` file, through `add_subdirectory()`. The top-level `CMakeLists.txt` always has to have these commands, but they are optional in subdirectories.

---

<div class="post-metadata">

### Author: ![Bravepaulo](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/65b543/32.png) [@Bravepaulo](https://discourse.cmake.org/u/Bravepaulo)
#### Post date: [February 13, 2020, 4:20pm UTC](https://discourse.cmake.org/t/types-of-cmakelist-txt/629/3 "2020-02-13T16:20:46Z")

</div>

Wow  
That’s was fast Kyle.  
Clear like water.  
Thank you very much
