I am trying to change CMake target name folders in my IDE (Xcode). I read the documentation that says PROJECT_LABEL will do exactly this. It seems when I apply this property, it has no affect in Xcode. Is there another way to change a target name folders in Xcode or is just unsupported for this IDE?
PROJECT_LABEL property takes effect only for projects that have separate project name field within project file. For instance, Visual Studio *.vcxproj have <ProjectName> field, which used for name representation within the IDE and is independent from the actual file name. In case with Xcode, project name comes from file name itself and there are no options to customise it.
Back to your initial question, in this scenario the only option is to rename project file. However here is the catch, CMake doesn't support any post-generation hooks, so you must be smarter. Essentially, you have 2 options:
Both ways well described in answers for this question Run Command after generation step in CMake.
Second option may looks easier, but be aware that in case of complicated calls with a lot of options you may lose some flags unintentionally so it becomes hard to follow at some point and not so versatile. Here an example of how it may looks like in your case:
project(MyProjectWithPostGeneratorStep)
option(MAIN_ACTION "Flag to differentiate main and post calls" OFF)
if(NOT MAIN_ACTION)
execute_process(COMMAND ${CMAKE_COMMAND}
-G "${CMAKE_GENERATOR}"
-T "${CMAKE_GENERATOR_TOOLSET}"
-A "${CMAKE_GENERATOR_PLATFORM}"
-B "${CMAKE_BINARY_DIR}"
-S "${CMAKE_SOURCE_DIR}"
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DMAIN_ACTION:BOOL=ON
${CMAKE_SOURCE_DIR})
message(STATUS "Postbuild action")
file(RENAME "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.xcodeproj" "${CMAKE_BINARY_DIR}/newname.xcodeproj")
return()
endif()
message(STATUS "Main action")
...
P.S. I need to say that PROJECT_LABEL documentation is not clear enough and I really don't know if any other project types support this, I believe it must be named as VS_PROJECT_NAME to be aligned with the existing CMake approaches and avoid any misreads
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With