# Build a framework on the Mac

**URL:** https://discourse.cmake.org/t/build-a-framework-on-the-mac/13443
**Category:** Usage
**Created:** [January 21, 2025, 9:41pm UTC](https://discourse.cmake.org/t/build-a-framework-on-the-mac/13443 "2025-01-21T21:41:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![SpacedCowboy](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@SpacedCowboy](https://discourse.cmake.org/u/SpacedCowboy)
#### Post date: [January 21, 2025, 9:41pm UTC](https://discourse.cmake.org/t/build-a-framework-on-the-mac/13443/1 "2025-01-21T21:41:19Z")

</div>

I’m trying to set up a CMakeLists.txt to build a Mac framework. I’m running into issues where any headers that include \<framework/something.h\> in angle brackets (because the include itself is in a public header) are not finding the file. For example:

```auto
@atlantis build % make
[1%] Building C object CMakeFiles/Azoth.dir/Azoth/Classes/Application/AZAppDelegate.m.o
[2%] Building C object CMakeFiles/Azoth.dir/Azoth/Classes/Application/AZApplication.m.o
In file included from ~/src/Azoth/Classes/Application/AZApplication.m:12:
~/src/Azoth/Classes/Application/AZApplication.h:9:9: fatal error: 'Azoth/AZTypes.h' file not found
    9 | #import <Azoth/AZTypes.h>
      | ^ ~~~~~~~~~~~~~~~~

```

I can understand that there’s a chicken-and-egg situation where it’s hard to include the headers from the framework you’re still building… So I thought I’d fake it 🙂 … If I create a directory called ‘Azoth/’ inside the build/ directory, and copy all the headers into it, then with suitable include flags that’d be “as if” the framework was already extant.

Except I can’t get cmake to make my directory and copy the headers from the source before the build. I’ve tried:

```auto
cmake_minimum_required(VERSION 3.10)

project(Azoth)

set (AZOTH_HEADER_DIR ${PROJECT_BINARY_DIR}/Azoth)
set (MODULE_HEADER ${AZOTH_HEADER_DIR}/Azoth.h)

file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "Azoth/*.m")
file(GLOB_RECURSE HEADERS RELATIVE ${CMAKE_SOURCE_DIR} "Azoth/*.h")

add_executable(Azoth 
		${MODULE_HEADER}
		${SOURCES}
		)

add_custom_command(
	OUTPUT ${AZOTH_HEADER_DIR}
    COMMAND make_directory(${AZOTH_HEADER_DIR})
    WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)

add_custom_command(
    OUTPUT ${MODULE_HEADER}
    COMMAND ${CMAKE_COMMAND} -E copy ${HEADERS} ${AZOTH_HEADER_DIR}
    WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
    DEPENDS ${AZOTH_HEADER_DIR}
)

target_include_directories(Azoth PUBLIC
		"${CMAKE_SOURCE_DIR}/Classes"
		"${CMAKE_SOURCE_DIR}/Classes/Utility"

		)

set_target_properties(Azoth PROPERTIES LINK_FLAGS "-Wl,-F/opt/SDL3")

target_link_libraries(Azoth PUBLIC -framework /opt/SDL3/SDL3.xcframework)
target_link_libraries(Azoth PUBLIC -framework /opt/SDL3/SDL3_image.xcframework)
target_link_libraries(Azoth PUBLIC -framework /opt/SDL3/SDL3_ttf.xcframework)

```

… where my thinking is to create the directory with one custom\_command and copy the files in with the other, but neither of them are running. I was hoping the dependency-tree for $MODULE\_HEADER would make this happen in the right order.

I also tried setting the mkdir command as a PRE\_BUILD task:

```auto
add_custom_command(
	TARGET Azoth PRE_BUILD
    COMMAND make_directory(${AZOTH_HEADER_DIR})
    WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)

```

… but I had to drop the OUTPUT (can’t have both, apparently) so I wasn’t sure if there would be a way to know the mkdir was running ahead of the copy. Didn’t matter, neither ran ☹

Presumably I’m missing something (or a lot of things [grin]). If there’s a better way to get around the include chicken/egg problem, I’m all ears, otherwise if some kind soul could point out what I’m doing wrong above, I’d really appreciate it 🙂

---

<div class="post-metadata">

### Author: ![vdamewood](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/7ab992/32.png) [@vdamewood](https://discourse.cmake.org/u/vdamewood)
#### Post date: [October 22, 2025, 11:14am UTC](https://discourse.cmake.org/t/build-a-framework-on-the-mac/13443/2 "2025-10-22T11:14:47Z")

</div>

Put the headers in a directory called `include/YourFramework` in your source tree, then add this to your CMakeLists.txt file:

```cmake
 target_include_directories(YourTarget PUBLIC
     "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")

```
