Suppose I have following C project structure:
├── CMakeLists.txt
├── include
│ ├── header.h
├── README.md
├── src
│ └── src.c
└── test
├── CMakeLists.txt
└── test.c
The CMakeLists.txt in the root directory contains a project called cproj
PROJECT(cproj C)
Also in test/CMakeLists.txt, I have another project
PROJECT(test C)
The question is how can I assess the project name cproj in the CMakeLists.txt in test directory?
If I gather your use case correctly, you should probably do as follows:
test is quite likely not a standalone sub-project. It should not have a project directive. If you remove it, it will now be under the cproj project.
Now you looking for the project name you've set in the root, it should be available via the CMAKE_PROJECT_NAME variable.
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