reusing CMAKELISTS.txt

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

reusing CMAKELISTS.txt

llvm 999

I have a CMAKELIST.txt file which can be used for more than 1 subdirectory.


Is there a way to "reuse" this CMAKELISTS.txt file?


I have tried placing this file at a common folder and then to place a shortcut or softlink in the sub-directories.

But, this does not work. CMAKE does not seem to recognize the link.


Any help would be much appreciated.


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: reusing CMAKELISTS.txt

Sylvain Joubert
Le 06/11/2017 à 20:36, llvm 999 a écrit :
> I have a CMAKELIST.txt file which can be used for more than 1 subdirectory.
>
>
> Is there a way to "reuse" this CMAKELISTS.txt file?
>

As such I don't think so.

>
> I have tried placing this file at a common folder and then to place a
> shortcut or softlink in the sub-directories.
>
> But, this does not work. CMAKE does not seem to recognize the link.
>
>
> Any help would be much appreciated.
>
>
>

What you can do is create a function in a top/common CMakeLists.txt and
call that function in each CMakeLists.txt of the different folders.
You still need a file per folder but you don't duplicate code.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: reusing CMAKELISTS.txt

Konstantin Tokarev
In reply to this post by llvm 999


> I have a CMAKELIST.txt file which can be used for more than 1 subdirectory.
>
> Is there a way to "reuse" this CMAKELISTS.txt file?
>
> I have tried placing this file at a common folder and then to place a shortcut or softlink in the sub-directories.

Instead of link you can create CMakeLists.txt in each directory with include() of your common file

>
> But, this does not work. CMAKE does not seem to recognize the link.
>
> Any help would be much appreciated.
--
Regards,
Konstantin
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: reusing CMAKELISTS.txt

Craig Scott-3
You can re-use the same CMakeLists.txt with add_subdirectory as long as each call specifies a different binary directory. Not saying this is a particularly good design, but it is allowable. E.g.

# First time with a particular value of someVar
set(someVar 1234)
add_subdirectory(foo foo1)

# Do it again with a different someVar
set(someVar abcd)
add_subdirectory(foo foo2)

Instead of trying to re-use a whole CMakeLists.txt, consider defining a function or macro instead and call that in the places where you want to re-use the same code.



On Tue, Nov 7, 2017 at 7:28 AM, Konstantin Tokarev <[hidden email]> wrote:


> I have a CMAKELIST.txt file which can be used for more than 1 subdirectory.
>
> Is there a way to "reuse" this CMAKELISTS.txt file?
>
> I have tried placing this file at a common folder and then to place a shortcut or softlink in the sub-directories.

Instead of link you can create CMakeLists.txt in each directory with include() of your common file

>
> But, this does not work. CMAKE does not seem to recognize the link.
>
> Any help would be much appreciated.
--
Regards,
Konstantin
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake



--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake