Reuse Clion Macros inside CMakeLists.txt
Answered
I want to name the CmakeProject exactly how I named the Clion-Project
For Clion I saw the /.idea/.name
And inside CmakeLists.txt I can test
if($ENV{CLION_IDE})
PROJECT($XXX)
How can I insert
${PROJECT_NAME}
for XXX to get value from .name?
Please sign in to leave a comment.
Hello!
Actually /.idea/.name contains the name from the project() command specified in the CMakeLists.txt.
In CLion I've created a project named untitled2:
In the created CMakeLists.txt this name was used in the project() command and as the target name:
Then I changed this name in both places to untitled2_renamed and reloaded the CMake project.
As a result /.idea/.name contains untitled2_renamed:
And it's the project name actually. untitled2 is only the directory name now.
What do you mean by the Clion-Project name?
I mean that these Makros should coresponse:
Clion is based on CMake, so I exspect to have the possibility to store attributes like ProjektName at one place and reuse it during Build/Debug Process.
It is confusing to maintain full path to */**untitled.elf during different Configurations.
So I want to check in Cmake for Clion-Makros or in Clion CMake-Makros all over the IDE
HARD-Coded is never a good solution.
SOLVED:
its all about the difference of:
${CMAKE_PROJECT_NAME} //defined in .name${PROJECT_NAME} //defined in PROJECT(${CMAKE_PROJECT_NAME})but namind is still irritating....
According to the CMake documentation:
CMAKE_PROJECT_NAME holds the name of the project as specified in the top level CMakeLists.txt file by a
project()command. In the event that the top level CMakeLists.txt contains multipleproject()calls, the most recently called one from that top level CMakeLists.txt will determine the name thatCMAKE_PROJECT_NAMEcontains.PROJECT_NAME is the name given to the most recently called
project()command in the current directory scope or above.Hope it clarifies the situation.