Issue
With cmake
, in a CMakeLists.txt
file I can get the the name of the root project with CMAKE_PROJECT_NAME
, and the name of the current subproject with PROJECT_NAME
.
Is there a way to get the name of the project at the level immediately above the current one?
Solution
You could check the PROJECT_NAME
before the project()
call in the current scope, which will give you the project name of the parent scope:
# Gives the project name of the parent scope.
message(${PROJECT_NAME})
# Define the project name for the current scope.
project(MyInnerProj)
# Now, gives the project name of the current scope: 'MyInnerProj'.
message(${PROJECT_NAME})
Answered By - squareskittles