Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple CMakeLists.txt in a project

Tags:

cmake

I have a project with two CMakeLists.txt files: CMakeLists.txt (default) and CMakeLists.2.txt. So my directory tree looks like project |---- CMakeLists.txt |---- CMakeLists.2.txt |---- main.cpp |---- otherfile.cpp I build like: mkdir build cd build cmake .. make

This uses the default CMakeLists.txt file. How can I specify to build using the CMakeLists.2.txt cmake file?

like image 237
mkuse Avatar asked Sep 11 '25 14:09

mkuse


1 Answers

You cannot change the file name of "CMakeLists.txt".

However, if you need different build configuration for one project, you should use the option in cmake:

option(BUILD_STATIC_LIBS "Build the static library" ON)
option(BUILD_SHARED_LIBS "Build the shared library" ON)
option(BUILD_TESTS "Build test programs" OFF)

And build like this:

cmake -D DBUILD_SHARED_LIBS=ON DBUILD_STATIC_LIBS=OFF DBUILD_TESTS=ON ..
like image 135
Wei Guo Avatar answered Sep 13 '25 17:09

Wei Guo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!