[CMake] Multiple Visual Studio Solutions through same master CMakeLists.txt

Nils Gladitz nilsgladitz at gmail.com
Thu Jan 28 06:57:25 EST 2016



On 01/28/2016 12:42 PM, Nikita Barawade wrote:
>
>
>
> Hi All ,
>
> It is possible to same master CMakeList to generate multiple visual 
> studio solution files ?
>
> here is my master CMakeList :
>
> cmake_minimum_required (VERSION 2.8.11)
> project (Myproject_all)
>
> set_property (GLOBAL PROPERTY USE_FOLDERS ON)
>
> # Set compiler flags and options.
> # enable the Visual Studio warning level to 4
> set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
>
> # Sub-directories where more CMakeLists.txt exist
> add_subdirectory (lib1)
> add_subdirectory (TestApp1)
> add_subdirectory (lib2)
> add_subdirectory (TestApp2)
> add_subdirectory (TestApp3)
>
> Now , my project "Myproject_all" includes all sub-projects as 
> lib1,TestApp1,lib2,TestApp2,TestApp3 (testApps depend on libraries )
> I want another solution to be generated through same CMakeList for 
> example with name "Myproject" which includes only ,
> lib1,TestApp1,lib2.
> I should not always edit master CMakeList to change project name and 
> remove TestApp2 and TestApp3.Is there any way to automate this?

CMake generates one solution per directory (CMakeLists.txt) that has its 
own project() call.
To put lib1,TestApp1,lib2 into their own solution you would therefor 
have to put them into a common parent directory (distinct from the other 
targets) and give that parent directory's CMakeLists.txt its own 
project(Myproject) call.

Nils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160128/f1c285c4/attachment-0001.html>


More information about the CMake mailing list