# Using ifelse in cmake

**URL:** https://discourse.cmake.org/t/using-ifelse-in-cmake/4622
**Category:** Code
**Tags:** os:linux
**Created:** [December 8, 2021, 4:45am UTC](https://discourse.cmake.org/t/using-ifelse-in-cmake/4622 "2021-12-08T04:45:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Vitaly\_Starkov](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vitaly_starkov/32/2015_2.png) [@Vitaly\_Starkov](https://discourse.cmake.org/u/Vitaly_Starkov)
#### Post date: [December 8, 2021, 4:45am UTC](https://discourse.cmake.org/t/using-ifelse-in-cmake/4622/1 "2021-12-08T04:45:21Z")

</div>

hi!

I am a technical writer and I have a book that works approximately as follows:

```auto
set(Installation_Name

Installation/Chapter1.md
Installation/Chapter2.md

)

add_custom_command(OUTPUT Installation_Output

COMMAND cat ${Installation_Name} > Book.md
COMMAND ${Pandoc_Command_Version} Book.md -o Book.pdf
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/MD/" 
		VERBATIM
		)

add_custom_target(MyDocs ALL DEPENDS Installation_Output)
install(FILES 
${CMAKE_CURRENT_SOURCE_DIR}/src/MD/Book.pdf

```

I want to make a construction that allows me to do something like that:

```auto
set(Installation_Name

Installation/Chapter1.md
Installation/Chapter2.md
)

if(${WORKING_DIRECTORY} STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/src/MD/")
set(Installation_Name
		Installation/Chaper3.md 
		)
elseif(${WORKING_DIRECTORY} STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/src/MD_special/")
	set(Installation_Name
		Special_Installation/Chaper4.md 
		)
endif()
)

set(Installation_Name
Installation/Chapter5.md
Installation/Chapter6.md

)

...

```

that is, I need the cmake file to start fulfilling the conditions: if the directory is “src/MD/”, then use the “Installation/Chaper3.md” chapter, and if the directory is different, then use another chapter  
I tried to use the above code (I wrote it approximately), but I’m not very familiar with the cmake syntax yet and obviously made a mistake somewhere  
Please tell me how can I execute this scenario and what am I doing wrong?

---

<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: [December 11, 2021, 7:17pm UTC](https://discourse.cmake.org/t/using-ifelse-in-cmake/4622/2 "2021-12-11T19:17:16Z")

</div>

What is “`WORKING_DIRECTORY`” here? Where are you expecting it to come from?
