I have a small project with several different parts that I would like to
build with CMake, but I'm having some trouble pulling it all together.
For example purposes, there's an overall project with three executables
that use two static libraries. The executables and static libraries are
produced as part of the build. The directory structure looks like this:
/
projects/
00-0000/
CMakeLists.txt
products/
executable_a/
src/
include/
CMakeLists.txt
executable_b/
src/
include/
CMakeLists.txt
executable_c/
src/
include/
CMakeLists.txt
components/
a/
src/
include/
CMakeLists.txt
b/
src/
include/
CMakeLists.txt
I would like /projects/00-0000/CMakeLists.txt to be the top level
CMakeLists.txt file and to contain:
PROJECT(00-0000)
ADD_SUBDIRECTORY(../../products/executable_a executable_a)
ADD_SUBDIRECTORY(../../products/executable_b executable_b)
ADD_SUBDIRECTORY(../../products/executable_c executable_c)
And /products/executable_a/CMakeLists.txt to contain:
PROJECT(executable_a)
ADD_SUBDIRECTORY(../../components/a a)
And /products/executable_b/CMakeLists.txt to contain:
PROJECT(executable_b)
ADD_SUBDIRECTORY(../../components/b b)
And /products/executable_c/CMakeLists.txt to contain:
PROJECT(executable_c)
ADD_SUBDIRECTORY(../../components/a a)
ADD_SUBDIRECTORY(../../components/b b)
So I have each executable using ADD_SUBDIRECTORY to get the components it
needs. The problem obviously is that the CMakeLists.txt for components a
and b are included twice, producing duplicate targets that CMake doesn't
like. I was thinking that this was similar to header files in C/C++, and
in that world every header files uses an include guard to prevent
duplication. So is there a way in CMake to implement include guards, or
rather ADD_SUBDIRECTORY guards?
Or, am I headed down the wrong path entirely?
---------------------------------------------------------
Aaron Wright
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake