How to suppress Xcode from creating a folder with a name after configuring the assembly in cmake?

I have a cmake configuration that works great for my project on Windows and Linux. We're remaking MacOS right now, and we're at the point where Xcode spits out libraries that built one directory from what we define. For example, instead of being reset to ~ / bin, it fell into ~ / bin / Debug. As far as I can tell, Xcode takes over to add this folder to the path, and I don't want that.

How can I disconnect Xcode from this from my cmake configuration?

+4
source share
1 answer

You will need to specify the target properties ARCHIVE_OUTPUT_DIRECTORY_<CONFIG> , LIBRARY_OUTPUT_DIRECTORY_<CONFIG> and / or RUNTIME_OUTPUT_DIRECTORY_<CONFIG> for each type of configuration and each target you target.

To influence all goals, you can set variables with names as with CMAKE_ prepended. Any relevant goal added after they are set will be affected.

So, for example, you can either do:

 add_library(MyLib ${Sources}) set_target_properties(MyLib PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) 

or you could do:

 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) add_library(MyLib ${Sources}) 

Having said that, I usually find it better if generators with multiple configurations, such as Xcode and MSVC, just add configuration-dependent directories. Unless you plan to change the default exes and lib names as well, these multi-configuration IDEs overwrite one configuration output with another. Therefore, itโ€™s hard to say whether you are looking at Debug or Release exe, for example.

For generators with a single connector, I believe that for each configuration for individual configurations it is necessary to have separate assembly trees.

In principle, I would not fight with the generator. CMake automates so much build process that I never find this small difference between generators a problem. You rarely have to consider whether the output path of the config directory contains or not.

+6
source

Source: https://habr.com/ru/post/1498523/


All Articles